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 char* const PROPERTY_NAME_REMOVE_FRONT_INSET = "removeFrontInset";
119 const char* const PROPERTY_NAME_REMOVE_BACK_INSET = "removeBackInset";
121 const Vector4 PLACEHOLDER_TEXT_COLOR(0.8f, 0.8f, 0.8f, 0.8f);
122 const Dali::Vector4 LIGHT_BLUE(0.75f, 0.96f, 1.f, 1.f); // The text highlight color.
124 const float RENDER_FRAME_INTERVAL = 16.66f;
126 const unsigned int DEFAULT_FONT_SIZE = 1152u;
127 const std::string DEFAULT_FONT_DIR("/resources/fonts");
129 const int KEY_RETURN_CODE = 36;
130 const int KEY_A_CODE = 38;
131 const int KEY_D_CODE = 40;
132 const int KEY_SHIFT_MODIFIER = 257;
134 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
136 static bool gSelectionChangedCallbackCalled;
137 static uint32_t oldSelectionStart;
138 static uint32_t oldSelectionEnd;
139 static bool gSelectionClearedCallbackCalled;
140 static bool gSelectionStartedCallbackCalled;
141 static bool gAnchorClickedCallBackCalled;
142 static bool gAnchorClickedCallBackNotCalled;
143 static bool gTextChangedCallBackCalled;
144 static bool gMaxCharactersCallBackCalled;
145 static bool gInputFilteredAcceptedCallbackCalled;
146 static bool gInputFilteredRejectedCallbackCalled;
147 static bool gInputStyleChangedCallbackCalled;
148 static bool gCursorPositionChangedCallbackCalled;
149 static uint32_t oldCursorPos;
150 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
152 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
154 Integration::Bitmap* bitmap = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD);
155 Integration::ResourcePointer resource(bitmap);
156 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
159 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
163 LoadBitmapResource(app.GetPlatform(), width, height);
165 Property::Map propertyMap;
166 propertyMap["filename"] = "image.png";
167 propertyMap["width"] = width;
168 propertyMap["height"] = height;
169 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap);
170 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap);
171 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap);
172 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap);
173 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap);
174 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap);
175 textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, "image.png");
176 textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image.png");
180 * Simulate time passed by.
182 * @note this will always process at least 1 frame (1/60 sec)
184 * @param application Test application instance
185 * @param duration Time to pass in milliseconds.
186 * @return The actual time passed in milliseconds
188 static int Wait(ToolkitTestApplication& application, int duration = 0)
192 for(int i = 0; i <= (duration / RENDER_FRAME_INTERVAL); i++)
194 application.SendNotification();
195 application.Render(RENDER_FRAME_INTERVAL);
196 time += RENDER_FRAME_INTERVAL;
202 Dali::Integration::Point GetPointDownInside(Vector2& pos)
204 Dali::Integration::Point point;
205 point.SetState(PointState::DOWN);
206 point.SetScreenPosition(pos);
210 Dali::Integration::Point GetPointUpInside(Vector2& pos)
212 Dali::Integration::Point point;
213 point.SetState(PointState::UP);
214 point.SetScreenPosition(pos);
218 struct CallbackFunctor
220 CallbackFunctor(bool* callbackFlag)
221 : mCallbackFlag(callbackFlag)
227 *mCallbackFlag = true;
232 static void TestSelectionClearedCallback(TextField control)
234 tet_infoline(" TestSelectionClearedCallback");
236 gSelectionClearedCallbackCalled = true;
239 static void TestSelectionStartedCallback(TextField control)
241 tet_infoline(" TestSelectionStartedCallback");
243 gSelectionStartedCallbackCalled = true;
246 static void TestSelectionChangedCallback(TextField control, uint32_t oldStart, uint32_t oldEnd)
248 tet_infoline(" TestSelectionChangedCallback");
250 gSelectionChangedCallbackCalled = true;
251 oldSelectionStart = oldStart;
252 oldSelectionEnd = oldEnd;
255 static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength)
257 tet_infoline(" TestAnchorClickedCallback");
259 gAnchorClickedCallBackNotCalled = false;
261 if(!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
263 gAnchorClickedCallBackCalled = true;
267 static void TestCursorPositionChangedCallback(TextField control, unsigned int oldPos)
269 tet_infoline(" TestCursorPositionChangedCallback");
271 gCursorPositionChangedCallbackCalled = true;
272 oldCursorPos = oldPos;
275 static void TestTextChangedCallback(TextField control)
277 tet_infoline(" TestTextChangedCallback");
279 gTextChangedCallBackCalled = true;
282 static void TestMaxLengthReachedCallback(TextField control)
284 tet_infoline(" TestMaxLengthReachedCallback");
286 gMaxCharactersCallBackCalled = true;
289 static void TestInputFilteredCallback(TextField control, Toolkit::InputFilter::Property::Type type)
291 tet_infoline(" TestInputFilteredCallback");
293 if(type == Toolkit::InputFilter::Property::ACCEPTED)
295 gInputFilteredAcceptedCallbackCalled = true;
297 else if(type == Toolkit::InputFilter::Property::REJECTED)
299 gInputFilteredRejectedCallbackCalled = true;
303 static void TestInputStyleChangedCallback(TextField control, TextField::InputStyle::Mask mask)
305 tet_infoline(" TestInputStyleChangedCallback");
307 gInputStyleChangedCallbackCalled = true;
308 gInputStyleMask = mask;
311 // Generate a KeyEvent to send to Core.
312 Integration::KeyEvent GenerateKey(const std::string& keyName,
313 const std::string& logicalKey,
314 const std::string& keyString,
317 unsigned long timeStamp,
318 const Integration::KeyEvent::State& keyState,
319 const std::string& compose = "",
320 const std::string& deviceName = DEFAULT_DEVICE_NAME,
321 const Device::Class::Type& deviceClass = Device::Class::NONE,
322 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE)
324 return Integration::KeyEvent(keyName,
337 bool DaliTestCheckMaps(const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet)
339 if(fontStyleMapGet.Count() == fontStyleMapSet.Count())
341 for(unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index)
343 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue(index);
345 Property::Value* valueSet = NULL;
346 if(valueGet.first.type == Property::Key::INDEX)
348 valueSet = fontStyleMapSet.Find(valueGet.first.indexKey);
352 // Get Key is a string so searching Set Map for a string key
353 valueSet = fontStyleMapSet.Find(valueGet.first.stringKey);
358 if(valueSet->GetType() == Dali::Property::STRING && (valueGet.second.Get<std::string>() != valueSet->Get<std::string>()))
360 tet_printf("Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str());
363 else if(valueSet->GetType() == Dali::Property::BOOLEAN && (valueGet.second.Get<bool>() != valueSet->Get<bool>()))
365 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>());
368 else if(valueSet->GetType() == Dali::Property::INTEGER && (valueGet.second.Get<int>() != valueSet->Get<int>()))
370 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>());
373 else if(valueSet->GetType() == Dali::Property::FLOAT && (valueGet.second.Get<float>() != valueSet->Get<float>()))
375 tet_printf("Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>());
378 else if(valueSet->GetType() == Dali::Property::VECTOR2 && (valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>()))
380 Vector2 vector2Get = valueGet.second.Get<Vector2>();
381 Vector2 vector2Set = valueSet->Get<Vector2>();
382 tet_printf("Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y);
385 else if(valueSet->GetType() == Dali::Property::VECTOR4 && (valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>()))
387 Vector4 vector4Get = valueGet.second.Get<Vector4>();
388 Vector4 vector4Set = valueSet->Get<Vector4>();
389 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);
395 if(valueGet.first.type == Property::Key::INDEX)
397 tet_printf(" The key %d doesn't exist.", valueGet.first.indexKey);
401 tet_printf(" The key %s doesn't exist.", valueGet.first.stringKey.c_str());
411 // Stores data that is populated in the callback and will be read by the test cases
415 : functorCalled(false),
416 voidFunctorCalled(false),
423 functorCalled = false;
424 voidFunctorCalled = false;
426 receivedGesture.Reset();
432 bool voidFunctorCalled;
433 PanGesture receivedGesture;
437 // Functor that sets the data when called
438 struct GestureReceivedFunctor
440 GestureReceivedFunctor(SignalData& data)
445 void operator()(Actor actor, const PanGesture& pan)
447 signalData.functorCalled = true;
448 signalData.receivedGesture = pan;
449 signalData.pannedActor = actor;
454 signalData.voidFunctorCalled = true;
457 SignalData& signalData;
462 int UtcDaliToolkitTextFieldConstructorP(void)
464 ToolkitTestApplication application;
465 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
467 DALI_TEST_CHECK(!textField);
471 int UtcDaliToolkitTextFieldNewP(void)
473 ToolkitTestApplication application;
474 tet_infoline(" UtcDaliToolkitTextFieldNewP");
475 TextField textField = TextField::New();
476 DALI_TEST_CHECK(textField);
480 int UtcDaliToolkitTextFieldDownCastP(void)
482 ToolkitTestApplication application;
483 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
484 TextField textField1 = TextField::New();
485 BaseHandle object(textField1);
487 TextField textField2 = TextField::DownCast(object);
488 DALI_TEST_CHECK(textField2);
490 TextField textField3 = DownCast<TextField>(object);
491 DALI_TEST_CHECK(textField3);
495 int UtcDaliToolkitTextFieldDownCastN(void)
497 ToolkitTestApplication application;
498 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
499 BaseHandle uninitializedObject;
500 TextField textField1 = TextField::DownCast(uninitializedObject);
501 DALI_TEST_CHECK(!textField1);
503 TextField textField2 = DownCast<TextField>(uninitializedObject);
504 DALI_TEST_CHECK(!textField2);
508 int UtcDaliToolkitTextFieldCopyConstructorP(void)
510 ToolkitTestApplication application;
511 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
512 TextField textField = TextField::New();
513 textField.SetProperty(TextField::Property::TEXT, "Test");
515 TextField copy(textField);
516 DALI_TEST_CHECK(copy);
517 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextField::Property::TEXT) == textField.GetProperty<std::string>(TextField::Property::TEXT));
521 int UtcDaliTextFieldMoveConstructor(void)
523 ToolkitTestApplication application;
525 TextField textField = TextField::New();
526 textField.SetProperty(TextEditor::Property::TEXT, "Test");
527 DALI_TEST_CHECK(textField.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
529 TextField moved = std::move(textField);
530 DALI_TEST_CHECK(moved);
531 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
532 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
533 DALI_TEST_CHECK(!textField);
538 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
540 ToolkitTestApplication application;
541 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
542 TextField textField = TextField::New();
543 textField.SetProperty(TextField::Property::TEXT, "Test");
545 TextField copy = textField;
546 DALI_TEST_CHECK(copy);
547 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextField::Property::TEXT) == textField.GetProperty<std::string>(TextField::Property::TEXT));
551 int UtcDaliTextFieldMoveAssignment(void)
553 ToolkitTestApplication application;
555 TextField textField = TextField::New();
556 textField.SetProperty(TextEditor::Property::TEXT, "Test");
557 DALI_TEST_CHECK(textField.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
560 moved = std::move(textField);
561 DALI_TEST_CHECK(moved);
562 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
563 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
564 DALI_TEST_CHECK(!textField);
569 int UtcDaliTextFieldNewP(void)
571 ToolkitTestApplication application;
572 tet_infoline(" UtcDaliToolkitTextFieldNewP");
573 TextField textField = TextField::New();
574 DALI_TEST_CHECK(textField);
578 // Positive test case for a method
579 int UtcDaliTextFieldGetPropertyP(void)
581 ToolkitTestApplication application;
582 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
583 TextField field = TextField::New();
584 DALI_TEST_CHECK(field);
586 // Check Property Indices are correct
587 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_RENDERING_BACKEND) == DevelTextField::Property::RENDERING_BACKEND);
588 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_TEXT) == TextField::Property::TEXT);
589 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT) == TextField::Property::PLACEHOLDER_TEXT);
590 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED);
591 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_FAMILY) == TextField::Property::FONT_FAMILY);
592 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_STYLE) == TextField::Property::FONT_STYLE);
593 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_POINT_SIZE) == TextField::Property::POINT_SIZE);
594 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_MAX_LENGTH) == TextField::Property::MAX_LENGTH);
595 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_EXCEED_POLICY) == TextField::Property::EXCEED_POLICY);
596 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_HORIZONTAL_ALIGNMENT) == TextField::Property::HORIZONTAL_ALIGNMENT);
597 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_VERTICAL_ALIGNMENT) == TextField::Property::VERTICAL_ALIGNMENT);
598 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_TEXT_COLOR) == TextField::Property::TEXT_COLOR);
599 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR) == TextField::Property::PLACEHOLDER_TEXT_COLOR);
600 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PRIMARY_CURSOR_COLOR) == TextField::Property::PRIMARY_CURSOR_COLOR);
601 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SECONDARY_CURSOR_COLOR) == TextField::Property::SECONDARY_CURSOR_COLOR);
602 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_CURSOR_BLINK) == TextField::Property::ENABLE_CURSOR_BLINK);
603 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_INTERVAL) == TextField::Property::CURSOR_BLINK_INTERVAL);
604 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_DURATION) == TextField::Property::CURSOR_BLINK_DURATION);
605 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_WIDTH) == TextField::Property::CURSOR_WIDTH);
606 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_IMAGE) == TextField::Property::GRAB_HANDLE_IMAGE);
607 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE);
608 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SCROLL_THRESHOLD) == TextField::Property::SCROLL_THRESHOLD);
609 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SCROLL_SPEED) == TextField::Property::SCROLL_SPEED);
610 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT);
611 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT);
612 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT);
613 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT);
614 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT);
615 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT);
616 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR) == TextField::Property::SELECTION_HIGHLIGHT_COLOR);
617 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_DECORATION_BOUNDING_BOX) == TextField::Property::DECORATION_BOUNDING_BOX);
618 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_METHOD_SETTINGS) == TextField::Property::INPUT_METHOD_SETTINGS);
619 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_COLOR) == TextField::Property::INPUT_COLOR);
620 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_MARKUP) == TextField::Property::ENABLE_MARKUP);
621 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_FAMILY) == TextField::Property::INPUT_FONT_FAMILY);
622 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_STYLE) == TextField::Property::INPUT_FONT_STYLE);
623 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_POINT_SIZE) == TextField::Property::INPUT_POINT_SIZE);
624 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_UNDERLINE) == TextField::Property::UNDERLINE);
625 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_UNDERLINE) == TextField::Property::INPUT_UNDERLINE);
626 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SHADOW) == TextField::Property::SHADOW);
627 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_SHADOW) == TextField::Property::INPUT_SHADOW);
628 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_EMBOSS) == TextField::Property::EMBOSS);
629 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_EMBOSS) == TextField::Property::INPUT_EMBOSS);
630 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_OUTLINE) == TextField::Property::OUTLINE);
631 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_OUTLINE) == TextField::Property::INPUT_OUTLINE);
632 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_HIDDEN_INPUT_SETTINGS) == TextField::Property::HIDDEN_INPUT_SETTINGS);
633 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PIXEL_SIZE) == TextField::Property::PIXEL_SIZE);
634 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_SELECTION) == TextField::Property::ENABLE_SELECTION);
635 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER) == TextField::Property::PLACEHOLDER);
636 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ELLIPSIS) == TextField::Property::ELLIPSIS);
637 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_SIZE_SCALE) == DevelTextField::Property::FONT_SIZE_SCALE);
638 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE) == DevelTextField::Property::ENABLE_FONT_SIZE_SCALE);
639 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_SHIFT_SELECTION) == DevelTextField::Property::ENABLE_SHIFT_SELECTION);
640 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE) == DevelTextField::Property::ENABLE_GRAB_HANDLE);
641 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION);
642 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP);
643 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_BACKGROUND) == DevelTextField::Property::BACKGROUND);
644 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_COLOR) == DevelTextField::Property::GRAB_HANDLE_COLOR);
645 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FILTER) == DevelTextField::Property::INPUT_FILTER);
646 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextField::Property::STRIKETHROUGH);
647 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextField::Property::INPUT_STRIKETHROUGH);
648 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_POPUP_STYLE) == DevelTextField::Property::SELECTION_POPUP_STYLE);
649 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_REMOVE_FRONT_INSET) == DevelTextField::Property::REMOVE_FRONT_INSET);
650 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_REMOVE_BACK_INSET) == DevelTextField::Property::REMOVE_BACK_INSET);
655 bool SetPropertyMapRetrieved(TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue)
658 Property::Map imageMap;
659 imageMap[mapKey] = mapValue;
661 field.SetProperty(property, imageMap);
662 Property::Value propValue = field.GetProperty(property);
663 Property::Map* resultMap = propValue.GetMap();
665 if(resultMap->Find(mapKey)->Get<std::string>() == mapValue)
673 // Positive test case for a method
674 int UtcDaliTextFieldSetPropertyP(void)
676 ToolkitTestApplication application;
677 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
678 TextField field = TextField::New();
679 DALI_TEST_CHECK(field);
680 application.GetScene().Add(field);
682 // Note - we can't check the defaults since the stylesheets are platform-specific
684 // Check the render backend property.
685 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
686 DALI_TEST_EQUALS((DevelText::RenderingType)field.GetProperty<int>(DevelTextField::Property::RENDERING_BACKEND), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION);
688 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED);
689 DALI_TEST_EQUALS((DevelText::RenderingType)field.GetProperty<int>(DevelTextField::Property::RENDERING_BACKEND), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION);
691 // Check text property.
692 field.SetProperty(TextField::Property::TEXT, "Setting Text");
693 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("Setting Text"), TEST_LOCATION);
695 // Check placeholder text properties.
696 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
697 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::PLACEHOLDER_TEXT), std::string("Setting Placeholder Text"), TEST_LOCATION);
699 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused");
700 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::PLACEHOLDER_TEXT_FOCUSED), std::string("Setting Placeholder Text Focused"), TEST_LOCATION);
702 // Check font properties.
703 field.SetProperty(TextField::Property::FONT_FAMILY, "Setting font family");
704 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::FONT_FAMILY), std::string("Setting font family"), TEST_LOCATION);
706 Property::Map fontStyleMapSet;
707 Property::Map fontStyleMapGet;
708 Property::Value* slantValue = NULL;
710 fontStyleMapSet.Insert("weight", "bold");
711 fontStyleMapSet.Insert("width", "condensed");
712 fontStyleMapSet.Insert("slant", "italic");
713 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
715 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
716 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
717 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
719 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
720 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::POINT_SIZE), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
722 field.SetProperty(DevelTextField::Property::FONT_SIZE_SCALE, 2.5f);
723 DALI_TEST_EQUALS(field.GetProperty<float>(DevelTextField::Property::FONT_SIZE_SCALE), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
724 field.SetProperty(DevelTextField::Property::FONT_SIZE_SCALE, 1.0f);
726 field.SetProperty(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, false);
727 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE), false, TEST_LOCATION);
728 field.SetProperty(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, true);
731 fontStyleMapSet.Clear();
732 fontStyleMapSet.Insert("weight", "normal");
733 fontStyleMapSet.Insert("slant", "oblique");
734 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
736 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
737 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
738 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
740 fontStyleMapSet.Clear();
741 fontStyleMapSet.Insert("slant", "roman");
742 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
743 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
745 // Replace 'roman' for 'normal'.
746 slantValue = fontStyleMapGet.Find("slant");
747 if(NULL != slantValue)
749 if("normal" == slantValue->Get<std::string>())
751 fontStyleMapGet["slant"] = "roman";
754 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
755 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
757 fontStyleMapSet.Clear();
759 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
760 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
761 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
762 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
764 // Check that the MAX_LENGTH property can be correctly set
765 const int maxNumberOfCharacters = 20;
766 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
767 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::MAX_LENGTH), maxNumberOfCharacters, TEST_LOCATION);
769 // Check exceed policy
770 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP);
771 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::EXCEED_POLICY), static_cast<int>(Dali::Toolkit::TextField::EXCEED_POLICY_CLIP), TEST_LOCATION);
772 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
773 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::EXCEED_POLICY), static_cast<int>(Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL), TEST_LOCATION);
775 // Check that the Alignment properties can be correctly set
776 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
777 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::HORIZONTAL_ALIGNMENT), "END", TEST_LOCATION);
778 field.SetProperty(TextField::Property::VERTICAL_ALIGNMENT, "CENTER");
779 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::VERTICAL_ALIGNMENT), "CENTER", TEST_LOCATION);
781 // Check text's color property
782 field.SetProperty(TextField::Property::TEXT_COLOR, Color::WHITE);
783 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::WHITE, TEST_LOCATION);
785 // Check placeholder text's color property.
786 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED);
787 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::PLACEHOLDER_TEXT_COLOR), Color::RED, TEST_LOCATION);
789 // Check cursor properties
790 field.SetProperty(TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED);
791 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION);
792 field.SetProperty(TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE);
793 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION);
795 field.SetProperty(TextField::Property::ENABLE_CURSOR_BLINK, false);
796 DALI_TEST_EQUALS(field.GetProperty<bool>(TextField::Property::ENABLE_CURSOR_BLINK), false, TEST_LOCATION);
797 field.SetProperty(TextField::Property::CURSOR_BLINK_INTERVAL, 1.f);
798 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::CURSOR_BLINK_INTERVAL), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
799 field.SetProperty(TextField::Property::CURSOR_BLINK_DURATION, 10.f);
800 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::CURSOR_BLINK_DURATION), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
801 field.SetProperty(TextField::Property::CURSOR_WIDTH, 1);
802 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::CURSOR_WIDTH), 1, TEST_LOCATION);
804 // Check scroll properties.
805 field.SetProperty(TextField::Property::SCROLL_THRESHOLD, 1.f);
806 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::SCROLL_THRESHOLD), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
807 field.SetProperty(TextField::Property::SCROLL_SPEED, 100.f);
808 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::SCROLL_SPEED), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
810 // Check handle images
811 field.SetProperty(TextField::Property::GRAB_HANDLE_IMAGE, "image1");
812 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::GRAB_HANDLE_IMAGE), "image1", TEST_LOCATION);
813 field.SetProperty(TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2");
814 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::GRAB_HANDLE_PRESSED_IMAGE), "image2", TEST_LOCATION);
815 field.SetProperty(TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3");
817 // Check handle images
818 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage"));
819 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage"));
820 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed"));
821 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed"));
822 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage"));
823 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage"));
825 // Check the selection popup style
826 const Vector2 popupMaxSize(200.0f, 300.0f);
827 const Vector2 optionDividerSize(30.0f, 5.0f);
828 const Vector4 optionDividerPadding(20.0f, 20.0f, 10.0f, 10.0f);
829 const Vector4 labelPadding(5.0f, 5.0f, 50.0f, 25.0f);
831 Property::Map selectionPopupStyle;
832 selectionPopupStyle.Insert(TextSelectionPopup::Property::POPUP_MAX_SIZE, popupMaxSize);
833 selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE, optionDividerSize);
834 selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING, optionDividerPadding);
835 selectionPopupStyle.Insert(TextSelectionPopup::Property::LABEL_PADDING, labelPadding);
837 field.SetProperty(DevelTextField::Property::SELECTION_POPUP_STYLE, selectionPopupStyle);
839 Property::Map selectionPopupStyleGet;
840 selectionPopupStyleGet = field.GetProperty<Property::Map>(DevelTextField::Property::SELECTION_POPUP_STYLE);
842 Property::Value* popupValue;
843 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::POPUP_MAX_SIZE);
844 DALI_TEST_CHECK(NULL != popupValue);
847 Vector2 popupMaxSizeGet;
848 popupValue->Get(popupMaxSizeGet);
849 DALI_TEST_EQUALS(popupMaxSizeGet, popupMaxSize, TEST_LOCATION);
852 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE);
853 DALI_TEST_CHECK(NULL != popupValue);
856 Vector2 optionDividerSizeGet;
857 popupValue->Get(optionDividerSizeGet);
858 DALI_TEST_EQUALS(optionDividerSizeGet, optionDividerSize, TEST_LOCATION);
861 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING);
862 DALI_TEST_CHECK(NULL != popupValue);
865 Vector4 optionDividerPaddingGet;
866 popupValue->Get(optionDividerPaddingGet);
867 DALI_TEST_EQUALS(optionDividerPaddingGet, optionDividerPadding, TEST_LOCATION);
870 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::LABEL_PADDING);
871 DALI_TEST_CHECK(NULL != popupValue);
874 Vector4 labelPaddingGet;
875 popupValue->Get(labelPaddingGet);
876 DALI_TEST_EQUALS(labelPaddingGet, labelPadding, TEST_LOCATION);
879 // Reset selection popup style
880 selectionPopupStyle.Clear();
881 field.SetProperty(DevelTextField::Property::SELECTION_POPUP_STYLE, selectionPopupStyle);
883 // Check the highlight color
884 field.SetProperty(TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN);
885 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION);
887 // Decoration bounding box
888 field.SetProperty(TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>(0, 0, 1, 1));
889 DALI_TEST_EQUALS(field.GetProperty<Rect<int> >(TextField::Property::DECORATION_BOUNDING_BOX), Rect<int>(0, 0, 1, 1), TEST_LOCATION);
891 // Check the input method setting
892 Property::Map propertyMap;
893 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
894 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
895 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
896 int inputVariation = 1;
897 propertyMap["PANEL_LAYOUT"] = panelLayout;
898 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
899 propertyMap["BUTTON_ACTION"] = buttonAction;
900 propertyMap["VARIATION"] = inputVariation;
901 field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
903 Property::Value value = field.GetProperty(TextField::Property::INPUT_METHOD_SETTINGS);
905 DALI_TEST_CHECK(value.Get(map));
908 DALI_TEST_CHECK(map["PANEL_LAYOUT"].Get(layout));
909 DALI_TEST_EQUALS(static_cast<int>(panelLayout), layout, TEST_LOCATION);
912 DALI_TEST_CHECK(map["AUTO_CAPITALIZE"].Get(capital));
913 DALI_TEST_EQUALS(static_cast<int>(autoCapital), capital, TEST_LOCATION);
916 DALI_TEST_CHECK(map["BUTTON_ACTION"].Get(action));
917 DALI_TEST_EQUALS(static_cast<int>(buttonAction), action, TEST_LOCATION);
920 DALI_TEST_CHECK(map["VARIATION"].Get(variation));
921 DALI_TEST_EQUALS(inputVariation, variation, TEST_LOCATION);
923 // Check input color property.
924 field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
925 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::INPUT_COLOR), Color::YELLOW, TEST_LOCATION);
927 // Check the enable markup property.
928 DALI_TEST_CHECK(!field.GetProperty<bool>(TextField::Property::ENABLE_MARKUP));
929 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
930 DALI_TEST_CHECK(field.GetProperty<bool>(TextField::Property::ENABLE_MARKUP));
932 // Check input font properties.
933 field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
934 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
936 fontStyleMapSet.Clear();
937 fontStyleMapSet.Insert("weight", "bold");
938 fontStyleMapSet.Insert("width", "condensed");
939 fontStyleMapSet.Insert("slant", "italic");
941 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
942 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
943 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
944 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
946 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
947 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
949 // Reset input font style.
950 fontStyleMapSet.Clear();
951 fontStyleMapSet.Insert("weight", "normal");
952 fontStyleMapSet.Insert("slant", "oblique");
954 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
955 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
956 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
957 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
959 fontStyleMapSet.Clear();
960 fontStyleMapSet.Insert("slant", "roman");
962 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
963 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
965 // Replace 'roman' for 'normal'.
966 slantValue = fontStyleMapGet.Find("slant");
967 if(NULL != slantValue)
969 if("normal" == slantValue->Get<std::string>())
971 fontStyleMapGet["slant"] = "roman";
974 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
975 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
977 fontStyleMapSet.Clear();
979 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
980 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
981 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
982 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
984 Property::Map strikethroughMapSet;
985 Property::Map strikethroughMapGet;
987 strikethroughMapSet.Insert("enable", true);
988 strikethroughMapSet.Insert("color", Color::RED);
989 strikethroughMapSet.Insert("height", 2.0f);
991 // Check the strikethrough property
992 field.SetProperty(DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet);
994 strikethroughMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::STRIKETHROUGH);
995 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
996 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
998 // Check the input strikethrough property
999 field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties");
1000 DALI_TEST_EQUALS(field.GetProperty<std::string>(DevelTextField::Property::INPUT_STRIKETHROUGH), std::string("Strikethrough input properties"), TEST_LOCATION);
1002 Property::Map underlineMapSet;
1003 Property::Map underlineMapGet;
1005 underlineMapSet.Insert("enable", true);
1006 underlineMapSet.Insert("color", Color::RED);
1007 underlineMapSet.Insert("height", 1);
1008 underlineMapSet.Insert("type", Text::Underline::SOLID);
1009 underlineMapSet.Insert("dashWidth", 2);
1010 underlineMapSet.Insert("dashGap", 1);
1012 // Check the underline property
1013 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
1015 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
1016 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
1017 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
1019 // Render and notify
1020 application.SendNotification();
1021 application.Render();
1023 underlineMapSet.Clear();
1024 underlineMapGet.Clear();
1026 underlineMapSet.Insert("enable", true);
1027 underlineMapSet.Insert("color", Color::BLUE);
1028 underlineMapSet.Insert("height", 1);
1029 underlineMapSet.Insert("type", Text::Underline::DASHED);
1030 underlineMapSet.Insert("dashWidth", 4);
1031 underlineMapSet.Insert("dashGap", 2);
1033 // Check the dashed underline property
1034 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
1036 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
1037 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
1038 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
1040 // Render and notify
1041 application.SendNotification();
1042 application.Render();
1044 underlineMapSet.Clear();
1045 underlineMapGet.Clear();
1047 underlineMapSet.Insert("enable", true);
1048 underlineMapSet.Insert("color", Color::BLUE);
1049 underlineMapSet.Insert("height", 4);
1050 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
1051 underlineMapSet.Insert("dashWidth", 4);
1052 underlineMapSet.Insert("dashGap", 2);
1054 // Check the dashed underline property
1055 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
1057 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
1058 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
1059 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
1061 // Render and notify
1062 application.SendNotification();
1063 application.Render();
1065 underlineMapSet.Clear();
1066 underlineMapGet.Clear();
1068 // Check the input underline property
1069 field.SetProperty(TextField::Property::INPUT_UNDERLINE, "Underline input properties");
1070 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_UNDERLINE), std::string("Underline input properties"), TEST_LOCATION);
1072 // Check the shadow property
1073 Property::Map shadowMapSet;
1074 Property::Map shadowMapGet;
1076 shadowMapSet.Insert("color", Color::GREEN);
1077 shadowMapSet.Insert("offset", Vector2(2.0f, 2.0f));
1078 shadowMapSet.Insert("blurRadius", 3.0f);
1080 field.SetProperty(TextField::Property::SHADOW, shadowMapSet);
1082 shadowMapGet = field.GetProperty<Property::Map>(TextField::Property::SHADOW);
1083 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
1084 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet), true, TEST_LOCATION);
1086 // Check the input shadow property
1087 field.SetProperty(TextField::Property::INPUT_SHADOW, "Shadow input properties");
1088 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_SHADOW), std::string("Shadow input properties"), TEST_LOCATION);
1090 // Check the emboss property
1091 field.SetProperty(TextField::Property::EMBOSS, "Emboss properties");
1092 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::EMBOSS), std::string("Emboss properties"), TEST_LOCATION);
1094 // Check the input emboss property
1095 field.SetProperty(TextField::Property::INPUT_EMBOSS, "Emboss input properties");
1096 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_EMBOSS), std::string("Emboss input properties"), TEST_LOCATION);
1098 // Check the outline property
1100 // Test string type first
1101 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
1102 field.SetProperty(TextField::Property::OUTLINE, "Outline properties");
1103 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::OUTLINE), std::string("Outline properties"), TEST_LOCATION);
1105 // Then test the property map type
1106 Property::Map outlineMapSet;
1107 Property::Map outlineMapGet;
1109 outlineMapSet["color"] = Color::RED;
1110 outlineMapSet["width"] = 2.0f;
1111 outlineMapSet["offset"] = Vector2(0.0f, 0.0f);
1112 outlineMapSet["blurRadius"] = 0.0f;
1114 field.SetProperty(TextField::Property::OUTLINE, outlineMapSet);
1116 outlineMapGet = field.GetProperty<Property::Map>(TextField::Property::OUTLINE);
1117 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
1118 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
1120 // Check the input outline property
1121 field.SetProperty(TextField::Property::INPUT_OUTLINE, "Outline input properties");
1122 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_OUTLINE), std::string("Outline input properties"), TEST_LOCATION);
1124 // Check the hidden input settings property
1125 Property::Map hiddenMapSet;
1126 Property::Map hiddenMapGet;
1127 hiddenMapSet[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL;
1128 hiddenMapSet[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 2;
1129 hiddenMapSet[HiddenInput::Property::SUBSTITUTE_COUNT] = 4;
1130 hiddenMapSet[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
1131 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet);
1133 hiddenMapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
1134 DALI_TEST_EQUALS(hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION);
1135 DALI_TEST_EQUALS(DaliTestCheckMaps(hiddenMapSet, hiddenMapGet), true, TEST_LOCATION);
1137 // Check the pixel size of font
1138 field.SetProperty(TextField::Property::PIXEL_SIZE, 20.f);
1139 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1141 // Check the enable selection property
1142 field.SetProperty(TextField::Property::ENABLE_SELECTION, false);
1143 DALI_TEST_EQUALS(field.GetProperty<bool>(TextField::Property::ENABLE_SELECTION), false, TEST_LOCATION);
1145 // Check the placeholder property with pixel size
1146 Property::Map placeholderPixelSizeMapSet;
1147 Property::Map placeholderPixelSizeMapGet;
1148 Property::Map placeholderFontstyleMap;
1149 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
1150 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
1151 placeholderPixelSizeMapSet["color"] = Color::BLUE;
1152 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
1153 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
1154 placeholderPixelSizeMapSet["ellipsis"] = true;
1156 placeholderFontstyleMap.Insert("weight", "bold");
1157 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
1158 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
1160 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1161 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
1163 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1164 Property::Map placeholderConversionMap;
1165 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1166 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1167 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1168 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1169 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1170 placeholderConversionMap[Text::PlaceHolder::Property::PIXEL_SIZE] = placeholderPixelSizeMapSet["pixelSize"];
1172 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderConversionMap), true, TEST_LOCATION);
1174 // Check the placeholder property with point size
1175 Property::Map placeholderMapSet;
1176 Property::Map placeholderMapGet;
1177 placeholderMapSet["text"] = "Setting Placeholder Text";
1178 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
1179 placeholderMapSet["color"] = Color::RED;
1180 placeholderMapSet["fontFamily"] = "Arial";
1181 placeholderMapSet["pointSize"] = 12.0f;
1182 placeholderMapSet["ellipsis"] = false;
1184 // Check the placeholder font style property
1185 placeholderFontstyleMap.Clear();
1187 placeholderFontstyleMap.Insert("weight", "bold");
1188 placeholderFontstyleMap.Insert("width", "condensed");
1189 placeholderFontstyleMap.Insert("slant", "italic");
1190 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1191 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1193 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1194 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1196 placeholderConversionMap.Clear();
1197 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1198 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1199 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1200 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1201 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1202 placeholderConversionMap[Text::PlaceHolder::Property::POINT_SIZE] = placeholderPixelSizeMapSet["pointSize"];
1204 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1206 // Reset font style.
1207 placeholderFontstyleMap.Clear();
1208 placeholderFontstyleMap.Insert("weight", "normal");
1209 placeholderFontstyleMap.Insert("slant", "oblique");
1210 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1211 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1213 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1214 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1216 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1217 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1219 placeholderFontstyleMap.Clear();
1220 placeholderFontstyleMap.Insert("slant", "roman");
1221 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1222 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1224 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1226 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1228 placeholderFontstyleMap.Clear();
1229 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1230 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1232 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1233 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1234 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1236 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1238 // Check the ellipsis property
1239 DALI_TEST_CHECK(!field.GetProperty<bool>(TextField::Property::ELLIPSIS));
1240 field.SetProperty(TextField::Property::ELLIPSIS, true);
1241 DALI_TEST_CHECK(field.GetProperty<bool>(TextField::Property::ELLIPSIS));
1243 field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1244 DALI_TEST_EQUALS(field.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1246 // Test the ENABLE_GRAB_HANDLE_POPUP property
1247 DALI_TEST_CHECK(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP));
1248 field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false);
1249 DALI_TEST_CHECK(!field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP));
1251 // Check the background property
1252 field.SetProperty(DevelTextField::Property::BACKGROUND, Color::RED);
1253 DALI_TEST_EQUALS(field.GetProperty<Vector4>(DevelTextField::Property::BACKGROUND), Color::RED, TEST_LOCATION);
1255 //Check handle color
1256 field.SetProperty(DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN);
1257 DALI_TEST_EQUALS(field.GetProperty<Vector4>(DevelTextField::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
1259 // Check the input filter property
1260 Property::Map inputFilterMapSet;
1261 Property::Map inputFilterMapGet;
1262 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1263 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1265 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1267 inputFilterMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::INPUT_FILTER);
1268 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1271 inputFilterMapSet.Clear();
1272 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1274 application.SendNotification();
1275 application.Render();
1277 // Check Remove Front/Back Inset Property
1278 DALI_TEST_CHECK(field.GetProperty<bool>(DevelTextField::Property::REMOVE_FRONT_INSET));
1279 field.SetProperty(DevelTextField::Property::REMOVE_FRONT_INSET, false);
1280 DALI_TEST_CHECK(!field.GetProperty<bool>(DevelTextField::Property::REMOVE_FRONT_INSET));
1282 DALI_TEST_CHECK(field.GetProperty<bool>(DevelTextField::Property::REMOVE_BACK_INSET));
1283 field.SetProperty(DevelTextField::Property::REMOVE_BACK_INSET, false);
1284 DALI_TEST_CHECK(!field.GetProperty<bool>(DevelTextField::Property::REMOVE_BACK_INSET));
1286 application.SendNotification();
1287 application.Render();
1293 // Positive Atlas Text Renderer test
1294 int utcDaliTextFieldAtlasRenderP(void)
1296 ToolkitTestApplication application;
1297 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1298 StyleManager styleManager = StyleManager::Get();
1299 styleManager.ApplyDefaultTheme();
1300 TextField field = TextField::New();
1301 DALI_TEST_CHECK(field);
1303 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1305 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1307 application.GetScene().Add(field);
1311 // Render some text with the shared atlas backend
1312 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1313 application.SendNotification();
1314 application.Render();
1318 tet_result(TET_FAIL);
1323 // Positive test for the anchorClicked signal.
1324 int utcDaliTextFieldAnchorClicked01(void)
1326 ToolkitTestApplication application;
1327 tet_infoline(" utcDaliTextFieldAnchorClicked01");
1328 TextField field = TextField::New();
1329 DALI_TEST_CHECK(field);
1331 application.GetScene().Add(field);
1333 // connect to the anchor clicked signal.
1334 ConnectionTracker* testTracker = new ConnectionTracker();
1335 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1336 bool anchorClickedSignal = false;
1337 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1339 gAnchorClickedCallBackCalled = false;
1340 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1341 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1342 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1343 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1344 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1346 application.SendNotification();
1347 application.Render();
1348 field.SetKeyInputFocus();
1350 // Create a tap event to touch the text field.
1351 TestGenerateTap(application, 5.0f, 25.0f);
1352 application.SendNotification();
1353 application.Render();
1355 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1356 DALI_TEST_CHECK(anchorClickedSignal);
1358 gAnchorClickedCallBackNotCalled = true;
1359 // Tap the outside of anchor, callback should not be called.
1360 TestGenerateTap(application, 150.f, 100.f);
1361 application.SendNotification();
1362 application.Render();
1364 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1369 // Positive test for the anchorClicked signal.
1370 int utcDaliTextFieldAnchorClicked02(void)
1372 ToolkitTestApplication application;
1373 tet_infoline(" utcDaliTextFieldAnchorClicked02");
1374 TextField field = TextField::New();
1375 DALI_TEST_CHECK(field);
1377 application.GetScene().Add(field);
1379 // connect to the anchor clicked signal.
1380 ConnectionTracker* testTracker = new ConnectionTracker();
1381 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1382 bool anchorClickedSignal = false;
1383 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1385 gAnchorClickedCallBackCalled = false;
1386 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1387 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1388 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1389 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1390 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1392 application.SendNotification();
1393 application.Render();
1394 field.SetKeyInputFocus();
1396 // Avoid a crash when core load gl resources.
1397 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1399 // Create a tap event to touch the text field.
1400 TestGenerateTap(application, 30.0f, 25.0f, 100);
1401 application.SendNotification();
1402 application.Render();
1404 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1405 DALI_TEST_CHECK(anchorClickedSignal);
1407 // For coverage InsertTextAnchor, RemoveTextAnchor
1408 // first index insert
1409 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1410 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1411 application.SendNotification();
1412 application.Render();
1414 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1415 application.SendNotification();
1416 application.Render();
1418 gAnchorClickedCallBackCalled = false;
1419 // Create a tap event to touch the text field.
1420 TestGenerateTap(application, 30.0f, 25.0f, 700);
1421 application.SendNotification();
1422 field.SetKeyInputFocus();
1424 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1426 // last index insert
1427 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1428 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1429 application.SendNotification();
1430 application.Render();
1432 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1433 application.SendNotification();
1434 application.Render();
1436 gAnchorClickedCallBackCalled = false;
1437 // Create a tap event to touch the text field.
1438 TestGenerateTap(application, 30.0f, 25.0f, 1300);
1439 application.SendNotification();
1440 field.SetKeyInputFocus();
1442 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1445 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1446 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1447 application.SendNotification();
1448 application.Render();
1450 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1451 application.SendNotification();
1452 application.Render();
1454 gAnchorClickedCallBackCalled = false;
1455 // Create a tap event to touch the text field.
1456 TestGenerateTap(application, 30.0f, 25.0f, 1900);
1457 application.SendNotification();
1458 field.SetKeyInputFocus();
1460 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1462 // first index remove
1463 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1464 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1465 application.SendNotification();
1466 application.Render();
1468 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1469 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));
1470 application.SendNotification();
1471 application.Render();
1473 gAnchorClickedCallBackCalled = false;
1474 // Create a tap event to touch the text field.
1475 TestGenerateTap(application, 30.0f, 25.0f, 2500);
1476 application.SendNotification();
1477 field.SetKeyInputFocus();
1479 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1481 // last index remove
1482 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1483 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1484 application.SendNotification();
1485 application.Render();
1487 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1488 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));
1489 application.SendNotification();
1490 application.Render();
1492 gAnchorClickedCallBackCalled = false;
1493 // Create a tap event to touch the text field.
1494 TestGenerateTap(application, 30.0f, 25.0f, 3100);
1495 application.SendNotification();
1496 application.Render();
1498 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1501 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1502 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
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.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1508 application.SendNotification();
1509 application.Render();
1511 gAnchorClickedCallBackCalled = false;
1512 // Create a tap event to touch the text field.
1513 TestGenerateTap(application, 30.0f, 25.0f, 3700);
1514 application.SendNotification();
1515 application.Render();
1517 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1519 // 0 ~ 1 index remove
1520 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1521 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 0);
1522 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 1);
1523 application.SendNotification();
1524 application.Render();
1526 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1527 application.SendNotification();
1528 application.Render();
1530 gAnchorClickedCallBackCalled = false;
1531 // Create a tap event to touch the text field.
1532 TestGenerateTap(application, 30.0f, 25.0f, 4300);
1533 application.SendNotification();
1534 application.Render();
1536 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1538 // 1 ~ 3 index remove
1539 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1540 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 1);
1541 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 3);
1542 application.SendNotification();
1543 application.Render();
1545 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1546 application.SendNotification();
1547 application.Render();
1549 gAnchorClickedCallBackCalled = false;
1550 // Create a tap event to touch the text field.
1551 TestGenerateTap(application, 30.0f, 25.0f, 4900);
1552 application.SendNotification();
1553 application.Render();
1555 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1557 // 3 ~ 4 index remove
1558 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1559 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 3);
1560 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 4);
1561 application.SendNotification();
1562 application.Render();
1564 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1565 application.SendNotification();
1566 application.Render();
1568 gAnchorClickedCallBackCalled = false;
1569 // Create a tap event to touch the text field.
1570 TestGenerateTap(application, 30.0f, 25.0f, 5500);
1571 application.SendNotification();
1572 application.Render();
1574 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1576 // Remove front of anchor
1577 field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
1578 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
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 whole text
1587 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1588 DevelTextField::SelectWholeText(field);
1589 application.SendNotification();
1590 application.Render();
1592 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1593 application.SendNotification();
1594 application.Render();
1596 // Remove all with backspace
1597 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1598 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
1599 application.SendNotification();
1600 application.Render();
1602 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1603 application.SendNotification();
1604 application.Render();
1606 // Remove all with delete
1607 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1608 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1609 application.SendNotification();
1610 application.Render();
1612 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));
1613 application.SendNotification();
1614 application.Render();
1619 // Positive test for the textChanged signal.
1620 int utcDaliTextFieldTextChangedP(void)
1622 ToolkitTestApplication application;
1623 tet_infoline(" utcDaliTextFieldTextChangedP");
1624 TextField field = TextField::New();
1625 DALI_TEST_CHECK(field);
1627 application.GetScene().Add(field);
1629 // connect to the text changed signal.
1630 ConnectionTracker* testTracker = new ConnectionTracker();
1631 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1632 bool textChangedSignal = false;
1633 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1635 gTextChangedCallBackCalled = false;
1636 field.SetProperty(TextField::Property::TEXT, "ABC");
1637 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1638 DALI_TEST_CHECK(textChangedSignal);
1640 application.SendNotification();
1641 field.SetKeyInputFocus();
1643 gTextChangedCallBackCalled = false;
1644 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1645 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1648 field.SetProperty(TextField::Property::TEXT, "");
1650 // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1651 gTextChangedCallBackCalled = false;
1652 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1653 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1655 // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1656 gTextChangedCallBackCalled = false;
1657 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1658 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1663 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1665 ToolkitTestApplication application;
1666 tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1667 TextField field = TextField::New();
1668 DALI_TEST_CHECK(field);
1670 application.GetScene().Add(field);
1672 // connect to the text changed signal.
1673 ConnectionTracker* testTracker = new ConnectionTracker();
1674 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1675 bool textChangedSignal = false;
1676 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1678 // get InputMethodContext
1680 InputMethodContext::EventData imfEvent;
1681 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1683 field.SetKeyInputFocus();
1684 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1687 gTextChangedCallBackCalled = false;
1688 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "ㅎ", 0, 1);
1689 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1690 application.SendNotification();
1691 application.Render();
1692 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1693 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ㅎ"), TEST_LOCATION);
1695 gTextChangedCallBackCalled = false;
1696 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "호", 0, 1);
1697 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1698 application.SendNotification();
1699 application.Render();
1700 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1701 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("호"), TEST_LOCATION);
1703 gTextChangedCallBackCalled = false;
1704 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "혿", 0, 1);
1705 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1706 application.SendNotification();
1707 application.Render();
1708 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1709 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("혿"), TEST_LOCATION);
1711 gTextChangedCallBackCalled = false;
1712 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "", 0, 1);
1713 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1714 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1716 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "호", 0, 1);
1717 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1718 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1720 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "두", 1, 2);
1721 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1722 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1724 application.SendNotification();
1725 application.Render();
1726 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1727 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("호두"), TEST_LOCATION);
1732 int utcDaliTextFieldSelectionWithInputMethodContext(void)
1734 ToolkitTestApplication application;
1735 tet_infoline(" utcDaliTextFieldSelectionWithInputMethodContext");
1736 TextField field = TextField::New();
1737 DALI_TEST_CHECK(field);
1739 field.SetProperty(TextField::Property::TEXT, "Hello world");
1741 application.GetScene().Add(field);
1743 // connect to the selection changed signal.
1744 ConnectionTracker* testTracker = new ConnectionTracker();
1745 DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
1746 bool selectionChangedSignal = false;
1747 field.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
1749 // get InputMethodContext
1751 InputMethodContext::EventData imfEvent;
1752 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1754 field.SetKeyInputFocus();
1755 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1758 gSelectionChangedCallbackCalled = false;
1759 imfEvent = InputMethodContext::EventData(InputMethodContext::SELECTION_SET, 1, 4);
1760 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1761 application.SendNotification();
1762 application.Render();
1763 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
1765 DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
1766 DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 4, TEST_LOCATION);
1771 int utcDaliTextFieldPositionWithInputMethodContext(void)
1773 ToolkitTestApplication application;
1774 tet_infoline(" utcDaliTextFieldPositionWithInputMethodContext");
1775 TextField field = TextField::New();
1776 DALI_TEST_CHECK(field);
1778 field.SetProperty(TextField::Property::TEXT, "Hello world");
1780 application.GetScene().Add(field);
1782 // connect to the selection changed signal.
1783 ConnectionTracker* testTracker = new ConnectionTracker();
1784 DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
1785 bool cursorPositionChangedSignal = false;
1786 field.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
1788 // get InputMethodContext
1790 InputMethodContext::EventData imfEvent;
1791 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1793 field.SetKeyInputFocus();
1794 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1797 gCursorPositionChangedCallbackCalled = false;
1798 imfEvent = InputMethodContext::EventData(InputMethodContext::SELECTION_SET, 2, 2);
1799 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1800 application.SendNotification();
1801 application.Render();
1802 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
1804 DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 2, TEST_LOCATION);
1809 int utcDaliTextFieldInputFilterWithInputMethodContext(void)
1811 ToolkitTestApplication application;
1812 tet_infoline(" utcDaliTextFieldInputFilterWithInputMethodContext");
1813 TextField field = TextField::New();
1814 DALI_TEST_CHECK(field);
1816 Property::Map inputFilter;
1817 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1818 inputFilter[InputFilter::Property::REJECTED] = "[5-7]";
1820 // Set input filter to TextField.
1821 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1823 application.GetScene().Add(field);
1825 // connect to the input filtered signal.
1826 ConnectionTracker* testTracker = new ConnectionTracker();
1827 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1828 bool inputFilteredSignal = false;
1829 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1831 // get InputMethodContext
1833 InputMethodContext::EventData imfEvent;
1834 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1836 field.SetKeyInputFocus();
1837 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1840 gInputFilteredAcceptedCallbackCalled = false;
1841 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "Hello1234", 0, 9);
1842 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1843 application.SendNotification();
1844 application.Render();
1845 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1846 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("1234"), TEST_LOCATION);
1848 inputFilteredSignal = false;
1849 gInputFilteredRejectedCallbackCalled = false;
1850 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "1234567", 0, 7);
1851 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1852 application.SendNotification();
1853 application.Render();
1854 DALI_TEST_CHECK(gInputFilteredRejectedCallbackCalled);
1855 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("12341234"), TEST_LOCATION);
1860 // Negative test for the textChanged signal.
1861 int utcDaliTextFieldTextChangedN(void)
1863 ToolkitTestApplication application;
1864 tet_infoline(" utcDaliTextFieldTextChangedN");
1865 TextField field = TextField::New();
1866 DALI_TEST_CHECK(field);
1868 application.GetScene().Add(field);
1870 // connect to the text changed signal.
1871 ConnectionTracker* testTracker = new ConnectionTracker();
1872 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1873 bool textChangedSignal = false;
1874 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1876 gTextChangedCallBackCalled = false;
1877 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "ABC"); // Setting placeholder, not TEXT
1878 application.SendNotification();
1879 application.Render();
1880 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1881 DALI_TEST_CHECK(!textChangedSignal);
1886 // Positive test for Max Characters reached signal.
1887 int utcDaliTextFieldMaxCharactersReachedP(void)
1889 ToolkitTestApplication application;
1890 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1891 TextField field = TextField::New();
1892 DALI_TEST_CHECK(field);
1894 application.GetScene().Add(field);
1896 const int maxNumberOfCharacters = 1;
1897 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1899 field.SetKeyInputFocus();
1901 // connect to the text changed signal.
1902 ConnectionTracker* testTracker = new ConnectionTracker();
1903 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1904 bool maxLengthReachedSignal = false;
1905 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1907 gMaxCharactersCallBackCalled = false;
1909 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1910 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1912 DALI_TEST_CHECK(gMaxCharactersCallBackCalled);
1913 DALI_TEST_CHECK(maxLengthReachedSignal);
1918 // Negative test for Max Characters reached signal.
1919 int utcDaliTextFieldMaxCharactersReachedN(void)
1921 ToolkitTestApplication application;
1922 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1923 TextField field = TextField::New();
1924 DALI_TEST_CHECK(field);
1926 application.GetScene().Add(field);
1928 const int maxNumberOfCharacters = 3;
1929 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1931 field.SetKeyInputFocus();
1933 // connect to the text changed signal.
1934 ConnectionTracker* testTracker = new ConnectionTracker();
1935 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1936 bool maxLengthReachedSignal = false;
1937 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1939 gMaxCharactersCallBackCalled = false;
1941 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1942 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1944 DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1945 DALI_TEST_CHECK(!maxLengthReachedSignal);
1947 application.ProcessEvent(GenerateKey("Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1949 DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1950 DALI_TEST_CHECK(!maxLengthReachedSignal);
1955 // Positive test for Input Filtered signal.
1956 int utcDaliTextFieldInputFilteredP(void)
1958 ToolkitTestApplication application;
1959 tet_infoline(" utcDaliTextFieldInputFilteredP");
1960 TextField field = TextField::New();
1961 DALI_TEST_CHECK(field);
1963 application.GetScene().Add(field);
1965 Property::Map inputFilter;
1967 // Only digit is accepted.
1968 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1970 // Set input filter to TextField.
1971 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1973 field.SetKeyInputFocus();
1975 // connect to the input filtered signal.
1976 ConnectionTracker* testTracker = new ConnectionTracker();
1977 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1978 bool inputFilteredSignal = false;
1979 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1981 gInputFilteredAcceptedCallbackCalled = false;
1983 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1985 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1986 DALI_TEST_CHECK(inputFilteredSignal);
1988 // Word is rejected.
1989 inputFilter[InputFilter::Property::ACCEPTED] = "";
1990 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1992 // Set input filter to TextField.
1993 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1995 field.SetKeyInputFocus();
1997 inputFilteredSignal = false;
1998 gInputFilteredRejectedCallbackCalled = false;
2000 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2002 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
2003 DALI_TEST_CHECK(inputFilteredSignal);
2008 // Negative test for Input Filtered signal.
2009 int utcDaliTextFieldInputFilteredN(void)
2011 ToolkitTestApplication application;
2012 tet_infoline(" utcDaliTextFieldInputFilteredP");
2013 TextField field = TextField::New();
2014 DALI_TEST_CHECK(field);
2016 application.GetScene().Add(field);
2018 Property::Map inputFilter;
2020 // Only word is accepted.
2021 inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
2023 // Set input filter to TextField.
2024 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
2026 field.SetKeyInputFocus();
2028 // connect to the input filtered signal.
2029 ConnectionTracker* testTracker = new ConnectionTracker();
2030 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
2031 bool inputFilteredSignal = false;
2032 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
2034 gInputFilteredAcceptedCallbackCalled = false;
2036 // Key a, d should not be filtered.
2037 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2038 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2039 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2040 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2042 // Backspace, Delete should not be filtered.
2043 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2044 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));
2046 // Render and notify
2047 application.SendNotification();
2048 application.Render();
2050 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
2051 DALI_TEST_CHECK(!inputFilteredSignal);
2053 // Digit is rejected.
2054 inputFilter[InputFilter::Property::ACCEPTED] = "";
2055 inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
2057 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
2059 field.SetKeyInputFocus();
2061 inputFilteredSignal = false;
2062 gInputFilteredRejectedCallbackCalled = false;
2064 // Key a, d should not be filtered.
2065 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2066 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2067 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2068 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2070 // Backspace, Delete should not be filtered.
2071 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2072 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));
2074 // Render and notify
2075 application.SendNotification();
2076 application.Render();
2078 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
2079 DALI_TEST_CHECK(!inputFilteredSignal);
2084 int utcDaliTextFieldInputStyleChanged01(void)
2086 // The text-field emits signals when the input style changes. These changes of style are
2087 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
2088 // can't be emitted during the size negotiation as the callbacks may update the UI.
2089 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
2090 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
2091 ToolkitTestApplication application;
2092 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
2096 char* pathNamePtr = get_current_dir_name();
2097 const std::string pathName(pathNamePtr);
2100 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2101 fontClient.SetDpi(93u, 93u);
2103 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2104 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2106 TextField field = TextField::New();
2107 DALI_TEST_CHECK(field);
2109 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2110 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2111 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2113 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2114 field.SetProperty(TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
2116 // connect to the text changed signal.
2117 ConnectionTracker* testTracker = new ConnectionTracker();
2118 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2119 bool inputStyleChangedSignal = false;
2120 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2122 application.GetScene().Add(field);
2124 // Render and notify
2125 application.SendNotification();
2126 application.Render();
2128 // Executes the idle callbacks added by the text control on the change of input style.
2129 application.RunIdles();
2131 gInputStyleChangedCallbackCalled = false;
2132 gInputStyleMask = TextField::InputStyle::NONE;
2133 inputStyleChangedSignal = false;
2135 // Create a tap event to touch the text field.
2136 TestGenerateTap(application, 18.0f, 25.0f);
2138 // Render and notify
2139 application.SendNotification();
2140 application.Render();
2142 // Executes the idle callbacks added by the text control on the change of input style.
2143 application.RunIdles();
2145 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2146 if(gInputStyleChangedCallbackCalled)
2148 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE), TEST_LOCATION);
2150 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2151 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2153 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2154 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2156 DALI_TEST_CHECK(inputStyleChangedSignal);
2158 gInputStyleChangedCallbackCalled = false;
2159 gInputStyleMask = TextField::InputStyle::NONE;
2160 inputStyleChangedSignal = false;
2162 // Create a tap event to touch the text field.
2163 TestGenerateTap(application, 30.0f, 25.0f);
2165 // Render and notify
2166 application.SendNotification();
2167 application.Render();
2169 // Executes the idle callbacks added by the text control on the change of input style.
2170 application.RunIdles();
2172 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2173 DALI_TEST_CHECK(!inputStyleChangedSignal);
2175 gInputStyleChangedCallbackCalled = false;
2176 gInputStyleMask = TextField::InputStyle::NONE;
2177 inputStyleChangedSignal = false;
2179 // Create a tap event to touch the text field.
2180 TestGenerateTap(application, 43.0f, 25.0f);
2182 // Render and notify
2183 application.SendNotification();
2184 application.Render();
2186 // Executes the idle callbacks added by the text control on the change of input style.
2187 application.RunIdles();
2189 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2190 if(gInputStyleChangedCallbackCalled)
2192 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR), TEST_LOCATION);
2194 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2195 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2197 DALI_TEST_CHECK(inputStyleChangedSignal);
2199 gInputStyleChangedCallbackCalled = false;
2200 gInputStyleMask = TextField::InputStyle::NONE;
2201 inputStyleChangedSignal = false;
2203 // Create a tap event to touch the text field.
2204 TestGenerateTap(application, 88.0f, 25.0f);
2206 // Render and notify
2207 application.SendNotification();
2208 application.Render();
2210 // Executes the idle callbacks added by the text control on the change of input style.
2211 application.RunIdles();
2213 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2214 if(gInputStyleChangedCallbackCalled)
2216 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2218 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2219 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2221 const Property::Map fontStyleMapGet = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<Property::Map>();
2223 Property::Map fontStyleMapSet;
2224 fontStyleMapSet.Insert("weight", "bold");
2226 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2227 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2229 DALI_TEST_CHECK(inputStyleChangedSignal);
2231 gInputStyleChangedCallbackCalled = false;
2232 gInputStyleMask = TextField::InputStyle::NONE;
2233 inputStyleChangedSignal = false;
2235 // Create a tap event to touch the text field.
2236 TestGenerateTap(application, 115.0f, 25.0f);
2238 // Render and notify
2239 application.SendNotification();
2240 application.Render();
2242 // Executes the idle callbacks added by the text control on the change of input style.
2243 application.RunIdles();
2245 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2246 DALI_TEST_CHECK(!inputStyleChangedSignal);
2248 gInputStyleChangedCallbackCalled = false;
2249 gInputStyleMask = TextField::InputStyle::NONE;
2250 inputStyleChangedSignal = false;
2252 // Create a tap event to touch the text field.
2253 TestGenerateTap(application, 164.0f, 25.0f);
2255 // Render and notify
2256 application.SendNotification();
2257 application.Render();
2259 // Executes the idle callbacks added by the text control on the change of input style.
2260 application.RunIdles();
2262 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2263 if(gInputStyleChangedCallbackCalled)
2265 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2267 const std::string style = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<std::string>();
2268 DALI_TEST_CHECK(style.empty());
2270 DALI_TEST_CHECK(inputStyleChangedSignal);
2272 gInputStyleChangedCallbackCalled = false;
2273 gInputStyleMask = TextField::InputStyle::NONE;
2274 inputStyleChangedSignal = false;
2276 // Create a tap event to touch the text field.
2277 TestGenerateTap(application, 191.0f, 25.0f);
2279 // Render and notify
2280 application.SendNotification();
2281 application.Render();
2283 // Executes the idle callbacks added by the text control on the change of input style.
2284 application.RunIdles();
2286 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2287 DALI_TEST_CHECK(!inputStyleChangedSignal);
2292 int utcDaliTextFieldInputStyleChanged02(void)
2294 // The text-field emits signals when the input style changes. These changes of style are
2295 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
2296 // can't be emitted during the size negotiation as the callbacks may update the UI.
2297 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
2298 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
2299 ToolkitTestApplication application;
2300 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
2304 char* pathNamePtr = get_current_dir_name();
2305 const std::string pathName(pathNamePtr);
2308 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2309 fontClient.SetDpi(93u, 93u);
2311 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2312 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2314 TextField field = TextField::New();
2315 DALI_TEST_CHECK(field);
2317 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2318 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2319 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2321 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2322 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>");
2324 // connect to the text changed signal.
2325 ConnectionTracker* testTracker = new ConnectionTracker();
2326 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2327 bool inputStyleChangedSignal = false;
2328 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2330 application.GetScene().Add(field);
2332 // Render and notify
2333 application.SendNotification();
2334 application.Render();
2336 // Executes the idle callbacks added by the text control on the change of input style.
2337 application.RunIdles();
2339 gInputStyleChangedCallbackCalled = false;
2340 gInputStyleMask = TextField::InputStyle::NONE;
2341 inputStyleChangedSignal = false;
2343 // Create a tap event to touch the text field.
2344 TestGenerateTap(application, 53.0f, 25.0f, 100);
2345 TestGenerateTap(application, 53.0f, 25.0f, 200);
2347 // Render and notify
2348 application.SendNotification();
2349 application.Render();
2351 // Executes the idle callbacks added by the text control on the change of input style.
2352 application.RunIdles();
2354 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2355 if(gInputStyleChangedCallbackCalled)
2357 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2358 static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY |
2359 TextField::InputStyle::POINT_SIZE |
2360 TextField::InputStyle::COLOR),
2363 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2364 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2366 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2367 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2369 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2370 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2372 DALI_TEST_CHECK(inputStyleChangedSignal);
2374 gInputStyleChangedCallbackCalled = false;
2375 gInputStyleMask = TextField::InputStyle::NONE;
2376 inputStyleChangedSignal = false;
2378 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2380 // Render and notify
2381 application.SendNotification();
2382 application.Render();
2384 // Executes the idle callbacks added by the text control on the change of input style.
2385 application.RunIdles();
2387 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2388 if(gInputStyleChangedCallbackCalled)
2390 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2391 static_cast<unsigned int>(TextField::InputStyle::COLOR),
2394 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2395 DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
2397 DALI_TEST_CHECK(inputStyleChangedSignal);
2399 gInputStyleChangedCallbackCalled = false;
2400 gInputStyleMask = TextField::InputStyle::NONE;
2401 inputStyleChangedSignal = false;
2403 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2405 // Render and notify
2406 application.SendNotification();
2407 application.Render();
2409 // Executes the idle callbacks added by the text control on the change of input style.
2410 application.RunIdles();
2412 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2413 DALI_TEST_CHECK(!inputStyleChangedSignal);
2415 gInputStyleChangedCallbackCalled = false;
2416 gInputStyleMask = TextField::InputStyle::NONE;
2417 inputStyleChangedSignal = false;
2419 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2421 // Render and notify
2422 application.SendNotification();
2423 application.Render();
2425 // Executes the idle callbacks added by the text control on the change of input style.
2426 application.RunIdles();
2428 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2429 if(gInputStyleChangedCallbackCalled)
2431 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2432 static_cast<unsigned int>(TextField::InputStyle::COLOR),
2435 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2436 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2438 DALI_TEST_CHECK(inputStyleChangedSignal);
2440 gInputStyleChangedCallbackCalled = false;
2441 gInputStyleMask = TextField::InputStyle::NONE;
2442 inputStyleChangedSignal = false;
2444 field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
2446 Property::Map fontStyleMapSet;
2447 fontStyleMapSet.Insert("weight", "thin");
2448 fontStyleMapSet.Insert("width", "condensed");
2449 fontStyleMapSet.Insert("slant", "italic");
2451 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
2452 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 20.f);
2454 field.SetProperty(TextField::Property::INPUT_UNDERLINE, "underline");
2455 field.SetProperty(TextField::Property::INPUT_SHADOW, "shadow");
2456 field.SetProperty(TextField::Property::INPUT_EMBOSS, "emboss");
2457 field.SetProperty(TextField::Property::INPUT_OUTLINE, "outline");
2458 field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "strikethrough");
2460 // Render and notify
2461 application.SendNotification();
2462 application.Render();
2464 // Executes the idle callbacks added by the text control on the change of input style.
2465 application.RunIdles();
2467 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2468 DALI_TEST_CHECK(!inputStyleChangedSignal);
2470 // Create a tap event to touch the text field.
2471 TestGenerateTap(application, 63.0f, 25.0f, 700);
2473 // Render and notify
2474 application.SendNotification();
2475 application.Render();
2477 // Executes the idle callbacks added by the text control on the change of input style.
2478 application.RunIdles();
2480 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2481 if(gInputStyleChangedCallbackCalled)
2483 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2484 static_cast<unsigned int>(TextField::InputStyle::COLOR |
2485 TextField::InputStyle::POINT_SIZE |
2486 TextField::InputStyle::FONT_STYLE |
2487 TextField::InputStyle::UNDERLINE |
2488 TextField::InputStyle::SHADOW |
2489 TextField::InputStyle::EMBOSS |
2490 TextField::InputStyle::OUTLINE),
2493 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2494 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2496 DALI_TEST_CHECK(inputStyleChangedSignal);
2501 int utcDaliTextFieldInputStyleChanged03(void)
2503 // Test InputStyleCahnged signal emitted even if AddIdle failed.
2504 ToolkitTestApplication application;
2505 tet_infoline(" utcDaliTextFieldInputStyleChanged03");
2509 char* pathNamePtr = get_current_dir_name();
2510 const std::string pathName(pathNamePtr);
2513 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2514 fontClient.SetDpi(93u, 93u);
2516 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2517 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2519 TextField field = TextField::New();
2520 DALI_TEST_CHECK(field);
2522 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2523 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2524 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2526 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2527 field.SetProperty(TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
2529 // connect to the text changed signal.
2530 ConnectionTracker* testTracker = new ConnectionTracker();
2531 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2532 bool inputStyleChangedSignal = false;
2533 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2535 application.GetScene().Add(field);
2537 // Render and notify
2538 application.SendNotification();
2539 application.Render();
2541 // Executes the idle callbacks added by the text control on the change of input style.
2542 application.RunIdles();
2544 gInputStyleChangedCallbackCalled = false;
2545 gInputStyleMask = TextField::InputStyle::NONE;
2546 inputStyleChangedSignal = false;
2548 // Create a tap event to touch the text field.
2549 TestGenerateTap(application, 18.0f, 25.0f);
2551 // Render and notify
2552 application.SendNotification();
2553 application.Render();
2555 // Executes the idle callbacks added by the text control on the change of input style.
2556 application.RunIdles();
2558 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2559 if(gInputStyleChangedCallbackCalled)
2561 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE), TEST_LOCATION);
2563 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2564 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2566 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2567 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2569 DALI_TEST_CHECK(inputStyleChangedSignal);
2571 gInputStyleChangedCallbackCalled = false;
2572 gInputStyleMask = TextField::InputStyle::NONE;
2573 inputStyleChangedSignal = false;
2575 // Create a tap event to touch the text field.
2576 TestGenerateTap(application, 30.0f, 25.0f);
2578 // Render and notify
2579 application.SendNotification();
2580 application.Render();
2582 // Executes the idle callbacks added by the text control on the change of input style.
2583 application.RunIdles();
2585 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2586 DALI_TEST_CHECK(!inputStyleChangedSignal);
2588 gInputStyleChangedCallbackCalled = false;
2589 gInputStyleMask = TextField::InputStyle::NONE;
2590 inputStyleChangedSignal = false;
2592 // Create a tap event to touch the text field.
2593 TestGenerateTap(application, 43.0f, 25.0f);
2595 // Render and notify
2596 application.SendNotification();
2597 application.Render();
2599 // Executes the idle callbacks added by the text control on the change of input style.
2600 application.RunIdles();
2602 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2603 if(gInputStyleChangedCallbackCalled)
2605 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR), TEST_LOCATION);
2607 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2608 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2610 DALI_TEST_CHECK(inputStyleChangedSignal);
2612 gInputStyleChangedCallbackCalled = false;
2613 gInputStyleMask = TextField::InputStyle::NONE;
2614 inputStyleChangedSignal = false;
2616 // Make AddIdle return false.
2617 ToolkitApplication::ADD_IDLE_SUCCESS = false;
2619 // Create a tap event to touch the text field.
2620 TestGenerateTap(application, 88.0f, 25.0f);
2622 // Render and notify
2623 application.SendNotification();
2624 application.Render();
2626 // Execute the idle callbacks.
2627 // And check whether we didn't change of input style.
2628 application.RunIdles();
2630 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2631 DALI_TEST_CHECK(!inputStyleChangedSignal);
2633 gInputStyleChangedCallbackCalled = false;
2634 gInputStyleMask = TextField::InputStyle::NONE;
2635 inputStyleChangedSignal = false;
2637 // Create a tap event to touch the text field.
2638 TestGenerateTap(application, 115.0f, 25.0f);
2640 // Render and notify
2641 application.SendNotification();
2642 application.Render();
2644 // Execute the idle callbacks.
2645 // And check whether we didn't change of input style.
2646 application.RunIdles();
2648 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2649 DALI_TEST_CHECK(!inputStyleChangedSignal);
2651 gInputStyleChangedCallbackCalled = false;
2652 gInputStyleMask = TextField::InputStyle::NONE;
2653 inputStyleChangedSignal = false;
2655 // Revert AddIdle return true.
2656 ToolkitApplication::ADD_IDLE_SUCCESS = true;
2658 // Create a tap event to touch the text field.
2659 TestGenerateTap(application, 164.0f, 25.0f);
2661 // Render and notify
2662 application.SendNotification();
2663 application.Render();
2665 // Executes the idle callbacks added by the text control on the change of input style.
2666 application.RunIdles();
2668 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2669 if(gInputStyleChangedCallbackCalled)
2671 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2673 const std::string style = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<std::string>();
2674 DALI_TEST_CHECK(style.empty());
2676 DALI_TEST_CHECK(inputStyleChangedSignal);
2678 gInputStyleChangedCallbackCalled = false;
2679 gInputStyleMask = TextField::InputStyle::NONE;
2680 inputStyleChangedSignal = false;
2682 // Create a tap event to touch the text field.
2683 TestGenerateTap(application, 191.0f, 25.0f);
2685 // Render and notify
2686 application.SendNotification();
2687 application.Render();
2689 // Executes the idle callbacks added by the text control on the change of input style.
2690 application.RunIdles();
2692 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2693 DALI_TEST_CHECK(!inputStyleChangedSignal);
2698 int utcDaliTextFieldEvent01(void)
2700 ToolkitTestApplication application;
2701 tet_infoline(" utcDaliTextFieldEvent01");
2703 // Creates a tap event. After creating a tap event the text field should
2704 // have the focus and add text with key events should be possible.
2706 TextField field = TextField::New();
2707 DALI_TEST_CHECK(field);
2709 application.GetScene().Add(field);
2711 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2712 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2713 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2715 // Render and notify
2716 application.SendNotification();
2717 application.Render();
2719 // Avoid a crash when core load gl resources.
2720 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2722 // Render and notify
2723 application.SendNotification();
2724 application.Render();
2726 // Add a key event but as the text field has not the focus it should do nothing.
2727 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2729 // Render and notify
2730 application.SendNotification();
2731 application.Render();
2733 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
2735 // Create a tap event to touch the text field.
2736 TestGenerateTap(application, 150.0f, 25.0f);
2738 // Render and notify
2739 application.SendNotification();
2740 application.Render();
2742 // Pressing delete key should be fine even if there is no text in TextField.
2743 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));
2744 // Render and notify
2745 application.SendNotification();
2746 application.Render();
2748 // Now the text field has the focus, so it can handle the key events.
2749 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2750 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2752 // Render and notify
2753 application.SendNotification();
2754 application.Render();
2756 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2758 // Create a second text field and send key events to it.
2759 TextField field2 = TextField::New();
2761 field2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2762 field2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2763 field2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2764 field2.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
2766 application.GetScene().Add(field2);
2768 // Render and notify
2769 application.SendNotification();
2770 application.Render();
2772 // Create a tap event on the second text field.
2773 TestGenerateTap(application, 150.0f, 125.0f);
2775 // Render and notify
2776 application.SendNotification();
2777 application.Render();
2779 // The second text field has the focus. It should handle the key events.
2780 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2781 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2783 // Render and notify
2784 application.SendNotification();
2785 application.Render();
2787 // Check the text has been added to the second text field.
2788 DALI_TEST_EQUALS(field2.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2793 int utcDaliTextFieldEvent02(void)
2795 ToolkitTestApplication application;
2796 tet_infoline(" utcDaliTextFieldEvent02");
2798 // Checks if the right number of actors are created.
2800 TextField field = TextField::New();
2801 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2802 DALI_TEST_CHECK(field);
2803 LoadMarkerImages(application, field);
2805 application.GetScene().Add(field);
2807 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2808 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2809 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2811 // Avoid a crash when core load gl resources.
2812 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2814 // Render and notify
2815 application.SendNotification();
2816 application.Render();
2818 // Check there are the expected number of children ( stencil ).
2819 DALI_TEST_EQUALS(field.GetChildCount(), 1u, TEST_LOCATION);
2821 Actor stencil = field.GetChildAt(0u);
2822 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2824 // Create a tap event to touch the text field.
2825 TestGenerateTap(application, 150.0f, 25.0f, 300);
2827 // Render and notify
2828 application.SendNotification();
2829 application.Render();
2831 Actor layer = field.GetChildAt(2u);
2832 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2833 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2835 // Now the text field has the focus, so it can handle the key events.
2836 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2837 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2839 // Render and notify
2840 application.SendNotification();
2841 application.Render();
2843 // Checks the cursor and the renderer have been created.
2844 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2845 DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
2847 Control cursor = Control::DownCast(layer.GetChildAt(0u));
2848 DALI_TEST_CHECK(cursor);
2850 // The offscreen root actor has a container with all the actors which contain the text renderers.
2851 Actor container = stencil.GetChildAt(0u);
2852 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2854 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2855 DALI_TEST_CHECK(renderer);
2858 // Move the cursor and check the position changes.
2859 Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
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 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2867 DALI_TEST_CHECK(position2.x < position1.x);
2869 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2871 // Render and notify
2872 application.SendNotification();
2873 application.Render();
2875 Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2876 DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
2878 // Move the cursor to the first position.
2879 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2880 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2882 // Render and notify
2883 application.SendNotification();
2884 application.Render();
2886 Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2888 // Send some taps and check the cursor positions.
2890 // Try to tap at the beginning.
2891 TestGenerateTap(application, 1.0f, 25.0f, 900);
2893 // Render and notify
2894 application.SendNotification();
2895 application.Render();
2897 // Cursor position should be the same than position1.
2898 Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2900 DALI_TEST_EQUALS(position4, position5, TEST_LOCATION); // Should be in the same position2.
2902 // Tap away from the start position.
2903 TestGenerateTap(application, 16.0f, 25.0f, 1500);
2905 // Render and notify
2906 application.SendNotification();
2907 application.Render();
2909 Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2911 DALI_TEST_CHECK(position6.x > position5.x);
2913 // Remove all the text.
2914 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2915 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2916 field.SetProperty(TextField::Property::TEXT, "");
2918 // Render and notify
2919 application.SendNotification();
2920 application.Render();
2922 // Cursor position should be the same than position2.
2923 Vector3 position7 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2925 DALI_TEST_EQUALS(position4, position7, TEST_LOCATION); // Should be in the same position2.
2927 // Should not be a renderer, there is only a clipped cursor.
2928 DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
2930 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2931 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2932 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
2934 application.SendNotification();
2935 application.Render();
2937 // There are renderer and decorator layer
2938 DALI_TEST_EQUALS(field.GetChildCount(), 2u, TEST_LOCATION);
2943 int utcDaliTextFieldEvent03(void)
2945 ToolkitTestApplication application;
2946 tet_infoline(" utcDaliTextFieldEvent03");
2948 // Checks if the highlight actor is created.
2950 TextField field = TextField::New();
2951 DALI_TEST_CHECK(field);
2953 application.GetScene().Add(field);
2955 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2956 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2957 field.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2958 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2959 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2961 // Avoid a crash when core load gl resources.
2962 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2963 LoadMarkerImages(application, field);
2965 // Render and notify
2966 application.SendNotification();
2967 application.Render();
2969 // Tap first to get the focus.
2970 TestGenerateTap(application, 3.0f, 25.0f, 100);
2972 // Render and notify
2973 application.SendNotification();
2974 application.Render();
2976 // Double tap to select a word.
2977 TestGenerateTap(application, 3.0f, 25.0f, 200);
2979 // Render and notify
2980 application.SendNotification();
2981 application.Render();
2983 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2984 Actor stencil = field.GetChildAt(0u);
2986 // The highlight actor is drawn first, so is the first actor in the list
2987 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2988 DALI_TEST_CHECK(highlight);
2990 // The offscreen root actor has a container with all the actors which contain the text renderers.
2991 Actor container = stencil.GetChildAt(1u);
2992 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2994 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2995 DALI_TEST_CHECK(renderer);
3001 int utcDaliTextFieldEvent04(void)
3003 ToolkitTestApplication application;
3004 tet_infoline(" utcDaliTextFieldEvent04");
3006 // Checks if the highlight actor is created.
3008 TextField field = TextField::New();
3009 DALI_TEST_CHECK(field);
3010 application.GetScene().Add(field);
3011 LoadMarkerImages(application, field);
3012 // Render and notify
3013 application.SendNotification();
3014 application.Render();
3016 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
3017 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3018 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3019 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3020 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3022 // Avoid a crash when core load gl resources.
3023 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3024 // Render and notify
3025 application.SendNotification();
3026 application.Render();
3028 // Create a tap event to touch the text field.
3029 TestGenerateTap(application, 150.0f, 25.0f);
3030 // Render and notify
3031 application.SendNotification();
3032 application.Render();
3034 // Tap first to get the focus.
3035 TestGenerateTap(application, 1.0f, 25.0f);
3037 // Render and notify
3038 application.SendNotification();
3039 application.Render();
3041 // Double tap to select a word.
3042 TestGenerateTap(application, 1.0f, 25.0f);
3044 // Render and notify
3045 application.SendNotification();
3046 application.Render();
3049 TestGenerateTap(application, 0.0f, 40.0f);
3051 field.SetProperty(TextField::Property::POINT_SIZE, 12.f);
3052 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3057 int utcDaliTextFieldEvent05(void)
3059 ToolkitTestApplication application;
3060 tet_infoline(" utcDaliTextFieldEvent05");
3062 // Checks dragging of cursor/grab handle
3064 TextField field = TextField::New();
3065 DALI_TEST_CHECK(field);
3066 application.GetScene().Add(field);
3067 LoadMarkerImages(application, field);
3068 // Render and notify
3069 application.SendNotification();
3070 application.Render();
3072 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
3073 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3074 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3075 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3076 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3078 // Avoid a crash when core load gl resources.
3079 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3080 // Render and notify
3081 application.SendNotification();
3082 application.Render();
3084 // Create a tap event to touch the text field.
3085 TestGenerateTap(application, 150.0f, 25.0f);
3086 // Render and notify
3087 application.SendNotification();
3088 application.Render();
3090 // Tap first to get the focus.
3091 TestGenerateTap(application, 1.0f, 25.0f);
3093 // Render and notify
3094 application.SendNotification();
3095 application.Render();
3097 // Double tap to select a word.
3098 TestGenerateTap(application, 1.0f, 25.0f);
3100 // Render and notify
3101 application.SendNotification();
3102 application.Render();
3104 Actor stencil = field.GetChildAt(1u);
3108 int utcDaliTextFieldEvent06(void)
3110 ToolkitTestApplication application;
3111 tet_infoline(" utcDaliTextFieldEvent06");
3113 // Checks Longpress when in edit mode
3115 TextField field = TextField::New();
3116 DALI_TEST_CHECK(field);
3117 application.GetScene().Add(field);
3118 LoadMarkerImages(application, field);
3119 // Render and notify
3120 application.SendNotification();
3121 application.Render();
3123 field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
3124 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3125 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3126 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3127 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3129 // Avoid a crash when core load gl resources.
3130 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3131 // Render and notify
3132 application.SendNotification();
3133 application.Render();
3135 // Create a tap event to touch the text field.
3136 TestGenerateTap(application, 150.0f, 25.0f);
3137 // Render and notify
3138 application.SendNotification();
3139 application.Render();
3141 // Tap first to get the focus.
3142 TestGenerateTap(application, 1.0f, 25.0f);
3144 // Render and notify
3145 application.SendNotification();
3146 application.Render();
3149 TestGenerateLongPress(application, 1.0f, 25.0f);
3151 // Render and notify
3152 application.SendNotification();
3153 application.Render();
3158 int utcDaliTextFieldEvent07(void)
3160 ToolkitTestApplication application;
3161 tet_infoline(" utcDaliTextFieldEvent07");
3163 // Checks Longpress to start edit mode
3165 TextField field = TextField::New();
3166 DALI_TEST_CHECK(field);
3167 application.GetScene().Add(field);
3168 LoadMarkerImages(application, field);
3169 // Render and notify
3170 application.SendNotification();
3171 application.Render();
3173 field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
3174 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3175 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3176 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3177 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3178 Property::Map propertyMap;
3179 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
3180 field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
3182 // Avoid a crash when core load gl resources.
3183 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3184 // Render and notify
3185 application.SendNotification();
3186 application.Render();
3189 TestGenerateLongPress(application, 1.0f, 25.0f);
3191 // Render and notify
3192 application.SendNotification();
3193 application.Render();
3198 int utcDaliTextFieldEvent08(void)
3200 ToolkitTestApplication application;
3201 tet_infoline(" utcDaliTextFieldEvent08");
3203 Dali::Clipboard clipboard = Clipboard::Get();
3204 Dali::Clipboard::ClipData data("text/plain;charset=utf-8", "testTextFieldEvent");
3205 clipboard.SetData(data);
3207 // Checks Longpress when only place holder text
3209 TextField field = TextField::New();
3210 DALI_TEST_CHECK(field);
3211 application.GetScene().Add(field);
3212 LoadMarkerImages(application, field);
3213 // Render and notify
3214 application.SendNotification();
3215 application.Render();
3217 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
3218 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3219 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3220 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3221 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3223 // Avoid a crash when core load gl resources.
3224 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3225 // Render and notify
3226 application.SendNotification();
3227 application.Render();
3230 TestGenerateLongPress(application, 1.0f, 25.0f, 20);
3232 // Render and notify
3233 application.SendNotification();
3234 application.Render();
3236 Wait(application, 500);
3238 TestEndLongPress(application, 1.0f, 25.0f, 520);
3241 TestGenerateLongPress(application, 1.0f, 25.0f, 600);
3243 // Render and notify
3244 application.Render();
3246 Wait(application, 500);
3248 Integration::Scene stage = application.GetScene();
3249 Layer layer = stage.GetRootLayer();
3250 Actor actor = layer.FindChildByName("optionPaste");
3254 Vector3 worldPosition = actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION);
3255 Vector2 halfStageSize = stage.GetSize() / 2.0f;
3256 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
3258 Dali::Integration::TouchEvent event;
3259 event = Dali::Integration::TouchEvent();
3260 event.AddPoint(GetPointDownInside(position));
3261 application.ProcessEvent(event);
3263 event = Dali::Integration::TouchEvent();
3264 event.AddPoint(GetPointUpInside(position));
3265 application.ProcessEvent(event);
3267 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("testTextFieldEvent"), TEST_LOCATION);
3269 Dali::Clipboard::ClipData htmlData("application/xhtml+xml", "testTextFieldEventHtml");
3270 clipboard.SetData(htmlData);
3272 field.SetProperty(TextField::Property::TEXT, "");
3274 // Render and notify
3275 application.SendNotification();
3276 application.Render();
3279 TestGenerateLongPress(application, 1.0f, 25.0f, 20);
3281 // Render and notify
3282 application.SendNotification();
3283 application.Render();
3285 Wait(application, 500);
3287 TestEndLongPress(application, 1.0f, 25.0f, 520);
3290 TestGenerateLongPress(application, 1.0f, 25.0f, 600);
3292 // Render and notify
3293 application.Render();
3295 Wait(application, 500);
3297 stage = application.GetScene();
3298 layer = stage.GetRootLayer();
3299 actor = layer.FindChildByName("optionPaste");
3303 Vector3 worldPosition = actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION);
3304 Vector2 halfStageSize = stage.GetSize() / 2.0f;
3305 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
3307 Dali::Integration::TouchEvent event;
3308 event = Dali::Integration::TouchEvent();
3309 event.AddPoint(GetPointDownInside(position));
3310 application.ProcessEvent(event);
3312 event = Dali::Integration::TouchEvent();
3313 event.AddPoint(GetPointUpInside(position));
3314 application.ProcessEvent(event);
3316 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("testTextFieldEventHtml"), TEST_LOCATION);
3321 int utcDaliTextFieldEvent09(void)
3323 ToolkitTestApplication application;
3324 tet_infoline(" utcDaliTextFieldEvent09");
3326 TextField field = TextField::New();
3327 DALI_TEST_CHECK(field);
3328 application.GetScene().Add(field);
3329 LoadMarkerImages(application, field);
3330 // Render and notify
3331 application.SendNotification();
3332 application.Render();
3334 field.SetProperty(TextField::Property::TEXT, "Hello");
3335 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Placeholder text");
3336 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3337 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3338 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3339 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3341 // Avoid a crash when core load gl resources.
3342 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3344 // Create a tap event to touch the text field.
3345 TestGenerateTap(application, 150.0f, 25.0f);
3346 application.SendNotification();
3347 application.Render();
3350 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_NONE;
3351 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3352 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3353 application.SendNotification();
3354 application.Render();
3355 for(unsigned int index = 0u; index < 6u; ++index)
3357 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3358 application.SendNotification();
3359 application.Render();
3362 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL;
3363 map[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
3364 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3365 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3366 application.SendNotification();
3367 application.Render();
3369 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_COUNT;
3370 map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
3371 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3372 for(unsigned int index = 0u; index < 5u; ++index)
3374 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3375 application.SendNotification();
3376 application.Render();
3379 map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_COUNT;
3380 map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
3381 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3382 for(unsigned int index = 0u; index < 5u; ++index)
3384 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3385 application.SendNotification();
3386 application.Render();
3389 map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
3390 map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 0;
3391 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3392 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3393 application.SendNotification();
3394 application.Render();
3395 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3396 application.SendNotification();
3397 application.Render();
3399 map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 100;
3400 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3401 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3402 application.SendNotification();
3403 application.Render();
3405 Property::Map mapGet;
3406 mapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
3407 DALI_TEST_EQUALS(map.Count(), mapGet.Count(), TEST_LOCATION);
3408 DALI_TEST_EQUALS(DaliTestCheckMaps(map, mapGet), true, TEST_LOCATION);
3412 int utcDaliTextFieldStyleWhilstSelected(void)
3414 ToolkitTestApplication application;
3415 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
3417 // Change font and styles whilst text is selected whilst word selected
3419 TextField field = TextField::New();
3420 DALI_TEST_CHECK(field);
3421 application.GetScene().Add(field);
3422 LoadMarkerImages(application, field);
3423 // Render and notify
3424 application.SendNotification();
3425 application.Render();
3427 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
3428 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3429 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3430 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3431 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3433 // Avoid a crash when core load gl resources.
3434 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3435 // Render and notify
3436 application.SendNotification();
3437 application.Render();
3439 // Create a tap event to touch the text field.
3440 TestGenerateTap(application, 150.0f, 25.0f);
3441 // Render and notify
3442 application.SendNotification();
3443 application.Render();
3445 // Tap first to get the focus.
3446 TestGenerateTap(application, 1.0f, 25.0f);
3448 // Render and notify
3449 application.SendNotification();
3450 application.Render();
3452 // Double tap to select a word.
3453 TestGenerateTap(application, 1.0f, 25.0f);
3455 // Render and notify
3456 application.SendNotification();
3457 application.Render();
3459 field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
3460 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
3462 Property::Map fontStyleMapSet;
3463 Property::Map fontStyleMapGet;
3465 fontStyleMapSet.Insert("weight", "bold");
3466 fontStyleMapSet.Insert("slant", "italic");
3467 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
3469 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
3470 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3471 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3473 fontStyleMapSet.Clear();
3474 fontStyleMapSet.Insert("width", "expanded");
3475 fontStyleMapSet.Insert("slant", "italic");
3476 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
3478 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
3479 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3480 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3482 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
3483 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3485 field.SetProperty(TextField::Property::TEXT_COLOR, Color::RED);
3486 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::RED, TEST_LOCATION);
3488 fontStyleMapSet.Clear();
3489 fontStyleMapSet.Insert("weight", "bold");
3490 fontStyleMapSet.Insert("slant", "italic");
3492 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
3494 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3495 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3496 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3498 fontStyleMapSet.Clear();
3499 fontStyleMapSet.Insert("width", "expanded");
3501 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
3503 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3504 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3505 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3507 // Press Escape to increase coverage
3508 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3509 application.SendNotification();
3510 application.Render();
3512 DALI_TEST_CHECK(!field.HasKeyInputFocus());
3517 int utcDaliTextFieldEscKeyLoseFocus(void)
3519 ToolkitTestApplication application;
3520 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
3522 // Creates a tap event. After creating a tap event the text field should
3523 // have the focus and add text with key events should be possible.
3525 TextField field = TextField::New();
3526 DALI_TEST_CHECK(field);
3528 application.GetScene().Add(field);
3530 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3531 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3532 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3534 // Avoid a crash when core load gl resources.
3535 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3537 // Render and notify
3538 application.SendNotification();
3539 application.Render();
3541 // Add a key event but as the text field has not the focus it should do nothing.
3542 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3543 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3545 // Render and notify
3546 application.SendNotification();
3547 application.Render();
3549 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
3551 // Create a tap event to touch the text field.
3552 TestGenerateTap(application, 150.0f, 25.0f);
3554 // Render and notify
3555 application.SendNotification();
3556 application.Render();
3558 // Now the text field has the focus, so it can handle the key events.
3559 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3560 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3561 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3562 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3564 // Render and notify
3565 application.SendNotification();
3566 application.Render();
3568 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3570 // Generate a Esc key event. The text field should lose the focus.
3571 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3572 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3574 // Render and notify
3575 application.SendNotification();
3576 application.Render();
3578 DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
3580 // No more text should be introduced
3581 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3582 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3584 // Render and notify
3585 application.SendNotification();
3586 application.Render();
3588 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3593 int utcDaliTextFieldSomeSpecialKeys(void)
3595 ToolkitTestApplication application;
3596 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
3598 // Checks some special keys when the text is selected.
3600 TextField field = TextField::New();
3601 DALI_TEST_CHECK(field);
3602 application.GetScene().Add(field);
3603 LoadMarkerImages(application, field);
3604 // Render and notify
3605 application.SendNotification();
3606 application.Render();
3608 const std::string longText("This is a long text for the size of the text-field.");
3610 field.SetProperty(TextField::Property::TEXT, longText);
3611 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3612 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3613 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3614 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3616 // Avoid a crash when core load gl resources.
3617 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3618 // Render and notify
3619 application.SendNotification();
3620 application.Render();
3622 // Create a tap event to touch the text field.
3623 TestGenerateTap(application, 150.0f, 25.0f);
3625 // Render and notify
3626 application.SendNotification();
3627 application.Render();
3629 // Tap first to get the focus.
3630 TestGenerateTap(application, 1.0f, 25.0f);
3632 // Render and notify
3633 application.SendNotification();
3634 application.Render();
3636 // Double tap to select a word.
3637 TestGenerateTap(application, 1.0f, 25.0f);
3639 // Render and notify
3640 application.SendNotification();
3641 application.Render();
3643 // Generate a Esc key event. The text field should lose the focus.
3644 application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3645 application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3647 // Render and notify
3648 application.SendNotification();
3649 application.Render();
3651 // Generate a Esc key event. The text field should lose the focus.
3652 application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3653 application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3655 // Render and notify
3656 application.SendNotification();
3657 application.Render();
3659 // Generate a Esc key event. The text field should lose the focus.
3660 application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3661 application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3663 // Render and notify
3664 application.SendNotification();
3665 application.Render();
3667 // Generate a Back key event. Nothing happens to the text field.
3668 application.ProcessEvent(GenerateKey("XF86Back", "", "XF86Back", DALI_KEY_BACK, 0, 0, Integration::KeyEvent::DOWN, "XF86Back", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3669 application.ProcessEvent(GenerateKey("XF86Back", "", "XF86Back", DALI_KEY_BACK, 0, 0, Integration::KeyEvent::UP, "XF86Back", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3671 // Render and notify
3672 application.SendNotification();
3673 application.Render();
3675 // The text shouldn't be deleted.
3676 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), longText, TEST_LOCATION);
3681 int utcDaliTextFieldSizeUpdate(void)
3683 ToolkitTestApplication application;
3684 tet_infoline("utcDaliTextFieldSizeUpdate");
3686 // Checks some special keys when the text is selected.
3687 TextField field = TextField::New();
3688 DALI_TEST_CHECK(field);
3689 application.GetScene().Add(field);
3691 float previousHeight = 0.0f;
3692 float currentHeight = 0.0f;
3693 const float fieldWidth = 1920.0f;
3695 // "ㅁ" is bigger then "ኢ"
3696 field.SetProperty(Actor::Property::SIZE, Vector2(fieldWidth, 10.0f));
3697 field.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3698 field.SetResizePolicy(ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT);
3700 field.SetProperty(TextField::Property::TEXT, "ኢ");
3701 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3702 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3704 field.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
3705 KeyboardFocusManager::Get().SetCurrentFocusActor(field);
3707 application.SendNotification();
3708 application.Render();
3710 previousHeight = field.GetHeightForWidth(fieldWidth);
3711 DALI_TEST_EQUALS(previousHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3713 // Add another script characters ( glyph height is defferent )
3714 application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3715 application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3717 application.SendNotification();
3718 application.Render();
3720 currentHeight = field.GetHeightForWidth(fieldWidth);
3721 DALI_TEST_EQUALS(currentHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3722 DALI_TEST_EQUALS((previousHeight < currentHeight), true, TEST_LOCATION);
3727 int utcDaliTextFieldExtremlyLargePointSize(void)
3729 ToolkitTestApplication application;
3730 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
3732 TextField field = TextField::New();
3734 field.SetProperty(TextField::Property::TEXT, "Text");
3735 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3736 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3737 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3738 application.GetScene().Add(field);
3742 field.SetProperty(TextField::Property::POINT_SIZE, 160.0f);
3743 application.SendNotification();
3744 DALI_TEST_CHECK(field);
3748 tet_result(TET_FAIL);
3753 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
3755 ToolkitTestApplication application;
3756 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
3757 TextField field = TextField::New();
3758 DALI_TEST_CHECK(field);
3759 application.GetScene().Add(field);
3761 Property::Map fontStyleMapGet;
3763 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3765 Property::Value* weightValue = NULL;
3766 Property::Value* widthValue = NULL;
3767 Property::Value* slantValue = NULL;
3768 weightValue = fontStyleMapGet.Find("weight");
3769 widthValue = fontStyleMapGet.Find("width");
3770 slantValue = fontStyleMapGet.Find("slant");
3771 DALI_TEST_CHECK(!weightValue);
3772 DALI_TEST_CHECK(!widthValue);
3773 DALI_TEST_CHECK(!slantValue);
3778 int UtcDaliTextFieldSettingPlaceholder(void)
3780 ToolkitTestApplication application;
3781 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
3783 TextField field = TextField::New();
3784 DALI_TEST_CHECK(field);
3785 application.GetScene().Add(field);
3787 // Check the placeholder property with pixel size
3788 Property::Map placeholderPixelSizeMapSet;
3789 Property::Map placeholderPixelSizeMapGet;
3790 Property::Map placeholderFontstyleMap;
3791 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT] = "Setting Placeholder Text";
3792 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3793 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::COLOR] = Color::BLUE;
3794 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3795 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3796 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::ELLIPSIS] = true;
3798 placeholderFontstyleMap.Insert("weight", "bold");
3799 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3800 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
3802 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3803 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
3804 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderPixelSizeMapSet), true, TEST_LOCATION);
3806 // Check the placeholder property with point size
3807 Property::Map placeholderMapSet;
3808 Property::Map placeholderMapGet;
3809 placeholderMapSet[Text::PlaceHolder::Property::TEXT] = "Setting Placeholder Text";
3810 placeholderMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3811 placeholderMapSet[Text::PlaceHolder::Property::COLOR] = Color::RED;
3812 placeholderMapSet[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3813 placeholderMapSet[Text::PlaceHolder::Property::POINT_SIZE] = 12.0f;
3814 placeholderMapSet[Text::PlaceHolder::Property::ELLIPSIS] = false;
3816 // Check the placeholder font style property
3817 placeholderFontstyleMap.Clear();
3819 placeholderFontstyleMap.Insert("weight", "bold");
3820 placeholderFontstyleMap.Insert("width", "condensed");
3821 placeholderFontstyleMap.Insert("slant", "italic");
3822 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3823 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3825 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3826 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3827 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3829 // Reset font style.
3830 placeholderFontstyleMap.Clear();
3831 placeholderFontstyleMap.Insert("weight", "normal");
3832 placeholderFontstyleMap.Insert("slant", "oblique");
3833 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3834 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3836 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3837 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3838 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3840 placeholderFontstyleMap.Clear();
3841 placeholderFontstyleMap.Insert("slant", "roman");
3842 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3843 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3845 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3847 placeholderFontstyleMap.Clear();
3848 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3850 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3851 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3852 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3853 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3858 int UtcDaliTextFieldPlaceholderCoverage(void)
3860 ToolkitTestApplication application;
3861 tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
3863 // mPlaceholderFont is created only once, so create a new control for coverage.
3864 TextField fieldForCoverage = TextField::New();
3865 DALI_TEST_CHECK(fieldForCoverage);
3866 application.GetScene().Add(fieldForCoverage);
3868 // for SetPlaceholderFontFamily() coverage.
3869 Property::Map fontFamilyMap;
3870 fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3871 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
3873 // mPlaceholderFont is created only once, so create a new control for coverage.
3874 fieldForCoverage = TextField::New();
3875 DALI_TEST_CHECK(fieldForCoverage);
3876 application.GetScene().Add(fieldForCoverage);
3878 // for SetPlaceholderTextFontSize coverage.
3879 Property::Map fontSizeMap;
3880 fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3881 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
3883 // mPlaceholderFont is created only once, so create a new control for coverage.
3884 fieldForCoverage = TextField::New();
3885 DALI_TEST_CHECK(fieldForCoverage);
3886 application.GetScene().Add(fieldForCoverage);
3888 // for SetPlaceholderTextFontWeight coverage.
3889 Property::Map fontStyleWeightMap;
3890 Property::Map fontStyleWeightPropertyMap;
3891 fontStyleWeightPropertyMap.Insert("weight", "bold");
3892 fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
3893 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
3895 // mPlaceholderFont is created only once, so create a new control for coverage.
3896 fieldForCoverage = TextField::New();
3897 DALI_TEST_CHECK(fieldForCoverage);
3898 application.GetScene().Add(fieldForCoverage);
3900 // for SetPlaceholderTextFontWidth coverage.
3901 Property::Map fontStyleWidthMap;
3902 Property::Map fontStyleWidthPropertyMap;
3903 fontStyleWidthPropertyMap.Insert("width", "expanded");
3904 fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
3905 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
3907 // mPlaceholderFont is created only once, so create a new control for coverage.
3908 fieldForCoverage = TextField::New();
3909 DALI_TEST_CHECK(fieldForCoverage);
3910 application.GetScene().Add(fieldForCoverage);
3912 // for SetPlaceholderTextFontSlant coverage.
3913 Property::Map fontStyleSlantMap;
3914 Property::Map fontStyleSlantPropertyMap;
3915 fontStyleSlantPropertyMap.Insert("slant", "italic");
3916 fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
3917 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
3922 int UtcDaliTextFieldSetPaddingProperty(void)
3924 ToolkitTestApplication application;
3925 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3927 TextField field = TextField::New();
3928 DALI_TEST_CHECK(field);
3929 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3930 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3931 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3932 application.GetScene().Add(field);
3934 application.SendNotification();
3935 application.Render();
3937 Vector3 originalSize = field.GetNaturalSize();
3939 field.SetProperty(Toolkit::Control::Property::PADDING, Extents(10, 10, 10, 10));
3941 application.SendNotification();
3942 application.Render();
3944 DALI_TEST_EQUALS(field.GetProperty<Extents>(Toolkit::Control::Property::PADDING), Extents(10, 10, 10, 10), TEST_LOCATION);
3946 Vector3 paddingAddedSize = field.GetNaturalSize();
3948 DALI_TEST_EQUALS(originalSize.width + 10 + 10, paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3950 DALI_TEST_EQUALS(originalSize.height + 10 + 10, paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3955 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3957 ToolkitTestApplication application;
3958 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3960 TextField field = TextField::New();
3961 DALI_TEST_CHECK(field);
3962 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3963 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3964 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3965 application.GetScene().Add(field);
3967 application.SendNotification();
3968 application.Render();
3970 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3971 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), true, TEST_LOCATION);
3973 // Check the enable shift selection property
3974 field.SetProperty(DevelTextField::Property::ENABLE_SHIFT_SELECTION, false);
3975 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), false, TEST_LOCATION);
3977 application.SendNotification();
3978 application.Render();
3983 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3985 ToolkitTestApplication application;
3986 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3988 TextField field = TextField::New();
3989 DALI_TEST_CHECK(field);
3990 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3991 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3992 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3993 application.GetScene().Add(field);
3995 application.SendNotification();
3996 application.Render();
3998 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3999 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), true, TEST_LOCATION);
4001 // Check the enable grab handle property
4002 field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE, false);
4003 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), false, TEST_LOCATION);
4005 application.SendNotification();
4006 application.Render();
4011 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
4013 ToolkitTestApplication application;
4014 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
4016 TextField field = TextField::New();
4017 DALI_TEST_CHECK(field);
4018 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4019 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4020 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4021 application.GetScene().Add(field);
4023 application.SendNotification();
4024 application.Render();
4026 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
4027 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), true, TEST_LOCATION);
4029 // Check the match system language direction property
4030 field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
4031 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), false, TEST_LOCATION);
4033 application.SendNotification();
4034 application.Render();
4039 int utcDaliTextFieldLayoutDirectionCoverage(void)
4041 ToolkitTestApplication application;
4042 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
4044 // Creates a tap event. After creating a tap event the text field should
4045 // have the focus and add text with key events should be possible.
4046 TextField field = TextField::New();
4047 DALI_TEST_CHECK(field);
4049 application.GetScene().Add(field);
4051 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4052 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4053 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4055 // Avoid a crash when core load gl resources.
4056 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4058 // Render and notify
4059 application.SendNotification();
4060 application.Render();
4062 // init direction for coverage
4063 // Set horizontal alignment END
4064 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
4066 // Create a tap event to touch the text field.
4067 TestGenerateTap(application, 150.0f, 25.0f);
4069 // Render and notify
4070 application.SendNotification();
4071 application.Render();
4073 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
4074 field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true);
4075 field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
4077 // Set horizontal alignment BEGIN
4078 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
4080 // Create a tap event to touch the text field.
4081 TestGenerateTap(application, 150.0f, 25.0f);
4083 // Render and notify
4084 application.SendNotification();
4085 application.Render();
4087 // Set horizontal alignment CENTER
4088 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
4090 // Create a tap event to touch the text field.
4091 TestGenerateTap(application, 150.0f, 25.0f);
4093 // Render and notify
4094 application.SendNotification();
4095 application.Render();
4097 // Set horizontal alignment END
4098 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
4100 // Create a tap event to touch the text field.
4101 TestGenerateTap(application, 150.0f, 25.0f);
4103 // Render and notify
4104 application.SendNotification();
4105 application.Render();
4107 // Generate a Esc key event. The text field should lose the focus.
4108 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4109 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4111 // Render and notify
4112 application.SendNotification();
4113 application.Render();
4115 DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
4120 int UtcDaliTextFieldGetInputMethodContext(void)
4122 ToolkitTestApplication application;
4123 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
4125 TextField field = TextField::New();
4126 DALI_TEST_CHECK(DevelTextField::GetInputMethodContext(field));
4131 int UtcDaliTextFieldSelectWholeText(void)
4133 ToolkitTestApplication application;
4134 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
4136 TextField textField = TextField::New();
4138 application.GetScene().Add(textField);
4140 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4141 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4142 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4144 // Avoid a crash when core load gl resources.
4145 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4147 application.SendNotification();
4148 application.Render();
4150 DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
4152 DevelTextField::SelectWholeText(textField);
4154 application.SendNotification();
4155 application.Render();
4157 // Nothing should have been selected. The number of children is still 1
4158 DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
4160 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4162 application.SendNotification();
4163 application.Render();
4165 DevelTextField::SelectWholeText(textField);
4167 application.SendNotification();
4168 application.Render();
4170 // Even if resize, selection should remain.
4171 textField.SetProperty(Actor::Property::SIZE, Vector2(150.f, 50.f));
4173 application.SendNotification();
4174 application.Render();
4176 // Should be 2 children, the stencil and the layer
4177 DALI_TEST_EQUALS(2u, textField.GetChildCount(), TEST_LOCATION);
4179 // The offscreen root actor should have two actors: the renderer and the highlight actor.
4180 Actor stencil = textField.GetChildAt(0u);
4182 // The highlight actor is drawn first, so is the first actor in the list
4183 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
4184 DALI_TEST_CHECK(highlight);
4189 int UtcDaliTextFieldSelectText(void)
4191 ToolkitTestApplication application;
4192 tet_infoline(" UtcDaliTextFieldSelectText ");
4194 TextField textField = TextField::New();
4196 application.GetScene().Add(textField);
4198 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4199 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4200 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4202 // Avoid a crash when core load gl resources.
4203 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4205 application.SendNotification();
4206 application.Render();
4208 DevelTextField::SelectText(textField, 0, 5);
4210 application.SendNotification();
4211 application.Render();
4213 // Nothing is selected
4214 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4215 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
4217 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4219 application.SendNotification();
4220 application.Render();
4222 // Hello is selected
4223 DevelTextField::SelectText(textField, 0, 5);
4225 application.SendNotification();
4226 application.Render();
4228 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4229 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4231 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4232 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4234 // world is selected
4235 DevelTextField::SelectText(textField, 6, 11);
4237 application.SendNotification();
4238 application.Render();
4240 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4241 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4243 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4244 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4249 int UtcDaliTextFieldSelectNone(void)
4251 ToolkitTestApplication application;
4252 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
4254 TextField textField = TextField::New();
4256 application.GetScene().Add(textField);
4258 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4259 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4260 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4262 // Avoid a crash when core load gl resources.
4263 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4265 application.SendNotification();
4266 application.Render();
4268 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4270 application.SendNotification();
4271 application.Render();
4273 // Nothing is selected
4274 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4275 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
4277 DevelTextField::SelectWholeText(textField);
4279 application.SendNotification();
4280 application.Render();
4282 // whole text is selected
4283 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4284 DALI_TEST_EQUALS("Hello world", selectedText, TEST_LOCATION);
4286 DevelTextField::SelectNone(textField);
4288 application.SendNotification();
4289 application.Render();
4291 // Nothing is selected
4292 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4293 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
4298 int UtcDaliTextFieldSelectRange(void)
4300 ToolkitTestApplication application;
4301 tet_infoline(" UtcDaliTextFieldSelectRange ");
4303 TextField textField = TextField::New();
4305 application.GetScene().Add(textField);
4307 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4308 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4309 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4311 // Avoid a crash when core load gl resources.
4312 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4314 application.SendNotification();
4315 application.Render();
4317 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4319 application.SendNotification();
4320 application.Render();
4322 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 0);
4323 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 5);
4325 // Hello is selected
4326 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4327 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4329 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4330 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4332 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 6);
4333 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 11);
4335 // world is selected
4336 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4337 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4339 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4340 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4345 int UtcDaliTextFieldEnableEditing(void)
4347 ToolkitTestApplication application;
4348 tet_infoline(" UtcDaliTextFieldEnableEditing ");
4350 TextField textField = TextField::New();
4352 application.GetScene().Add(textField);
4354 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4355 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4356 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4358 // Avoid a crash when core load gl resources.
4359 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4361 application.SendNotification();
4362 application.Render();
4364 textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
4365 DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), true, TEST_LOCATION);
4367 textField.SetKeyInputFocus();
4368 textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, false);
4369 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4371 // Render and notify
4372 application.SendNotification();
4373 application.Render();
4375 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "", TEST_LOCATION);
4376 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), false, TEST_LOCATION);
4378 textField.SetKeyInputFocus();
4379 textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
4380 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4382 // Render and notify
4383 application.SendNotification();
4384 application.Render();
4386 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
4387 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), true, TEST_LOCATION);
4389 // Check the user interaction enabled and for coverage
4390 DevelTextField::SelectWholeText(textField);
4392 // Render and notify
4393 application.SendNotification();
4394 application.Render();
4396 textField.SetKeyInputFocus();
4397 textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false);
4398 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4400 // Render and notify
4401 application.SendNotification();
4402 application.Render();
4404 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
4405 DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), false, TEST_LOCATION);
4410 int UtcDaliToolkitTextFieldFontSizeScale(void)
4412 ToolkitTestApplication application;
4413 tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
4415 TextField textField = TextField::New();
4416 textField.SetProperty(TextField::Property::POINT_SIZE, 30.f);
4417 textField.SetProperty(TextField::Property::TEXT, "Test");
4418 Vector3 nonScaledSize = textField.GetNaturalSize();
4420 TextField textFieldScaled = TextField::New();
4421 textFieldScaled.SetProperty(TextField::Property::POINT_SIZE, 15.f);
4422 textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
4423 textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
4424 Vector3 scaledSize = textFieldScaled.GetNaturalSize();
4426 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4428 textField.SetProperty(TextField::Property::PIXEL_SIZE, 30.f);
4429 textField.SetProperty(TextField::Property::TEXT, "Test");
4430 nonScaledSize = textField.GetNaturalSize();
4432 textFieldScaled.SetProperty(TextField::Property::PIXEL_SIZE, 15.f);
4433 textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
4434 textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
4435 scaledSize = textFieldScaled.GetNaturalSize();
4437 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4442 int UtcDaliTextFieldPrimaryCursorPosition(void)
4444 ToolkitTestApplication application;
4445 tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
4447 TextField textField = TextField::New();
4449 application.GetScene().Add(textField);
4451 textField.SetProperty(TextField::Property::TEXT, "ABCEF");
4452 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4453 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4454 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4456 // Avoid a crash when core load gl resources.
4457 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4459 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4460 application.SendNotification();
4461 application.Render();
4462 textField.SetKeyInputFocus();
4464 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4466 // Render and notify
4467 application.SendNotification();
4468 application.Render();
4470 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCDEF", TEST_LOCATION);
4471 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
4476 // test max length when set after setting long text
4477 int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
4479 ToolkitTestApplication application;
4480 tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
4481 TextField field = TextField::New();
4482 DALI_TEST_CHECK(field);
4484 application.GetScene().Add(field);
4486 field.SetProperty(TextField::Property::TEXT, "123456789");
4488 const int maxNumberOfCharacters = 3;
4489 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
4491 field.SetKeyInputFocus();
4493 // connect to the text max lengh reached signal.
4494 ConnectionTracker* testTracker = new ConnectionTracker();
4495 bool maxLengthReachedSignal = false;
4496 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
4498 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4499 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4501 DALI_TEST_CHECK(maxLengthReachedSignal);
4503 DALI_TEST_EQUALS(field.GetProperty(TextField::Property::TEXT).Get<std::string>(), "123456789", TEST_LOCATION);
4508 int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
4510 ToolkitTestApplication application;
4511 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
4513 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4514 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4515 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4517 // Create a text field
4518 TextField textField = TextField::New();
4520 //Set size to avoid automatic eliding
4521 textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4522 //Set very large font-size using point-size
4523 textField.SetProperty(TextField::Property::POINT_SIZE, 1000);
4524 //Specify font-family
4525 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4526 //Set text to check if appear or not
4527 textField.SetProperty(TextField::Property::TEXT, "A");
4529 application.GetScene().Add(textField);
4531 application.SendNotification();
4532 application.Render();
4533 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4534 Vector3 naturalSize = textField.GetNaturalSize();
4536 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4537 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4542 int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
4544 ToolkitTestApplication application;
4545 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
4547 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4548 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4549 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4551 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4552 // Create a text editor
4553 TextField textField = TextField::New();
4555 //Set size to avoid automatic eliding
4556 textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4557 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4558 textField.SetProperty(TextField::Property::TEXT, "A");
4560 const int numberOfCases = 6;
4561 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
4563 for(int index = 0; index < numberOfCases; index++)
4565 tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
4566 textField.SetProperty(TextField::Property::POINT_SIZE, arrayCases[index]);
4567 application.GetScene().Add(textField);
4568 application.SendNotification();
4569 application.Render();
4570 naturalSize = textField.GetNaturalSize();
4571 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4572 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4578 int UtcDaliToolkitTextFieldEllipsisPositionProperty(void)
4580 ToolkitTestApplication application;
4581 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty ");
4582 TextField textField = TextField::New();
4584 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Default is END");
4585 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4587 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START");
4588 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4589 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4591 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE");
4592 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4593 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4595 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END");
4596 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4597 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4599 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START using integer");
4600 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 1);
4601 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4603 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE using integer");
4604 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 2);
4605 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4607 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END using integer");
4608 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 0);
4609 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4611 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4612 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "START");
4613 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4615 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4616 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "MIDDLE");
4617 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4619 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4620 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "END");
4621 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4623 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4624 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "start");
4625 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4627 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4628 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "middle");
4629 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4631 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4632 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "end");
4633 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4638 int UtcDaliTextFieldCopyText(void)
4640 ToolkitTestApplication application;
4641 tet_infoline(" UtcDaliTextFieldCopyText ");
4643 TextField textField = TextField::New();
4645 std::string selectedText = "";
4646 std::string copiedText = "";
4648 application.GetScene().Add(textField);
4650 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4651 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4652 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4654 // Avoid a crash when core load gl resources.
4655 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4657 application.SendNotification();
4658 application.Render();
4660 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4662 application.SendNotification();
4663 application.Render();
4665 // Hello is selected
4666 DevelTextField::SelectText(textField, 0, 5);
4668 application.SendNotification();
4669 application.Render();
4671 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4672 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4674 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4675 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4678 copiedText = DevelTextField::CopyText(textField);
4679 DALI_TEST_EQUALS("Hello", copiedText, TEST_LOCATION);
4681 // world is selected
4682 DevelTextField::SelectText(textField, 6, 11);
4684 application.SendNotification();
4685 application.Render();
4687 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4688 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4690 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4691 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4694 copiedText = DevelTextField::CopyText(textField);
4695 DALI_TEST_EQUALS("world", copiedText, TEST_LOCATION);
4697 // "lo wo" is selected
4698 DevelTextField::SelectText(textField, 3, 8);
4700 application.SendNotification();
4701 application.Render();
4703 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4704 DALI_TEST_EQUALS("lo wo", selectedText, TEST_LOCATION);
4706 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 3, TEST_LOCATION);
4707 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 8, TEST_LOCATION);
4709 // "lo wo" is copied
4710 copiedText = DevelTextField::CopyText(textField);
4711 DALI_TEST_EQUALS("lo wo", copiedText, TEST_LOCATION);
4716 int UtcDaliTextFieldCutText(void)
4718 ToolkitTestApplication application;
4719 tet_infoline(" UtcDaliTextFieldCutText ");
4721 TextField textField = TextField::New();
4723 std::string selectedText = "";
4725 application.GetScene().Add(textField);
4727 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4728 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4729 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4731 // Avoid a crash when core load gl resources.
4732 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4734 application.SendNotification();
4735 application.Render();
4737 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4739 application.SendNotification();
4740 application.Render();
4742 // Hello is selected
4743 DevelTextField::SelectText(textField, 0, 5);
4745 application.SendNotification();
4746 application.Render();
4748 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4749 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4751 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4752 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4755 DALI_TEST_EQUALS("Hello", DevelTextField::CutText(textField), TEST_LOCATION);
4757 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), " world", TEST_LOCATION);
4760 DevelTextField::SelectText(textField, 0, 2);
4762 application.SendNotification();
4763 application.Render();
4765 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4766 DALI_TEST_EQUALS(" w", selectedText, TEST_LOCATION);
4768 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4769 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4772 DALI_TEST_EQUALS(" w", DevelTextField::CutText(textField), TEST_LOCATION);
4774 application.SendNotification();
4775 application.Render();
4777 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "orld", TEST_LOCATION);
4779 // Test Cut from the middle
4782 DevelTextField::SelectText(textField, 1, 3);
4784 application.SendNotification();
4785 application.Render();
4787 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4788 DALI_TEST_EQUALS("rl", selectedText, TEST_LOCATION);
4790 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4791 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 3, TEST_LOCATION);
4794 DALI_TEST_EQUALS("rl", DevelTextField::CutText(textField), TEST_LOCATION);
4796 application.SendNotification();
4797 application.Render();
4799 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "od", TEST_LOCATION);
4801 // Test Cut from the end
4804 DevelTextField::SelectText(textField, 1, 2);
4806 application.SendNotification();
4807 application.Render();
4809 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4810 DALI_TEST_EQUALS("d", selectedText, TEST_LOCATION);
4812 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4813 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4816 DALI_TEST_EQUALS("d", DevelTextField::CutText(textField), TEST_LOCATION);
4818 application.SendNotification();
4819 application.Render();
4821 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "o", TEST_LOCATION);
4826 int UtcDaliTextFieldPasteText(void)
4828 ToolkitTestApplication application;
4829 tet_infoline(" UtcDaliTextFieldPasteText ");
4831 TextField textField = TextField::New();
4833 application.GetScene().Add(textField);
4835 std::string cutText = "";
4836 std::string copiedText = "";
4838 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4839 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4840 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4842 // Avoid a crash when core load gl resources.
4843 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4845 application.SendNotification();
4846 application.Render();
4848 textField.SetProperty(TextField::Property::TEXT, "Hello World");
4850 application.SendNotification();
4851 application.Render();
4853 // Tap on the text editor
4854 TestGenerateTap(application, 3.0f, 25.0f);
4856 // Render and notify
4857 application.SendNotification();
4858 application.Render();
4860 // Select some text in the right of the current cursor position
4861 DevelTextField::SelectText(textField, 0, 3);
4863 // Render and notify
4864 application.SendNotification();
4865 application.Render();
4867 // Cut the selected text
4868 cutText = DevelTextField::CutText(textField);
4870 // Render and notify
4871 application.SendNotification();
4872 application.Render();
4874 DALI_TEST_EQUALS("Hel", cutText, TEST_LOCATION);
4875 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo World", TEST_LOCATION);
4877 DevelTextField::SelectText(textField, 0, 3);
4879 // Render and notify
4880 application.SendNotification();
4881 application.Render();
4883 // Copy the selected text
4884 copiedText = DevelTextField::CopyText(textField);
4886 // Render and notify
4887 application.SendNotification();
4888 application.Render();
4890 DALI_TEST_EQUALS("lo ", copiedText, TEST_LOCATION);
4891 DALI_TEST_EQUALS("lo World", textField.GetProperty<std::string>(TextField::Property::TEXT), TEST_LOCATION);
4893 // Move the cursor to the end of the line
4894 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4895 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4896 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4897 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4898 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4899 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4900 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4901 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4903 // Render and notify
4904 application.SendNotification();
4905 application.Render();
4907 // Paste the selected text at the current cursor position
4908 DevelTextField::PasteText(textField);
4910 // Render and notify
4911 application.SendNotification();
4912 application.Render();
4914 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo Worldlo ", TEST_LOCATION);
4919 int utcDaliTextFieldCursorPositionChangedSignal(void)
4921 ToolkitTestApplication application;
4922 tet_infoline(" utcDaliTextFieldCursorPositionChangedSignal");
4924 TextField field = TextField::New();
4925 DALI_TEST_CHECK(field);
4927 application.GetScene().Add(field);
4929 // connect to the selection changed signal.
4930 ConnectionTracker* testTracker = new ConnectionTracker();
4931 DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
4932 bool cursorPositionChangedSignal = false;
4933 field.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
4935 field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
4936 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4937 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4938 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4939 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4941 // Avoid a crash when core load gl resources.
4942 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4944 // Render and notify
4945 application.SendNotification();
4946 application.Render();
4948 field.SetKeyInputFocus();
4950 // Tap on the text field
4951 TestGenerateTap(application, 3.0f, 25.0f);
4953 // Render and notify
4954 application.SendNotification();
4955 application.Render();
4957 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4958 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4960 gCursorPositionChangedCallbackCalled = false;
4963 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4965 // Render and notify
4966 application.SendNotification();
4967 application.Render();
4969 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4970 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4972 gCursorPositionChangedCallbackCalled = false;
4975 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4977 // Render and notify
4978 application.SendNotification();
4979 application.Render();
4981 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4982 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4984 gCursorPositionChangedCallbackCalled = false;
4986 //delete one character
4987 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4989 // Render and notify
4990 application.SendNotification();
4991 application.Render();
4993 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4994 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4996 gCursorPositionChangedCallbackCalled = false;
4998 field.SetProperty(TextField::Property::TEXT, "Hello");
5000 // Render and notify
5001 application.SendNotification();
5002 application.Render();
5004 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5005 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
5007 gCursorPositionChangedCallbackCalled = false;
5009 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5011 // Render and notify
5012 application.SendNotification();
5013 application.Render();
5015 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5016 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
5021 int utcDaliTextFieldGeometryEllipsisStart(void)
5023 ToolkitTestApplication application;
5024 tet_infoline(" utcDaliTextFieldGeometryEllipsisStart");
5026 TextField field = TextField::New();
5027 DALI_TEST_CHECK(field);
5029 application.GetScene().Add(field);
5031 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5032 field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
5033 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5034 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5035 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5036 field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
5037 field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
5038 field.SetProperty(TextField::Property::TEXT, "Hello World");
5040 // Avoid a crash when core load gl resources.
5041 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5043 // Render and notify
5044 application.SendNotification();
5045 application.Render();
5047 unsigned int expectedCount = 1;
5048 unsigned int startIndex = 0;
5049 unsigned int endIndex = 10;
5051 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5052 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
5054 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5055 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5057 Vector<Vector2> expectedSizes;
5058 Vector<Vector2> expectedPositions;
5060 expectedPositions.PushBack(Vector2(14, 0));
5061 expectedSizes.PushBack(Vector2(107, 25));
5063 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5068 int utcDaliTextFieldGeometryEllipsisEnd(void)
5070 ToolkitTestApplication application;
5071 tet_infoline(" utcDaliTextFieldGeometryEllipsisEnd");
5073 TextField field = TextField::New();
5074 DALI_TEST_CHECK(field);
5076 application.GetScene().Add(field);
5078 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5079 field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
5080 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5081 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5082 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5083 field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
5084 field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
5085 field.SetProperty(TextField::Property::TEXT, "Hello World");
5087 // Avoid a crash when core load gl resources.
5088 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5090 // Render and notify
5091 application.SendNotification();
5092 application.Render();
5094 unsigned int expectedCount = 1;
5095 unsigned int startIndex = 0;
5096 unsigned int endIndex = 10;
5098 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5099 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
5101 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5102 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5104 Vector<Vector2> expectedSizes;
5105 Vector<Vector2> expectedPositions;
5107 expectedPositions.PushBack(Vector2(-2, 0));
5108 expectedSizes.PushBack(Vector2(123, 25));
5110 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5115 int utcDaliTextFieldGeometryRTL(void)
5117 ToolkitTestApplication application;
5118 tet_infoline(" utcDaliTextFieldGeometryRTL");
5120 TextField field = TextField::New();
5121 DALI_TEST_CHECK(field);
5123 application.GetScene().Add(field);
5125 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5126 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
5127 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5128 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5129 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5130 field.SetProperty(TextField::Property::TEXT, "السطر الاخير");
5132 // Avoid a crash when core load gl resources.
5133 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5135 // Render and notify
5136 application.SendNotification();
5137 application.Render();
5139 unsigned int expectedCount = 1;
5140 unsigned int startIndex = 1;
5141 unsigned int endIndex = 7;
5143 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5144 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
5146 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5147 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5149 Vector<Vector2> expectedSizes;
5150 Vector<Vector2> expectedPositions;
5152 expectedPositions.PushBack(Vector2(38, 0));
5153 expectedSizes.PushBack(Vector2(75, 25));
5155 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5160 int utcDaliTextFieldGeometryGlyphMiddle(void)
5162 ToolkitTestApplication application;
5163 tet_infoline(" utcDaliTextFieldGeometryGlyphMiddle");
5165 TextField field = TextField::New();
5166 DALI_TEST_CHECK(field);
5168 application.GetScene().Add(field);
5170 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5171 field.SetProperty(Actor::Property::SIZE, Vector2(150.f, 200.f));
5172 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5173 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5174 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5175 field.SetProperty(TextField::Property::TEXT, "لا تحتوي على لا");
5177 // Avoid a crash when core load gl resources.
5178 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5180 // Render and notify
5181 application.SendNotification();
5182 application.Render();
5184 unsigned int expectedCount = 1;
5185 unsigned int startIndex = 1;
5186 unsigned int endIndex = 13;
5188 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5189 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
5191 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5192 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5194 Vector<Vector2> expectedSizes;
5195 Vector<Vector2> expectedPositions;
5197 expectedPositions.PushBack(Vector2(6, 0));
5198 expectedSizes.PushBack(Vector2(125, 25));
5200 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5205 int utcDaliTextFieldGeometryNullPtr(void)
5207 ToolkitTestApplication application;
5208 tet_infoline("utcDaliTextFieldGeometryNullPtr");
5210 TextField field = TextField::New();
5211 DALI_TEST_CHECK(field);
5213 application.GetScene().Add(field);
5215 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5216 field.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
5217 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5218 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5219 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5220 field.SetProperty(TextField::Property::TEXT, "");
5222 // Avoid a crash when core load gl resources.
5223 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5225 unsigned int expectedCount = 0;
5226 unsigned int startIndex = 0;
5227 unsigned int endIndex = 0;
5229 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5230 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
5232 // Render and notify
5233 application.SendNotification();
5234 application.Render();
5236 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5237 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5242 int utcDaliTextFieldSelectionClearedSignal(void)
5244 ToolkitTestApplication application;
5245 tet_infoline(" utcDaliTextFieldSelectionClearedSignal");
5247 TextField field = TextField::New();
5248 DALI_TEST_CHECK(field);
5250 application.GetScene().Add(field);
5252 // connect to the selection changed signal.
5253 ConnectionTracker* testTracker = new ConnectionTracker();
5254 DevelTextField::SelectionClearedSignal(field).Connect(&TestSelectionClearedCallback);
5255 bool selectionClearedSignal = false;
5256 field.ConnectSignal(testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal));
5258 field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
5259 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5260 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5261 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5262 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5264 // Avoid a crash when core load gl resources.
5265 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5267 // Render and notify
5268 application.SendNotification();
5269 application.Render();
5271 // Tap on the text editor
5272 TestGenerateTap(application, 3.0f, 25.0f);
5274 // Render and notify
5275 application.SendNotification();
5276 application.Render();
5278 // Move to second line of the text & Select some text in the right of the current cursor position
5279 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5280 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5283 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5285 // Render and notify
5286 application.SendNotification();
5287 application.Render();
5289 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5291 // Render and notify
5292 application.SendNotification();
5293 application.Render();
5295 // Tap on the text editor
5296 TestGenerateTap(application, 3.0f, 25.0f);
5298 // Render and notify
5299 application.SendNotification();
5300 application.Render();
5302 gSelectionClearedCallbackCalled = false;
5304 // Move to second line of the text & select.
5305 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5306 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5309 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5311 // Render and notify
5312 application.SendNotification();
5313 application.Render();
5315 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5317 gSelectionClearedCallbackCalled = false;
5319 // Render and notify
5320 application.SendNotification();
5321 application.Render();
5323 // Move to second line of the text & select.
5324 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5325 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5327 // replace D with selected text
5328 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5330 // Render and notify
5331 application.SendNotification();
5332 application.Render();
5334 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5336 gSelectionClearedCallbackCalled = false;
5338 // Render and notify
5339 application.SendNotification();
5340 application.Render();
5342 DevelTextField::SelectText(field, 1, 3);
5344 // Render and notify
5345 application.SendNotification();
5346 application.Render();
5348 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5350 // Render and notify
5351 application.SendNotification();
5352 application.Render();
5354 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5356 gSelectionClearedCallbackCalled = false;
5358 DevelTextField::SelectText(field, 1, 3);
5360 // Render and notify
5361 application.SendNotification();
5362 application.Render();
5365 DevelTextField::SelectNone(field);
5367 // Render and notify
5368 application.SendNotification();
5369 application.Render();
5371 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5376 int utcDaliTextFieldSelectionStartedSignal(void)
5378 ToolkitTestApplication application;
5379 tet_infoline(" utcDaliTextFieldSelectionStartedSignal");
5381 TextField field = TextField::New();
5382 DALI_TEST_CHECK(field);
5384 application.GetScene().Add(field);
5386 // connect to the selection changed signal.
5387 ConnectionTracker* testTracker = new ConnectionTracker();
5388 DevelTextField::SelectionStartedSignal(field).Connect(&TestSelectionStartedCallback);
5389 bool selectionStartedSignal = false;
5390 field.ConnectSignal(testTracker, "selectionStarted", CallbackFunctor(&selectionStartedSignal));
5392 field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
5393 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5394 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5395 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5396 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5398 // Avoid a crash when core load gl resources.
5399 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5401 // Render and notify
5402 application.SendNotification();
5403 application.Render();
5405 // Tap on the text field
5406 TestGenerateTap(application, 3.0f, 25.0f);
5408 // Render and notify
5409 application.SendNotification();
5410 application.Render();
5412 // Move to second line of the text & Select some text in the right of the current cursor position
5413 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5414 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5416 // Render and notify
5417 application.SendNotification();
5418 application.Render();
5420 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5423 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5425 // Render and notify
5426 application.SendNotification();
5427 application.Render();
5429 gSelectionStartedCallbackCalled = false;
5431 DevelTextField::SelectText(field, 1, 3);
5433 // Render and notify
5434 application.SendNotification();
5435 application.Render();
5437 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5442 int utcDaliTextFieldSelectionChangedSignal(void)
5444 ToolkitTestApplication application;
5445 tet_infoline(" utcDaliTextFieldSelectionChangedSignal");
5447 TextField field = TextField::New();
5448 DALI_TEST_CHECK(field);
5450 application.GetScene().Add(field);
5452 // connect to the selection changed signal.
5453 ConnectionTracker* testTracker = new ConnectionTracker();
5454 DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
5455 bool selectionChangedSignal = false;
5456 field.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
5458 field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
5459 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5460 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5461 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5462 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5464 // Avoid a crash when core load gl resources.
5465 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5467 // Render and notify
5468 application.SendNotification();
5469 application.Render();
5471 // Tap on the text field
5472 TestGenerateTap(application, 3.0f, 25.0f);
5474 // Render and notify
5475 application.SendNotification();
5476 application.Render();
5478 // Select some text in the right of the current cursor position
5479 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5480 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5482 // Render and notify
5483 application.SendNotification();
5484 application.Render();
5486 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5487 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5489 gSelectionChangedCallbackCalled = false;
5491 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5493 // Render and notify
5494 application.SendNotification();
5495 application.Render();
5497 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5498 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5499 DALI_TEST_EQUALS(oldSelectionEnd, 1, TEST_LOCATION);
5501 gSelectionChangedCallbackCalled = false;
5503 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5505 // Render and notify
5506 application.SendNotification();
5507 application.Render();
5509 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5510 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5511 DALI_TEST_EQUALS(oldSelectionEnd, 2, TEST_LOCATION);
5513 gSelectionChangedCallbackCalled = false;
5514 field.SetKeyInputFocus();
5516 // Render and notify
5517 application.SendNotification();
5518 application.Render();
5520 DevelTextField::SelectText(field, 0, 5);
5522 application.SendNotification();
5523 application.Render();
5525 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5526 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5528 gSelectionChangedCallbackCalled = false;
5530 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5532 // Render and notify
5533 application.SendNotification();
5534 application.Render();
5536 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5537 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5538 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
5540 gSelectionChangedCallbackCalled = false;
5543 DevelTextField::SelectWholeText(field);
5545 // Render and notify
5546 application.SendNotification();
5547 application.Render();
5549 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5550 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5552 gSelectionChangedCallbackCalled = false;
5555 DevelTextField::SelectNone(field);
5557 // Render and notify
5558 application.SendNotification();
5559 application.Render();
5561 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5562 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5563 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5568 int UtcDaliToolkitTextFieldStrikethroughGeneration(void)
5570 ToolkitTestApplication application;
5571 tet_infoline(" UtcDaliToolkitTextFieldStrikethroughGeneration");
5573 TextField textField = TextField::New();
5574 textField.SetProperty(TextField::Property::TEXT, "Test");
5575 textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5576 textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5577 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5579 application.GetScene().Add(textField);
5580 application.SendNotification();
5581 application.Render();
5583 Property::Map strikethroughMapSet;
5584 Property::Map strikethroughMapGet;
5586 strikethroughMapSet.Insert("enable", true);
5587 strikethroughMapSet.Insert("color", Color::RED);
5588 strikethroughMapSet.Insert("height", 2.0f);
5590 // Check the strikethrough property
5591 textField.SetProperty(DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet);
5592 strikethroughMapGet = textField.GetProperty<Property::Map>(DevelTextField::Property::STRIKETHROUGH);
5593 textField.SetProperty(TextField::Property::TEXT, "Test1");
5594 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
5595 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
5597 // Render and notify
5598 application.SendNotification();
5599 application.Render();
5601 strikethroughMapSet.Clear();
5602 strikethroughMapGet.Clear();
5607 int UtcDaliToolkitTextFieldInputStrikethroughGeneration(void)
5609 ToolkitTestApplication application;
5610 tet_infoline(" UtcDaliToolkitTextFieldInputStrikethroughGeneration");
5612 TextField textField = TextField::New();
5613 textField.SetProperty(TextField::Property::TEXT, "Test");
5614 textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5615 textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5616 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5618 application.GetScene().Add(textField);
5619 application.SendNotification();
5620 application.Render();
5622 std::string strikethroughSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}");
5624 // Check the strikethrough property
5625 textField.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, strikethroughSettings1);
5626 textField.SetProperty(TextField::Property::TEXT, "Test1");
5627 DALI_TEST_EQUALS(textField.GetProperty<std::string>(DevelTextField::Property::INPUT_STRIKETHROUGH), strikethroughSettings1, TEST_LOCATION);
5629 // Render and notify
5630 application.SendNotification();
5631 application.Render();
5636 int UtcDaliToolkitTextFieldUnderlineTypesGeneration1(void)
5638 ToolkitTestApplication application;
5639 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration1");
5640 TextField field = TextField::New();
5641 field.SetProperty(TextField::Property::TEXT, "Test");
5642 field.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5643 field.SetProperty(TextField::Property::POINT_SIZE, 10);
5644 field.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5646 application.GetScene().Add(field);
5647 application.SendNotification();
5648 application.Render();
5650 Property::Map underlineMapSet;
5651 Property::Map underlineMapGet;
5653 underlineMapSet.Insert("enable", true);
5654 underlineMapSet.Insert("color", Color::RED);
5655 underlineMapSet.Insert("height", 1);
5656 underlineMapSet.Insert("type", Text::Underline::SOLID);
5657 underlineMapSet.Insert("dashWidth", 2);
5658 underlineMapSet.Insert("dashGap", 1);
5660 // Check the underline property
5661 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5663 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5664 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5665 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5667 // Render and notify
5668 application.SendNotification();
5669 application.Render();
5671 underlineMapSet.Clear();
5672 underlineMapGet.Clear();
5674 underlineMapSet.Insert("enable", true);
5675 underlineMapSet.Insert("color", Color::BLUE);
5676 underlineMapSet.Insert("height", 1);
5677 underlineMapSet.Insert("type", Text::Underline::DASHED);
5678 underlineMapSet.Insert("dashWidth", 4);
5679 underlineMapSet.Insert("dashGap", 2);
5681 // Check the dashed underline property
5682 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5684 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5685 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5686 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5688 // Render and notify
5689 application.SendNotification();
5690 application.Render();
5692 underlineMapSet.Clear();
5693 underlineMapGet.Clear();
5695 underlineMapSet.Insert("enable", true);
5696 underlineMapSet.Insert("color", Color::BLUE);
5697 underlineMapSet.Insert("height", 1);
5698 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
5699 underlineMapSet.Insert("dashWidth", 4);
5700 underlineMapSet.Insert("dashGap", 2);
5702 // Check the dashed underline property
5703 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5705 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5706 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5707 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5709 // Render and notify
5710 application.SendNotification();
5711 application.Render();
5713 underlineMapSet.Clear();
5714 underlineMapGet.Clear();
5719 int UtcDaliToolkitTextFieldUnderlineTypesGeneration2(void)
5721 ToolkitTestApplication application;
5722 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration2");
5724 TextField field1 = TextField::New();
5725 field1.SetProperty(TextField::Property::TEXT, "Test");
5726 field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5727 field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5728 field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5730 Property::Map underlineMapSet1;
5731 Property::Map underlineMapGet1;
5733 underlineMapSet1.Insert("enable", true);
5734 underlineMapSet1.Insert("color", Color::RED);
5735 underlineMapSet1.Insert("height", 1);
5736 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5737 underlineMapSet1.Insert("dashWidth", 2);
5738 underlineMapSet1.Insert("dashGap", 1);
5740 // Check the underline property
5741 field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5743 underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5744 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5745 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5747 application.GetScene().Add(field1);
5748 application.SendNotification();
5749 application.Render();
5751 TextField field2 = TextField::New();
5752 field2.SetProperty(TextField::Property::TEXT, "Test");
5753 field2.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5754 field2.SetProperty(TextField::Property::POINT_SIZE, 10);
5755 field2.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5757 Property::Map underlineMapSet2;
5758 Property::Map underlineMapGet2;
5760 underlineMapSet2.Insert("enable", true);
5761 underlineMapSet2.Insert("color", Color::BLUE);
5762 underlineMapSet2.Insert("height", 1);
5763 underlineMapSet2.Insert("type", Text::Underline::DASHED);
5764 underlineMapSet2.Insert("dashWidth", 4);
5765 underlineMapSet2.Insert("dashGap", 2);
5767 // Check the dashed underline property
5768 field2.SetProperty(TextField::Property::UNDERLINE, underlineMapSet2);
5770 underlineMapGet2 = field2.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5771 DALI_TEST_EQUALS(underlineMapGet2.Count(), underlineMapSet2.Count(), TEST_LOCATION);
5772 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet2, underlineMapSet2), true, TEST_LOCATION);
5774 application.GetScene().Add(field2);
5775 application.SendNotification();
5776 application.Render();
5778 TextField field3 = TextField::New();
5779 field3.SetProperty(TextField::Property::TEXT, "Test");
5780 field3.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5781 field3.SetProperty(TextField::Property::POINT_SIZE, 10);
5782 field3.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5784 Property::Map underlineMapSet3;
5785 Property::Map underlineMapGet3;
5787 underlineMapSet3.Insert("enable", true);
5788 underlineMapSet3.Insert("color", Color::BLUE);
5789 underlineMapSet3.Insert("height", 1);
5790 underlineMapSet3.Insert("type", Text::Underline::DOUBLE);
5791 underlineMapSet3.Insert("dashWidth", 4);
5792 underlineMapSet3.Insert("dashGap", 2);
5794 // Check the dashed underline property
5795 field3.SetProperty(TextField::Property::UNDERLINE, underlineMapSet3);
5797 underlineMapGet3 = field3.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5798 DALI_TEST_EQUALS(underlineMapGet3.Count(), underlineMapSet3.Count(), TEST_LOCATION);
5799 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
5801 application.GetScene().Add(field3);
5803 application.SendNotification();
5804 application.Render();
5809 int UtcDaliTextFieldCharacterSpacing(void)
5811 ToolkitTestApplication application;
5812 tet_infoline(" UtcDaliTextFieldCharacterSpacing ");
5814 TextField textField = TextField::New();
5816 textField.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
5818 application.GetScene().Add(textField);
5819 application.SendNotification();
5820 application.Render();
5822 textField.SetProperty(TextField::Property::TEXT, "Hi Experiment");
5823 textField.SetProperty(DevelTextField::Property::CHARACTER_SPACING, 10.f);
5824 DALI_TEST_EQUALS(textField.GetProperty<float>(DevelTextField::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
5826 application.SendNotification();
5827 application.Render();
5832 int UtcDaliToolkitTextFieldUnderlineTypesGeneration3(void)
5834 ToolkitTestApplication application;
5835 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration3");
5837 TextField field1 = TextField::New();
5838 field1.SetProperty(TextField::Property::TEXT, "Test1");
5839 field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5840 field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5841 field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5843 Property::Map underlineMapSet1;
5844 Property::Map underlineMapGet1;
5846 underlineMapSet1.Insert("enable", true);
5847 underlineMapSet1.Insert("color", Color::RED);
5848 underlineMapSet1.Insert("height", 1);
5849 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5850 underlineMapSet1.Insert("dashWidth", 2);
5851 underlineMapSet1.Insert("dashGap", 1);
5853 // Check the underline property
5854 field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5855 //field1.SetProperty( TextField::Property::TEXT, "Test2" );
5857 underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5858 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5859 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5861 application.GetScene().Add(field1);
5862 application.SendNotification();
5863 application.Render();
5868 int UtcDaliToolkitTextfieldParagraphTag(void)
5870 ToolkitTestApplication application;
5871 tet_infoline(" UtcDaliToolkitTextfieldParagraphTag");
5872 TextField fieldNewlineSeparator = TextField::New();
5873 TextField fieldParagraphTag = TextField::New();
5874 DALI_TEST_CHECK(fieldNewlineSeparator);
5875 DALI_TEST_CHECK(fieldParagraphTag);
5877 application.GetScene().Add(fieldNewlineSeparator);
5878 application.GetScene().Add(fieldParagraphTag);
5880 //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
5881 fieldNewlineSeparator.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5882 fieldNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5883 fieldNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5884 fieldNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5885 fieldNewlineSeparator.SetProperty(TextField::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
5887 fieldParagraphTag.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5888 fieldParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5889 fieldParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5890 fieldParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5891 fieldParagraphTag.SetProperty(TextField::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
5893 application.SendNotification();
5894 application.Render();
5896 Vector3 textNaturalSizeNewlineSeparator = fieldNewlineSeparator.GetNaturalSize();
5897 Vector3 textNaturalSizeParagraphTag = fieldParagraphTag.GetNaturalSize();
5899 DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
5901 application.SendNotification();
5902 application.Render();
5907 //Handle Emoji clustering for cursor handling
5908 int utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey(void)
5910 ToolkitTestApplication application;
5911 tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey ");
5912 TextField textField = TextField::New();
5913 DALI_TEST_CHECK(textField);
5915 application.GetScene().Add(textField);
5917 // Avoid a crash when core load gl resources.
5918 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5920 textField.SetProperty(TextField::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
5921 textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5923 // Render and notify
5924 application.SendNotification();
5925 application.Render();
5928 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 10);
5929 application.SendNotification();
5930 application.Render();
5932 // Set focus and remove Emoji
5933 textField.SetKeyInputFocus();
5934 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5936 //Check the changed text and cursor position
5937 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5938 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5940 // Render and notify
5941 application.SendNotification();
5942 application.Render();
5947 int utcDaliTextFieldClusteredEmojiDeletionDeleteKey(void)
5949 ToolkitTestApplication application;
5950 tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionDeleteKey ");
5951 TextField textField = TextField::New();
5952 DALI_TEST_CHECK(textField);
5954 application.GetScene().Add(textField);
5956 // Avoid a crash when core load gl resources.
5957 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5959 textField.SetProperty(TextField::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
5960 textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5962 // Render and notify
5963 application.SendNotification();
5964 application.Render();
5967 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5968 application.SendNotification();
5969 application.Render();
5971 // Set focus and remove Emoji
5972 textField.SetKeyInputFocus();
5973 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5975 //Check the changed text and cursor position
5976 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5977 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5979 // Render and notify
5980 application.SendNotification();
5981 application.Render();
5986 int utcDaliTextFieldPanGesturePropagation(void)
5988 ToolkitTestApplication application;
5989 tet_infoline(" utcDaliTextFieldPanGesturePropagation");
5991 Actor actor = Actor::New();
5992 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
5993 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5994 application.GetScene().Add(actor);
5996 TextField field = TextField::New();
5997 DALI_TEST_CHECK(field);
5999 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
6000 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
6002 field.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
6003 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6004 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6008 // Render and notify
6009 application.SendNotification();
6010 application.Render();
6013 GestureReceivedFunctor functor(data);
6015 PanGestureDetector detector = PanGestureDetector::New();
6016 detector.Attach(actor);
6017 detector.DetectedSignal().Connect(&application, functor);
6019 // Tap first to get the focus.
6020 TestGenerateTap(application, 3.0f, 25.0f, 100);
6022 // Render and notify
6023 application.SendNotification();
6024 application.Render();
6026 // Pan the text field
6027 uint32_t time = 100;
6028 TestStartPan(application, Vector2(40.0f, 50.0f), Vector2(40.0f, 50.0f), time);
6029 TestMovePan(application, Vector2(10.0f, 50.0f), time);
6030 TestEndPan(application, Vector2(40.0f, 50.0f), time);
6031 application.SendNotification();
6032 application.Render();
6034 // The text scrolls because there is text that is scrolling.
6035 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
6038 // Set the size large enough to prevent scrolling.
6039 field.SetProperty(Actor::Property::SIZE, Vector2(700.f, 100.f));
6041 // Render and notify
6042 application.SendNotification();
6043 application.Render();
6046 TestStartPan(application, Vector2(40.0f, 50.0f), Vector2(40.0f, 50.0f), time);
6047 TestMovePan(application, Vector2(10.0f, 50.0f), time);
6048 TestEndPan(application, Vector2(40.0f, 50.0f), time);
6050 // Because scrolling is not possible, the pan gesture is propagated.
6051 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
6057 int utcDaliTextFieldGetTextBoundingRectangle(void)
6059 ToolkitTestApplication application;
6060 tet_infoline(" utcDaliTextFieldGeometryEllipsisMiddle");
6062 TextField field = TextField::New();
6063 DALI_TEST_CHECK(field);
6065 application.GetScene().Add(field);
6067 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
6068 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6069 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6070 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6071 field.SetProperty(TextField::Property::TEXT, "Hello this is the Text Bounding Rectangle TC");
6073 // Avoid a crash when core load gl resources.
6074 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6076 // Render and notify
6077 application.SendNotification();
6078 application.Render();
6080 unsigned int startIndex = 0;
6081 unsigned int endIndex = 15;
6083 Rect<> textBoundingRectangle = DevelTextField::GetTextBoundingRectangle(field, startIndex, endIndex);
6084 Rect<> expectedTextBoundingRectangle = {0, 0, 100, 25};
6086 TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle);
6091 int utcDaliTextFieldDecoratorColor(void)
6093 ToolkitTestApplication application;
6094 tet_infoline(" utcDaliTextFieldDecoratorColor");
6095 TextField textField = TextField::New();
6096 DALI_TEST_CHECK(textField);
6097 LoadMarkerImages(application, textField);
6098 application.GetScene().Add(textField);
6100 // Render and notify
6101 application.SendNotification();
6102 application.Render();
6104 textField.SetProperty(TextField::Property::TEXT, "العالم Hello");
6105 textField.SetProperty(TextField::Property::POINT_SIZE, 10.f);
6106 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
6107 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6108 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6110 // Avoid a crash when core load gl resources.
6111 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6113 application.SendNotification();
6114 application.Render();
6116 textField.SetKeyInputFocus();
6118 application.SendNotification();
6119 application.Render();
6121 // Create a tap event to touch the text field.
6122 TestGenerateTap(application, 1.0f, 25.0f, 100);
6124 // Render and notify
6125 application.SendNotification();
6126 application.Render();
6128 // Double tap to select a word.
6129 TestGenerateTap(application, 1.0f, 25.0f, 200);
6131 application.SendNotification();
6132 application.Render();
6134 // At this point, the text decorator's primary/secondary cursor, grab/left/right handle and highlight actor were all created.
6135 // Check some properties for coverage.
6136 textField.SetProperty(TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED);
6137 DALI_TEST_EQUALS(textField.GetProperty<Vector4>(TextField::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION);
6139 textField.SetProperty(TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE);
6140 DALI_TEST_EQUALS(textField.GetProperty<Vector4>(TextField::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION);
6142 textField.SetProperty(DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN);
6143 DALI_TEST_EQUALS(textField.GetProperty<Vector4>(DevelTextField::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
6145 textField.SetProperty(TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN);
6146 DALI_TEST_EQUALS(textField.GetProperty<Vector4>(TextField::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION);
6148 textField.SetProperty(TextField::Property::CURSOR_WIDTH, 3);
6149 DALI_TEST_EQUALS(textField.GetProperty<int>(TextField::Property::CURSOR_WIDTH), 3, TEST_LOCATION);
6151 application.SendNotification();
6152 application.Render();
6157 int utcDaliTextFieldRemoveFrontInset(void)
6159 ToolkitTestApplication application;
6160 tet_infoline(" utcDaliTextFieldRemoveFrontInset");
6162 TextField field = TextField::New();
6163 DALI_TEST_CHECK(field);
6165 application.GetScene().Add(field);
6166 application.SendNotification();
6167 application.Render();
6169 DevelTextField::SetRemoveFrontInset(field, false);
6170 DALI_TEST_CHECK(!DevelTextField::IsRemoveFrontInset(field));
6175 int utcDaliTextFieldRemoveBackInset(void)
6177 ToolkitTestApplication application;
6178 tet_infoline(" utcDaliTextFieldRemoveBackInset");
6180 TextField field = TextField::New();
6181 DALI_TEST_CHECK(field);
6183 application.GetScene().Add(field);
6184 application.SendNotification();
6185 application.Render();
6187 DevelTextField::SetRemoveBackInset(field, false);
6188 DALI_TEST_CHECK(!DevelTextField::IsRemoveBackInset(field));