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;
1112 field.SetProperty(TextField::Property::OUTLINE, outlineMapSet);
1114 outlineMapGet = field.GetProperty<Property::Map>(TextField::Property::OUTLINE);
1115 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
1116 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
1118 // Check the input outline property
1119 field.SetProperty(TextField::Property::INPUT_OUTLINE, "Outline input properties");
1120 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_OUTLINE), std::string("Outline input properties"), TEST_LOCATION);
1122 // Check the hidden input settings property
1123 Property::Map hiddenMapSet;
1124 Property::Map hiddenMapGet;
1125 hiddenMapSet[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL;
1126 hiddenMapSet[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 2;
1127 hiddenMapSet[HiddenInput::Property::SUBSTITUTE_COUNT] = 4;
1128 hiddenMapSet[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
1129 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet);
1131 hiddenMapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
1132 DALI_TEST_EQUALS(hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION);
1133 DALI_TEST_EQUALS(DaliTestCheckMaps(hiddenMapSet, hiddenMapGet), true, TEST_LOCATION);
1135 // Check the pixel size of font
1136 field.SetProperty(TextField::Property::PIXEL_SIZE, 20.f);
1137 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1139 // Check the enable selection property
1140 field.SetProperty(TextField::Property::ENABLE_SELECTION, false);
1141 DALI_TEST_EQUALS(field.GetProperty<bool>(TextField::Property::ENABLE_SELECTION), false, TEST_LOCATION);
1143 // Check the placeholder property with pixel size
1144 Property::Map placeholderPixelSizeMapSet;
1145 Property::Map placeholderPixelSizeMapGet;
1146 Property::Map placeholderFontstyleMap;
1147 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
1148 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
1149 placeholderPixelSizeMapSet["color"] = Color::BLUE;
1150 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
1151 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
1152 placeholderPixelSizeMapSet["ellipsis"] = true;
1154 placeholderFontstyleMap.Insert("weight", "bold");
1155 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
1156 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
1158 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1159 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
1161 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1162 Property::Map placeholderConversionMap;
1163 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1164 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1165 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1166 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1167 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1168 placeholderConversionMap[Text::PlaceHolder::Property::PIXEL_SIZE] = placeholderPixelSizeMapSet["pixelSize"];
1170 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderConversionMap), true, TEST_LOCATION);
1172 // Check the placeholder property with point size
1173 Property::Map placeholderMapSet;
1174 Property::Map placeholderMapGet;
1175 placeholderMapSet["text"] = "Setting Placeholder Text";
1176 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
1177 placeholderMapSet["color"] = Color::RED;
1178 placeholderMapSet["fontFamily"] = "Arial";
1179 placeholderMapSet["pointSize"] = 12.0f;
1180 placeholderMapSet["ellipsis"] = false;
1182 // Check the placeholder font style property
1183 placeholderFontstyleMap.Clear();
1185 placeholderFontstyleMap.Insert("weight", "bold");
1186 placeholderFontstyleMap.Insert("width", "condensed");
1187 placeholderFontstyleMap.Insert("slant", "italic");
1188 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1189 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1191 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1192 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1194 placeholderConversionMap.Clear();
1195 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1196 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1197 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1198 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1199 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1200 placeholderConversionMap[Text::PlaceHolder::Property::POINT_SIZE] = placeholderPixelSizeMapSet["pointSize"];
1202 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1204 // Reset font style.
1205 placeholderFontstyleMap.Clear();
1206 placeholderFontstyleMap.Insert("weight", "normal");
1207 placeholderFontstyleMap.Insert("slant", "oblique");
1208 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1209 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1211 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1212 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1214 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1215 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1217 placeholderFontstyleMap.Clear();
1218 placeholderFontstyleMap.Insert("slant", "roman");
1219 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1220 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1222 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1224 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1226 placeholderFontstyleMap.Clear();
1227 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1228 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1230 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1231 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1232 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1234 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1236 // Check the ellipsis property
1237 DALI_TEST_CHECK(!field.GetProperty<bool>(TextField::Property::ELLIPSIS));
1238 field.SetProperty(TextField::Property::ELLIPSIS, true);
1239 DALI_TEST_CHECK(field.GetProperty<bool>(TextField::Property::ELLIPSIS));
1241 field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1242 DALI_TEST_EQUALS(field.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1244 // Test the ENABLE_GRAB_HANDLE_POPUP property
1245 DALI_TEST_CHECK(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP));
1246 field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false);
1247 DALI_TEST_CHECK(!field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP));
1249 // Check the background property
1250 field.SetProperty(DevelTextField::Property::BACKGROUND, Color::RED);
1251 DALI_TEST_EQUALS(field.GetProperty<Vector4>(DevelTextField::Property::BACKGROUND), Color::RED, TEST_LOCATION);
1253 //Check handle color
1254 field.SetProperty(DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN);
1255 DALI_TEST_EQUALS(field.GetProperty<Vector4>(DevelTextField::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
1257 // Check the input filter property
1258 Property::Map inputFilterMapSet;
1259 Property::Map inputFilterMapGet;
1260 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1261 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1263 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1265 inputFilterMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::INPUT_FILTER);
1266 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1269 inputFilterMapSet.Clear();
1270 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1272 application.SendNotification();
1273 application.Render();
1275 // Check Remove Front/Back Inset Property
1276 DALI_TEST_CHECK(field.GetProperty<bool>(DevelTextField::Property::REMOVE_FRONT_INSET));
1277 field.SetProperty(DevelTextField::Property::REMOVE_FRONT_INSET, false);
1278 DALI_TEST_CHECK(!field.GetProperty<bool>(DevelTextField::Property::REMOVE_FRONT_INSET));
1280 DALI_TEST_CHECK(field.GetProperty<bool>(DevelTextField::Property::REMOVE_BACK_INSET));
1281 field.SetProperty(DevelTextField::Property::REMOVE_BACK_INSET, false);
1282 DALI_TEST_CHECK(!field.GetProperty<bool>(DevelTextField::Property::REMOVE_BACK_INSET));
1284 application.SendNotification();
1285 application.Render();
1291 // Positive Atlas Text Renderer test
1292 int utcDaliTextFieldAtlasRenderP(void)
1294 ToolkitTestApplication application;
1295 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1296 StyleManager styleManager = StyleManager::Get();
1297 styleManager.ApplyDefaultTheme();
1298 TextField field = TextField::New();
1299 DALI_TEST_CHECK(field);
1301 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1303 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1305 application.GetScene().Add(field);
1309 // Render some text with the shared atlas backend
1310 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1311 application.SendNotification();
1312 application.Render();
1316 tet_result(TET_FAIL);
1321 // Positive test for the anchorClicked signal.
1322 int utcDaliTextFieldAnchorClicked01(void)
1324 ToolkitTestApplication application;
1325 tet_infoline(" utcDaliTextFieldAnchorClicked01");
1326 TextField field = TextField::New();
1327 DALI_TEST_CHECK(field);
1329 application.GetScene().Add(field);
1331 // connect to the anchor clicked signal.
1332 ConnectionTracker* testTracker = new ConnectionTracker();
1333 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1334 bool anchorClickedSignal = false;
1335 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1337 gAnchorClickedCallBackCalled = false;
1338 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1339 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1340 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1341 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1342 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1344 application.SendNotification();
1345 application.Render();
1346 field.SetKeyInputFocus();
1348 // Create a tap event to touch the text field.
1349 TestGenerateTap(application, 5.0f, 25.0f);
1350 application.SendNotification();
1351 application.Render();
1353 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1354 DALI_TEST_CHECK(anchorClickedSignal);
1356 gAnchorClickedCallBackNotCalled = true;
1357 // Tap the outside of anchor, callback should not be called.
1358 TestGenerateTap(application, 150.f, 100.f);
1359 application.SendNotification();
1360 application.Render();
1362 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1367 // Positive test for the anchorClicked signal.
1368 int utcDaliTextFieldAnchorClicked02(void)
1370 ToolkitTestApplication application;
1371 tet_infoline(" utcDaliTextFieldAnchorClicked02");
1372 TextField field = TextField::New();
1373 DALI_TEST_CHECK(field);
1375 application.GetScene().Add(field);
1377 // connect to the anchor clicked signal.
1378 ConnectionTracker* testTracker = new ConnectionTracker();
1379 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1380 bool anchorClickedSignal = false;
1381 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1383 gAnchorClickedCallBackCalled = false;
1384 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1385 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1386 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1387 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1388 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1390 application.SendNotification();
1391 application.Render();
1392 field.SetKeyInputFocus();
1394 // Avoid a crash when core load gl resources.
1395 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1397 // Create a tap event to touch the text field.
1398 TestGenerateTap(application, 30.0f, 25.0f, 100);
1399 application.SendNotification();
1400 application.Render();
1402 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1403 DALI_TEST_CHECK(anchorClickedSignal);
1405 // For coverage InsertTextAnchor, RemoveTextAnchor
1406 // first index insert
1407 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1408 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1409 application.SendNotification();
1410 application.Render();
1412 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1413 application.SendNotification();
1414 application.Render();
1416 gAnchorClickedCallBackCalled = false;
1417 // Create a tap event to touch the text field.
1418 TestGenerateTap(application, 30.0f, 25.0f, 700);
1419 application.SendNotification();
1420 field.SetKeyInputFocus();
1422 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1424 // last index insert
1425 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1426 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1427 application.SendNotification();
1428 application.Render();
1430 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1431 application.SendNotification();
1432 application.Render();
1434 gAnchorClickedCallBackCalled = false;
1435 // Create a tap event to touch the text field.
1436 TestGenerateTap(application, 30.0f, 25.0f, 1300);
1437 application.SendNotification();
1438 field.SetKeyInputFocus();
1440 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1443 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1444 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1445 application.SendNotification();
1446 application.Render();
1448 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1449 application.SendNotification();
1450 application.Render();
1452 gAnchorClickedCallBackCalled = false;
1453 // Create a tap event to touch the text field.
1454 TestGenerateTap(application, 30.0f, 25.0f, 1900);
1455 application.SendNotification();
1456 field.SetKeyInputFocus();
1458 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1460 // first index remove
1461 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1462 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1463 application.SendNotification();
1464 application.Render();
1466 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1467 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));
1468 application.SendNotification();
1469 application.Render();
1471 gAnchorClickedCallBackCalled = false;
1472 // Create a tap event to touch the text field.
1473 TestGenerateTap(application, 30.0f, 25.0f, 2500);
1474 application.SendNotification();
1475 field.SetKeyInputFocus();
1477 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1479 // last index remove
1480 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1481 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1482 application.SendNotification();
1483 application.Render();
1485 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1486 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));
1487 application.SendNotification();
1488 application.Render();
1490 gAnchorClickedCallBackCalled = false;
1491 // Create a tap event to touch the text field.
1492 TestGenerateTap(application, 30.0f, 25.0f, 3100);
1493 application.SendNotification();
1494 application.Render();
1496 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1499 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1500 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1501 application.SendNotification();
1502 application.Render();
1504 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1505 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));
1506 application.SendNotification();
1507 application.Render();
1509 gAnchorClickedCallBackCalled = false;
1510 // Create a tap event to touch the text field.
1511 TestGenerateTap(application, 30.0f, 25.0f, 3700);
1512 application.SendNotification();
1513 application.Render();
1515 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1517 // 0 ~ 1 index remove
1518 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1519 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 0);
1520 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 1);
1521 application.SendNotification();
1522 application.Render();
1524 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1525 application.SendNotification();
1526 application.Render();
1528 gAnchorClickedCallBackCalled = false;
1529 // Create a tap event to touch the text field.
1530 TestGenerateTap(application, 30.0f, 25.0f, 4300);
1531 application.SendNotification();
1532 application.Render();
1534 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1536 // 1 ~ 3 index remove
1537 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1538 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 1);
1539 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 3);
1540 application.SendNotification();
1541 application.Render();
1543 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1544 application.SendNotification();
1545 application.Render();
1547 gAnchorClickedCallBackCalled = false;
1548 // Create a tap event to touch the text field.
1549 TestGenerateTap(application, 30.0f, 25.0f, 4900);
1550 application.SendNotification();
1551 application.Render();
1553 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1555 // 3 ~ 4 index remove
1556 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1557 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 3);
1558 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 4);
1559 application.SendNotification();
1560 application.Render();
1562 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1563 application.SendNotification();
1564 application.Render();
1566 gAnchorClickedCallBackCalled = false;
1567 // Create a tap event to touch the text field.
1568 TestGenerateTap(application, 30.0f, 25.0f, 5500);
1569 application.SendNotification();
1570 application.Render();
1572 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1574 // Remove front of anchor
1575 field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
1576 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
1577 application.SendNotification();
1578 application.Render();
1580 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1581 application.SendNotification();
1582 application.Render();
1584 // Remove whole text
1585 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1586 DevelTextField::SelectWholeText(field);
1587 application.SendNotification();
1588 application.Render();
1590 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1591 application.SendNotification();
1592 application.Render();
1594 // Remove all with backspace
1595 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1596 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
1597 application.SendNotification();
1598 application.Render();
1600 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1601 application.SendNotification();
1602 application.Render();
1604 // Remove all with delete
1605 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1606 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1607 application.SendNotification();
1608 application.Render();
1610 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));
1611 application.SendNotification();
1612 application.Render();
1617 // Positive test for the textChanged signal.
1618 int utcDaliTextFieldTextChangedP(void)
1620 ToolkitTestApplication application;
1621 tet_infoline(" utcDaliTextFieldTextChangedP");
1622 TextField field = TextField::New();
1623 DALI_TEST_CHECK(field);
1625 application.GetScene().Add(field);
1627 // connect to the text changed signal.
1628 ConnectionTracker* testTracker = new ConnectionTracker();
1629 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1630 bool textChangedSignal = false;
1631 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1633 gTextChangedCallBackCalled = false;
1634 field.SetProperty(TextField::Property::TEXT, "ABC");
1635 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1636 DALI_TEST_CHECK(textChangedSignal);
1638 application.SendNotification();
1639 field.SetKeyInputFocus();
1641 gTextChangedCallBackCalled = false;
1642 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1643 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1646 field.SetProperty(TextField::Property::TEXT, "");
1648 // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1649 gTextChangedCallBackCalled = false;
1650 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1651 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1653 // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1654 gTextChangedCallBackCalled = false;
1655 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1656 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1661 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1663 ToolkitTestApplication application;
1664 tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1665 TextField field = TextField::New();
1666 DALI_TEST_CHECK(field);
1668 application.GetScene().Add(field);
1670 // connect to the text changed signal.
1671 ConnectionTracker* testTracker = new ConnectionTracker();
1672 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1673 bool textChangedSignal = false;
1674 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1676 // get InputMethodContext
1678 InputMethodContext::EventData imfEvent;
1679 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1681 field.SetKeyInputFocus();
1682 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1685 gTextChangedCallBackCalled = false;
1686 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "ㅎ", 0, 1);
1687 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1688 application.SendNotification();
1689 application.Render();
1690 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1691 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ㅎ"), TEST_LOCATION);
1693 gTextChangedCallBackCalled = false;
1694 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "호", 0, 1);
1695 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1696 application.SendNotification();
1697 application.Render();
1698 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1699 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("호"), TEST_LOCATION);
1701 gTextChangedCallBackCalled = false;
1702 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "혿", 0, 1);
1703 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1704 application.SendNotification();
1705 application.Render();
1706 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1707 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("혿"), TEST_LOCATION);
1709 gTextChangedCallBackCalled = false;
1710 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "", 0, 1);
1711 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1712 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1714 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "호", 0, 1);
1715 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1716 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1718 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "두", 1, 2);
1719 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1720 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1722 application.SendNotification();
1723 application.Render();
1724 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1725 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("호두"), TEST_LOCATION);
1730 int utcDaliTextFieldSelectionWithInputMethodContext(void)
1732 ToolkitTestApplication application;
1733 tet_infoline(" utcDaliTextFieldSelectionWithInputMethodContext");
1734 TextField field = TextField::New();
1735 DALI_TEST_CHECK(field);
1737 field.SetProperty(TextField::Property::TEXT, "Hello world");
1739 application.GetScene().Add(field);
1741 // connect to the selection changed signal.
1742 ConnectionTracker* testTracker = new ConnectionTracker();
1743 DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
1744 bool selectionChangedSignal = false;
1745 field.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
1747 // get InputMethodContext
1749 InputMethodContext::EventData imfEvent;
1750 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1752 field.SetKeyInputFocus();
1753 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1756 gSelectionChangedCallbackCalled = false;
1757 imfEvent = InputMethodContext::EventData(InputMethodContext::SELECTION_SET, 1, 4);
1758 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1759 application.SendNotification();
1760 application.Render();
1761 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
1763 DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
1764 DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 4, TEST_LOCATION);
1769 int utcDaliTextFieldPositionWithInputMethodContext(void)
1771 ToolkitTestApplication application;
1772 tet_infoline(" utcDaliTextFieldPositionWithInputMethodContext");
1773 TextField field = TextField::New();
1774 DALI_TEST_CHECK(field);
1776 field.SetProperty(TextField::Property::TEXT, "Hello world");
1778 application.GetScene().Add(field);
1780 // connect to the selection changed signal.
1781 ConnectionTracker* testTracker = new ConnectionTracker();
1782 DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
1783 bool cursorPositionChangedSignal = false;
1784 field.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
1786 // get InputMethodContext
1788 InputMethodContext::EventData imfEvent;
1789 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1791 field.SetKeyInputFocus();
1792 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1795 gCursorPositionChangedCallbackCalled = false;
1796 imfEvent = InputMethodContext::EventData(InputMethodContext::SELECTION_SET, 2, 2);
1797 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1798 application.SendNotification();
1799 application.Render();
1800 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
1802 DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 2, TEST_LOCATION);
1807 int utcDaliTextFieldInputFilterWithInputMethodContext(void)
1809 ToolkitTestApplication application;
1810 tet_infoline(" utcDaliTextFieldInputFilterWithInputMethodContext");
1811 TextField field = TextField::New();
1812 DALI_TEST_CHECK(field);
1814 Property::Map inputFilter;
1815 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1816 inputFilter[InputFilter::Property::REJECTED] = "[5-7]";
1818 // Set input filter to TextField.
1819 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1821 application.GetScene().Add(field);
1823 // connect to the input filtered signal.
1824 ConnectionTracker* testTracker = new ConnectionTracker();
1825 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1826 bool inputFilteredSignal = false;
1827 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1829 // get InputMethodContext
1831 InputMethodContext::EventData imfEvent;
1832 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1834 field.SetKeyInputFocus();
1835 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1838 gInputFilteredAcceptedCallbackCalled = false;
1839 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "Hello1234", 0, 9);
1840 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1841 application.SendNotification();
1842 application.Render();
1843 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1844 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("1234"), TEST_LOCATION);
1846 inputFilteredSignal = false;
1847 gInputFilteredRejectedCallbackCalled = false;
1848 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "1234567", 0, 7);
1849 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1850 application.SendNotification();
1851 application.Render();
1852 DALI_TEST_CHECK(gInputFilteredRejectedCallbackCalled);
1853 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("12341234"), TEST_LOCATION);
1858 // Negative test for the textChanged signal.
1859 int utcDaliTextFieldTextChangedN(void)
1861 ToolkitTestApplication application;
1862 tet_infoline(" utcDaliTextFieldTextChangedN");
1863 TextField field = TextField::New();
1864 DALI_TEST_CHECK(field);
1866 application.GetScene().Add(field);
1868 // connect to the text changed signal.
1869 ConnectionTracker* testTracker = new ConnectionTracker();
1870 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1871 bool textChangedSignal = false;
1872 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1874 gTextChangedCallBackCalled = false;
1875 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "ABC"); // Setting placeholder, not TEXT
1876 application.SendNotification();
1877 application.Render();
1878 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1879 DALI_TEST_CHECK(!textChangedSignal);
1884 // Positive test for Max Characters reached signal.
1885 int utcDaliTextFieldMaxCharactersReachedP(void)
1887 ToolkitTestApplication application;
1888 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1889 TextField field = TextField::New();
1890 DALI_TEST_CHECK(field);
1892 application.GetScene().Add(field);
1894 const int maxNumberOfCharacters = 1;
1895 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1897 field.SetKeyInputFocus();
1899 // connect to the text changed signal.
1900 ConnectionTracker* testTracker = new ConnectionTracker();
1901 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1902 bool maxLengthReachedSignal = false;
1903 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1905 gMaxCharactersCallBackCalled = false;
1907 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1908 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1910 DALI_TEST_CHECK(gMaxCharactersCallBackCalled);
1911 DALI_TEST_CHECK(maxLengthReachedSignal);
1916 // Negative test for Max Characters reached signal.
1917 int utcDaliTextFieldMaxCharactersReachedN(void)
1919 ToolkitTestApplication application;
1920 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1921 TextField field = TextField::New();
1922 DALI_TEST_CHECK(field);
1924 application.GetScene().Add(field);
1926 const int maxNumberOfCharacters = 3;
1927 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1929 field.SetKeyInputFocus();
1931 // connect to the text changed signal.
1932 ConnectionTracker* testTracker = new ConnectionTracker();
1933 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1934 bool maxLengthReachedSignal = false;
1935 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1937 gMaxCharactersCallBackCalled = false;
1939 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1940 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1942 DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1943 DALI_TEST_CHECK(!maxLengthReachedSignal);
1945 application.ProcessEvent(GenerateKey("Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1947 DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1948 DALI_TEST_CHECK(!maxLengthReachedSignal);
1953 // Positive test for Input Filtered signal.
1954 int utcDaliTextFieldInputFilteredP(void)
1956 ToolkitTestApplication application;
1957 tet_infoline(" utcDaliTextFieldInputFilteredP");
1958 TextField field = TextField::New();
1959 DALI_TEST_CHECK(field);
1961 application.GetScene().Add(field);
1963 Property::Map inputFilter;
1965 // Only digit is accepted.
1966 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1968 // Set input filter to TextField.
1969 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1971 field.SetKeyInputFocus();
1973 // connect to the input filtered signal.
1974 ConnectionTracker* testTracker = new ConnectionTracker();
1975 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1976 bool inputFilteredSignal = false;
1977 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1979 gInputFilteredAcceptedCallbackCalled = false;
1981 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1983 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1984 DALI_TEST_CHECK(inputFilteredSignal);
1986 // Word is rejected.
1987 inputFilter[InputFilter::Property::ACCEPTED] = "";
1988 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1990 // Set input filter to TextField.
1991 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1993 field.SetKeyInputFocus();
1995 inputFilteredSignal = false;
1996 gInputFilteredRejectedCallbackCalled = false;
1998 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2000 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
2001 DALI_TEST_CHECK(inputFilteredSignal);
2006 // Negative test for Input Filtered signal.
2007 int utcDaliTextFieldInputFilteredN(void)
2009 ToolkitTestApplication application;
2010 tet_infoline(" utcDaliTextFieldInputFilteredP");
2011 TextField field = TextField::New();
2012 DALI_TEST_CHECK(field);
2014 application.GetScene().Add(field);
2016 Property::Map inputFilter;
2018 // Only word is accepted.
2019 inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
2021 // Set input filter to TextField.
2022 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
2024 field.SetKeyInputFocus();
2026 // connect to the input filtered signal.
2027 ConnectionTracker* testTracker = new ConnectionTracker();
2028 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
2029 bool inputFilteredSignal = false;
2030 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
2032 gInputFilteredAcceptedCallbackCalled = false;
2034 // Key a, d should not be filtered.
2035 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2036 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2037 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2038 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2040 // Backspace, Delete should not be filtered.
2041 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2042 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));
2044 // Render and notify
2045 application.SendNotification();
2046 application.Render();
2048 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
2049 DALI_TEST_CHECK(!inputFilteredSignal);
2051 // Digit is rejected.
2052 inputFilter[InputFilter::Property::ACCEPTED] = "";
2053 inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
2055 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
2057 field.SetKeyInputFocus();
2059 inputFilteredSignal = false;
2060 gInputFilteredRejectedCallbackCalled = false;
2062 // Key a, d should not be filtered.
2063 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2064 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2065 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2066 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2068 // Backspace, Delete should not be filtered.
2069 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2070 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));
2072 // Render and notify
2073 application.SendNotification();
2074 application.Render();
2076 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
2077 DALI_TEST_CHECK(!inputFilteredSignal);
2082 int utcDaliTextFieldInputStyleChanged01(void)
2084 // The text-field emits signals when the input style changes. These changes of style are
2085 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
2086 // can't be emitted during the size negotiation as the callbacks may update the UI.
2087 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
2088 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
2089 ToolkitTestApplication application;
2090 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
2094 char* pathNamePtr = get_current_dir_name();
2095 const std::string pathName(pathNamePtr);
2098 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2099 fontClient.SetDpi(93u, 93u);
2101 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2102 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2104 TextField field = TextField::New();
2105 DALI_TEST_CHECK(field);
2107 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2108 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2109 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2111 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2112 field.SetProperty(TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
2114 // connect to the text changed signal.
2115 ConnectionTracker* testTracker = new ConnectionTracker();
2116 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2117 bool inputStyleChangedSignal = false;
2118 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2120 application.GetScene().Add(field);
2122 // Render and notify
2123 application.SendNotification();
2124 application.Render();
2126 // Executes the idle callbacks added by the text control on the change of input style.
2127 application.RunIdles();
2129 gInputStyleChangedCallbackCalled = false;
2130 gInputStyleMask = TextField::InputStyle::NONE;
2131 inputStyleChangedSignal = false;
2133 // Create a tap event to touch the text field.
2134 TestGenerateTap(application, 18.0f, 25.0f);
2136 // Render and notify
2137 application.SendNotification();
2138 application.Render();
2140 // Executes the idle callbacks added by the text control on the change of input style.
2141 application.RunIdles();
2143 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2144 if(gInputStyleChangedCallbackCalled)
2146 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE), TEST_LOCATION);
2148 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2149 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2151 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2152 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2154 DALI_TEST_CHECK(inputStyleChangedSignal);
2156 gInputStyleChangedCallbackCalled = false;
2157 gInputStyleMask = TextField::InputStyle::NONE;
2158 inputStyleChangedSignal = false;
2160 // Create a tap event to touch the text field.
2161 TestGenerateTap(application, 30.0f, 25.0f);
2163 // Render and notify
2164 application.SendNotification();
2165 application.Render();
2167 // Executes the idle callbacks added by the text control on the change of input style.
2168 application.RunIdles();
2170 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2171 DALI_TEST_CHECK(!inputStyleChangedSignal);
2173 gInputStyleChangedCallbackCalled = false;
2174 gInputStyleMask = TextField::InputStyle::NONE;
2175 inputStyleChangedSignal = false;
2177 // Create a tap event to touch the text field.
2178 TestGenerateTap(application, 43.0f, 25.0f);
2180 // Render and notify
2181 application.SendNotification();
2182 application.Render();
2184 // Executes the idle callbacks added by the text control on the change of input style.
2185 application.RunIdles();
2187 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2188 if(gInputStyleChangedCallbackCalled)
2190 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR), TEST_LOCATION);
2192 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2193 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2195 DALI_TEST_CHECK(inputStyleChangedSignal);
2197 gInputStyleChangedCallbackCalled = false;
2198 gInputStyleMask = TextField::InputStyle::NONE;
2199 inputStyleChangedSignal = false;
2201 // Create a tap event to touch the text field.
2202 TestGenerateTap(application, 88.0f, 25.0f);
2204 // Render and notify
2205 application.SendNotification();
2206 application.Render();
2208 // Executes the idle callbacks added by the text control on the change of input style.
2209 application.RunIdles();
2211 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2212 if(gInputStyleChangedCallbackCalled)
2214 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2216 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2217 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2219 const Property::Map fontStyleMapGet = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<Property::Map>();
2221 Property::Map fontStyleMapSet;
2222 fontStyleMapSet.Insert("weight", "bold");
2224 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2225 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2227 DALI_TEST_CHECK(inputStyleChangedSignal);
2229 gInputStyleChangedCallbackCalled = false;
2230 gInputStyleMask = TextField::InputStyle::NONE;
2231 inputStyleChangedSignal = false;
2233 // Create a tap event to touch the text field.
2234 TestGenerateTap(application, 115.0f, 25.0f);
2236 // Render and notify
2237 application.SendNotification();
2238 application.Render();
2240 // Executes the idle callbacks added by the text control on the change of input style.
2241 application.RunIdles();
2243 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2244 DALI_TEST_CHECK(!inputStyleChangedSignal);
2246 gInputStyleChangedCallbackCalled = false;
2247 gInputStyleMask = TextField::InputStyle::NONE;
2248 inputStyleChangedSignal = false;
2250 // Create a tap event to touch the text field.
2251 TestGenerateTap(application, 164.0f, 25.0f);
2253 // Render and notify
2254 application.SendNotification();
2255 application.Render();
2257 // Executes the idle callbacks added by the text control on the change of input style.
2258 application.RunIdles();
2260 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2261 if(gInputStyleChangedCallbackCalled)
2263 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2265 const std::string style = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<std::string>();
2266 DALI_TEST_CHECK(style.empty());
2268 DALI_TEST_CHECK(inputStyleChangedSignal);
2270 gInputStyleChangedCallbackCalled = false;
2271 gInputStyleMask = TextField::InputStyle::NONE;
2272 inputStyleChangedSignal = false;
2274 // Create a tap event to touch the text field.
2275 TestGenerateTap(application, 191.0f, 25.0f);
2277 // Render and notify
2278 application.SendNotification();
2279 application.Render();
2281 // Executes the idle callbacks added by the text control on the change of input style.
2282 application.RunIdles();
2284 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2285 DALI_TEST_CHECK(!inputStyleChangedSignal);
2290 int utcDaliTextFieldInputStyleChanged02(void)
2292 // The text-field emits signals when the input style changes. These changes of style are
2293 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
2294 // can't be emitted during the size negotiation as the callbacks may update the UI.
2295 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
2296 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
2297 ToolkitTestApplication application;
2298 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
2302 char* pathNamePtr = get_current_dir_name();
2303 const std::string pathName(pathNamePtr);
2306 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2307 fontClient.SetDpi(93u, 93u);
2309 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2310 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2312 TextField field = TextField::New();
2313 DALI_TEST_CHECK(field);
2315 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2316 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2317 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2319 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2320 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>");
2322 // connect to the text changed signal.
2323 ConnectionTracker* testTracker = new ConnectionTracker();
2324 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2325 bool inputStyleChangedSignal = false;
2326 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2328 application.GetScene().Add(field);
2330 // Render and notify
2331 application.SendNotification();
2332 application.Render();
2334 // Executes the idle callbacks added by the text control on the change of input style.
2335 application.RunIdles();
2337 gInputStyleChangedCallbackCalled = false;
2338 gInputStyleMask = TextField::InputStyle::NONE;
2339 inputStyleChangedSignal = false;
2341 // Create a tap event to touch the text field.
2342 TestGenerateTap(application, 53.0f, 25.0f, 100);
2343 TestGenerateTap(application, 53.0f, 25.0f, 200);
2345 // Render and notify
2346 application.SendNotification();
2347 application.Render();
2349 // Executes the idle callbacks added by the text control on the change of input style.
2350 application.RunIdles();
2352 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2353 if(gInputStyleChangedCallbackCalled)
2355 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2356 static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY |
2357 TextField::InputStyle::POINT_SIZE |
2358 TextField::InputStyle::COLOR),
2361 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2362 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2364 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2365 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2367 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2368 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2370 DALI_TEST_CHECK(inputStyleChangedSignal);
2372 gInputStyleChangedCallbackCalled = false;
2373 gInputStyleMask = TextField::InputStyle::NONE;
2374 inputStyleChangedSignal = false;
2376 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2378 // Render and notify
2379 application.SendNotification();
2380 application.Render();
2382 // Executes the idle callbacks added by the text control on the change of input style.
2383 application.RunIdles();
2385 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2386 if(gInputStyleChangedCallbackCalled)
2388 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2389 static_cast<unsigned int>(TextField::InputStyle::COLOR),
2392 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2393 DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
2395 DALI_TEST_CHECK(inputStyleChangedSignal);
2397 gInputStyleChangedCallbackCalled = false;
2398 gInputStyleMask = TextField::InputStyle::NONE;
2399 inputStyleChangedSignal = false;
2401 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2403 // Render and notify
2404 application.SendNotification();
2405 application.Render();
2407 // Executes the idle callbacks added by the text control on the change of input style.
2408 application.RunIdles();
2410 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2411 DALI_TEST_CHECK(!inputStyleChangedSignal);
2413 gInputStyleChangedCallbackCalled = false;
2414 gInputStyleMask = TextField::InputStyle::NONE;
2415 inputStyleChangedSignal = false;
2417 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2419 // Render and notify
2420 application.SendNotification();
2421 application.Render();
2423 // Executes the idle callbacks added by the text control on the change of input style.
2424 application.RunIdles();
2426 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2427 if(gInputStyleChangedCallbackCalled)
2429 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2430 static_cast<unsigned int>(TextField::InputStyle::COLOR),
2433 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2434 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2436 DALI_TEST_CHECK(inputStyleChangedSignal);
2438 gInputStyleChangedCallbackCalled = false;
2439 gInputStyleMask = TextField::InputStyle::NONE;
2440 inputStyleChangedSignal = false;
2442 field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
2444 Property::Map fontStyleMapSet;
2445 fontStyleMapSet.Insert("weight", "thin");
2446 fontStyleMapSet.Insert("width", "condensed");
2447 fontStyleMapSet.Insert("slant", "italic");
2449 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
2450 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 20.f);
2452 field.SetProperty(TextField::Property::INPUT_UNDERLINE, "underline");
2453 field.SetProperty(TextField::Property::INPUT_SHADOW, "shadow");
2454 field.SetProperty(TextField::Property::INPUT_EMBOSS, "emboss");
2455 field.SetProperty(TextField::Property::INPUT_OUTLINE, "outline");
2456 field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "strikethrough");
2458 // Render and notify
2459 application.SendNotification();
2460 application.Render();
2462 // Executes the idle callbacks added by the text control on the change of input style.
2463 application.RunIdles();
2465 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2466 DALI_TEST_CHECK(!inputStyleChangedSignal);
2468 // Create a tap event to touch the text field.
2469 TestGenerateTap(application, 63.0f, 25.0f, 700);
2471 // Render and notify
2472 application.SendNotification();
2473 application.Render();
2475 // Executes the idle callbacks added by the text control on the change of input style.
2476 application.RunIdles();
2478 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2479 if(gInputStyleChangedCallbackCalled)
2481 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2482 static_cast<unsigned int>(TextField::InputStyle::COLOR |
2483 TextField::InputStyle::POINT_SIZE |
2484 TextField::InputStyle::FONT_STYLE |
2485 TextField::InputStyle::UNDERLINE |
2486 TextField::InputStyle::SHADOW |
2487 TextField::InputStyle::EMBOSS |
2488 TextField::InputStyle::OUTLINE),
2491 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2492 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2494 DALI_TEST_CHECK(inputStyleChangedSignal);
2499 int utcDaliTextFieldInputStyleChanged03(void)
2501 // Test InputStyleCahnged signal emitted even if AddIdle failed.
2502 ToolkitTestApplication application;
2503 tet_infoline(" utcDaliTextFieldInputStyleChanged03");
2507 char* pathNamePtr = get_current_dir_name();
2508 const std::string pathName(pathNamePtr);
2511 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2512 fontClient.SetDpi(93u, 93u);
2514 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2515 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2517 TextField field = TextField::New();
2518 DALI_TEST_CHECK(field);
2520 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2521 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2522 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2524 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2525 field.SetProperty(TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
2527 // connect to the text changed signal.
2528 ConnectionTracker* testTracker = new ConnectionTracker();
2529 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2530 bool inputStyleChangedSignal = false;
2531 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2533 application.GetScene().Add(field);
2535 // Render and notify
2536 application.SendNotification();
2537 application.Render();
2539 // Executes the idle callbacks added by the text control on the change of input style.
2540 application.RunIdles();
2542 gInputStyleChangedCallbackCalled = false;
2543 gInputStyleMask = TextField::InputStyle::NONE;
2544 inputStyleChangedSignal = false;
2546 // Create a tap event to touch the text field.
2547 TestGenerateTap(application, 18.0f, 25.0f);
2549 // Render and notify
2550 application.SendNotification();
2551 application.Render();
2553 // Executes the idle callbacks added by the text control on the change of input style.
2554 application.RunIdles();
2556 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2557 if(gInputStyleChangedCallbackCalled)
2559 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE), TEST_LOCATION);
2561 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2562 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2564 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2565 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2567 DALI_TEST_CHECK(inputStyleChangedSignal);
2569 gInputStyleChangedCallbackCalled = false;
2570 gInputStyleMask = TextField::InputStyle::NONE;
2571 inputStyleChangedSignal = false;
2573 // Create a tap event to touch the text field.
2574 TestGenerateTap(application, 30.0f, 25.0f);
2576 // Render and notify
2577 application.SendNotification();
2578 application.Render();
2580 // Executes the idle callbacks added by the text control on the change of input style.
2581 application.RunIdles();
2583 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2584 DALI_TEST_CHECK(!inputStyleChangedSignal);
2586 gInputStyleChangedCallbackCalled = false;
2587 gInputStyleMask = TextField::InputStyle::NONE;
2588 inputStyleChangedSignal = false;
2590 // Create a tap event to touch the text field.
2591 TestGenerateTap(application, 43.0f, 25.0f);
2593 // Render and notify
2594 application.SendNotification();
2595 application.Render();
2597 // Executes the idle callbacks added by the text control on the change of input style.
2598 application.RunIdles();
2600 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2601 if(gInputStyleChangedCallbackCalled)
2603 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR), TEST_LOCATION);
2605 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2606 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2608 DALI_TEST_CHECK(inputStyleChangedSignal);
2610 gInputStyleChangedCallbackCalled = false;
2611 gInputStyleMask = TextField::InputStyle::NONE;
2612 inputStyleChangedSignal = false;
2614 // Make AddIdle return false.
2615 ToolkitApplication::ADD_IDLE_SUCCESS = false;
2617 // Create a tap event to touch the text field.
2618 TestGenerateTap(application, 88.0f, 25.0f);
2620 // Render and notify
2621 application.SendNotification();
2622 application.Render();
2624 // Execute the idle callbacks.
2625 // And check whether we didn't change of input style.
2626 application.RunIdles();
2628 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2629 DALI_TEST_CHECK(!inputStyleChangedSignal);
2631 gInputStyleChangedCallbackCalled = false;
2632 gInputStyleMask = TextField::InputStyle::NONE;
2633 inputStyleChangedSignal = false;
2635 // Create a tap event to touch the text field.
2636 TestGenerateTap(application, 115.0f, 25.0f);
2638 // Render and notify
2639 application.SendNotification();
2640 application.Render();
2642 // Execute the idle callbacks.
2643 // And check whether we didn't change of input style.
2644 application.RunIdles();
2646 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2647 DALI_TEST_CHECK(!inputStyleChangedSignal);
2649 gInputStyleChangedCallbackCalled = false;
2650 gInputStyleMask = TextField::InputStyle::NONE;
2651 inputStyleChangedSignal = false;
2653 // Revert AddIdle return true.
2654 ToolkitApplication::ADD_IDLE_SUCCESS = true;
2656 // Create a tap event to touch the text field.
2657 TestGenerateTap(application, 164.0f, 25.0f);
2659 // Render and notify
2660 application.SendNotification();
2661 application.Render();
2663 // Executes the idle callbacks added by the text control on the change of input style.
2664 application.RunIdles();
2666 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2667 if(gInputStyleChangedCallbackCalled)
2669 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2671 const std::string style = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<std::string>();
2672 DALI_TEST_CHECK(style.empty());
2674 DALI_TEST_CHECK(inputStyleChangedSignal);
2676 gInputStyleChangedCallbackCalled = false;
2677 gInputStyleMask = TextField::InputStyle::NONE;
2678 inputStyleChangedSignal = false;
2680 // Create a tap event to touch the text field.
2681 TestGenerateTap(application, 191.0f, 25.0f);
2683 // Render and notify
2684 application.SendNotification();
2685 application.Render();
2687 // Executes the idle callbacks added by the text control on the change of input style.
2688 application.RunIdles();
2690 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2691 DALI_TEST_CHECK(!inputStyleChangedSignal);
2696 int utcDaliTextFieldEvent01(void)
2698 ToolkitTestApplication application;
2699 tet_infoline(" utcDaliTextFieldEvent01");
2701 // Creates a tap event. After creating a tap event the text field should
2702 // have the focus and add text with key events should be possible.
2704 TextField field = TextField::New();
2705 DALI_TEST_CHECK(field);
2707 application.GetScene().Add(field);
2709 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2710 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2711 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2713 // Render and notify
2714 application.SendNotification();
2715 application.Render();
2717 // Avoid a crash when core load gl resources.
2718 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2720 // Render and notify
2721 application.SendNotification();
2722 application.Render();
2724 // Add a key event but as the text field has not the focus it should do nothing.
2725 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2727 // Render and notify
2728 application.SendNotification();
2729 application.Render();
2731 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
2733 // Create a tap event to touch the text field.
2734 TestGenerateTap(application, 150.0f, 25.0f);
2736 // Render and notify
2737 application.SendNotification();
2738 application.Render();
2740 // Pressing delete key should be fine even if there is no text in TextField.
2741 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));
2742 // Render and notify
2743 application.SendNotification();
2744 application.Render();
2746 // Now the text field has the focus, so it can handle the key events.
2747 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2748 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2750 // Render and notify
2751 application.SendNotification();
2752 application.Render();
2754 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2756 // Create a second text field and send key events to it.
2757 TextField field2 = TextField::New();
2759 field2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2760 field2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2761 field2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2762 field2.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
2764 application.GetScene().Add(field2);
2766 // Render and notify
2767 application.SendNotification();
2768 application.Render();
2770 // Create a tap event on the second text field.
2771 TestGenerateTap(application, 150.0f, 125.0f);
2773 // Render and notify
2774 application.SendNotification();
2775 application.Render();
2777 // The second text field has the focus. It should handle the key events.
2778 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2779 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2781 // Render and notify
2782 application.SendNotification();
2783 application.Render();
2785 // Check the text has been added to the second text field.
2786 DALI_TEST_EQUALS(field2.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2791 int utcDaliTextFieldEvent02(void)
2793 ToolkitTestApplication application;
2794 tet_infoline(" utcDaliTextFieldEvent02");
2796 // Checks if the right number of actors are created.
2798 TextField field = TextField::New();
2799 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2800 DALI_TEST_CHECK(field);
2801 LoadMarkerImages(application, field);
2803 application.GetScene().Add(field);
2805 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2806 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2807 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2809 // Avoid a crash when core load gl resources.
2810 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2812 // Render and notify
2813 application.SendNotification();
2814 application.Render();
2816 // Check there are the expected number of children ( stencil ).
2817 DALI_TEST_EQUALS(field.GetChildCount(), 1u, TEST_LOCATION);
2819 Actor stencil = field.GetChildAt(0u);
2820 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2822 // Create a tap event to touch the text field.
2823 TestGenerateTap(application, 150.0f, 25.0f, 300);
2825 // Render and notify
2826 application.SendNotification();
2827 application.Render();
2829 Actor layer = field.GetChildAt(2u);
2830 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2831 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2833 // Now the text field has the focus, so it can handle the key events.
2834 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2835 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2837 // Render and notify
2838 application.SendNotification();
2839 application.Render();
2841 // Checks the cursor and the renderer have been created.
2842 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2843 DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
2845 Control cursor = Control::DownCast(layer.GetChildAt(0u));
2846 DALI_TEST_CHECK(cursor);
2848 // The offscreen root actor has a container with all the actors which contain the text renderers.
2849 Actor container = stencil.GetChildAt(0u);
2850 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2852 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2853 DALI_TEST_CHECK(renderer);
2856 // Move the cursor and check the position changes.
2857 Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2858 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2860 // Render and notify
2861 application.SendNotification();
2862 application.Render();
2864 Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2865 DALI_TEST_CHECK(position2.x < position1.x);
2867 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2869 // Render and notify
2870 application.SendNotification();
2871 application.Render();
2873 Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2874 DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
2876 // Move the cursor to the first position.
2877 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2878 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2880 // Render and notify
2881 application.SendNotification();
2882 application.Render();
2884 Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2886 // Send some taps and check the cursor positions.
2888 // Try to tap at the beginning.
2889 TestGenerateTap(application, 1.0f, 25.0f, 900);
2891 // Render and notify
2892 application.SendNotification();
2893 application.Render();
2895 // Cursor position should be the same than position1.
2896 Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2898 DALI_TEST_EQUALS(position4, position5, TEST_LOCATION); // Should be in the same position2.
2900 // Tap away from the start position.
2901 TestGenerateTap(application, 16.0f, 25.0f, 1500);
2903 // Render and notify
2904 application.SendNotification();
2905 application.Render();
2907 Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2909 DALI_TEST_CHECK(position6.x > position5.x);
2911 // Remove all the text.
2912 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2913 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2914 field.SetProperty(TextField::Property::TEXT, "");
2916 // Render and notify
2917 application.SendNotification();
2918 application.Render();
2920 // Cursor position should be the same than position2.
2921 Vector3 position7 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2923 DALI_TEST_EQUALS(position4, position7, TEST_LOCATION); // Should be in the same position2.
2925 // Should not be a renderer, there is only a clipped cursor.
2926 DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
2928 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2929 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2930 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
2932 application.SendNotification();
2933 application.Render();
2935 // There are renderer and decorator layer
2936 DALI_TEST_EQUALS(field.GetChildCount(), 2u, TEST_LOCATION);
2941 int utcDaliTextFieldEvent03(void)
2943 ToolkitTestApplication application;
2944 tet_infoline(" utcDaliTextFieldEvent03");
2946 // Checks if the highlight actor is created.
2948 TextField field = TextField::New();
2949 DALI_TEST_CHECK(field);
2951 application.GetScene().Add(field);
2953 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2954 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2955 field.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2956 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2957 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2959 // Avoid a crash when core load gl resources.
2960 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2961 LoadMarkerImages(application, field);
2963 // Render and notify
2964 application.SendNotification();
2965 application.Render();
2967 // Tap first to get the focus.
2968 TestGenerateTap(application, 3.0f, 25.0f, 100);
2970 // Render and notify
2971 application.SendNotification();
2972 application.Render();
2974 // Double tap to select a word.
2975 TestGenerateTap(application, 3.0f, 25.0f, 200);
2977 // Render and notify
2978 application.SendNotification();
2979 application.Render();
2981 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2982 Actor stencil = field.GetChildAt(0u);
2984 // The highlight actor is drawn first, so is the first actor in the list
2985 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2986 DALI_TEST_CHECK(highlight);
2988 // The offscreen root actor has a container with all the actors which contain the text renderers.
2989 Actor container = stencil.GetChildAt(1u);
2990 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2992 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2993 DALI_TEST_CHECK(renderer);
2999 int utcDaliTextFieldEvent04(void)
3001 ToolkitTestApplication application;
3002 tet_infoline(" utcDaliTextFieldEvent04");
3004 // Checks if the highlight actor is created.
3006 TextField field = TextField::New();
3007 DALI_TEST_CHECK(field);
3008 application.GetScene().Add(field);
3009 LoadMarkerImages(application, field);
3010 // Render and notify
3011 application.SendNotification();
3012 application.Render();
3014 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
3015 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3016 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3017 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3018 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3020 // Avoid a crash when core load gl resources.
3021 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3022 // Render and notify
3023 application.SendNotification();
3024 application.Render();
3026 // Create a tap event to touch the text field.
3027 TestGenerateTap(application, 150.0f, 25.0f);
3028 // Render and notify
3029 application.SendNotification();
3030 application.Render();
3032 // Tap first to get the focus.
3033 TestGenerateTap(application, 1.0f, 25.0f);
3035 // Render and notify
3036 application.SendNotification();
3037 application.Render();
3039 // Double tap to select a word.
3040 TestGenerateTap(application, 1.0f, 25.0f);
3042 // Render and notify
3043 application.SendNotification();
3044 application.Render();
3047 TestGenerateTap(application, 0.0f, 40.0f);
3049 field.SetProperty(TextField::Property::POINT_SIZE, 12.f);
3050 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3055 int utcDaliTextFieldEvent05(void)
3057 ToolkitTestApplication application;
3058 tet_infoline(" utcDaliTextFieldEvent05");
3060 // Checks dragging of cursor/grab handle
3062 TextField field = TextField::New();
3063 DALI_TEST_CHECK(field);
3064 application.GetScene().Add(field);
3065 LoadMarkerImages(application, field);
3066 // Render and notify
3067 application.SendNotification();
3068 application.Render();
3070 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
3071 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3072 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3073 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3074 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3076 // Avoid a crash when core load gl resources.
3077 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3078 // Render and notify
3079 application.SendNotification();
3080 application.Render();
3082 // Create a tap event to touch the text field.
3083 TestGenerateTap(application, 150.0f, 25.0f);
3084 // Render and notify
3085 application.SendNotification();
3086 application.Render();
3088 // Tap first to get the focus.
3089 TestGenerateTap(application, 1.0f, 25.0f);
3091 // Render and notify
3092 application.SendNotification();
3093 application.Render();
3095 // Double tap to select a word.
3096 TestGenerateTap(application, 1.0f, 25.0f);
3098 // Render and notify
3099 application.SendNotification();
3100 application.Render();
3102 Actor stencil = field.GetChildAt(1u);
3106 int utcDaliTextFieldEvent06(void)
3108 ToolkitTestApplication application;
3109 tet_infoline(" utcDaliTextFieldEvent06");
3111 // Checks Longpress when in edit mode
3113 TextField field = TextField::New();
3114 DALI_TEST_CHECK(field);
3115 application.GetScene().Add(field);
3116 LoadMarkerImages(application, field);
3117 // Render and notify
3118 application.SendNotification();
3119 application.Render();
3121 field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
3122 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3123 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3124 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3125 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3127 // Avoid a crash when core load gl resources.
3128 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3129 // Render and notify
3130 application.SendNotification();
3131 application.Render();
3133 // Create a tap event to touch the text field.
3134 TestGenerateTap(application, 150.0f, 25.0f);
3135 // Render and notify
3136 application.SendNotification();
3137 application.Render();
3139 // Tap first to get the focus.
3140 TestGenerateTap(application, 1.0f, 25.0f);
3142 // Render and notify
3143 application.SendNotification();
3144 application.Render();
3147 TestGenerateLongPress(application, 1.0f, 25.0f);
3149 // Render and notify
3150 application.SendNotification();
3151 application.Render();
3156 int utcDaliTextFieldEvent07(void)
3158 ToolkitTestApplication application;
3159 tet_infoline(" utcDaliTextFieldEvent07");
3161 // Checks Longpress to start edit mode
3163 TextField field = TextField::New();
3164 DALI_TEST_CHECK(field);
3165 application.GetScene().Add(field);
3166 LoadMarkerImages(application, field);
3167 // Render and notify
3168 application.SendNotification();
3169 application.Render();
3171 field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
3172 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3173 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3174 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3175 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3176 Property::Map propertyMap;
3177 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
3178 field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
3180 // Avoid a crash when core load gl resources.
3181 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3182 // Render and notify
3183 application.SendNotification();
3184 application.Render();
3187 TestGenerateLongPress(application, 1.0f, 25.0f);
3189 // Render and notify
3190 application.SendNotification();
3191 application.Render();
3196 int utcDaliTextFieldEvent08(void)
3198 ToolkitTestApplication application;
3199 tet_infoline(" utcDaliTextFieldEvent08");
3201 Dali::Clipboard clipboard = Clipboard::Get();
3202 Dali::Clipboard::ClipData data("text/plain;charset=utf-8", "testTextFieldEvent");
3203 clipboard.SetData(data);
3205 // Checks Longpress when only place holder text
3207 TextField field = TextField::New();
3208 DALI_TEST_CHECK(field);
3209 application.GetScene().Add(field);
3210 LoadMarkerImages(application, field);
3211 // Render and notify
3212 application.SendNotification();
3213 application.Render();
3215 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
3216 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3217 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3218 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3219 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3221 // Avoid a crash when core load gl resources.
3222 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3223 // Render and notify
3224 application.SendNotification();
3225 application.Render();
3228 TestGenerateLongPress(application, 1.0f, 25.0f, 20);
3230 // Render and notify
3231 application.SendNotification();
3232 application.Render();
3234 Wait(application, 500);
3236 TestEndLongPress(application, 1.0f, 25.0f, 520);
3239 TestGenerateLongPress(application, 1.0f, 25.0f, 600);
3241 // Render and notify
3242 application.Render();
3244 Wait(application, 500);
3246 Integration::Scene stage = application.GetScene();
3247 Layer layer = stage.GetRootLayer();
3248 Actor actor = layer.FindChildByName("optionPaste");
3252 Vector3 worldPosition = actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION);
3253 Vector2 halfStageSize = stage.GetSize() / 2.0f;
3254 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
3256 Dali::Integration::TouchEvent event;
3257 event = Dali::Integration::TouchEvent();
3258 event.AddPoint(GetPointDownInside(position));
3259 application.ProcessEvent(event);
3261 event = Dali::Integration::TouchEvent();
3262 event.AddPoint(GetPointUpInside(position));
3263 application.ProcessEvent(event);
3265 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("testTextFieldEvent"), TEST_LOCATION);
3270 int utcDaliTextFieldEvent09(void)
3272 ToolkitTestApplication application;
3273 tet_infoline(" utcDaliTextFieldEvent09");
3275 TextField field = TextField::New();
3276 DALI_TEST_CHECK(field);
3277 application.GetScene().Add(field);
3278 LoadMarkerImages(application, field);
3279 // Render and notify
3280 application.SendNotification();
3281 application.Render();
3283 field.SetProperty(TextField::Property::TEXT, "Hello");
3284 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Placeholder text");
3285 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3286 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3287 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3288 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3290 // Avoid a crash when core load gl resources.
3291 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3293 // Create a tap event to touch the text field.
3294 TestGenerateTap(application, 150.0f, 25.0f);
3295 application.SendNotification();
3296 application.Render();
3299 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_NONE;
3300 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3301 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3302 application.SendNotification();
3303 application.Render();
3304 for(unsigned int index = 0u; index < 6u; ++index)
3306 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3307 application.SendNotification();
3308 application.Render();
3311 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL;
3312 map[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
3313 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3314 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3315 application.SendNotification();
3316 application.Render();
3318 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_COUNT;
3319 map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
3320 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3321 for(unsigned int index = 0u; index < 5u; ++index)
3323 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3324 application.SendNotification();
3325 application.Render();
3328 map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_COUNT;
3329 map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
3330 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3331 for(unsigned int index = 0u; index < 5u; ++index)
3333 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3334 application.SendNotification();
3335 application.Render();
3338 map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
3339 map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 0;
3340 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3341 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3342 application.SendNotification();
3343 application.Render();
3344 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3345 application.SendNotification();
3346 application.Render();
3348 map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 100;
3349 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3350 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3351 application.SendNotification();
3352 application.Render();
3354 Property::Map mapGet;
3355 mapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
3356 DALI_TEST_EQUALS(map.Count(), mapGet.Count(), TEST_LOCATION);
3357 DALI_TEST_EQUALS(DaliTestCheckMaps(map, mapGet), true, TEST_LOCATION);
3361 int utcDaliTextFieldStyleWhilstSelected(void)
3363 ToolkitTestApplication application;
3364 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
3366 // Change font and styles whilst text is selected whilst word selected
3368 TextField field = TextField::New();
3369 DALI_TEST_CHECK(field);
3370 application.GetScene().Add(field);
3371 LoadMarkerImages(application, field);
3372 // Render and notify
3373 application.SendNotification();
3374 application.Render();
3376 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
3377 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3378 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3379 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3380 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3382 // Avoid a crash when core load gl resources.
3383 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3384 // Render and notify
3385 application.SendNotification();
3386 application.Render();
3388 // Create a tap event to touch the text field.
3389 TestGenerateTap(application, 150.0f, 25.0f);
3390 // Render and notify
3391 application.SendNotification();
3392 application.Render();
3394 // Tap first to get the focus.
3395 TestGenerateTap(application, 1.0f, 25.0f);
3397 // Render and notify
3398 application.SendNotification();
3399 application.Render();
3401 // Double tap to select a word.
3402 TestGenerateTap(application, 1.0f, 25.0f);
3404 // Render and notify
3405 application.SendNotification();
3406 application.Render();
3408 field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
3409 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
3411 Property::Map fontStyleMapSet;
3412 Property::Map fontStyleMapGet;
3414 fontStyleMapSet.Insert("weight", "bold");
3415 fontStyleMapSet.Insert("slant", "italic");
3416 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
3418 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
3419 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3420 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3422 fontStyleMapSet.Clear();
3423 fontStyleMapSet.Insert("width", "expanded");
3424 fontStyleMapSet.Insert("slant", "italic");
3425 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
3427 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
3428 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3429 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3431 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
3432 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3434 field.SetProperty(TextField::Property::TEXT_COLOR, Color::RED);
3435 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::RED, TEST_LOCATION);
3437 fontStyleMapSet.Clear();
3438 fontStyleMapSet.Insert("weight", "bold");
3439 fontStyleMapSet.Insert("slant", "italic");
3441 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
3443 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3444 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3445 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3447 fontStyleMapSet.Clear();
3448 fontStyleMapSet.Insert("width", "expanded");
3450 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
3452 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3453 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3454 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3456 // Press Escape to increase coverage
3457 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3458 application.SendNotification();
3459 application.Render();
3461 DALI_TEST_CHECK(!field.HasKeyInputFocus());
3466 int utcDaliTextFieldEscKeyLoseFocus(void)
3468 ToolkitTestApplication application;
3469 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
3471 // Creates a tap event. After creating a tap event the text field should
3472 // have the focus and add text with key events should be possible.
3474 TextField field = TextField::New();
3475 DALI_TEST_CHECK(field);
3477 application.GetScene().Add(field);
3479 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3480 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3481 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3483 // Avoid a crash when core load gl resources.
3484 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3486 // Render and notify
3487 application.SendNotification();
3488 application.Render();
3490 // Add a key event but as the text field has not the focus it should do nothing.
3491 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3492 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3494 // Render and notify
3495 application.SendNotification();
3496 application.Render();
3498 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
3500 // Create a tap event to touch the text field.
3501 TestGenerateTap(application, 150.0f, 25.0f);
3503 // Render and notify
3504 application.SendNotification();
3505 application.Render();
3507 // Now the text field has the focus, so it can handle the key events.
3508 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3509 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3510 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3511 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3513 // Render and notify
3514 application.SendNotification();
3515 application.Render();
3517 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3519 // Generate a Esc key event. The text field should lose the focus.
3520 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3521 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3523 // Render and notify
3524 application.SendNotification();
3525 application.Render();
3527 DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
3529 // No more text should be introduced
3530 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3531 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3533 // Render and notify
3534 application.SendNotification();
3535 application.Render();
3537 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3542 int utcDaliTextFieldSomeSpecialKeys(void)
3544 ToolkitTestApplication application;
3545 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
3547 // Checks some special keys when the text is selected.
3549 TextField field = TextField::New();
3550 DALI_TEST_CHECK(field);
3551 application.GetScene().Add(field);
3552 LoadMarkerImages(application, field);
3553 // Render and notify
3554 application.SendNotification();
3555 application.Render();
3557 const std::string longText("This is a long text for the size of the text-field.");
3559 field.SetProperty(TextField::Property::TEXT, longText);
3560 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3561 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3562 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3563 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3565 // Avoid a crash when core load gl resources.
3566 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3567 // Render and notify
3568 application.SendNotification();
3569 application.Render();
3571 // Create a tap event to touch the text field.
3572 TestGenerateTap(application, 150.0f, 25.0f);
3574 // Render and notify
3575 application.SendNotification();
3576 application.Render();
3578 // Tap first to get the focus.
3579 TestGenerateTap(application, 1.0f, 25.0f);
3581 // Render and notify
3582 application.SendNotification();
3583 application.Render();
3585 // Double tap to select a word.
3586 TestGenerateTap(application, 1.0f, 25.0f);
3588 // Render and notify
3589 application.SendNotification();
3590 application.Render();
3592 // Generate a Esc key event. The text field should lose the focus.
3593 application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3594 application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3596 // Render and notify
3597 application.SendNotification();
3598 application.Render();
3600 // Generate a Esc key event. The text field should lose the focus.
3601 application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3602 application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3604 // Render and notify
3605 application.SendNotification();
3606 application.Render();
3608 // Generate a Esc key event. The text field should lose the focus.
3609 application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3610 application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3612 // Render and notify
3613 application.SendNotification();
3614 application.Render();
3616 // Generate a Back key event. Nothing happens to the text field.
3617 application.ProcessEvent(GenerateKey("XF86Back", "", "XF86Back", DALI_KEY_BACK, 0, 0, Integration::KeyEvent::DOWN, "XF86Back", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3618 application.ProcessEvent(GenerateKey("XF86Back", "", "XF86Back", DALI_KEY_BACK, 0, 0, Integration::KeyEvent::UP, "XF86Back", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3620 // Render and notify
3621 application.SendNotification();
3622 application.Render();
3624 // The text shouldn't be deleted.
3625 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), longText, TEST_LOCATION);
3630 int utcDaliTextFieldSizeUpdate(void)
3632 ToolkitTestApplication application;
3633 tet_infoline("utcDaliTextFieldSizeUpdate");
3635 // Checks some special keys when the text is selected.
3636 TextField field = TextField::New();
3637 DALI_TEST_CHECK(field);
3638 application.GetScene().Add(field);
3640 float previousHeight = 0.0f;
3641 float currentHeight = 0.0f;
3642 const float fieldWidth = 1920.0f;
3644 // "ㅁ" is bigger then "ኢ"
3645 field.SetProperty(Actor::Property::SIZE, Vector2(fieldWidth, 10.0f));
3646 field.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3647 field.SetResizePolicy(ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT);
3649 field.SetProperty(TextField::Property::TEXT, "ኢ");
3650 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3651 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3653 field.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
3654 KeyboardFocusManager::Get().SetCurrentFocusActor(field);
3656 application.SendNotification();
3657 application.Render();
3659 previousHeight = field.GetHeightForWidth(fieldWidth);
3660 DALI_TEST_EQUALS(previousHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3662 // Add another script characters ( glyph height is defferent )
3663 application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3664 application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3666 application.SendNotification();
3667 application.Render();
3669 currentHeight = field.GetHeightForWidth(fieldWidth);
3670 DALI_TEST_EQUALS(currentHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3671 DALI_TEST_EQUALS((previousHeight < currentHeight), true, TEST_LOCATION);
3676 int utcDaliTextFieldExtremlyLargePointSize(void)
3678 ToolkitTestApplication application;
3679 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
3681 TextField field = TextField::New();
3683 field.SetProperty(TextField::Property::TEXT, "Text");
3684 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3685 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3686 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3687 application.GetScene().Add(field);
3691 field.SetProperty(TextField::Property::POINT_SIZE, 160.0f);
3692 application.SendNotification();
3693 DALI_TEST_CHECK(field);
3697 tet_result(TET_FAIL);
3702 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
3704 ToolkitTestApplication application;
3705 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
3706 TextField field = TextField::New();
3707 DALI_TEST_CHECK(field);
3708 application.GetScene().Add(field);
3710 Property::Map fontStyleMapGet;
3712 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3714 Property::Value* weightValue = NULL;
3715 Property::Value* widthValue = NULL;
3716 Property::Value* slantValue = NULL;
3717 weightValue = fontStyleMapGet.Find("weight");
3718 widthValue = fontStyleMapGet.Find("width");
3719 slantValue = fontStyleMapGet.Find("slant");
3720 DALI_TEST_CHECK(!weightValue);
3721 DALI_TEST_CHECK(!widthValue);
3722 DALI_TEST_CHECK(!slantValue);
3727 int UtcDaliTextFieldSettingPlaceholder(void)
3729 ToolkitTestApplication application;
3730 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
3732 TextField field = TextField::New();
3733 DALI_TEST_CHECK(field);
3734 application.GetScene().Add(field);
3736 // Check the placeholder property with pixel size
3737 Property::Map placeholderPixelSizeMapSet;
3738 Property::Map placeholderPixelSizeMapGet;
3739 Property::Map placeholderFontstyleMap;
3740 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT] = "Setting Placeholder Text";
3741 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3742 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::COLOR] = Color::BLUE;
3743 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3744 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3745 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::ELLIPSIS] = true;
3747 placeholderFontstyleMap.Insert("weight", "bold");
3748 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3749 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
3751 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3752 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
3753 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderPixelSizeMapSet), true, TEST_LOCATION);
3755 // Check the placeholder property with point size
3756 Property::Map placeholderMapSet;
3757 Property::Map placeholderMapGet;
3758 placeholderMapSet[Text::PlaceHolder::Property::TEXT] = "Setting Placeholder Text";
3759 placeholderMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3760 placeholderMapSet[Text::PlaceHolder::Property::COLOR] = Color::RED;
3761 placeholderMapSet[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3762 placeholderMapSet[Text::PlaceHolder::Property::POINT_SIZE] = 12.0f;
3763 placeholderMapSet[Text::PlaceHolder::Property::ELLIPSIS] = false;
3765 // Check the placeholder font style property
3766 placeholderFontstyleMap.Clear();
3768 placeholderFontstyleMap.Insert("weight", "bold");
3769 placeholderFontstyleMap.Insert("width", "condensed");
3770 placeholderFontstyleMap.Insert("slant", "italic");
3771 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3772 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3774 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3775 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3776 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3778 // Reset font style.
3779 placeholderFontstyleMap.Clear();
3780 placeholderFontstyleMap.Insert("weight", "normal");
3781 placeholderFontstyleMap.Insert("slant", "oblique");
3782 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3783 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3785 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3786 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3787 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3789 placeholderFontstyleMap.Clear();
3790 placeholderFontstyleMap.Insert("slant", "roman");
3791 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3792 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3794 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3796 placeholderFontstyleMap.Clear();
3797 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3799 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3800 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3801 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3802 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3807 int UtcDaliTextFieldPlaceholderCoverage(void)
3809 ToolkitTestApplication application;
3810 tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
3812 // mPlaceholderFont is created only once, so create a new control for coverage.
3813 TextField fieldForCoverage = TextField::New();
3814 DALI_TEST_CHECK(fieldForCoverage);
3815 application.GetScene().Add(fieldForCoverage);
3817 // for SetPlaceholderFontFamily() coverage.
3818 Property::Map fontFamilyMap;
3819 fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3820 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
3822 // mPlaceholderFont is created only once, so create a new control for coverage.
3823 fieldForCoverage = TextField::New();
3824 DALI_TEST_CHECK(fieldForCoverage);
3825 application.GetScene().Add(fieldForCoverage);
3827 // for SetPlaceholderTextFontSize coverage.
3828 Property::Map fontSizeMap;
3829 fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3830 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
3832 // mPlaceholderFont is created only once, so create a new control for coverage.
3833 fieldForCoverage = TextField::New();
3834 DALI_TEST_CHECK(fieldForCoverage);
3835 application.GetScene().Add(fieldForCoverage);
3837 // for SetPlaceholderTextFontWeight coverage.
3838 Property::Map fontStyleWeightMap;
3839 Property::Map fontStyleWeightPropertyMap;
3840 fontStyleWeightPropertyMap.Insert("weight", "bold");
3841 fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
3842 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
3844 // mPlaceholderFont is created only once, so create a new control for coverage.
3845 fieldForCoverage = TextField::New();
3846 DALI_TEST_CHECK(fieldForCoverage);
3847 application.GetScene().Add(fieldForCoverage);
3849 // for SetPlaceholderTextFontWidth coverage.
3850 Property::Map fontStyleWidthMap;
3851 Property::Map fontStyleWidthPropertyMap;
3852 fontStyleWidthPropertyMap.Insert("width", "expanded");
3853 fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
3854 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
3856 // mPlaceholderFont is created only once, so create a new control for coverage.
3857 fieldForCoverage = TextField::New();
3858 DALI_TEST_CHECK(fieldForCoverage);
3859 application.GetScene().Add(fieldForCoverage);
3861 // for SetPlaceholderTextFontSlant coverage.
3862 Property::Map fontStyleSlantMap;
3863 Property::Map fontStyleSlantPropertyMap;
3864 fontStyleSlantPropertyMap.Insert("slant", "italic");
3865 fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
3866 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
3871 int UtcDaliTextFieldSetPaddingProperty(void)
3873 ToolkitTestApplication application;
3874 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3876 TextField field = TextField::New();
3877 DALI_TEST_CHECK(field);
3878 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3879 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3880 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3881 application.GetScene().Add(field);
3883 application.SendNotification();
3884 application.Render();
3886 Vector3 originalSize = field.GetNaturalSize();
3888 field.SetProperty(Toolkit::Control::Property::PADDING, Extents(10, 10, 10, 10));
3890 application.SendNotification();
3891 application.Render();
3893 DALI_TEST_EQUALS(field.GetProperty<Extents>(Toolkit::Control::Property::PADDING), Extents(10, 10, 10, 10), TEST_LOCATION);
3895 Vector3 paddingAddedSize = field.GetNaturalSize();
3897 DALI_TEST_EQUALS(originalSize.width + 10 + 10, paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3899 DALI_TEST_EQUALS(originalSize.height + 10 + 10, paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3904 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3906 ToolkitTestApplication application;
3907 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3909 TextField field = TextField::New();
3910 DALI_TEST_CHECK(field);
3911 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3912 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3913 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3914 application.GetScene().Add(field);
3916 application.SendNotification();
3917 application.Render();
3919 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3920 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), true, TEST_LOCATION);
3922 // Check the enable shift selection property
3923 field.SetProperty(DevelTextField::Property::ENABLE_SHIFT_SELECTION, false);
3924 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), false, TEST_LOCATION);
3926 application.SendNotification();
3927 application.Render();
3932 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3934 ToolkitTestApplication application;
3935 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3937 TextField field = TextField::New();
3938 DALI_TEST_CHECK(field);
3939 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3940 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3941 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3942 application.GetScene().Add(field);
3944 application.SendNotification();
3945 application.Render();
3947 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3948 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), true, TEST_LOCATION);
3950 // Check the enable grab handle property
3951 field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE, false);
3952 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), false, TEST_LOCATION);
3954 application.SendNotification();
3955 application.Render();
3960 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
3962 ToolkitTestApplication application;
3963 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
3965 TextField field = TextField::New();
3966 DALI_TEST_CHECK(field);
3967 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3968 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3969 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3970 application.GetScene().Add(field);
3972 application.SendNotification();
3973 application.Render();
3975 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3976 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), true, TEST_LOCATION);
3978 // Check the match system language direction property
3979 field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
3980 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), false, TEST_LOCATION);
3982 application.SendNotification();
3983 application.Render();
3988 int utcDaliTextFieldLayoutDirectionCoverage(void)
3990 ToolkitTestApplication application;
3991 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
3993 // Creates a tap event. After creating a tap event the text field should
3994 // have the focus and add text with key events should be possible.
3995 TextField field = TextField::New();
3996 DALI_TEST_CHECK(field);
3998 application.GetScene().Add(field);
4000 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4001 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4002 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4004 // Avoid a crash when core load gl resources.
4005 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4007 // Render and notify
4008 application.SendNotification();
4009 application.Render();
4011 // init direction for coverage
4012 // Set horizontal alignment END
4013 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
4015 // Create a tap event to touch the text field.
4016 TestGenerateTap(application, 150.0f, 25.0f);
4018 // Render and notify
4019 application.SendNotification();
4020 application.Render();
4022 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
4023 field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true);
4024 field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
4026 // Set horizontal alignment BEGIN
4027 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
4029 // Create a tap event to touch the text field.
4030 TestGenerateTap(application, 150.0f, 25.0f);
4032 // Render and notify
4033 application.SendNotification();
4034 application.Render();
4036 // Set horizontal alignment CENTER
4037 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
4039 // Create a tap event to touch the text field.
4040 TestGenerateTap(application, 150.0f, 25.0f);
4042 // Render and notify
4043 application.SendNotification();
4044 application.Render();
4046 // Set horizontal alignment END
4047 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
4049 // Create a tap event to touch the text field.
4050 TestGenerateTap(application, 150.0f, 25.0f);
4052 // Render and notify
4053 application.SendNotification();
4054 application.Render();
4056 // Generate a Esc key event. The text field should lose the focus.
4057 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4058 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4060 // Render and notify
4061 application.SendNotification();
4062 application.Render();
4064 DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
4069 int UtcDaliTextFieldGetInputMethodContext(void)
4071 ToolkitTestApplication application;
4072 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
4074 TextField field = TextField::New();
4075 DALI_TEST_CHECK(DevelTextField::GetInputMethodContext(field));
4080 int UtcDaliTextFieldSelectWholeText(void)
4082 ToolkitTestApplication application;
4083 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
4085 TextField textField = TextField::New();
4087 application.GetScene().Add(textField);
4089 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4090 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4091 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4093 // Avoid a crash when core load gl resources.
4094 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4096 application.SendNotification();
4097 application.Render();
4099 DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
4101 DevelTextField::SelectWholeText(textField);
4103 application.SendNotification();
4104 application.Render();
4106 // Nothing should have been selected. The number of children is still 1
4107 DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
4109 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4111 application.SendNotification();
4112 application.Render();
4114 DevelTextField::SelectWholeText(textField);
4116 application.SendNotification();
4117 application.Render();
4119 // Even if resize, selection should remain.
4120 textField.SetProperty(Actor::Property::SIZE, Vector2(150.f, 50.f));
4122 application.SendNotification();
4123 application.Render();
4125 // Should be 2 children, the stencil and the layer
4126 DALI_TEST_EQUALS(2u, textField.GetChildCount(), TEST_LOCATION);
4128 // The offscreen root actor should have two actors: the renderer and the highlight actor.
4129 Actor stencil = textField.GetChildAt(0u);
4131 // The highlight actor is drawn first, so is the first actor in the list
4132 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
4133 DALI_TEST_CHECK(highlight);
4138 int UtcDaliTextFieldSelectText(void)
4140 ToolkitTestApplication application;
4141 tet_infoline(" UtcDaliTextFieldSelectText ");
4143 TextField textField = TextField::New();
4145 application.GetScene().Add(textField);
4147 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4148 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4149 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4151 // Avoid a crash when core load gl resources.
4152 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4154 application.SendNotification();
4155 application.Render();
4157 DevelTextField::SelectText(textField, 0, 5);
4159 application.SendNotification();
4160 application.Render();
4162 // Nothing is selected
4163 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4164 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
4166 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4168 application.SendNotification();
4169 application.Render();
4171 // Hello is selected
4172 DevelTextField::SelectText(textField, 0, 5);
4174 application.SendNotification();
4175 application.Render();
4177 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4178 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4180 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4181 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4183 // world is selected
4184 DevelTextField::SelectText(textField, 6, 11);
4186 application.SendNotification();
4187 application.Render();
4189 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4190 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4192 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4193 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4198 int UtcDaliTextFieldSelectNone(void)
4200 ToolkitTestApplication application;
4201 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
4203 TextField textField = TextField::New();
4205 application.GetScene().Add(textField);
4207 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4208 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4209 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4211 // Avoid a crash when core load gl resources.
4212 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4214 application.SendNotification();
4215 application.Render();
4217 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4219 application.SendNotification();
4220 application.Render();
4222 // Nothing is selected
4223 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4224 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
4226 DevelTextField::SelectWholeText(textField);
4228 application.SendNotification();
4229 application.Render();
4231 // whole text is selected
4232 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4233 DALI_TEST_EQUALS("Hello world", selectedText, TEST_LOCATION);
4235 DevelTextField::SelectNone(textField);
4237 application.SendNotification();
4238 application.Render();
4240 // Nothing is selected
4241 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4242 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
4247 int UtcDaliTextFieldSelectRange(void)
4249 ToolkitTestApplication application;
4250 tet_infoline(" UtcDaliTextFieldSelectRange ");
4252 TextField textField = TextField::New();
4254 application.GetScene().Add(textField);
4256 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4257 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4258 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4260 // Avoid a crash when core load gl resources.
4261 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4263 application.SendNotification();
4264 application.Render();
4266 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4268 application.SendNotification();
4269 application.Render();
4271 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 0);
4272 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 5);
4274 // Hello is selected
4275 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4276 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4278 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4279 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4281 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 6);
4282 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 11);
4284 // world is selected
4285 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4286 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4288 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4289 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4294 int UtcDaliTextFieldEnableEditing(void)
4296 ToolkitTestApplication application;
4297 tet_infoline(" UtcDaliTextFieldEnableEditing ");
4299 TextField textField = TextField::New();
4301 application.GetScene().Add(textField);
4303 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4304 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4305 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4307 // Avoid a crash when core load gl resources.
4308 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4310 application.SendNotification();
4311 application.Render();
4313 textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
4314 DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), true, TEST_LOCATION);
4316 textField.SetKeyInputFocus();
4317 textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, false);
4318 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4320 // Render and notify
4321 application.SendNotification();
4322 application.Render();
4324 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "", TEST_LOCATION);
4325 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), false, TEST_LOCATION);
4327 textField.SetKeyInputFocus();
4328 textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
4329 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4331 // Render and notify
4332 application.SendNotification();
4333 application.Render();
4335 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
4336 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), true, TEST_LOCATION);
4338 // Check the user interaction enabled and for coverage
4339 DevelTextField::SelectWholeText(textField);
4341 // Render and notify
4342 application.SendNotification();
4343 application.Render();
4345 textField.SetKeyInputFocus();
4346 textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false);
4347 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4349 // Render and notify
4350 application.SendNotification();
4351 application.Render();
4353 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
4354 DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), false, TEST_LOCATION);
4359 int UtcDaliToolkitTextFieldFontSizeScale(void)
4361 ToolkitTestApplication application;
4362 tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
4364 TextField textField = TextField::New();
4365 textField.SetProperty(TextField::Property::POINT_SIZE, 30.f);
4366 textField.SetProperty(TextField::Property::TEXT, "Test");
4367 Vector3 nonScaledSize = textField.GetNaturalSize();
4369 TextField textFieldScaled = TextField::New();
4370 textFieldScaled.SetProperty(TextField::Property::POINT_SIZE, 15.f);
4371 textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
4372 textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
4373 Vector3 scaledSize = textFieldScaled.GetNaturalSize();
4375 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4377 textField.SetProperty(TextField::Property::PIXEL_SIZE, 30.f);
4378 textField.SetProperty(TextField::Property::TEXT, "Test");
4379 nonScaledSize = textField.GetNaturalSize();
4381 textFieldScaled.SetProperty(TextField::Property::PIXEL_SIZE, 15.f);
4382 textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
4383 textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
4384 scaledSize = textFieldScaled.GetNaturalSize();
4386 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4391 int UtcDaliTextFieldPrimaryCursorPosition(void)
4393 ToolkitTestApplication application;
4394 tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
4396 TextField textField = TextField::New();
4398 application.GetScene().Add(textField);
4400 textField.SetProperty(TextField::Property::TEXT, "ABCEF");
4401 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4402 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4403 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4405 // Avoid a crash when core load gl resources.
4406 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4408 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4409 application.SendNotification();
4410 application.Render();
4411 textField.SetKeyInputFocus();
4413 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4415 // Render and notify
4416 application.SendNotification();
4417 application.Render();
4419 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCDEF", TEST_LOCATION);
4420 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
4425 // test max length when set after setting long text
4426 int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
4428 ToolkitTestApplication application;
4429 tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
4430 TextField field = TextField::New();
4431 DALI_TEST_CHECK(field);
4433 application.GetScene().Add(field);
4435 field.SetProperty(TextField::Property::TEXT, "123456789");
4437 const int maxNumberOfCharacters = 3;
4438 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
4440 field.SetKeyInputFocus();
4442 // connect to the text max lengh reached signal.
4443 ConnectionTracker* testTracker = new ConnectionTracker();
4444 bool maxLengthReachedSignal = false;
4445 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
4447 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4448 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4450 DALI_TEST_CHECK(maxLengthReachedSignal);
4452 DALI_TEST_EQUALS(field.GetProperty(TextField::Property::TEXT).Get<std::string>(), "123456789", TEST_LOCATION);
4457 int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
4459 ToolkitTestApplication application;
4460 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
4462 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4463 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4464 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4466 // Create a text field
4467 TextField textField = TextField::New();
4469 //Set size to avoid automatic eliding
4470 textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4471 //Set very large font-size using point-size
4472 textField.SetProperty(TextField::Property::POINT_SIZE, 1000);
4473 //Specify font-family
4474 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4475 //Set text to check if appear or not
4476 textField.SetProperty(TextField::Property::TEXT, "A");
4478 application.GetScene().Add(textField);
4480 application.SendNotification();
4481 application.Render();
4482 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4483 Vector3 naturalSize = textField.GetNaturalSize();
4485 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4486 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4491 int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
4493 ToolkitTestApplication application;
4494 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
4496 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4497 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4498 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4500 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4501 // Create a text editor
4502 TextField textField = TextField::New();
4504 //Set size to avoid automatic eliding
4505 textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4506 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4507 textField.SetProperty(TextField::Property::TEXT, "A");
4509 const int numberOfCases = 6;
4510 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
4512 for(int index = 0; index < numberOfCases; index++)
4514 tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
4515 textField.SetProperty(TextField::Property::POINT_SIZE, arrayCases[index]);
4516 application.GetScene().Add(textField);
4517 application.SendNotification();
4518 application.Render();
4519 naturalSize = textField.GetNaturalSize();
4520 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4521 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4527 int UtcDaliToolkitTextFieldEllipsisPositionProperty(void)
4529 ToolkitTestApplication application;
4530 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty ");
4531 TextField textField = TextField::New();
4533 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Default is END");
4534 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4536 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START");
4537 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4538 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4540 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE");
4541 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4542 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4544 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END");
4545 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4546 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4548 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START using integer");
4549 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 1);
4550 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4552 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE using integer");
4553 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 2);
4554 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4556 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END using integer");
4557 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 0);
4558 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4560 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4561 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "START");
4562 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4564 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4565 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "MIDDLE");
4566 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4568 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4569 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "END");
4570 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4572 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4573 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "start");
4574 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4576 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4577 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "middle");
4578 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4580 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4581 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "end");
4582 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4587 int UtcDaliTextFieldCopyText(void)
4589 ToolkitTestApplication application;
4590 tet_infoline(" UtcDaliTextFieldCopyText ");
4592 TextField textField = TextField::New();
4594 std::string selectedText = "";
4595 std::string copiedText = "";
4597 application.GetScene().Add(textField);
4599 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4600 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4601 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4603 // Avoid a crash when core load gl resources.
4604 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4606 application.SendNotification();
4607 application.Render();
4609 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4611 application.SendNotification();
4612 application.Render();
4614 // Hello is selected
4615 DevelTextField::SelectText(textField, 0, 5);
4617 application.SendNotification();
4618 application.Render();
4620 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4621 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4623 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4624 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4627 copiedText = DevelTextField::CopyText(textField);
4628 DALI_TEST_EQUALS("Hello", copiedText, TEST_LOCATION);
4630 // world is selected
4631 DevelTextField::SelectText(textField, 6, 11);
4633 application.SendNotification();
4634 application.Render();
4636 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4637 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4639 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4640 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4643 copiedText = DevelTextField::CopyText(textField);
4644 DALI_TEST_EQUALS("world", copiedText, TEST_LOCATION);
4646 // "lo wo" is selected
4647 DevelTextField::SelectText(textField, 3, 8);
4649 application.SendNotification();
4650 application.Render();
4652 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4653 DALI_TEST_EQUALS("lo wo", selectedText, TEST_LOCATION);
4655 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 3, TEST_LOCATION);
4656 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 8, TEST_LOCATION);
4658 // "lo wo" is copied
4659 copiedText = DevelTextField::CopyText(textField);
4660 DALI_TEST_EQUALS("lo wo", copiedText, TEST_LOCATION);
4665 int UtcDaliTextFieldCutText(void)
4667 ToolkitTestApplication application;
4668 tet_infoline(" UtcDaliTextFieldCutText ");
4670 TextField textField = TextField::New();
4672 std::string selectedText = "";
4674 application.GetScene().Add(textField);
4676 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4677 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4678 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4680 // Avoid a crash when core load gl resources.
4681 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4683 application.SendNotification();
4684 application.Render();
4686 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4688 application.SendNotification();
4689 application.Render();
4691 // Hello is selected
4692 DevelTextField::SelectText(textField, 0, 5);
4694 application.SendNotification();
4695 application.Render();
4697 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4698 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4700 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4701 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4704 DALI_TEST_EQUALS("Hello", DevelTextField::CutText(textField), TEST_LOCATION);
4706 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), " world", TEST_LOCATION);
4709 DevelTextField::SelectText(textField, 0, 2);
4711 application.SendNotification();
4712 application.Render();
4714 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4715 DALI_TEST_EQUALS(" w", selectedText, TEST_LOCATION);
4717 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4718 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4721 DALI_TEST_EQUALS(" w", DevelTextField::CutText(textField), TEST_LOCATION);
4723 application.SendNotification();
4724 application.Render();
4726 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "orld", TEST_LOCATION);
4728 // Test Cut from the middle
4731 DevelTextField::SelectText(textField, 1, 3);
4733 application.SendNotification();
4734 application.Render();
4736 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4737 DALI_TEST_EQUALS("rl", selectedText, TEST_LOCATION);
4739 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4740 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 3, TEST_LOCATION);
4743 DALI_TEST_EQUALS("rl", DevelTextField::CutText(textField), TEST_LOCATION);
4745 application.SendNotification();
4746 application.Render();
4748 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "od", TEST_LOCATION);
4750 // Test Cut from the end
4753 DevelTextField::SelectText(textField, 1, 2);
4755 application.SendNotification();
4756 application.Render();
4758 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4759 DALI_TEST_EQUALS("d", selectedText, TEST_LOCATION);
4761 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4762 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4765 DALI_TEST_EQUALS("d", DevelTextField::CutText(textField), TEST_LOCATION);
4767 application.SendNotification();
4768 application.Render();
4770 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "o", TEST_LOCATION);
4775 int UtcDaliTextFieldPasteText(void)
4777 ToolkitTestApplication application;
4778 tet_infoline(" UtcDaliTextFieldPasteText ");
4780 TextField textField = TextField::New();
4782 application.GetScene().Add(textField);
4784 std::string cutText = "";
4785 std::string copiedText = "";
4787 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4788 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4789 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4791 // Avoid a crash when core load gl resources.
4792 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4794 application.SendNotification();
4795 application.Render();
4797 textField.SetProperty(TextField::Property::TEXT, "Hello World");
4799 application.SendNotification();
4800 application.Render();
4802 // Tap on the text editor
4803 TestGenerateTap(application, 3.0f, 25.0f);
4805 // Render and notify
4806 application.SendNotification();
4807 application.Render();
4809 // Select some text in the right of the current cursor position
4810 DevelTextField::SelectText(textField, 0, 3);
4812 // Render and notify
4813 application.SendNotification();
4814 application.Render();
4816 // Cut the selected text
4817 cutText = DevelTextField::CutText(textField);
4819 // Render and notify
4820 application.SendNotification();
4821 application.Render();
4823 DALI_TEST_EQUALS("Hel", cutText, TEST_LOCATION);
4824 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo World", TEST_LOCATION);
4826 DevelTextField::SelectText(textField, 0, 3);
4828 // Render and notify
4829 application.SendNotification();
4830 application.Render();
4832 // Copy the selected text
4833 copiedText = DevelTextField::CopyText(textField);
4835 // Render and notify
4836 application.SendNotification();
4837 application.Render();
4839 DALI_TEST_EQUALS("lo ", copiedText, TEST_LOCATION);
4840 DALI_TEST_EQUALS("lo World", textField.GetProperty<std::string>(TextField::Property::TEXT), TEST_LOCATION);
4842 // Move the cursor to the end of the line
4843 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4844 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4845 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4846 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4847 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4848 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4849 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4850 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4852 // Render and notify
4853 application.SendNotification();
4854 application.Render();
4856 // Paste the selected text at the current cursor position
4857 DevelTextField::PasteText(textField);
4859 // Render and notify
4860 application.SendNotification();
4861 application.Render();
4863 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo Worldlo ", TEST_LOCATION);
4868 int utcDaliTextFieldCursorPositionChangedSignal(void)
4870 ToolkitTestApplication application;
4871 tet_infoline(" utcDaliTextFieldCursorPositionChangedSignal");
4873 TextField field = TextField::New();
4874 DALI_TEST_CHECK(field);
4876 application.GetScene().Add(field);
4878 // connect to the selection changed signal.
4879 ConnectionTracker* testTracker = new ConnectionTracker();
4880 DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
4881 bool cursorPositionChangedSignal = false;
4882 field.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
4884 field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
4885 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4886 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4887 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4888 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4890 // Avoid a crash when core load gl resources.
4891 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4893 // Render and notify
4894 application.SendNotification();
4895 application.Render();
4897 field.SetKeyInputFocus();
4899 // Tap on the text field
4900 TestGenerateTap(application, 3.0f, 25.0f);
4902 // Render and notify
4903 application.SendNotification();
4904 application.Render();
4906 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4907 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4909 gCursorPositionChangedCallbackCalled = false;
4912 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4914 // Render and notify
4915 application.SendNotification();
4916 application.Render();
4918 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4919 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4921 gCursorPositionChangedCallbackCalled = false;
4924 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4926 // Render and notify
4927 application.SendNotification();
4928 application.Render();
4930 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4931 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4933 gCursorPositionChangedCallbackCalled = false;
4935 //delete one character
4936 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4938 // Render and notify
4939 application.SendNotification();
4940 application.Render();
4942 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4943 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4945 gCursorPositionChangedCallbackCalled = false;
4947 field.SetProperty(TextField::Property::TEXT, "Hello");
4949 // Render and notify
4950 application.SendNotification();
4951 application.Render();
4953 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4954 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4956 gCursorPositionChangedCallbackCalled = false;
4958 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4960 // Render and notify
4961 application.SendNotification();
4962 application.Render();
4964 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4965 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4970 int utcDaliTextFieldGeometryEllipsisStart(void)
4972 ToolkitTestApplication application;
4973 tet_infoline(" utcDaliTextFieldGeometryEllipsisStart");
4975 TextField field = TextField::New();
4976 DALI_TEST_CHECK(field);
4978 application.GetScene().Add(field);
4980 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
4981 field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
4982 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4983 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4984 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
4985 field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
4986 field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4987 field.SetProperty(TextField::Property::TEXT, "Hello World");
4989 // Avoid a crash when core load gl resources.
4990 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4992 // Render and notify
4993 application.SendNotification();
4994 application.Render();
4996 unsigned int expectedCount = 1;
4997 unsigned int startIndex = 0;
4998 unsigned int endIndex = 10;
5000 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5001 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
5003 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5004 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5006 Vector<Vector2> expectedSizes;
5007 Vector<Vector2> expectedPositions;
5009 expectedPositions.PushBack(Vector2(14, 0));
5010 expectedSizes.PushBack(Vector2(107, 25));
5012 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5017 int utcDaliTextFieldGeometryEllipsisEnd(void)
5019 ToolkitTestApplication application;
5020 tet_infoline(" utcDaliTextFieldGeometryEllipsisEnd");
5022 TextField field = TextField::New();
5023 DALI_TEST_CHECK(field);
5025 application.GetScene().Add(field);
5027 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5028 field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
5029 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5030 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5031 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5032 field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
5033 field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
5034 field.SetProperty(TextField::Property::TEXT, "Hello World");
5036 // Avoid a crash when core load gl resources.
5037 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5039 // Render and notify
5040 application.SendNotification();
5041 application.Render();
5043 unsigned int expectedCount = 1;
5044 unsigned int startIndex = 0;
5045 unsigned int endIndex = 10;
5047 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5048 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
5050 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5051 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5053 Vector<Vector2> expectedSizes;
5054 Vector<Vector2> expectedPositions;
5056 expectedPositions.PushBack(Vector2(-2, 0));
5057 expectedSizes.PushBack(Vector2(123, 25));
5059 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5064 int utcDaliTextFieldGeometryRTL(void)
5066 ToolkitTestApplication application;
5067 tet_infoline(" utcDaliTextFieldGeometryRTL");
5069 TextField field = TextField::New();
5070 DALI_TEST_CHECK(field);
5072 application.GetScene().Add(field);
5074 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5075 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
5076 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5077 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5078 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5079 field.SetProperty(TextField::Property::TEXT, "السطر الاخير");
5081 // Avoid a crash when core load gl resources.
5082 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5084 // Render and notify
5085 application.SendNotification();
5086 application.Render();
5088 unsigned int expectedCount = 1;
5089 unsigned int startIndex = 1;
5090 unsigned int endIndex = 7;
5092 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5093 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
5095 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5096 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5098 Vector<Vector2> expectedSizes;
5099 Vector<Vector2> expectedPositions;
5101 expectedPositions.PushBack(Vector2(38, 0));
5102 expectedSizes.PushBack(Vector2(75, 25));
5104 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5109 int utcDaliTextFieldGeometryGlyphMiddle(void)
5111 ToolkitTestApplication application;
5112 tet_infoline(" utcDaliTextFieldGeometryGlyphMiddle");
5114 TextField field = TextField::New();
5115 DALI_TEST_CHECK(field);
5117 application.GetScene().Add(field);
5119 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5120 field.SetProperty(Actor::Property::SIZE, Vector2(150.f, 200.f));
5121 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5122 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5123 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5124 field.SetProperty(TextField::Property::TEXT, "لا تحتوي على لا");
5126 // Avoid a crash when core load gl resources.
5127 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5129 // Render and notify
5130 application.SendNotification();
5131 application.Render();
5133 unsigned int expectedCount = 1;
5134 unsigned int startIndex = 1;
5135 unsigned int endIndex = 13;
5137 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5138 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
5140 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5141 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5143 Vector<Vector2> expectedSizes;
5144 Vector<Vector2> expectedPositions;
5146 expectedPositions.PushBack(Vector2(6, 0));
5147 expectedSizes.PushBack(Vector2(125, 25));
5149 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5154 int utcDaliTextFieldGeometryNullPtr(void)
5156 ToolkitTestApplication application;
5157 tet_infoline("utcDaliTextFieldGeometryNullPtr");
5159 TextField field = TextField::New();
5160 DALI_TEST_CHECK(field);
5162 application.GetScene().Add(field);
5164 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5165 field.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
5166 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5167 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5168 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5169 field.SetProperty(TextField::Property::TEXT, "");
5171 // Avoid a crash when core load gl resources.
5172 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5174 unsigned int expectedCount = 0;
5175 unsigned int startIndex = 0;
5176 unsigned int endIndex = 0;
5178 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5179 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
5181 // Render and notify
5182 application.SendNotification();
5183 application.Render();
5185 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5186 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5191 int utcDaliTextFieldSelectionClearedSignal(void)
5193 ToolkitTestApplication application;
5194 tet_infoline(" utcDaliTextFieldSelectionClearedSignal");
5196 TextField field = TextField::New();
5197 DALI_TEST_CHECK(field);
5199 application.GetScene().Add(field);
5201 // connect to the selection changed signal.
5202 ConnectionTracker* testTracker = new ConnectionTracker();
5203 DevelTextField::SelectionClearedSignal(field).Connect(&TestSelectionClearedCallback);
5204 bool selectionClearedSignal = false;
5205 field.ConnectSignal(testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal));
5207 field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
5208 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5209 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5210 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5211 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5213 // Avoid a crash when core load gl resources.
5214 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5216 // Render and notify
5217 application.SendNotification();
5218 application.Render();
5220 // Tap on the text editor
5221 TestGenerateTap(application, 3.0f, 25.0f);
5223 // Render and notify
5224 application.SendNotification();
5225 application.Render();
5227 // Move to second line of the text & Select some text in the right of the current cursor position
5228 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5229 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5232 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5234 // Render and notify
5235 application.SendNotification();
5236 application.Render();
5238 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5240 // Render and notify
5241 application.SendNotification();
5242 application.Render();
5244 // Tap on the text editor
5245 TestGenerateTap(application, 3.0f, 25.0f);
5247 // Render and notify
5248 application.SendNotification();
5249 application.Render();
5251 gSelectionClearedCallbackCalled = false;
5253 // Move to second line of the text & select.
5254 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5255 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5258 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5260 // Render and notify
5261 application.SendNotification();
5262 application.Render();
5264 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5266 gSelectionClearedCallbackCalled = false;
5268 // Render and notify
5269 application.SendNotification();
5270 application.Render();
5272 // Move to second line of the text & select.
5273 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5274 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5276 // replace D with selected text
5277 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5279 // Render and notify
5280 application.SendNotification();
5281 application.Render();
5283 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5285 gSelectionClearedCallbackCalled = false;
5287 // Render and notify
5288 application.SendNotification();
5289 application.Render();
5291 DevelTextField::SelectText(field, 1, 3);
5293 // Render and notify
5294 application.SendNotification();
5295 application.Render();
5297 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5299 // Render and notify
5300 application.SendNotification();
5301 application.Render();
5303 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5305 gSelectionClearedCallbackCalled = false;
5307 DevelTextField::SelectText(field, 1, 3);
5309 // Render and notify
5310 application.SendNotification();
5311 application.Render();
5314 DevelTextField::SelectNone(field);
5316 // Render and notify
5317 application.SendNotification();
5318 application.Render();
5320 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5325 int utcDaliTextFieldSelectionStartedSignal(void)
5327 ToolkitTestApplication application;
5328 tet_infoline(" utcDaliTextFieldSelectionStartedSignal");
5330 TextField field = TextField::New();
5331 DALI_TEST_CHECK(field);
5333 application.GetScene().Add(field);
5335 // connect to the selection changed signal.
5336 ConnectionTracker* testTracker = new ConnectionTracker();
5337 DevelTextField::SelectionStartedSignal(field).Connect(&TestSelectionStartedCallback);
5338 bool selectionStartedSignal = false;
5339 field.ConnectSignal(testTracker, "selectionStarted", CallbackFunctor(&selectionStartedSignal));
5341 field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
5342 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5343 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5344 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5345 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5347 // Avoid a crash when core load gl resources.
5348 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5350 // Render and notify
5351 application.SendNotification();
5352 application.Render();
5354 // Tap on the text field
5355 TestGenerateTap(application, 3.0f, 25.0f);
5357 // Render and notify
5358 application.SendNotification();
5359 application.Render();
5361 // Move to second line of the text & Select some text in the right of the current cursor position
5362 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5363 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5365 // Render and notify
5366 application.SendNotification();
5367 application.Render();
5369 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5372 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5374 // Render and notify
5375 application.SendNotification();
5376 application.Render();
5378 gSelectionStartedCallbackCalled = false;
5380 DevelTextField::SelectText(field, 1, 3);
5382 // Render and notify
5383 application.SendNotification();
5384 application.Render();
5386 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5391 int utcDaliTextFieldSelectionChangedSignal(void)
5393 ToolkitTestApplication application;
5394 tet_infoline(" utcDaliTextFieldSelectionChangedSignal");
5396 TextField field = TextField::New();
5397 DALI_TEST_CHECK(field);
5399 application.GetScene().Add(field);
5401 // connect to the selection changed signal.
5402 ConnectionTracker* testTracker = new ConnectionTracker();
5403 DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
5404 bool selectionChangedSignal = false;
5405 field.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
5407 field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
5408 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5409 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5410 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5411 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5413 // Avoid a crash when core load gl resources.
5414 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5416 // Render and notify
5417 application.SendNotification();
5418 application.Render();
5420 // Tap on the text field
5421 TestGenerateTap(application, 3.0f, 25.0f);
5423 // Render and notify
5424 application.SendNotification();
5425 application.Render();
5427 // Select some text in the right of the current cursor position
5428 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5429 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5431 // Render and notify
5432 application.SendNotification();
5433 application.Render();
5435 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5436 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5438 gSelectionChangedCallbackCalled = false;
5440 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5442 // Render and notify
5443 application.SendNotification();
5444 application.Render();
5446 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5447 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5448 DALI_TEST_EQUALS(oldSelectionEnd, 1, TEST_LOCATION);
5450 gSelectionChangedCallbackCalled = false;
5452 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5454 // Render and notify
5455 application.SendNotification();
5456 application.Render();
5458 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5459 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5460 DALI_TEST_EQUALS(oldSelectionEnd, 2, TEST_LOCATION);
5462 gSelectionChangedCallbackCalled = false;
5463 field.SetKeyInputFocus();
5465 // Render and notify
5466 application.SendNotification();
5467 application.Render();
5469 DevelTextField::SelectText(field, 0, 5);
5471 application.SendNotification();
5472 application.Render();
5474 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5475 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5477 gSelectionChangedCallbackCalled = false;
5479 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5481 // Render and notify
5482 application.SendNotification();
5483 application.Render();
5485 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5486 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5487 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
5489 gSelectionChangedCallbackCalled = false;
5492 DevelTextField::SelectWholeText(field);
5494 // Render and notify
5495 application.SendNotification();
5496 application.Render();
5498 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5499 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5501 gSelectionChangedCallbackCalled = false;
5504 DevelTextField::SelectNone(field);
5506 // Render and notify
5507 application.SendNotification();
5508 application.Render();
5510 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5511 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5512 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5517 int UtcDaliToolkitTextFieldStrikethroughGeneration(void)
5519 ToolkitTestApplication application;
5520 tet_infoline(" UtcDaliToolkitTextFieldStrikethroughGeneration");
5522 TextField textField = TextField::New();
5523 textField.SetProperty(TextField::Property::TEXT, "Test");
5524 textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5525 textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5526 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5528 application.GetScene().Add(textField);
5529 application.SendNotification();
5530 application.Render();
5532 Property::Map strikethroughMapSet;
5533 Property::Map strikethroughMapGet;
5535 strikethroughMapSet.Insert("enable", true);
5536 strikethroughMapSet.Insert("color", Color::RED);
5537 strikethroughMapSet.Insert("height", 2.0f);
5539 // Check the strikethrough property
5540 textField.SetProperty(DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet);
5541 strikethroughMapGet = textField.GetProperty<Property::Map>(DevelTextField::Property::STRIKETHROUGH);
5542 textField.SetProperty(TextField::Property::TEXT, "Test1");
5543 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
5544 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
5546 // Render and notify
5547 application.SendNotification();
5548 application.Render();
5550 strikethroughMapSet.Clear();
5551 strikethroughMapGet.Clear();
5556 int UtcDaliToolkitTextFieldInputStrikethroughGeneration(void)
5558 ToolkitTestApplication application;
5559 tet_infoline(" UtcDaliToolkitTextFieldInputStrikethroughGeneration");
5561 TextField textField = TextField::New();
5562 textField.SetProperty(TextField::Property::TEXT, "Test");
5563 textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5564 textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5565 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5567 application.GetScene().Add(textField);
5568 application.SendNotification();
5569 application.Render();
5571 std::string strikethroughSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}");
5573 // Check the strikethrough property
5574 textField.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, strikethroughSettings1);
5575 textField.SetProperty(TextField::Property::TEXT, "Test1");
5576 DALI_TEST_EQUALS(textField.GetProperty<std::string>(DevelTextField::Property::INPUT_STRIKETHROUGH), strikethroughSettings1, TEST_LOCATION);
5578 // Render and notify
5579 application.SendNotification();
5580 application.Render();
5585 int UtcDaliToolkitTextFieldUnderlineTypesGeneration1(void)
5587 ToolkitTestApplication application;
5588 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration1");
5589 TextField field = TextField::New();
5590 field.SetProperty(TextField::Property::TEXT, "Test");
5591 field.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5592 field.SetProperty(TextField::Property::POINT_SIZE, 10);
5593 field.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5595 application.GetScene().Add(field);
5596 application.SendNotification();
5597 application.Render();
5599 Property::Map underlineMapSet;
5600 Property::Map underlineMapGet;
5602 underlineMapSet.Insert("enable", true);
5603 underlineMapSet.Insert("color", Color::RED);
5604 underlineMapSet.Insert("height", 1);
5605 underlineMapSet.Insert("type", Text::Underline::SOLID);
5606 underlineMapSet.Insert("dashWidth", 2);
5607 underlineMapSet.Insert("dashGap", 1);
5609 // Check the underline property
5610 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5612 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5613 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5614 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5616 // Render and notify
5617 application.SendNotification();
5618 application.Render();
5620 underlineMapSet.Clear();
5621 underlineMapGet.Clear();
5623 underlineMapSet.Insert("enable", true);
5624 underlineMapSet.Insert("color", Color::BLUE);
5625 underlineMapSet.Insert("height", 1);
5626 underlineMapSet.Insert("type", Text::Underline::DASHED);
5627 underlineMapSet.Insert("dashWidth", 4);
5628 underlineMapSet.Insert("dashGap", 2);
5630 // Check the dashed underline property
5631 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5633 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5634 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5635 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5637 // Render and notify
5638 application.SendNotification();
5639 application.Render();
5641 underlineMapSet.Clear();
5642 underlineMapGet.Clear();
5644 underlineMapSet.Insert("enable", true);
5645 underlineMapSet.Insert("color", Color::BLUE);
5646 underlineMapSet.Insert("height", 1);
5647 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
5648 underlineMapSet.Insert("dashWidth", 4);
5649 underlineMapSet.Insert("dashGap", 2);
5651 // Check the dashed underline property
5652 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5654 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5655 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5656 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5658 // Render and notify
5659 application.SendNotification();
5660 application.Render();
5662 underlineMapSet.Clear();
5663 underlineMapGet.Clear();
5668 int UtcDaliToolkitTextFieldUnderlineTypesGeneration2(void)
5670 ToolkitTestApplication application;
5671 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration2");
5673 TextField field1 = TextField::New();
5674 field1.SetProperty(TextField::Property::TEXT, "Test");
5675 field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5676 field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5677 field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5679 Property::Map underlineMapSet1;
5680 Property::Map underlineMapGet1;
5682 underlineMapSet1.Insert("enable", true);
5683 underlineMapSet1.Insert("color", Color::RED);
5684 underlineMapSet1.Insert("height", 1);
5685 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5686 underlineMapSet1.Insert("dashWidth", 2);
5687 underlineMapSet1.Insert("dashGap", 1);
5689 // Check the underline property
5690 field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5692 underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5693 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5694 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5696 application.GetScene().Add(field1);
5697 application.SendNotification();
5698 application.Render();
5700 TextField field2 = TextField::New();
5701 field2.SetProperty(TextField::Property::TEXT, "Test");
5702 field2.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5703 field2.SetProperty(TextField::Property::POINT_SIZE, 10);
5704 field2.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5706 Property::Map underlineMapSet2;
5707 Property::Map underlineMapGet2;
5709 underlineMapSet2.Insert("enable", true);
5710 underlineMapSet2.Insert("color", Color::BLUE);
5711 underlineMapSet2.Insert("height", 1);
5712 underlineMapSet2.Insert("type", Text::Underline::DASHED);
5713 underlineMapSet2.Insert("dashWidth", 4);
5714 underlineMapSet2.Insert("dashGap", 2);
5716 // Check the dashed underline property
5717 field2.SetProperty(TextField::Property::UNDERLINE, underlineMapSet2);
5719 underlineMapGet2 = field2.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5720 DALI_TEST_EQUALS(underlineMapGet2.Count(), underlineMapSet2.Count(), TEST_LOCATION);
5721 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet2, underlineMapSet2), true, TEST_LOCATION);
5723 application.GetScene().Add(field2);
5724 application.SendNotification();
5725 application.Render();
5727 TextField field3 = TextField::New();
5728 field3.SetProperty(TextField::Property::TEXT, "Test");
5729 field3.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5730 field3.SetProperty(TextField::Property::POINT_SIZE, 10);
5731 field3.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5733 Property::Map underlineMapSet3;
5734 Property::Map underlineMapGet3;
5736 underlineMapSet3.Insert("enable", true);
5737 underlineMapSet3.Insert("color", Color::BLUE);
5738 underlineMapSet3.Insert("height", 1);
5739 underlineMapSet3.Insert("type", Text::Underline::DOUBLE);
5740 underlineMapSet3.Insert("dashWidth", 4);
5741 underlineMapSet3.Insert("dashGap", 2);
5743 // Check the dashed underline property
5744 field3.SetProperty(TextField::Property::UNDERLINE, underlineMapSet3);
5746 underlineMapGet3 = field3.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5747 DALI_TEST_EQUALS(underlineMapGet3.Count(), underlineMapSet3.Count(), TEST_LOCATION);
5748 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
5750 application.GetScene().Add(field3);
5752 application.SendNotification();
5753 application.Render();
5758 int UtcDaliTextFieldCharacterSpacing(void)
5760 ToolkitTestApplication application;
5761 tet_infoline(" UtcDaliTextFieldCharacterSpacing ");
5763 TextField textField = TextField::New();
5765 textField.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
5767 application.GetScene().Add(textField);
5768 application.SendNotification();
5769 application.Render();
5771 textField.SetProperty(TextField::Property::TEXT, "Hi Experiment");
5772 textField.SetProperty(DevelTextField::Property::CHARACTER_SPACING, 10.f);
5773 DALI_TEST_EQUALS(textField.GetProperty<float>(DevelTextField::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
5775 application.SendNotification();
5776 application.Render();
5781 int UtcDaliToolkitTextFieldUnderlineTypesGeneration3(void)
5783 ToolkitTestApplication application;
5784 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration3");
5786 TextField field1 = TextField::New();
5787 field1.SetProperty(TextField::Property::TEXT, "Test1");
5788 field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5789 field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5790 field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5792 Property::Map underlineMapSet1;
5793 Property::Map underlineMapGet1;
5795 underlineMapSet1.Insert("enable", true);
5796 underlineMapSet1.Insert("color", Color::RED);
5797 underlineMapSet1.Insert("height", 1);
5798 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5799 underlineMapSet1.Insert("dashWidth", 2);
5800 underlineMapSet1.Insert("dashGap", 1);
5802 // Check the underline property
5803 field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5804 //field1.SetProperty( TextField::Property::TEXT, "Test2" );
5806 underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5807 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5808 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5810 application.GetScene().Add(field1);
5811 application.SendNotification();
5812 application.Render();
5817 int UtcDaliToolkitTextfieldParagraphTag(void)
5819 ToolkitTestApplication application;
5820 tet_infoline(" UtcDaliToolkitTextfieldParagraphTag");
5821 TextField fieldNewlineSeparator = TextField::New();
5822 TextField fieldParagraphTag = TextField::New();
5823 DALI_TEST_CHECK(fieldNewlineSeparator);
5824 DALI_TEST_CHECK(fieldParagraphTag);
5826 application.GetScene().Add(fieldNewlineSeparator);
5827 application.GetScene().Add(fieldParagraphTag);
5829 //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
5830 fieldNewlineSeparator.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5831 fieldNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5832 fieldNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5833 fieldNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5834 fieldNewlineSeparator.SetProperty(TextField::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
5836 fieldParagraphTag.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5837 fieldParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5838 fieldParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5839 fieldParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5840 fieldParagraphTag.SetProperty(TextField::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
5842 application.SendNotification();
5843 application.Render();
5845 Vector3 textNaturalSizeNewlineSeparator = fieldNewlineSeparator.GetNaturalSize();
5846 Vector3 textNaturalSizeParagraphTag = fieldParagraphTag.GetNaturalSize();
5848 DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
5850 application.SendNotification();
5851 application.Render();
5856 //Handle Emoji clustering for cursor handling
5857 int utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey(void)
5859 ToolkitTestApplication application;
5860 tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey ");
5861 TextField textField = TextField::New();
5862 DALI_TEST_CHECK(textField);
5864 application.GetScene().Add(textField);
5866 // Avoid a crash when core load gl resources.
5867 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5869 textField.SetProperty(TextField::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
5870 textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5872 // Render and notify
5873 application.SendNotification();
5874 application.Render();
5877 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 10);
5878 application.SendNotification();
5879 application.Render();
5881 // Set focus and remove Emoji
5882 textField.SetKeyInputFocus();
5883 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5885 //Check the changed text and cursor position
5886 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5887 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5889 // Render and notify
5890 application.SendNotification();
5891 application.Render();
5896 int utcDaliTextFieldClusteredEmojiDeletionDeleteKey(void)
5898 ToolkitTestApplication application;
5899 tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionDeleteKey ");
5900 TextField textField = TextField::New();
5901 DALI_TEST_CHECK(textField);
5903 application.GetScene().Add(textField);
5905 // Avoid a crash when core load gl resources.
5906 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5908 textField.SetProperty(TextField::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
5909 textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5911 // Render and notify
5912 application.SendNotification();
5913 application.Render();
5916 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5917 application.SendNotification();
5918 application.Render();
5920 // Set focus and remove Emoji
5921 textField.SetKeyInputFocus();
5922 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5924 //Check the changed text and cursor position
5925 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5926 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5928 // Render and notify
5929 application.SendNotification();
5930 application.Render();
5935 int utcDaliTextFieldPanGesturePropagation(void)
5937 ToolkitTestApplication application;
5938 tet_infoline(" utcDaliTextFieldPanGesturePropagation");
5940 Actor actor = Actor::New();
5941 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
5942 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5943 application.GetScene().Add(actor);
5945 TextField field = TextField::New();
5946 DALI_TEST_CHECK(field);
5948 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
5949 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5951 field.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
5952 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5953 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5957 // Render and notify
5958 application.SendNotification();
5959 application.Render();
5962 GestureReceivedFunctor functor(data);
5964 PanGestureDetector detector = PanGestureDetector::New();
5965 detector.Attach(actor);
5966 detector.DetectedSignal().Connect(&application, functor);
5968 // Tap first to get the focus.
5969 TestGenerateTap(application, 3.0f, 25.0f, 100);
5971 // Render and notify
5972 application.SendNotification();
5973 application.Render();
5975 // Pan the text field
5976 uint32_t time = 100;
5977 TestStartPan(application, Vector2(40.0f, 50.0f), Vector2(40.0f, 50.0f), time);
5978 TestMovePan(application, Vector2(10.0f, 50.0f), time);
5979 TestEndPan(application, Vector2(40.0f, 50.0f), time);
5980 application.SendNotification();
5981 application.Render();
5983 // The text scrolls because there is text that is scrolling.
5984 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
5987 // Set the size large enough to prevent scrolling.
5988 field.SetProperty(Actor::Property::SIZE, Vector2(700.f, 100.f));
5990 // Render and notify
5991 application.SendNotification();
5992 application.Render();
5995 TestStartPan(application, Vector2(40.0f, 50.0f), Vector2(40.0f, 50.0f), time);
5996 TestMovePan(application, Vector2(10.0f, 50.0f), time);
5997 TestEndPan(application, Vector2(40.0f, 50.0f), time);
5999 // Because scrolling is not possible, the pan gesture is propagated.
6000 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
6006 int utcDaliTextFieldGetTextBoundingRectangle(void)
6008 ToolkitTestApplication application;
6009 tet_infoline(" utcDaliTextFieldGeometryEllipsisMiddle");
6011 TextField field = TextField::New();
6012 DALI_TEST_CHECK(field);
6014 application.GetScene().Add(field);
6016 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
6017 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6018 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6019 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6020 field.SetProperty(TextField::Property::TEXT, "Hello this is the Text Bounding Rectangle TC");
6022 // Avoid a crash when core load gl resources.
6023 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6025 // Render and notify
6026 application.SendNotification();
6027 application.Render();
6029 unsigned int startIndex = 0;
6030 unsigned int endIndex = 15;
6032 Rect<> textBoundingRectangle = DevelTextField::GetTextBoundingRectangle(field, startIndex, endIndex);
6033 Rect<> expectedTextBoundingRectangle = {0, 0, 100, 25};
6035 TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle);
6040 int utcDaliTextFieldDecoratorColor(void)
6042 ToolkitTestApplication application;
6043 tet_infoline(" utcDaliTextFieldDecoratorColor");
6044 TextField textField = TextField::New();
6045 DALI_TEST_CHECK(textField);
6046 LoadMarkerImages(application, textField);
6047 application.GetScene().Add(textField);
6049 // Render and notify
6050 application.SendNotification();
6051 application.Render();
6053 textField.SetProperty(TextField::Property::TEXT, "العالم Hello");
6054 textField.SetProperty(TextField::Property::POINT_SIZE, 10.f);
6055 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
6056 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6057 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6059 // Avoid a crash when core load gl resources.
6060 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6062 application.SendNotification();
6063 application.Render();
6065 textField.SetKeyInputFocus();
6067 application.SendNotification();
6068 application.Render();
6070 // Create a tap event to touch the text field.
6071 TestGenerateTap(application, 1.0f, 25.0f, 100);
6073 // Render and notify
6074 application.SendNotification();
6075 application.Render();
6077 // Double tap to select a word.
6078 TestGenerateTap(application, 1.0f, 25.0f, 200);
6080 application.SendNotification();
6081 application.Render();
6083 // At this point, the text decorator's primary/secondary cursor, grab/left/right handle and highlight actor were all created.
6084 // Check some properties for coverage.
6085 textField.SetProperty(TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED);
6086 DALI_TEST_EQUALS(textField.GetProperty<Vector4>(TextField::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION);
6088 textField.SetProperty(TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE);
6089 DALI_TEST_EQUALS(textField.GetProperty<Vector4>(TextField::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION);
6091 textField.SetProperty(DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN);
6092 DALI_TEST_EQUALS(textField.GetProperty<Vector4>(DevelTextField::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
6094 textField.SetProperty(TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN);
6095 DALI_TEST_EQUALS(textField.GetProperty<Vector4>(TextField::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION);
6097 textField.SetProperty(TextField::Property::CURSOR_WIDTH, 3);
6098 DALI_TEST_EQUALS(textField.GetProperty<int>(TextField::Property::CURSOR_WIDTH), 3, TEST_LOCATION);
6100 application.SendNotification();
6101 application.Render();
6106 int utcDaliTextFieldRemoveFrontInset(void)
6108 ToolkitTestApplication application;
6109 tet_infoline(" utcDaliTextFieldRemoveFrontInset");
6111 TextField field = TextField::New();
6112 DALI_TEST_CHECK(field);
6114 application.GetScene().Add(field);
6115 application.SendNotification();
6116 application.Render();
6118 DevelTextField::SetRemoveFrontInset(field, false);
6119 DALI_TEST_CHECK(!DevelTextField::IsRemoveFrontInset(field));
6124 int utcDaliTextFieldRemoveBackInset(void)
6126 ToolkitTestApplication application;
6127 tet_infoline(" utcDaliTextFieldRemoveBackInset");
6129 TextField field = TextField::New();
6130 DALI_TEST_CHECK(field);
6132 application.GetScene().Add(field);
6133 application.SendNotification();
6134 application.Render();
6136 DevelTextField::SetRemoveBackInset(field, false);
6137 DALI_TEST_CHECK(!DevelTextField::IsRemoveBackInset(field));