2 * Copyright (c) 2024 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali-toolkit-test-suite-utils.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
25 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h>
26 #include <dali-toolkit/devel-api/text/rendering-backend.h>
27 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
28 #include <dali/devel-api/actors/actor-devel.h>
29 #include <dali/devel-api/adaptor-framework/key-devel.h>
30 #include <dali/devel-api/events/pan-gesture-devel.h>
31 #include <dali/devel-api/text-abstraction/font-client.h>
32 #include <dali/integration-api/events/key-event-integ.h>
33 #include <dali/integration-api/events/touch-event-integ.h>
34 #include <dali/public-api/rendering/renderer.h>
35 #include "test-text-geometry-utils.h"
36 #include "toolkit-clipboard.h"
39 using namespace Toolkit;
41 void dali_textfield_startup(void)
43 test_return_value = TET_UNDEF;
46 void dali_textfield_cleanup(void)
48 test_return_value = TET_PASS;
53 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
54 const char* const PROPERTY_NAME_TEXT = "text";
55 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
56 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
57 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
58 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
59 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
60 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
61 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
62 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
63 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
64 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
65 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
66 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
67 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
68 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
69 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
70 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
71 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
72 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
73 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
74 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
75 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
76 const char* const PROPERTY_NAME_SELECTION_POPUP_STYLE = "selectionPopupStyle";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
80 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
81 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
82 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
83 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
84 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
85 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
86 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
87 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
88 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
89 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
90 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
92 const char* const PROPERTY_NAME_UNDERLINE = "underline";
93 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
94 const char* const PROPERTY_NAME_SHADOW = "shadow";
95 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
96 const char* const PROPERTY_NAME_EMBOSS = "emboss";
97 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
98 const char* const PROPERTY_NAME_OUTLINE = "outline";
99 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
100 const char* const PROPERTY_NAME_STRIKETHROUGH = "strikethrough";
101 const char* const PROPERTY_NAME_INPUT_STRIKETHROUGH = "inputStrikethrough";
103 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
104 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
105 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
106 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
107 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
108 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
109 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
110 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
111 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
112 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
113 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
114 const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE = "enableFontSizeScale";
115 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
116 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
118 const char* const PROPERTY_NAME_REMOVE_FRONT_INSET = "removeFrontInset";
119 const char* const PROPERTY_NAME_REMOVE_BACK_INSET = "removeBackInset";
121 const Vector4 PLACEHOLDER_TEXT_COLOR(0.8f, 0.8f, 0.8f, 0.8f);
122 const Dali::Vector4 LIGHT_BLUE(0.75f, 0.96f, 1.f, 1.f); // The text highlight color.
124 const float RENDER_FRAME_INTERVAL = 16.66f;
126 const unsigned int DEFAULT_FONT_SIZE = 1152u;
127 const std::string DEFAULT_FONT_DIR("/resources/fonts");
129 const int KEY_RETURN_CODE = 36;
130 const int KEY_A_CODE = 38;
131 const int KEY_D_CODE = 40;
132 const int KEY_SHIFT_MODIFIER = 257;
134 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
136 static bool gSelectionChangedCallbackCalled;
137 static uint32_t oldSelectionStart;
138 static uint32_t oldSelectionEnd;
139 static bool gSelectionClearedCallbackCalled;
140 static bool gSelectionStartedCallbackCalled;
141 static bool gAnchorClickedCallBackCalled;
142 static bool gAnchorClickedCallBackNotCalled;
143 static bool gTextChangedCallBackCalled;
144 static bool gMaxCharactersCallBackCalled;
145 static bool gInputFilteredAcceptedCallbackCalled;
146 static bool gInputFilteredRejectedCallbackCalled;
147 static bool gInputStyleChangedCallbackCalled;
148 static bool gCursorPositionChangedCallbackCalled;
149 static uint32_t oldCursorPos;
150 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
152 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
154 Integration::Bitmap* bitmap = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD);
155 Integration::ResourcePointer resource(bitmap);
156 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
159 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
163 LoadBitmapResource(app.GetPlatform(), width, height);
165 Property::Map propertyMap;
166 propertyMap["filename"] = "image.png";
167 propertyMap["width"] = width;
168 propertyMap["height"] = height;
169 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap);
170 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap);
171 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap);
172 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap);
173 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap);
174 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap);
175 textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, "image.png");
176 textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image.png");
180 * Simulate time passed by.
182 * @note this will always process at least 1 frame (1/60 sec)
184 * @param application Test application instance
185 * @param duration Time to pass in milliseconds.
186 * @return The actual time passed in milliseconds
188 static int Wait(ToolkitTestApplication& application, int duration = 0)
192 for(int i = 0; i <= (duration / RENDER_FRAME_INTERVAL); i++)
194 application.SendNotification();
195 application.Render(RENDER_FRAME_INTERVAL);
196 time += RENDER_FRAME_INTERVAL;
202 Dali::Integration::Point GetPointDownInside(Vector2& pos)
204 Dali::Integration::Point point;
205 point.SetState(PointState::DOWN);
206 point.SetScreenPosition(pos);
210 Dali::Integration::Point GetPointUpInside(Vector2& pos)
212 Dali::Integration::Point point;
213 point.SetState(PointState::UP);
214 point.SetScreenPosition(pos);
218 struct CallbackFunctor
220 CallbackFunctor(bool* callbackFlag)
221 : mCallbackFlag(callbackFlag)
227 *mCallbackFlag = true;
232 static void TestSelectionClearedCallback(TextField control)
234 tet_infoline(" TestSelectionClearedCallback");
236 gSelectionClearedCallbackCalled = true;
239 static void TestSelectionStartedCallback(TextField control)
241 tet_infoline(" TestSelectionStartedCallback");
243 gSelectionStartedCallbackCalled = true;
246 static void TestSelectionChangedCallback(TextField control, uint32_t oldStart, uint32_t oldEnd)
248 tet_infoline(" TestSelectionChangedCallback");
250 gSelectionChangedCallbackCalled = true;
251 oldSelectionStart = oldStart;
252 oldSelectionEnd = oldEnd;
255 static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength)
257 tet_infoline(" TestAnchorClickedCallback");
259 gAnchorClickedCallBackNotCalled = false;
261 if(!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
263 gAnchorClickedCallBackCalled = true;
267 static void TestCursorPositionChangedCallback(TextField control, unsigned int oldPos)
269 tet_infoline(" TestCursorPositionChangedCallback");
271 gCursorPositionChangedCallbackCalled = true;
272 oldCursorPos = oldPos;
275 static void TestTextChangedCallback(TextField control)
277 tet_infoline(" TestTextChangedCallback");
279 gTextChangedCallBackCalled = true;
282 static void TestMaxLengthReachedCallback(TextField control)
284 tet_infoline(" TestMaxLengthReachedCallback");
286 gMaxCharactersCallBackCalled = true;
289 static void TestInputFilteredCallback(TextField control, Toolkit::InputFilter::Property::Type type)
291 tet_infoline(" TestInputFilteredCallback");
293 if(type == Toolkit::InputFilter::Property::ACCEPTED)
295 gInputFilteredAcceptedCallbackCalled = true;
297 else if(type == Toolkit::InputFilter::Property::REJECTED)
299 gInputFilteredRejectedCallbackCalled = true;
303 static void TestInputStyleChangedCallback(TextField control, TextField::InputStyle::Mask mask)
305 tet_infoline(" TestInputStyleChangedCallback");
307 gInputStyleChangedCallbackCalled = true;
308 gInputStyleMask = mask;
311 // Generate a KeyEvent to send to Core.
312 Integration::KeyEvent GenerateKey(const std::string& keyName,
313 const std::string& logicalKey,
314 const std::string& keyString,
317 unsigned long timeStamp,
318 const Integration::KeyEvent::State& keyState,
319 const std::string& compose = "",
320 const std::string& deviceName = DEFAULT_DEVICE_NAME,
321 const Device::Class::Type& deviceClass = Device::Class::NONE,
322 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE)
324 return Integration::KeyEvent(keyName,
337 bool DaliTestCheckMaps(const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet)
339 if(fontStyleMapGet.Count() == fontStyleMapSet.Count())
341 for(unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index)
343 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue(index);
345 Property::Value* valueSet = NULL;
346 if(valueGet.first.type == Property::Key::INDEX)
348 valueSet = fontStyleMapSet.Find(valueGet.first.indexKey);
352 // Get Key is a string so searching Set Map for a string key
353 valueSet = fontStyleMapSet.Find(valueGet.first.stringKey);
358 if(valueSet->GetType() == Dali::Property::STRING && (valueGet.second.Get<std::string>() != valueSet->Get<std::string>()))
360 tet_printf("Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str());
363 else if(valueSet->GetType() == Dali::Property::BOOLEAN && (valueGet.second.Get<bool>() != valueSet->Get<bool>()))
365 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>());
368 else if(valueSet->GetType() == Dali::Property::INTEGER && (valueGet.second.Get<int>() != valueSet->Get<int>()))
370 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>());
373 else if(valueSet->GetType() == Dali::Property::FLOAT && (valueGet.second.Get<float>() != valueSet->Get<float>()))
375 tet_printf("Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>());
378 else if(valueSet->GetType() == Dali::Property::VECTOR2 && (valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>()))
380 Vector2 vector2Get = valueGet.second.Get<Vector2>();
381 Vector2 vector2Set = valueSet->Get<Vector2>();
382 tet_printf("Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y);
385 else if(valueSet->GetType() == Dali::Property::VECTOR4 && (valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>()))
387 Vector4 vector4Get = valueGet.second.Get<Vector4>();
388 Vector4 vector4Set = valueSet->Get<Vector4>();
389 tet_printf("Value got : [%f, %f, %f, %f], expected : [%f, %f, %f, %f]", vector4Get.r, vector4Get.g, vector4Get.b, vector4Get.a, vector4Set.r, vector4Set.g, vector4Set.b, vector4Set.a);
395 if(valueGet.first.type == Property::Key::INDEX)
397 tet_printf(" The key %d doesn't exist.", valueGet.first.indexKey);
401 tet_printf(" The key %s doesn't exist.", valueGet.first.stringKey.c_str());
411 // Stores data that is populated in the callback and will be read by the test cases
415 : functorCalled(false),
416 voidFunctorCalled(false),
423 functorCalled = false;
424 voidFunctorCalled = false;
426 receivedGesture.Reset();
432 bool voidFunctorCalled;
433 PanGesture receivedGesture;
437 // Functor that sets the data when called
438 struct GestureReceivedFunctor
440 GestureReceivedFunctor(SignalData& data)
445 void operator()(Actor actor, const PanGesture& pan)
447 signalData.functorCalled = true;
448 signalData.receivedGesture = pan;
449 signalData.pannedActor = actor;
454 signalData.voidFunctorCalled = true;
457 SignalData& signalData;
462 int UtcDaliToolkitTextFieldConstructorP(void)
464 ToolkitTestApplication application;
465 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
467 DALI_TEST_CHECK(!textField);
471 int UtcDaliToolkitTextFieldNewP(void)
473 ToolkitTestApplication application;
474 tet_infoline(" UtcDaliToolkitTextFieldNewP");
475 TextField textField = TextField::New();
476 DALI_TEST_CHECK(textField);
480 int UtcDaliToolkitTextFieldDownCastP(void)
482 ToolkitTestApplication application;
483 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
484 TextField textField1 = TextField::New();
485 BaseHandle object(textField1);
487 TextField textField2 = TextField::DownCast(object);
488 DALI_TEST_CHECK(textField2);
490 TextField textField3 = DownCast<TextField>(object);
491 DALI_TEST_CHECK(textField3);
495 int UtcDaliToolkitTextFieldDownCastN(void)
497 ToolkitTestApplication application;
498 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
499 BaseHandle uninitializedObject;
500 TextField textField1 = TextField::DownCast(uninitializedObject);
501 DALI_TEST_CHECK(!textField1);
503 TextField textField2 = DownCast<TextField>(uninitializedObject);
504 DALI_TEST_CHECK(!textField2);
508 int UtcDaliToolkitTextFieldCopyConstructorP(void)
510 ToolkitTestApplication application;
511 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
512 TextField textField = TextField::New();
513 textField.SetProperty(TextField::Property::TEXT, "Test");
515 TextField copy(textField);
516 DALI_TEST_CHECK(copy);
517 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextField::Property::TEXT) == textField.GetProperty<std::string>(TextField::Property::TEXT));
521 int UtcDaliTextFieldMoveConstructor(void)
523 ToolkitTestApplication application;
525 TextField textField = TextField::New();
526 textField.SetProperty(TextEditor::Property::TEXT, "Test");
527 DALI_TEST_CHECK(textField.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
529 TextField moved = std::move(textField);
530 DALI_TEST_CHECK(moved);
531 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
532 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
533 DALI_TEST_CHECK(!textField);
538 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
540 ToolkitTestApplication application;
541 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
542 TextField textField = TextField::New();
543 textField.SetProperty(TextField::Property::TEXT, "Test");
545 TextField copy = textField;
546 DALI_TEST_CHECK(copy);
547 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextField::Property::TEXT) == textField.GetProperty<std::string>(TextField::Property::TEXT));
551 int UtcDaliTextFieldMoveAssignment(void)
553 ToolkitTestApplication application;
555 TextField textField = TextField::New();
556 textField.SetProperty(TextEditor::Property::TEXT, "Test");
557 DALI_TEST_CHECK(textField.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
560 moved = std::move(textField);
561 DALI_TEST_CHECK(moved);
562 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
563 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
564 DALI_TEST_CHECK(!textField);
569 int UtcDaliTextFieldNewP(void)
571 ToolkitTestApplication application;
572 tet_infoline(" UtcDaliToolkitTextFieldNewP");
573 TextField textField = TextField::New();
574 DALI_TEST_CHECK(textField);
578 // Positive test case for a method
579 int UtcDaliTextFieldGetPropertyP(void)
581 ToolkitTestApplication application;
582 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
583 TextField field = TextField::New();
584 DALI_TEST_CHECK(field);
586 // Check Property Indices are correct
587 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_RENDERING_BACKEND) == DevelTextField::Property::RENDERING_BACKEND);
588 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_TEXT) == TextField::Property::TEXT);
589 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT) == TextField::Property::PLACEHOLDER_TEXT);
590 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED);
591 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_FAMILY) == TextField::Property::FONT_FAMILY);
592 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_STYLE) == TextField::Property::FONT_STYLE);
593 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_POINT_SIZE) == TextField::Property::POINT_SIZE);
594 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_MAX_LENGTH) == TextField::Property::MAX_LENGTH);
595 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_EXCEED_POLICY) == TextField::Property::EXCEED_POLICY);
596 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_HORIZONTAL_ALIGNMENT) == TextField::Property::HORIZONTAL_ALIGNMENT);
597 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_VERTICAL_ALIGNMENT) == TextField::Property::VERTICAL_ALIGNMENT);
598 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_TEXT_COLOR) == TextField::Property::TEXT_COLOR);
599 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR) == TextField::Property::PLACEHOLDER_TEXT_COLOR);
600 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PRIMARY_CURSOR_COLOR) == TextField::Property::PRIMARY_CURSOR_COLOR);
601 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SECONDARY_CURSOR_COLOR) == TextField::Property::SECONDARY_CURSOR_COLOR);
602 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_CURSOR_BLINK) == TextField::Property::ENABLE_CURSOR_BLINK);
603 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_INTERVAL) == TextField::Property::CURSOR_BLINK_INTERVAL);
604 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_DURATION) == TextField::Property::CURSOR_BLINK_DURATION);
605 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_WIDTH) == TextField::Property::CURSOR_WIDTH);
606 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_IMAGE) == TextField::Property::GRAB_HANDLE_IMAGE);
607 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE);
608 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SCROLL_THRESHOLD) == TextField::Property::SCROLL_THRESHOLD);
609 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SCROLL_SPEED) == TextField::Property::SCROLL_SPEED);
610 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT);
611 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT);
612 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT);
613 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT);
614 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT);
615 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT);
616 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR) == TextField::Property::SELECTION_HIGHLIGHT_COLOR);
617 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_DECORATION_BOUNDING_BOX) == TextField::Property::DECORATION_BOUNDING_BOX);
618 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_METHOD_SETTINGS) == TextField::Property::INPUT_METHOD_SETTINGS);
619 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_COLOR) == TextField::Property::INPUT_COLOR);
620 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_MARKUP) == TextField::Property::ENABLE_MARKUP);
621 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_FAMILY) == TextField::Property::INPUT_FONT_FAMILY);
622 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_STYLE) == TextField::Property::INPUT_FONT_STYLE);
623 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_POINT_SIZE) == TextField::Property::INPUT_POINT_SIZE);
624 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_UNDERLINE) == TextField::Property::UNDERLINE);
625 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_UNDERLINE) == TextField::Property::INPUT_UNDERLINE);
626 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SHADOW) == TextField::Property::SHADOW);
627 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_SHADOW) == TextField::Property::INPUT_SHADOW);
628 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_EMBOSS) == TextField::Property::EMBOSS);
629 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_EMBOSS) == TextField::Property::INPUT_EMBOSS);
630 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_OUTLINE) == TextField::Property::OUTLINE);
631 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_OUTLINE) == TextField::Property::INPUT_OUTLINE);
632 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_HIDDEN_INPUT_SETTINGS) == TextField::Property::HIDDEN_INPUT_SETTINGS);
633 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PIXEL_SIZE) == TextField::Property::PIXEL_SIZE);
634 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_SELECTION) == TextField::Property::ENABLE_SELECTION);
635 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER) == TextField::Property::PLACEHOLDER);
636 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ELLIPSIS) == TextField::Property::ELLIPSIS);
637 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_SIZE_SCALE) == DevelTextField::Property::FONT_SIZE_SCALE);
638 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE) == DevelTextField::Property::ENABLE_FONT_SIZE_SCALE);
639 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_SHIFT_SELECTION) == DevelTextField::Property::ENABLE_SHIFT_SELECTION);
640 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE) == DevelTextField::Property::ENABLE_GRAB_HANDLE);
641 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION);
642 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP);
643 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_BACKGROUND) == DevelTextField::Property::BACKGROUND);
644 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_COLOR) == DevelTextField::Property::GRAB_HANDLE_COLOR);
645 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FILTER) == DevelTextField::Property::INPUT_FILTER);
646 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextField::Property::STRIKETHROUGH);
647 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextField::Property::INPUT_STRIKETHROUGH);
648 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_POPUP_STYLE) == DevelTextField::Property::SELECTION_POPUP_STYLE);
649 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_REMOVE_FRONT_INSET) == DevelTextField::Property::REMOVE_FRONT_INSET);
650 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_REMOVE_BACK_INSET) == DevelTextField::Property::REMOVE_BACK_INSET);
655 bool SetPropertyMapRetrieved(TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue)
658 Property::Map imageMap;
659 imageMap[mapKey] = mapValue;
661 field.SetProperty(property, imageMap);
662 Property::Value propValue = field.GetProperty(property);
663 Property::Map* resultMap = propValue.GetMap();
665 if(resultMap->Find(mapKey)->Get<std::string>() == mapValue)
673 // Positive test case for a method
674 int UtcDaliTextFieldSetPropertyP(void)
676 ToolkitTestApplication application;
677 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
678 TextField field = TextField::New();
679 DALI_TEST_CHECK(field);
680 application.GetScene().Add(field);
682 // Note - we can't check the defaults since the stylesheets are platform-specific
684 // Check the render backend property.
685 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
686 DALI_TEST_EQUALS((DevelText::RenderingType)field.GetProperty<int>(DevelTextField::Property::RENDERING_BACKEND), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION);
688 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED);
689 DALI_TEST_EQUALS((DevelText::RenderingType)field.GetProperty<int>(DevelTextField::Property::RENDERING_BACKEND), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION);
691 // Check text property.
692 field.SetProperty(TextField::Property::TEXT, "Setting Text");
693 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("Setting Text"), TEST_LOCATION);
695 // Check placeholder text properties.
696 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
697 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::PLACEHOLDER_TEXT), std::string("Setting Placeholder Text"), TEST_LOCATION);
699 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused");
700 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::PLACEHOLDER_TEXT_FOCUSED), std::string("Setting Placeholder Text Focused"), TEST_LOCATION);
702 // Check font properties.
703 field.SetProperty(TextField::Property::FONT_FAMILY, "Setting font family");
704 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::FONT_FAMILY), std::string("Setting font family"), TEST_LOCATION);
706 Property::Map fontStyleMapSet;
707 Property::Map fontStyleMapGet;
708 Property::Value* slantValue = NULL;
710 fontStyleMapSet.Insert("weight", "bold");
711 fontStyleMapSet.Insert("width", "condensed");
712 fontStyleMapSet.Insert("slant", "italic");
713 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
715 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
716 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
717 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
719 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
720 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::POINT_SIZE), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
722 field.SetProperty(DevelTextField::Property::FONT_SIZE_SCALE, 2.5f);
723 DALI_TEST_EQUALS(field.GetProperty<float>(DevelTextField::Property::FONT_SIZE_SCALE), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
724 field.SetProperty(DevelTextField::Property::FONT_SIZE_SCALE, 1.0f);
726 field.SetProperty(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, false);
727 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE), false, TEST_LOCATION);
728 field.SetProperty(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, true);
731 fontStyleMapSet.Clear();
732 fontStyleMapSet.Insert("weight", "normal");
733 fontStyleMapSet.Insert("slant", "oblique");
734 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
736 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
737 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
738 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
740 fontStyleMapSet.Clear();
741 fontStyleMapSet.Insert("slant", "roman");
742 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
743 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
745 // Replace 'roman' for 'normal'.
746 slantValue = fontStyleMapGet.Find("slant");
747 if(NULL != slantValue)
749 if("normal" == slantValue->Get<std::string>())
751 fontStyleMapGet["slant"] = "roman";
754 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
755 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
757 fontStyleMapSet.Clear();
759 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
760 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
761 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
762 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
764 // Check that the MAX_LENGTH property can be correctly set
765 const int maxNumberOfCharacters = 20;
766 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
767 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::MAX_LENGTH), maxNumberOfCharacters, TEST_LOCATION);
769 // Check exceed policy
770 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP);
771 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::EXCEED_POLICY), static_cast<int>(Dali::Toolkit::TextField::EXCEED_POLICY_CLIP), TEST_LOCATION);
772 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
773 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::EXCEED_POLICY), static_cast<int>(Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL), TEST_LOCATION);
775 // Check that the Alignment properties can be correctly set
776 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
777 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::HORIZONTAL_ALIGNMENT), "END", TEST_LOCATION);
778 field.SetProperty(TextField::Property::VERTICAL_ALIGNMENT, "CENTER");
779 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::VERTICAL_ALIGNMENT), "CENTER", TEST_LOCATION);
781 // Check text's color property
782 field.SetProperty(TextField::Property::TEXT_COLOR, Color::WHITE);
783 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::WHITE, TEST_LOCATION);
785 // Check placeholder text's color property.
786 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED);
787 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::PLACEHOLDER_TEXT_COLOR), Color::RED, TEST_LOCATION);
789 // Check cursor properties
790 field.SetProperty(TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED);
791 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION);
792 field.SetProperty(TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE);
793 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION);
795 field.SetProperty(TextField::Property::ENABLE_CURSOR_BLINK, false);
796 DALI_TEST_EQUALS(field.GetProperty<bool>(TextField::Property::ENABLE_CURSOR_BLINK), false, TEST_LOCATION);
797 field.SetProperty(TextField::Property::CURSOR_BLINK_INTERVAL, 1.f);
798 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::CURSOR_BLINK_INTERVAL), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
799 field.SetProperty(TextField::Property::CURSOR_BLINK_DURATION, 10.f);
800 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::CURSOR_BLINK_DURATION), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
801 field.SetProperty(TextField::Property::CURSOR_WIDTH, 1);
802 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::CURSOR_WIDTH), 1, TEST_LOCATION);
804 // Check scroll properties.
805 field.SetProperty(TextField::Property::SCROLL_THRESHOLD, 1.f);
806 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::SCROLL_THRESHOLD), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
807 field.SetProperty(TextField::Property::SCROLL_SPEED, 100.f);
808 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::SCROLL_SPEED), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
810 // Check handle images
811 field.SetProperty(TextField::Property::GRAB_HANDLE_IMAGE, "image1");
812 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::GRAB_HANDLE_IMAGE), "image1", TEST_LOCATION);
813 field.SetProperty(TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2");
814 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::GRAB_HANDLE_PRESSED_IMAGE), "image2", TEST_LOCATION);
815 field.SetProperty(TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3");
817 // Check handle images
818 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage"));
819 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage"));
820 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed"));
821 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed"));
822 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage"));
823 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage"));
825 // Check the selection popup style
826 const Vector2 popupMaxSize(200.0f, 300.0f);
827 const Vector2 optionDividerSize(30.0f, 5.0f);
828 const Vector4 optionDividerPadding(20.0f, 20.0f, 10.0f, 10.0f);
829 const Vector4 labelPadding(5.0f, 5.0f, 50.0f, 25.0f);
831 Property::Map selectionPopupStyle;
832 selectionPopupStyle.Insert(TextSelectionPopup::Property::POPUP_MAX_SIZE, popupMaxSize);
833 selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE, optionDividerSize);
834 selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING, optionDividerPadding);
835 selectionPopupStyle.Insert(TextSelectionPopup::Property::LABEL_PADDING, labelPadding);
837 field.SetProperty(DevelTextField::Property::SELECTION_POPUP_STYLE, selectionPopupStyle);
839 Property::Map selectionPopupStyleGet;
840 selectionPopupStyleGet = field.GetProperty<Property::Map>(DevelTextField::Property::SELECTION_POPUP_STYLE);
842 Property::Value* popupValue;
843 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::POPUP_MAX_SIZE);
844 DALI_TEST_CHECK(NULL != popupValue);
847 Vector2 popupMaxSizeGet;
848 popupValue->Get(popupMaxSizeGet);
849 DALI_TEST_EQUALS(popupMaxSizeGet, popupMaxSize, TEST_LOCATION);
852 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE);
853 DALI_TEST_CHECK(NULL != popupValue);
856 Vector2 optionDividerSizeGet;
857 popupValue->Get(optionDividerSizeGet);
858 DALI_TEST_EQUALS(optionDividerSizeGet, optionDividerSize, TEST_LOCATION);
861 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING);
862 DALI_TEST_CHECK(NULL != popupValue);
865 Vector4 optionDividerPaddingGet;
866 popupValue->Get(optionDividerPaddingGet);
867 DALI_TEST_EQUALS(optionDividerPaddingGet, optionDividerPadding, TEST_LOCATION);
870 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::LABEL_PADDING);
871 DALI_TEST_CHECK(NULL != popupValue);
874 Vector4 labelPaddingGet;
875 popupValue->Get(labelPaddingGet);
876 DALI_TEST_EQUALS(labelPaddingGet, labelPadding, TEST_LOCATION);
879 // Reset selection popup style
880 selectionPopupStyle.Clear();
881 field.SetProperty(DevelTextField::Property::SELECTION_POPUP_STYLE, selectionPopupStyle);
883 // Check the highlight color
884 field.SetProperty(TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN);
885 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION);
887 // Decoration bounding box
888 field.SetProperty(TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>(0, 0, 1, 1));
889 DALI_TEST_EQUALS(field.GetProperty<Rect<int> >(TextField::Property::DECORATION_BOUNDING_BOX), Rect<int>(0, 0, 1, 1), TEST_LOCATION);
891 // Check the input method setting
892 Property::Map propertyMap;
893 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
894 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
895 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
896 int inputVariation = 1;
897 propertyMap["PANEL_LAYOUT"] = panelLayout;
898 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
899 propertyMap["BUTTON_ACTION"] = buttonAction;
900 propertyMap["VARIATION"] = inputVariation;
901 field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
903 Property::Value value = field.GetProperty(TextField::Property::INPUT_METHOD_SETTINGS);
905 DALI_TEST_CHECK(value.Get(map));
908 DALI_TEST_CHECK(map["PANEL_LAYOUT"].Get(layout));
909 DALI_TEST_EQUALS(static_cast<int>(panelLayout), layout, TEST_LOCATION);
912 DALI_TEST_CHECK(map["AUTO_CAPITALIZE"].Get(capital));
913 DALI_TEST_EQUALS(static_cast<int>(autoCapital), capital, TEST_LOCATION);
916 DALI_TEST_CHECK(map["BUTTON_ACTION"].Get(action));
917 DALI_TEST_EQUALS(static_cast<int>(buttonAction), action, TEST_LOCATION);
920 DALI_TEST_CHECK(map["VARIATION"].Get(variation));
921 DALI_TEST_EQUALS(inputVariation, variation, TEST_LOCATION);
923 // Check input color property.
924 field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
925 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::INPUT_COLOR), Color::YELLOW, TEST_LOCATION);
927 // Check the enable markup property.
928 DALI_TEST_CHECK(!field.GetProperty<bool>(TextField::Property::ENABLE_MARKUP));
929 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
930 DALI_TEST_CHECK(field.GetProperty<bool>(TextField::Property::ENABLE_MARKUP));
932 // Check input font properties.
933 field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
934 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
936 fontStyleMapSet.Clear();
937 fontStyleMapSet.Insert("weight", "bold");
938 fontStyleMapSet.Insert("width", "condensed");
939 fontStyleMapSet.Insert("slant", "italic");
941 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
942 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
943 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
944 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
946 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
947 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
949 // Reset input font style.
950 fontStyleMapSet.Clear();
951 fontStyleMapSet.Insert("weight", "normal");
952 fontStyleMapSet.Insert("slant", "oblique");
954 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
955 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
956 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
957 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
959 fontStyleMapSet.Clear();
960 fontStyleMapSet.Insert("slant", "roman");
962 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
963 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
965 // Replace 'roman' for 'normal'.
966 slantValue = fontStyleMapGet.Find("slant");
967 if(NULL != slantValue)
969 if("normal" == slantValue->Get<std::string>())
971 fontStyleMapGet["slant"] = "roman";
974 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
975 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
977 fontStyleMapSet.Clear();
979 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
980 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
981 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
982 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
984 Property::Map strikethroughMapSet;
985 Property::Map strikethroughMapGet;
987 strikethroughMapSet.Insert("enable", true);
988 strikethroughMapSet.Insert("color", Color::RED);
989 strikethroughMapSet.Insert("height", 2.0f);
991 // Check the strikethrough property
992 field.SetProperty(DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet);
994 strikethroughMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::STRIKETHROUGH);
995 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
996 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
998 // Check the input strikethrough property
999 field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties");
1000 DALI_TEST_EQUALS(field.GetProperty<std::string>(DevelTextField::Property::INPUT_STRIKETHROUGH), std::string("Strikethrough input properties"), TEST_LOCATION);
1002 Property::Map underlineMapSet;
1003 Property::Map underlineMapGet;
1005 underlineMapSet.Insert("enable", true);
1006 underlineMapSet.Insert("color", Color::RED);
1007 underlineMapSet.Insert("height", 1);
1008 underlineMapSet.Insert("type", Text::Underline::SOLID);
1009 underlineMapSet.Insert("dashWidth", 2);
1010 underlineMapSet.Insert("dashGap", 1);
1012 // Check the underline property
1013 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
1015 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
1016 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
1017 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
1019 // Render and notify
1020 application.SendNotification();
1021 application.Render();
1023 underlineMapSet.Clear();
1024 underlineMapGet.Clear();
1026 underlineMapSet.Insert("enable", true);
1027 underlineMapSet.Insert("color", Color::BLUE);
1028 underlineMapSet.Insert("height", 1);
1029 underlineMapSet.Insert("type", Text::Underline::DASHED);
1030 underlineMapSet.Insert("dashWidth", 4);
1031 underlineMapSet.Insert("dashGap", 2);
1033 // Check the dashed underline property
1034 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
1036 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
1037 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
1038 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
1040 // Render and notify
1041 application.SendNotification();
1042 application.Render();
1044 underlineMapSet.Clear();
1045 underlineMapGet.Clear();
1047 underlineMapSet.Insert("enable", true);
1048 underlineMapSet.Insert("color", Color::BLUE);
1049 underlineMapSet.Insert("height", 4);
1050 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
1051 underlineMapSet.Insert("dashWidth", 4);
1052 underlineMapSet.Insert("dashGap", 2);
1054 // Check the dashed underline property
1055 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
1057 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
1058 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
1059 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
1061 // Render and notify
1062 application.SendNotification();
1063 application.Render();
1065 underlineMapSet.Clear();
1066 underlineMapGet.Clear();
1068 // Check the input underline property
1069 field.SetProperty(TextField::Property::INPUT_UNDERLINE, "Underline input properties");
1070 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_UNDERLINE), std::string("Underline input properties"), TEST_LOCATION);
1072 // Check the shadow property
1073 Property::Map shadowMapSet;
1074 Property::Map shadowMapGet;
1076 shadowMapSet.Insert("color", Color::GREEN);
1077 shadowMapSet.Insert("offset", Vector2(2.0f, 2.0f));
1078 shadowMapSet.Insert("blurRadius", 3.0f);
1080 field.SetProperty(TextField::Property::SHADOW, shadowMapSet);
1082 shadowMapGet = field.GetProperty<Property::Map>(TextField::Property::SHADOW);
1083 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
1084 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet), true, TEST_LOCATION);
1086 // Check the input shadow property
1087 field.SetProperty(TextField::Property::INPUT_SHADOW, "Shadow input properties");
1088 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_SHADOW), std::string("Shadow input properties"), TEST_LOCATION);
1090 // Check the emboss property
1091 field.SetProperty(TextField::Property::EMBOSS, "Emboss properties");
1092 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::EMBOSS), std::string("Emboss properties"), TEST_LOCATION);
1094 // Check the input emboss property
1095 field.SetProperty(TextField::Property::INPUT_EMBOSS, "Emboss input properties");
1096 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_EMBOSS), std::string("Emboss input properties"), TEST_LOCATION);
1098 // Check the outline property
1100 // Test string type first
1101 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
1102 field.SetProperty(TextField::Property::OUTLINE, "Outline properties");
1103 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::OUTLINE), std::string("Outline properties"), TEST_LOCATION);
1105 // Then test the property map type
1106 Property::Map outlineMapSet;
1107 Property::Map outlineMapGet;
1109 outlineMapSet["color"] = Color::RED;
1110 outlineMapSet["width"] = 2.0f;
1111 outlineMapSet["offset"] = Vector2(0.0f, 0.0f);
1113 field.SetProperty(TextField::Property::OUTLINE, outlineMapSet);
1115 outlineMapGet = field.GetProperty<Property::Map>(TextField::Property::OUTLINE);
1116 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
1117 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
1119 // Check the input outline property
1120 field.SetProperty(TextField::Property::INPUT_OUTLINE, "Outline input properties");
1121 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_OUTLINE), std::string("Outline input properties"), TEST_LOCATION);
1123 // Check the hidden input settings property
1124 Property::Map hiddenMapSet;
1125 Property::Map hiddenMapGet;
1126 hiddenMapSet[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL;
1127 hiddenMapSet[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 2;
1128 hiddenMapSet[HiddenInput::Property::SUBSTITUTE_COUNT] = 4;
1129 hiddenMapSet[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
1130 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet);
1132 hiddenMapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
1133 DALI_TEST_EQUALS(hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION);
1134 DALI_TEST_EQUALS(DaliTestCheckMaps(hiddenMapSet, hiddenMapGet), true, TEST_LOCATION);
1136 // Check the pixel size of font
1137 field.SetProperty(TextField::Property::PIXEL_SIZE, 20.f);
1138 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1140 // Check the enable selection property
1141 field.SetProperty(TextField::Property::ENABLE_SELECTION, false);
1142 DALI_TEST_EQUALS(field.GetProperty<bool>(TextField::Property::ENABLE_SELECTION), false, TEST_LOCATION);
1144 // Check the placeholder property with pixel size
1145 Property::Map placeholderPixelSizeMapSet;
1146 Property::Map placeholderPixelSizeMapGet;
1147 Property::Map placeholderFontstyleMap;
1148 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
1149 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
1150 placeholderPixelSizeMapSet["color"] = Color::BLUE;
1151 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
1152 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
1153 placeholderPixelSizeMapSet["ellipsis"] = true;
1155 placeholderFontstyleMap.Insert("weight", "bold");
1156 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
1157 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
1159 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1160 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
1162 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1163 Property::Map placeholderConversionMap;
1164 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1165 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1166 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1167 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1168 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1169 placeholderConversionMap[Text::PlaceHolder::Property::PIXEL_SIZE] = placeholderPixelSizeMapSet["pixelSize"];
1171 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderConversionMap), true, TEST_LOCATION);
1173 // Check the placeholder property with point size
1174 Property::Map placeholderMapSet;
1175 Property::Map placeholderMapGet;
1176 placeholderMapSet["text"] = "Setting Placeholder Text";
1177 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
1178 placeholderMapSet["color"] = Color::RED;
1179 placeholderMapSet["fontFamily"] = "Arial";
1180 placeholderMapSet["pointSize"] = 12.0f;
1181 placeholderMapSet["ellipsis"] = false;
1183 // Check the placeholder font style property
1184 placeholderFontstyleMap.Clear();
1186 placeholderFontstyleMap.Insert("weight", "bold");
1187 placeholderFontstyleMap.Insert("width", "condensed");
1188 placeholderFontstyleMap.Insert("slant", "italic");
1189 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1190 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1192 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1193 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1195 placeholderConversionMap.Clear();
1196 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1197 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1198 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1199 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1200 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1201 placeholderConversionMap[Text::PlaceHolder::Property::POINT_SIZE] = placeholderPixelSizeMapSet["pointSize"];
1203 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1205 // Reset font style.
1206 placeholderFontstyleMap.Clear();
1207 placeholderFontstyleMap.Insert("weight", "normal");
1208 placeholderFontstyleMap.Insert("slant", "oblique");
1209 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1210 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1212 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1213 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1215 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1216 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1218 placeholderFontstyleMap.Clear();
1219 placeholderFontstyleMap.Insert("slant", "roman");
1220 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1221 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1223 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1225 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1227 placeholderFontstyleMap.Clear();
1228 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1229 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1231 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1232 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1233 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1235 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1237 // Check the ellipsis property
1238 DALI_TEST_CHECK(!field.GetProperty<bool>(TextField::Property::ELLIPSIS));
1239 field.SetProperty(TextField::Property::ELLIPSIS, true);
1240 DALI_TEST_CHECK(field.GetProperty<bool>(TextField::Property::ELLIPSIS));
1242 field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1243 DALI_TEST_EQUALS(field.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1245 // Test the ENABLE_GRAB_HANDLE_POPUP property
1246 DALI_TEST_CHECK(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP));
1247 field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false);
1248 DALI_TEST_CHECK(!field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP));
1250 // Check the background property
1251 field.SetProperty(DevelTextField::Property::BACKGROUND, Color::RED);
1252 DALI_TEST_EQUALS(field.GetProperty<Vector4>(DevelTextField::Property::BACKGROUND), Color::RED, TEST_LOCATION);
1254 //Check handle color
1255 field.SetProperty(DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN);
1256 DALI_TEST_EQUALS(field.GetProperty<Vector4>(DevelTextField::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
1258 // Check the input filter property
1259 Property::Map inputFilterMapSet;
1260 Property::Map inputFilterMapGet;
1261 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1262 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1264 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1266 inputFilterMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::INPUT_FILTER);
1267 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1270 inputFilterMapSet.Clear();
1271 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1273 application.SendNotification();
1274 application.Render();
1276 // Check Remove Front/Back Inset Property
1277 DALI_TEST_CHECK(field.GetProperty<bool>(DevelTextField::Property::REMOVE_FRONT_INSET));
1278 field.SetProperty(DevelTextField::Property::REMOVE_FRONT_INSET, false);
1279 DALI_TEST_CHECK(!field.GetProperty<bool>(DevelTextField::Property::REMOVE_FRONT_INSET));
1281 DALI_TEST_CHECK(field.GetProperty<bool>(DevelTextField::Property::REMOVE_BACK_INSET));
1282 field.SetProperty(DevelTextField::Property::REMOVE_BACK_INSET, false);
1283 DALI_TEST_CHECK(!field.GetProperty<bool>(DevelTextField::Property::REMOVE_BACK_INSET));
1285 application.SendNotification();
1286 application.Render();
1292 // Positive Atlas Text Renderer test
1293 int utcDaliTextFieldAtlasRenderP(void)
1295 ToolkitTestApplication application;
1296 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1297 StyleManager styleManager = StyleManager::Get();
1298 styleManager.ApplyDefaultTheme();
1299 TextField field = TextField::New();
1300 DALI_TEST_CHECK(field);
1302 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1304 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1306 application.GetScene().Add(field);
1310 // Render some text with the shared atlas backend
1311 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1312 application.SendNotification();
1313 application.Render();
1317 tet_result(TET_FAIL);
1322 // Positive test for the anchorClicked signal.
1323 int utcDaliTextFieldAnchorClicked01(void)
1325 ToolkitTestApplication application;
1326 tet_infoline(" utcDaliTextFieldAnchorClicked01");
1327 TextField field = TextField::New();
1328 DALI_TEST_CHECK(field);
1330 application.GetScene().Add(field);
1332 // connect to the anchor clicked signal.
1333 ConnectionTracker* testTracker = new ConnectionTracker();
1334 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1335 bool anchorClickedSignal = false;
1336 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1338 gAnchorClickedCallBackCalled = false;
1339 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1340 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1341 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1342 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1343 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1345 application.SendNotification();
1346 application.Render();
1347 field.SetKeyInputFocus();
1349 // Create a tap event to touch the text field.
1350 TestGenerateTap(application, 5.0f, 25.0f);
1351 application.SendNotification();
1352 application.Render();
1354 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1355 DALI_TEST_CHECK(anchorClickedSignal);
1357 gAnchorClickedCallBackNotCalled = true;
1358 // Tap the outside of anchor, callback should not be called.
1359 TestGenerateTap(application, 150.f, 100.f);
1360 application.SendNotification();
1361 application.Render();
1363 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1368 // Positive test for the anchorClicked signal.
1369 int utcDaliTextFieldAnchorClicked02(void)
1371 ToolkitTestApplication application;
1372 tet_infoline(" utcDaliTextFieldAnchorClicked02");
1373 TextField field = TextField::New();
1374 DALI_TEST_CHECK(field);
1376 application.GetScene().Add(field);
1378 // connect to the anchor clicked signal.
1379 ConnectionTracker* testTracker = new ConnectionTracker();
1380 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1381 bool anchorClickedSignal = false;
1382 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1384 gAnchorClickedCallBackCalled = false;
1385 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1386 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1387 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1388 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1389 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1391 application.SendNotification();
1392 application.Render();
1393 field.SetKeyInputFocus();
1395 // Avoid a crash when core load gl resources.
1396 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1398 // Create a tap event to touch the text field.
1399 TestGenerateTap(application, 30.0f, 25.0f, 100);
1400 application.SendNotification();
1401 application.Render();
1403 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1404 DALI_TEST_CHECK(anchorClickedSignal);
1406 // For coverage InsertTextAnchor, RemoveTextAnchor
1407 // first index insert
1408 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1409 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1410 application.SendNotification();
1411 application.Render();
1413 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1414 application.SendNotification();
1415 application.Render();
1417 gAnchorClickedCallBackCalled = false;
1418 // Create a tap event to touch the text field.
1419 TestGenerateTap(application, 30.0f, 25.0f, 700);
1420 application.SendNotification();
1421 field.SetKeyInputFocus();
1423 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1425 // last index insert
1426 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1427 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1428 application.SendNotification();
1429 application.Render();
1431 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1432 application.SendNotification();
1433 application.Render();
1435 gAnchorClickedCallBackCalled = false;
1436 // Create a tap event to touch the text field.
1437 TestGenerateTap(application, 30.0f, 25.0f, 1300);
1438 application.SendNotification();
1439 field.SetKeyInputFocus();
1441 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1444 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1445 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1446 application.SendNotification();
1447 application.Render();
1449 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1450 application.SendNotification();
1451 application.Render();
1453 gAnchorClickedCallBackCalled = false;
1454 // Create a tap event to touch the text field.
1455 TestGenerateTap(application, 30.0f, 25.0f, 1900);
1456 application.SendNotification();
1457 field.SetKeyInputFocus();
1459 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1461 // first index remove
1462 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1463 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1464 application.SendNotification();
1465 application.Render();
1467 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1468 application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1469 application.SendNotification();
1470 application.Render();
1472 gAnchorClickedCallBackCalled = false;
1473 // Create a tap event to touch the text field.
1474 TestGenerateTap(application, 30.0f, 25.0f, 2500);
1475 application.SendNotification();
1476 field.SetKeyInputFocus();
1478 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1480 // last index remove
1481 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1482 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1483 application.SendNotification();
1484 application.Render();
1486 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1487 application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1488 application.SendNotification();
1489 application.Render();
1491 gAnchorClickedCallBackCalled = false;
1492 // Create a tap event to touch the text field.
1493 TestGenerateTap(application, 30.0f, 25.0f, 3100);
1494 application.SendNotification();
1495 application.Render();
1497 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1500 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1501 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1502 application.SendNotification();
1503 application.Render();
1505 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1506 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));
1507 application.SendNotification();
1508 application.Render();
1510 gAnchorClickedCallBackCalled = false;
1511 // Create a tap event to touch the text field.
1512 TestGenerateTap(application, 30.0f, 25.0f, 3700);
1513 application.SendNotification();
1514 application.Render();
1516 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1518 // 0 ~ 1 index remove
1519 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1520 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 0);
1521 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 1);
1522 application.SendNotification();
1523 application.Render();
1525 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1526 application.SendNotification();
1527 application.Render();
1529 gAnchorClickedCallBackCalled = false;
1530 // Create a tap event to touch the text field.
1531 TestGenerateTap(application, 30.0f, 25.0f, 4300);
1532 application.SendNotification();
1533 application.Render();
1535 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1537 // 1 ~ 3 index remove
1538 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1539 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 1);
1540 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 3);
1541 application.SendNotification();
1542 application.Render();
1544 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1545 application.SendNotification();
1546 application.Render();
1548 gAnchorClickedCallBackCalled = false;
1549 // Create a tap event to touch the text field.
1550 TestGenerateTap(application, 30.0f, 25.0f, 4900);
1551 application.SendNotification();
1552 application.Render();
1554 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1556 // 3 ~ 4 index remove
1557 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1558 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 3);
1559 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 4);
1560 application.SendNotification();
1561 application.Render();
1563 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1564 application.SendNotification();
1565 application.Render();
1567 gAnchorClickedCallBackCalled = false;
1568 // Create a tap event to touch the text field.
1569 TestGenerateTap(application, 30.0f, 25.0f, 5500);
1570 application.SendNotification();
1571 application.Render();
1573 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1575 // Remove front of anchor
1576 field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
1577 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
1578 application.SendNotification();
1579 application.Render();
1581 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1582 application.SendNotification();
1583 application.Render();
1585 // Remove whole text
1586 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1587 DevelTextField::SelectWholeText(field);
1588 application.SendNotification();
1589 application.Render();
1591 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1592 application.SendNotification();
1593 application.Render();
1595 // Remove all with backspace
1596 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1597 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
1598 application.SendNotification();
1599 application.Render();
1601 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1602 application.SendNotification();
1603 application.Render();
1605 // Remove all with delete
1606 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1607 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1608 application.SendNotification();
1609 application.Render();
1611 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));
1612 application.SendNotification();
1613 application.Render();
1618 // Positive test for the textChanged signal.
1619 int utcDaliTextFieldTextChangedP(void)
1621 ToolkitTestApplication application;
1622 tet_infoline(" utcDaliTextFieldTextChangedP");
1623 TextField field = TextField::New();
1624 DALI_TEST_CHECK(field);
1626 application.GetScene().Add(field);
1628 // connect to the text changed signal.
1629 ConnectionTracker* testTracker = new ConnectionTracker();
1630 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1631 bool textChangedSignal = false;
1632 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1634 gTextChangedCallBackCalled = false;
1635 field.SetProperty(TextField::Property::TEXT, "ABC");
1636 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1637 DALI_TEST_CHECK(textChangedSignal);
1639 application.SendNotification();
1640 field.SetKeyInputFocus();
1642 gTextChangedCallBackCalled = false;
1643 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1644 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1647 field.SetProperty(TextField::Property::TEXT, "");
1649 // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1650 gTextChangedCallBackCalled = false;
1651 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1652 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1654 // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1655 gTextChangedCallBackCalled = false;
1656 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1657 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1662 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1664 ToolkitTestApplication application;
1665 tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1666 TextField field = TextField::New();
1667 DALI_TEST_CHECK(field);
1669 application.GetScene().Add(field);
1671 // connect to the text changed signal.
1672 ConnectionTracker* testTracker = new ConnectionTracker();
1673 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1674 bool textChangedSignal = false;
1675 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1677 // get InputMethodContext
1679 InputMethodContext::EventData imfEvent;
1680 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1682 field.SetKeyInputFocus();
1683 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1686 gTextChangedCallBackCalled = false;
1687 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "ㅎ", 0, 1);
1688 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1689 application.SendNotification();
1690 application.Render();
1691 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1692 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ㅎ"), TEST_LOCATION);
1694 gTextChangedCallBackCalled = false;
1695 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "호", 0, 1);
1696 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1697 application.SendNotification();
1698 application.Render();
1699 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1700 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("호"), TEST_LOCATION);
1702 gTextChangedCallBackCalled = false;
1703 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "혿", 0, 1);
1704 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1705 application.SendNotification();
1706 application.Render();
1707 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1708 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("혿"), TEST_LOCATION);
1710 gTextChangedCallBackCalled = false;
1711 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "", 0, 1);
1712 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1713 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1715 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "호", 0, 1);
1716 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1717 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1719 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "두", 1, 2);
1720 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1721 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1723 application.SendNotification();
1724 application.Render();
1725 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1726 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("호두"), TEST_LOCATION);
1731 int utcDaliTextFieldSelectionWithInputMethodContext(void)
1733 ToolkitTestApplication application;
1734 tet_infoline(" utcDaliTextFieldSelectionWithInputMethodContext");
1735 TextField field = TextField::New();
1736 DALI_TEST_CHECK(field);
1738 field.SetProperty(TextField::Property::TEXT, "Hello world");
1740 application.GetScene().Add(field);
1742 // connect to the selection changed signal.
1743 ConnectionTracker* testTracker = new ConnectionTracker();
1744 DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
1745 bool selectionChangedSignal = false;
1746 field.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
1748 // get InputMethodContext
1750 InputMethodContext::EventData imfEvent;
1751 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1753 field.SetKeyInputFocus();
1754 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1757 gSelectionChangedCallbackCalled = false;
1758 imfEvent = InputMethodContext::EventData(InputMethodContext::SELECTION_SET, 1, 4);
1759 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1760 application.SendNotification();
1761 application.Render();
1762 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
1764 DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
1765 DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 4, TEST_LOCATION);
1770 int utcDaliTextFieldPositionWithInputMethodContext(void)
1772 ToolkitTestApplication application;
1773 tet_infoline(" utcDaliTextFieldPositionWithInputMethodContext");
1774 TextField field = TextField::New();
1775 DALI_TEST_CHECK(field);
1777 field.SetProperty(TextField::Property::TEXT, "Hello world");
1779 application.GetScene().Add(field);
1781 // connect to the selection changed signal.
1782 ConnectionTracker* testTracker = new ConnectionTracker();
1783 DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
1784 bool cursorPositionChangedSignal = false;
1785 field.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
1787 // get InputMethodContext
1789 InputMethodContext::EventData imfEvent;
1790 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1792 field.SetKeyInputFocus();
1793 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1796 gCursorPositionChangedCallbackCalled = false;
1797 imfEvent = InputMethodContext::EventData(InputMethodContext::SELECTION_SET, 2, 2);
1798 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1799 application.SendNotification();
1800 application.Render();
1801 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
1803 DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 2, TEST_LOCATION);
1808 int utcDaliTextFieldInputFilterWithInputMethodContext(void)
1810 ToolkitTestApplication application;
1811 tet_infoline(" utcDaliTextFieldInputFilterWithInputMethodContext");
1812 TextField field = TextField::New();
1813 DALI_TEST_CHECK(field);
1815 Property::Map inputFilter;
1816 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1817 inputFilter[InputFilter::Property::REJECTED] = "[5-7]";
1819 // Set input filter to TextField.
1820 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1822 application.GetScene().Add(field);
1824 // connect to the input filtered signal.
1825 ConnectionTracker* testTracker = new ConnectionTracker();
1826 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1827 bool inputFilteredSignal = false;
1828 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1830 // get InputMethodContext
1832 InputMethodContext::EventData imfEvent;
1833 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1835 field.SetKeyInputFocus();
1836 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1839 gInputFilteredAcceptedCallbackCalled = false;
1840 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "Hello1234", 0, 9);
1841 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1842 application.SendNotification();
1843 application.Render();
1844 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1845 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("1234"), TEST_LOCATION);
1847 inputFilteredSignal = false;
1848 gInputFilteredRejectedCallbackCalled = false;
1849 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "1234567", 0, 7);
1850 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1851 application.SendNotification();
1852 application.Render();
1853 DALI_TEST_CHECK(gInputFilteredRejectedCallbackCalled);
1854 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("12341234"), TEST_LOCATION);
1859 // Negative test for the textChanged signal.
1860 int utcDaliTextFieldTextChangedN(void)
1862 ToolkitTestApplication application;
1863 tet_infoline(" utcDaliTextFieldTextChangedN");
1864 TextField field = TextField::New();
1865 DALI_TEST_CHECK(field);
1867 application.GetScene().Add(field);
1869 // connect to the text changed signal.
1870 ConnectionTracker* testTracker = new ConnectionTracker();
1871 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1872 bool textChangedSignal = false;
1873 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1875 gTextChangedCallBackCalled = false;
1876 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "ABC"); // Setting placeholder, not TEXT
1877 application.SendNotification();
1878 application.Render();
1879 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1880 DALI_TEST_CHECK(!textChangedSignal);
1885 // Positive test for Max Characters reached signal.
1886 int utcDaliTextFieldMaxCharactersReachedP(void)
1888 ToolkitTestApplication application;
1889 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1890 TextField field = TextField::New();
1891 DALI_TEST_CHECK(field);
1893 application.GetScene().Add(field);
1895 const int maxNumberOfCharacters = 1;
1896 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1898 field.SetKeyInputFocus();
1900 // connect to the text changed signal.
1901 ConnectionTracker* testTracker = new ConnectionTracker();
1902 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1903 bool maxLengthReachedSignal = false;
1904 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1906 gMaxCharactersCallBackCalled = false;
1908 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1909 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1911 DALI_TEST_CHECK(gMaxCharactersCallBackCalled);
1912 DALI_TEST_CHECK(maxLengthReachedSignal);
1917 // Negative test for Max Characters reached signal.
1918 int utcDaliTextFieldMaxCharactersReachedN(void)
1920 ToolkitTestApplication application;
1921 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1922 TextField field = TextField::New();
1923 DALI_TEST_CHECK(field);
1925 application.GetScene().Add(field);
1927 const int maxNumberOfCharacters = 3;
1928 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1930 field.SetKeyInputFocus();
1932 // connect to the text changed signal.
1933 ConnectionTracker* testTracker = new ConnectionTracker();
1934 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1935 bool maxLengthReachedSignal = false;
1936 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1938 gMaxCharactersCallBackCalled = false;
1940 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1941 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1943 DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1944 DALI_TEST_CHECK(!maxLengthReachedSignal);
1946 application.ProcessEvent(GenerateKey("Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1948 DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1949 DALI_TEST_CHECK(!maxLengthReachedSignal);
1954 // Positive test for Input Filtered signal.
1955 int utcDaliTextFieldInputFilteredP(void)
1957 ToolkitTestApplication application;
1958 tet_infoline(" utcDaliTextFieldInputFilteredP");
1959 TextField field = TextField::New();
1960 DALI_TEST_CHECK(field);
1962 application.GetScene().Add(field);
1964 Property::Map inputFilter;
1966 // Only digit is accepted.
1967 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1969 // Set input filter to TextField.
1970 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1972 field.SetKeyInputFocus();
1974 // connect to the input filtered signal.
1975 ConnectionTracker* testTracker = new ConnectionTracker();
1976 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1977 bool inputFilteredSignal = false;
1978 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1980 gInputFilteredAcceptedCallbackCalled = false;
1982 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1984 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1985 DALI_TEST_CHECK(inputFilteredSignal);
1987 // Word is rejected.
1988 inputFilter[InputFilter::Property::ACCEPTED] = "";
1989 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1991 // Set input filter to TextField.
1992 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1994 field.SetKeyInputFocus();
1996 inputFilteredSignal = false;
1997 gInputFilteredRejectedCallbackCalled = false;
1999 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2001 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
2002 DALI_TEST_CHECK(inputFilteredSignal);
2007 // Negative test for Input Filtered signal.
2008 int utcDaliTextFieldInputFilteredN(void)
2010 ToolkitTestApplication application;
2011 tet_infoline(" utcDaliTextFieldInputFilteredP");
2012 TextField field = TextField::New();
2013 DALI_TEST_CHECK(field);
2015 application.GetScene().Add(field);
2017 Property::Map inputFilter;
2019 // Only word is accepted.
2020 inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
2022 // Set input filter to TextField.
2023 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
2025 field.SetKeyInputFocus();
2027 // connect to the input filtered signal.
2028 ConnectionTracker* testTracker = new ConnectionTracker();
2029 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
2030 bool inputFilteredSignal = false;
2031 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
2033 gInputFilteredAcceptedCallbackCalled = false;
2035 // Key a, d should not be filtered.
2036 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2037 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2038 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2039 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2041 // Backspace, Delete should not be filtered.
2042 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2043 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));
2045 // Render and notify
2046 application.SendNotification();
2047 application.Render();
2049 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
2050 DALI_TEST_CHECK(!inputFilteredSignal);
2052 // Digit is rejected.
2053 inputFilter[InputFilter::Property::ACCEPTED] = "";
2054 inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
2056 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
2058 field.SetKeyInputFocus();
2060 inputFilteredSignal = false;
2061 gInputFilteredRejectedCallbackCalled = false;
2063 // Key a, d should not be filtered.
2064 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2065 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2066 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2067 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2069 // Backspace, Delete should not be filtered.
2070 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2071 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));
2073 // Render and notify
2074 application.SendNotification();
2075 application.Render();
2077 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
2078 DALI_TEST_CHECK(!inputFilteredSignal);
2083 int utcDaliTextFieldInputStyleChanged01(void)
2085 // The text-field emits signals when the input style changes. These changes of style are
2086 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
2087 // can't be emitted during the size negotiation as the callbacks may update the UI.
2088 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
2089 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
2090 ToolkitTestApplication application;
2091 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
2095 char* pathNamePtr = get_current_dir_name();
2096 const std::string pathName(pathNamePtr);
2099 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2100 fontClient.SetDpi(93u, 93u);
2102 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2103 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2105 TextField field = TextField::New();
2106 DALI_TEST_CHECK(field);
2108 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2109 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2110 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2112 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2113 field.SetProperty(TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
2115 // connect to the text changed signal.
2116 ConnectionTracker* testTracker = new ConnectionTracker();
2117 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2118 bool inputStyleChangedSignal = false;
2119 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2121 application.GetScene().Add(field);
2123 // Render and notify
2124 application.SendNotification();
2125 application.Render();
2127 // Executes the idle callbacks added by the text control on the change of input style.
2128 application.RunIdles();
2130 gInputStyleChangedCallbackCalled = false;
2131 gInputStyleMask = TextField::InputStyle::NONE;
2132 inputStyleChangedSignal = false;
2134 // Create a tap event to touch the text field.
2135 TestGenerateTap(application, 18.0f, 25.0f);
2137 // Render and notify
2138 application.SendNotification();
2139 application.Render();
2141 // Executes the idle callbacks added by the text control on the change of input style.
2142 application.RunIdles();
2144 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2145 if(gInputStyleChangedCallbackCalled)
2147 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE), TEST_LOCATION);
2149 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2150 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2152 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2153 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2155 DALI_TEST_CHECK(inputStyleChangedSignal);
2157 gInputStyleChangedCallbackCalled = false;
2158 gInputStyleMask = TextField::InputStyle::NONE;
2159 inputStyleChangedSignal = false;
2161 // Create a tap event to touch the text field.
2162 TestGenerateTap(application, 30.0f, 25.0f);
2164 // Render and notify
2165 application.SendNotification();
2166 application.Render();
2168 // Executes the idle callbacks added by the text control on the change of input style.
2169 application.RunIdles();
2171 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2172 DALI_TEST_CHECK(!inputStyleChangedSignal);
2174 gInputStyleChangedCallbackCalled = false;
2175 gInputStyleMask = TextField::InputStyle::NONE;
2176 inputStyleChangedSignal = false;
2178 // Create a tap event to touch the text field.
2179 TestGenerateTap(application, 43.0f, 25.0f);
2181 // Render and notify
2182 application.SendNotification();
2183 application.Render();
2185 // Executes the idle callbacks added by the text control on the change of input style.
2186 application.RunIdles();
2188 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2189 if(gInputStyleChangedCallbackCalled)
2191 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR), TEST_LOCATION);
2193 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2194 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2196 DALI_TEST_CHECK(inputStyleChangedSignal);
2198 gInputStyleChangedCallbackCalled = false;
2199 gInputStyleMask = TextField::InputStyle::NONE;
2200 inputStyleChangedSignal = false;
2202 // Create a tap event to touch the text field.
2203 TestGenerateTap(application, 88.0f, 25.0f);
2205 // Render and notify
2206 application.SendNotification();
2207 application.Render();
2209 // Executes the idle callbacks added by the text control on the change of input style.
2210 application.RunIdles();
2212 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2213 if(gInputStyleChangedCallbackCalled)
2215 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2217 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2218 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2220 const Property::Map fontStyleMapGet = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<Property::Map>();
2222 Property::Map fontStyleMapSet;
2223 fontStyleMapSet.Insert("weight", "bold");
2225 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2226 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2228 DALI_TEST_CHECK(inputStyleChangedSignal);
2230 gInputStyleChangedCallbackCalled = false;
2231 gInputStyleMask = TextField::InputStyle::NONE;
2232 inputStyleChangedSignal = false;
2234 // Create a tap event to touch the text field.
2235 TestGenerateTap(application, 115.0f, 25.0f);
2237 // Render and notify
2238 application.SendNotification();
2239 application.Render();
2241 // Executes the idle callbacks added by the text control on the change of input style.
2242 application.RunIdles();
2244 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2245 DALI_TEST_CHECK(!inputStyleChangedSignal);
2247 gInputStyleChangedCallbackCalled = false;
2248 gInputStyleMask = TextField::InputStyle::NONE;
2249 inputStyleChangedSignal = false;
2251 // Create a tap event to touch the text field.
2252 TestGenerateTap(application, 164.0f, 25.0f);
2254 // Render and notify
2255 application.SendNotification();
2256 application.Render();
2258 // Executes the idle callbacks added by the text control on the change of input style.
2259 application.RunIdles();
2261 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2262 if(gInputStyleChangedCallbackCalled)
2264 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2266 const std::string style = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<std::string>();
2267 DALI_TEST_CHECK(style.empty());
2269 DALI_TEST_CHECK(inputStyleChangedSignal);
2271 gInputStyleChangedCallbackCalled = false;
2272 gInputStyleMask = TextField::InputStyle::NONE;
2273 inputStyleChangedSignal = false;
2275 // Create a tap event to touch the text field.
2276 TestGenerateTap(application, 191.0f, 25.0f);
2278 // Render and notify
2279 application.SendNotification();
2280 application.Render();
2282 // Executes the idle callbacks added by the text control on the change of input style.
2283 application.RunIdles();
2285 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2286 DALI_TEST_CHECK(!inputStyleChangedSignal);
2291 int utcDaliTextFieldInputStyleChanged02(void)
2293 // The text-field emits signals when the input style changes. These changes of style are
2294 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
2295 // can't be emitted during the size negotiation as the callbacks may update the UI.
2296 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
2297 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
2298 ToolkitTestApplication application;
2299 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
2303 char* pathNamePtr = get_current_dir_name();
2304 const std::string pathName(pathNamePtr);
2307 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2308 fontClient.SetDpi(93u, 93u);
2310 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2311 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2313 TextField field = TextField::New();
2314 DALI_TEST_CHECK(field);
2316 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2317 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2318 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2320 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2321 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>");
2323 // connect to the text changed signal.
2324 ConnectionTracker* testTracker = new ConnectionTracker();
2325 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2326 bool inputStyleChangedSignal = false;
2327 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2329 application.GetScene().Add(field);
2331 // Render and notify
2332 application.SendNotification();
2333 application.Render();
2335 // Executes the idle callbacks added by the text control on the change of input style.
2336 application.RunIdles();
2338 gInputStyleChangedCallbackCalled = false;
2339 gInputStyleMask = TextField::InputStyle::NONE;
2340 inputStyleChangedSignal = false;
2342 // Create a tap event to touch the text field.
2343 TestGenerateTap(application, 53.0f, 25.0f, 100);
2344 TestGenerateTap(application, 53.0f, 25.0f, 200);
2346 // Render and notify
2347 application.SendNotification();
2348 application.Render();
2350 // Executes the idle callbacks added by the text control on the change of input style.
2351 application.RunIdles();
2353 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2354 if(gInputStyleChangedCallbackCalled)
2356 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2357 static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY |
2358 TextField::InputStyle::POINT_SIZE |
2359 TextField::InputStyle::COLOR),
2362 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2363 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2365 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2366 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2368 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2369 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2371 DALI_TEST_CHECK(inputStyleChangedSignal);
2373 gInputStyleChangedCallbackCalled = false;
2374 gInputStyleMask = TextField::InputStyle::NONE;
2375 inputStyleChangedSignal = false;
2377 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2379 // Render and notify
2380 application.SendNotification();
2381 application.Render();
2383 // Executes the idle callbacks added by the text control on the change of input style.
2384 application.RunIdles();
2386 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2387 if(gInputStyleChangedCallbackCalled)
2389 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2390 static_cast<unsigned int>(TextField::InputStyle::COLOR),
2393 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2394 DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
2396 DALI_TEST_CHECK(inputStyleChangedSignal);
2398 gInputStyleChangedCallbackCalled = false;
2399 gInputStyleMask = TextField::InputStyle::NONE;
2400 inputStyleChangedSignal = false;
2402 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2404 // Render and notify
2405 application.SendNotification();
2406 application.Render();
2408 // Executes the idle callbacks added by the text control on the change of input style.
2409 application.RunIdles();
2411 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2412 DALI_TEST_CHECK(!inputStyleChangedSignal);
2414 gInputStyleChangedCallbackCalled = false;
2415 gInputStyleMask = TextField::InputStyle::NONE;
2416 inputStyleChangedSignal = false;
2418 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2420 // Render and notify
2421 application.SendNotification();
2422 application.Render();
2424 // Executes the idle callbacks added by the text control on the change of input style.
2425 application.RunIdles();
2427 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2428 if(gInputStyleChangedCallbackCalled)
2430 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2431 static_cast<unsigned int>(TextField::InputStyle::COLOR),
2434 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2435 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2437 DALI_TEST_CHECK(inputStyleChangedSignal);
2439 gInputStyleChangedCallbackCalled = false;
2440 gInputStyleMask = TextField::InputStyle::NONE;
2441 inputStyleChangedSignal = false;
2443 field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
2445 Property::Map fontStyleMapSet;
2446 fontStyleMapSet.Insert("weight", "thin");
2447 fontStyleMapSet.Insert("width", "condensed");
2448 fontStyleMapSet.Insert("slant", "italic");
2450 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
2451 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 20.f);
2453 field.SetProperty(TextField::Property::INPUT_UNDERLINE, "underline");
2454 field.SetProperty(TextField::Property::INPUT_SHADOW, "shadow");
2455 field.SetProperty(TextField::Property::INPUT_EMBOSS, "emboss");
2456 field.SetProperty(TextField::Property::INPUT_OUTLINE, "outline");
2457 field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "strikethrough");
2459 // Render and notify
2460 application.SendNotification();
2461 application.Render();
2463 // Executes the idle callbacks added by the text control on the change of input style.
2464 application.RunIdles();
2466 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2467 DALI_TEST_CHECK(!inputStyleChangedSignal);
2469 // Create a tap event to touch the text field.
2470 TestGenerateTap(application, 63.0f, 25.0f, 700);
2472 // Render and notify
2473 application.SendNotification();
2474 application.Render();
2476 // Executes the idle callbacks added by the text control on the change of input style.
2477 application.RunIdles();
2479 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2480 if(gInputStyleChangedCallbackCalled)
2482 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2483 static_cast<unsigned int>(TextField::InputStyle::COLOR |
2484 TextField::InputStyle::POINT_SIZE |
2485 TextField::InputStyle::FONT_STYLE |
2486 TextField::InputStyle::UNDERLINE |
2487 TextField::InputStyle::SHADOW |
2488 TextField::InputStyle::EMBOSS |
2489 TextField::InputStyle::OUTLINE),
2492 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2493 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2495 DALI_TEST_CHECK(inputStyleChangedSignal);
2500 int utcDaliTextFieldInputStyleChanged03(void)
2502 // Test InputStyleCahnged signal emitted even if AddIdle failed.
2503 ToolkitTestApplication application;
2504 tet_infoline(" utcDaliTextFieldInputStyleChanged03");
2508 char* pathNamePtr = get_current_dir_name();
2509 const std::string pathName(pathNamePtr);
2512 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2513 fontClient.SetDpi(93u, 93u);
2515 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2516 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2518 TextField field = TextField::New();
2519 DALI_TEST_CHECK(field);
2521 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2522 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2523 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2525 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2526 field.SetProperty(TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
2528 // connect to the text changed signal.
2529 ConnectionTracker* testTracker = new ConnectionTracker();
2530 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2531 bool inputStyleChangedSignal = false;
2532 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2534 application.GetScene().Add(field);
2536 // Render and notify
2537 application.SendNotification();
2538 application.Render();
2540 // Executes the idle callbacks added by the text control on the change of input style.
2541 application.RunIdles();
2543 gInputStyleChangedCallbackCalled = false;
2544 gInputStyleMask = TextField::InputStyle::NONE;
2545 inputStyleChangedSignal = false;
2547 // Create a tap event to touch the text field.
2548 TestGenerateTap(application, 18.0f, 25.0f);
2550 // Render and notify
2551 application.SendNotification();
2552 application.Render();
2554 // Executes the idle callbacks added by the text control on the change of input style.
2555 application.RunIdles();
2557 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2558 if(gInputStyleChangedCallbackCalled)
2560 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE), TEST_LOCATION);
2562 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2563 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2565 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2566 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2568 DALI_TEST_CHECK(inputStyleChangedSignal);
2570 gInputStyleChangedCallbackCalled = false;
2571 gInputStyleMask = TextField::InputStyle::NONE;
2572 inputStyleChangedSignal = false;
2574 // Create a tap event to touch the text field.
2575 TestGenerateTap(application, 30.0f, 25.0f);
2577 // Render and notify
2578 application.SendNotification();
2579 application.Render();
2581 // Executes the idle callbacks added by the text control on the change of input style.
2582 application.RunIdles();
2584 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2585 DALI_TEST_CHECK(!inputStyleChangedSignal);
2587 gInputStyleChangedCallbackCalled = false;
2588 gInputStyleMask = TextField::InputStyle::NONE;
2589 inputStyleChangedSignal = false;
2591 // Create a tap event to touch the text field.
2592 TestGenerateTap(application, 43.0f, 25.0f);
2594 // Render and notify
2595 application.SendNotification();
2596 application.Render();
2598 // Executes the idle callbacks added by the text control on the change of input style.
2599 application.RunIdles();
2601 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2602 if(gInputStyleChangedCallbackCalled)
2604 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR), TEST_LOCATION);
2606 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2607 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2609 DALI_TEST_CHECK(inputStyleChangedSignal);
2611 gInputStyleChangedCallbackCalled = false;
2612 gInputStyleMask = TextField::InputStyle::NONE;
2613 inputStyleChangedSignal = false;
2615 // Make AddIdle return false.
2616 ToolkitApplication::ADD_IDLE_SUCCESS = false;
2618 // Create a tap event to touch the text field.
2619 TestGenerateTap(application, 88.0f, 25.0f);
2621 // Render and notify
2622 application.SendNotification();
2623 application.Render();
2625 // Execute the idle callbacks.
2626 // And check whether we didn't change of input style.
2627 application.RunIdles();
2629 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2630 DALI_TEST_CHECK(!inputStyleChangedSignal);
2632 gInputStyleChangedCallbackCalled = false;
2633 gInputStyleMask = TextField::InputStyle::NONE;
2634 inputStyleChangedSignal = false;
2636 // Create a tap event to touch the text field.
2637 TestGenerateTap(application, 115.0f, 25.0f);
2639 // Render and notify
2640 application.SendNotification();
2641 application.Render();
2643 // Execute the idle callbacks.
2644 // And check whether we didn't change of input style.
2645 application.RunIdles();
2647 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2648 DALI_TEST_CHECK(!inputStyleChangedSignal);
2650 gInputStyleChangedCallbackCalled = false;
2651 gInputStyleMask = TextField::InputStyle::NONE;
2652 inputStyleChangedSignal = false;
2654 // Revert AddIdle return true.
2655 ToolkitApplication::ADD_IDLE_SUCCESS = true;
2657 // Create a tap event to touch the text field.
2658 TestGenerateTap(application, 164.0f, 25.0f);
2660 // Render and notify
2661 application.SendNotification();
2662 application.Render();
2664 // Executes the idle callbacks added by the text control on the change of input style.
2665 application.RunIdles();
2667 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2668 if(gInputStyleChangedCallbackCalled)
2670 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2672 const std::string style = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<std::string>();
2673 DALI_TEST_CHECK(style.empty());
2675 DALI_TEST_CHECK(inputStyleChangedSignal);
2677 gInputStyleChangedCallbackCalled = false;
2678 gInputStyleMask = TextField::InputStyle::NONE;
2679 inputStyleChangedSignal = false;
2681 // Create a tap event to touch the text field.
2682 TestGenerateTap(application, 191.0f, 25.0f);
2684 // Render and notify
2685 application.SendNotification();
2686 application.Render();
2688 // Executes the idle callbacks added by the text control on the change of input style.
2689 application.RunIdles();
2691 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2692 DALI_TEST_CHECK(!inputStyleChangedSignal);
2697 int utcDaliTextFieldEvent01(void)
2699 ToolkitTestApplication application;
2700 tet_infoline(" utcDaliTextFieldEvent01");
2702 // Creates a tap event. After creating a tap event the text field should
2703 // have the focus and add text with key events should be possible.
2705 TextField field = TextField::New();
2706 DALI_TEST_CHECK(field);
2708 application.GetScene().Add(field);
2710 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2711 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2712 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2714 // Render and notify
2715 application.SendNotification();
2716 application.Render();
2718 // Avoid a crash when core load gl resources.
2719 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2721 // Render and notify
2722 application.SendNotification();
2723 application.Render();
2725 // Add a key event but as the text field has not the focus it should do nothing.
2726 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2728 // Render and notify
2729 application.SendNotification();
2730 application.Render();
2732 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
2734 // Create a tap event to touch the text field.
2735 TestGenerateTap(application, 150.0f, 25.0f);
2737 // Render and notify
2738 application.SendNotification();
2739 application.Render();
2741 // Pressing delete key should be fine even if there is no text in TextField.
2742 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));
2743 // Render and notify
2744 application.SendNotification();
2745 application.Render();
2747 // Now the text field has the focus, so it can handle the key events.
2748 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2749 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2751 // Render and notify
2752 application.SendNotification();
2753 application.Render();
2755 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2757 // Create a second text field and send key events to it.
2758 TextField field2 = TextField::New();
2760 field2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2761 field2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2762 field2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2763 field2.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
2765 application.GetScene().Add(field2);
2767 // Render and notify
2768 application.SendNotification();
2769 application.Render();
2771 // Create a tap event on the second text field.
2772 TestGenerateTap(application, 150.0f, 125.0f);
2774 // Render and notify
2775 application.SendNotification();
2776 application.Render();
2778 // The second text field has the focus. It should handle the key events.
2779 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2780 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2782 // Render and notify
2783 application.SendNotification();
2784 application.Render();
2786 // Check the text has been added to the second text field.
2787 DALI_TEST_EQUALS(field2.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2792 int utcDaliTextFieldEvent02(void)
2794 ToolkitTestApplication application;
2795 tet_infoline(" utcDaliTextFieldEvent02");
2797 // Checks if the right number of actors are created.
2799 TextField field = TextField::New();
2800 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2801 DALI_TEST_CHECK(field);
2802 LoadMarkerImages(application, field);
2804 application.GetScene().Add(field);
2806 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2807 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2808 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2810 // Avoid a crash when core load gl resources.
2811 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2813 // Render and notify
2814 application.SendNotification();
2815 application.Render();
2817 // Check there are the expected number of children ( stencil ).
2818 DALI_TEST_EQUALS(field.GetChildCount(), 1u, TEST_LOCATION);
2820 Actor stencil = field.GetChildAt(0u);
2821 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2823 // Create a tap event to touch the text field.
2824 TestGenerateTap(application, 150.0f, 25.0f, 300);
2826 // Render and notify
2827 application.SendNotification();
2828 application.Render();
2830 Actor layer = field.GetChildAt(2u);
2831 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2832 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2834 // Now the text field has the focus, so it can handle the key events.
2835 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2836 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2838 // Render and notify
2839 application.SendNotification();
2840 application.Render();
2842 // Checks the cursor and the renderer have been created.
2843 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2844 DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
2846 Control cursor = Control::DownCast(layer.GetChildAt(0u));
2847 DALI_TEST_CHECK(cursor);
2849 // The offscreen root actor has a container with all the actors which contain the text renderers.
2850 Actor container = stencil.GetChildAt(0u);
2851 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2853 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2854 DALI_TEST_CHECK(renderer);
2857 // Move the cursor and check the position changes.
2858 Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2859 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2861 // Render and notify
2862 application.SendNotification();
2863 application.Render();
2865 Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2866 DALI_TEST_CHECK(position2.x < position1.x);
2868 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2870 // Render and notify
2871 application.SendNotification();
2872 application.Render();
2874 Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2875 DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
2877 // Move the cursor to the first position.
2878 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2879 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2881 // Render and notify
2882 application.SendNotification();
2883 application.Render();
2885 Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2887 // Send some taps and check the cursor positions.
2889 // Try to tap at the beginning.
2890 TestGenerateTap(application, 1.0f, 25.0f, 900);
2892 // Render and notify
2893 application.SendNotification();
2894 application.Render();
2896 // Cursor position should be the same than position1.
2897 Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2899 DALI_TEST_EQUALS(position4, position5, TEST_LOCATION); // Should be in the same position2.
2901 // Tap away from the start position.
2902 TestGenerateTap(application, 16.0f, 25.0f, 1500);
2904 // Render and notify
2905 application.SendNotification();
2906 application.Render();
2908 Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2910 DALI_TEST_CHECK(position6.x > position5.x);
2912 // Remove all the text.
2913 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2914 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2915 field.SetProperty(TextField::Property::TEXT, "");
2917 // Render and notify
2918 application.SendNotification();
2919 application.Render();
2921 // Cursor position should be the same than position2.
2922 Vector3 position7 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2924 DALI_TEST_EQUALS(position4, position7, TEST_LOCATION); // Should be in the same position2.
2926 // Should not be a renderer, there is only a clipped cursor.
2927 DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
2929 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2930 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2931 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
2933 application.SendNotification();
2934 application.Render();
2936 // There are renderer and decorator layer
2937 DALI_TEST_EQUALS(field.GetChildCount(), 2u, TEST_LOCATION);
2942 int utcDaliTextFieldEvent03(void)
2944 ToolkitTestApplication application;
2945 tet_infoline(" utcDaliTextFieldEvent03");
2947 // Checks if the highlight actor is created.
2949 TextField field = TextField::New();
2950 DALI_TEST_CHECK(field);
2952 application.GetScene().Add(field);
2954 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2955 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2956 field.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2957 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2958 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2960 // Avoid a crash when core load gl resources.
2961 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2962 LoadMarkerImages(application, field);
2964 // Render and notify
2965 application.SendNotification();
2966 application.Render();
2968 // Tap first to get the focus.
2969 TestGenerateTap(application, 3.0f, 25.0f, 100);
2971 // Render and notify
2972 application.SendNotification();
2973 application.Render();
2975 // Double tap to select a word.
2976 TestGenerateTap(application, 3.0f, 25.0f, 200);
2978 // Render and notify
2979 application.SendNotification();
2980 application.Render();
2982 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2983 Actor stencil = field.GetChildAt(0u);
2985 // The highlight actor is drawn first, so is the first actor in the list
2986 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2987 DALI_TEST_CHECK(highlight);
2989 // The offscreen root actor has a container with all the actors which contain the text renderers.
2990 Actor container = stencil.GetChildAt(1u);
2991 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2993 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2994 DALI_TEST_CHECK(renderer);
3000 int utcDaliTextFieldEvent04(void)
3002 ToolkitTestApplication application;
3003 tet_infoline(" utcDaliTextFieldEvent04");
3005 // Checks if the highlight actor is created.
3007 TextField field = TextField::New();
3008 DALI_TEST_CHECK(field);
3009 application.GetScene().Add(field);
3010 LoadMarkerImages(application, field);
3011 // Render and notify
3012 application.SendNotification();
3013 application.Render();
3015 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
3016 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3017 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3018 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3019 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3021 // Avoid a crash when core load gl resources.
3022 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3023 // Render and notify
3024 application.SendNotification();
3025 application.Render();
3027 // Create a tap event to touch the text field.
3028 TestGenerateTap(application, 150.0f, 25.0f);
3029 // Render and notify
3030 application.SendNotification();
3031 application.Render();
3033 // Tap first to get the focus.
3034 TestGenerateTap(application, 1.0f, 25.0f);
3036 // Render and notify
3037 application.SendNotification();
3038 application.Render();
3040 // Double tap to select a word.
3041 TestGenerateTap(application, 1.0f, 25.0f);
3043 // Render and notify
3044 application.SendNotification();
3045 application.Render();
3048 TestGenerateTap(application, 0.0f, 40.0f);
3050 field.SetProperty(TextField::Property::POINT_SIZE, 12.f);
3051 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3056 int utcDaliTextFieldEvent05(void)
3058 ToolkitTestApplication application;
3059 tet_infoline(" utcDaliTextFieldEvent05");
3061 // Checks dragging of cursor/grab handle
3063 TextField field = TextField::New();
3064 DALI_TEST_CHECK(field);
3065 application.GetScene().Add(field);
3066 LoadMarkerImages(application, field);
3067 // Render and notify
3068 application.SendNotification();
3069 application.Render();
3071 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
3072 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3073 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3074 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3075 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3077 // Avoid a crash when core load gl resources.
3078 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3079 // Render and notify
3080 application.SendNotification();
3081 application.Render();
3083 // Create a tap event to touch the text field.
3084 TestGenerateTap(application, 150.0f, 25.0f);
3085 // Render and notify
3086 application.SendNotification();
3087 application.Render();
3089 // Tap first to get the focus.
3090 TestGenerateTap(application, 1.0f, 25.0f);
3092 // Render and notify
3093 application.SendNotification();
3094 application.Render();
3096 // Double tap to select a word.
3097 TestGenerateTap(application, 1.0f, 25.0f);
3099 // Render and notify
3100 application.SendNotification();
3101 application.Render();
3103 Actor stencil = field.GetChildAt(1u);
3107 int utcDaliTextFieldEvent06(void)
3109 ToolkitTestApplication application;
3110 tet_infoline(" utcDaliTextFieldEvent06");
3112 // Checks Longpress when in edit mode
3114 TextField field = TextField::New();
3115 DALI_TEST_CHECK(field);
3116 application.GetScene().Add(field);
3117 LoadMarkerImages(application, field);
3118 // Render and notify
3119 application.SendNotification();
3120 application.Render();
3122 field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
3123 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3124 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3125 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3126 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3128 // Avoid a crash when core load gl resources.
3129 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3130 // Render and notify
3131 application.SendNotification();
3132 application.Render();
3134 // Create a tap event to touch the text field.
3135 TestGenerateTap(application, 150.0f, 25.0f);
3136 // Render and notify
3137 application.SendNotification();
3138 application.Render();
3140 // Tap first to get the focus.
3141 TestGenerateTap(application, 1.0f, 25.0f);
3143 // Render and notify
3144 application.SendNotification();
3145 application.Render();
3148 TestGenerateLongPress(application, 1.0f, 25.0f);
3150 // Render and notify
3151 application.SendNotification();
3152 application.Render();
3157 int utcDaliTextFieldEvent07(void)
3159 ToolkitTestApplication application;
3160 tet_infoline(" utcDaliTextFieldEvent07");
3162 // Checks Longpress to start edit mode
3164 TextField field = TextField::New();
3165 DALI_TEST_CHECK(field);
3166 application.GetScene().Add(field);
3167 LoadMarkerImages(application, field);
3168 // Render and notify
3169 application.SendNotification();
3170 application.Render();
3172 field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
3173 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3174 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3175 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3176 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3177 Property::Map propertyMap;
3178 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
3179 field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
3181 // Avoid a crash when core load gl resources.
3182 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3183 // Render and notify
3184 application.SendNotification();
3185 application.Render();
3188 TestGenerateLongPress(application, 1.0f, 25.0f);
3190 // Render and notify
3191 application.SendNotification();
3192 application.Render();
3197 int utcDaliTextFieldEvent08(void)
3199 ToolkitTestApplication application;
3200 tet_infoline(" utcDaliTextFieldEvent08");
3202 Dali::Clipboard clipboard = Clipboard::Get();
3203 Dali::Clipboard::ClipData data("text/plain;charset=utf-8", "testTextFieldEvent");
3204 clipboard.SetData(data);
3206 // Checks Longpress when only place holder text
3208 TextField field = TextField::New();
3209 DALI_TEST_CHECK(field);
3210 application.GetScene().Add(field);
3211 LoadMarkerImages(application, field);
3212 // Render and notify
3213 application.SendNotification();
3214 application.Render();
3216 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
3217 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3218 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3219 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3220 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3222 // Avoid a crash when core load gl resources.
3223 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3224 // Render and notify
3225 application.SendNotification();
3226 application.Render();
3229 TestGenerateLongPress(application, 1.0f, 25.0f, 20);
3231 // Render and notify
3232 application.SendNotification();
3233 application.Render();
3235 Wait(application, 500);
3237 TestEndLongPress(application, 1.0f, 25.0f, 520);
3240 TestGenerateLongPress(application, 1.0f, 25.0f, 600);
3242 // Render and notify
3243 application.Render();
3245 Wait(application, 500);
3247 Integration::Scene stage = application.GetScene();
3248 Layer layer = stage.GetRootLayer();
3249 Actor actor = layer.FindChildByName("optionPaste");
3253 Vector3 worldPosition = actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION);
3254 Vector2 halfStageSize = stage.GetSize() / 2.0f;
3255 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
3257 Dali::Integration::TouchEvent event;
3258 event = Dali::Integration::TouchEvent();
3259 event.AddPoint(GetPointDownInside(position));
3260 application.ProcessEvent(event);
3262 event = Dali::Integration::TouchEvent();
3263 event.AddPoint(GetPointUpInside(position));
3264 application.ProcessEvent(event);
3266 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("testTextFieldEvent"), TEST_LOCATION);
3268 Dali::Clipboard::ClipData htmlData("application/xhtml+xml", "testTextFieldEventHtml");
3269 clipboard.SetData(htmlData);
3271 field.SetProperty(TextField::Property::TEXT, "");
3273 // Render and notify
3274 application.SendNotification();
3275 application.Render();
3278 TestGenerateLongPress(application, 1.0f, 25.0f, 20);
3280 // Render and notify
3281 application.SendNotification();
3282 application.Render();
3284 Wait(application, 500);
3286 TestEndLongPress(application, 1.0f, 25.0f, 520);
3289 TestGenerateLongPress(application, 1.0f, 25.0f, 600);
3291 // Render and notify
3292 application.Render();
3294 Wait(application, 500);
3296 stage = application.GetScene();
3297 layer = stage.GetRootLayer();
3298 actor = layer.FindChildByName("optionPaste");
3302 Vector3 worldPosition = actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION);
3303 Vector2 halfStageSize = stage.GetSize() / 2.0f;
3304 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
3306 Dali::Integration::TouchEvent event;
3307 event = Dali::Integration::TouchEvent();
3308 event.AddPoint(GetPointDownInside(position));
3309 application.ProcessEvent(event);
3311 event = Dali::Integration::TouchEvent();
3312 event.AddPoint(GetPointUpInside(position));
3313 application.ProcessEvent(event);
3315 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("testTextFieldEventHtml"), TEST_LOCATION);
3320 int utcDaliTextFieldEvent09(void)
3322 ToolkitTestApplication application;
3323 tet_infoline(" utcDaliTextFieldEvent09");
3325 TextField field = TextField::New();
3326 DALI_TEST_CHECK(field);
3327 application.GetScene().Add(field);
3328 LoadMarkerImages(application, field);
3329 // Render and notify
3330 application.SendNotification();
3331 application.Render();
3333 field.SetProperty(TextField::Property::TEXT, "Hello");
3334 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Placeholder text");
3335 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3336 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3337 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3338 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3340 // Avoid a crash when core load gl resources.
3341 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3343 // Create a tap event to touch the text field.
3344 TestGenerateTap(application, 150.0f, 25.0f);
3345 application.SendNotification();
3346 application.Render();
3349 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_NONE;
3350 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3351 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3352 application.SendNotification();
3353 application.Render();
3354 for(unsigned int index = 0u; index < 6u; ++index)
3356 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3357 application.SendNotification();
3358 application.Render();
3361 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL;
3362 map[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
3363 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3364 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3365 application.SendNotification();
3366 application.Render();
3368 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_COUNT;
3369 map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
3370 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3371 for(unsigned int index = 0u; index < 5u; ++index)
3373 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3374 application.SendNotification();
3375 application.Render();
3378 map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_COUNT;
3379 map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
3380 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3381 for(unsigned int index = 0u; index < 5u; ++index)
3383 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3384 application.SendNotification();
3385 application.Render();
3388 map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
3389 map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 0;
3390 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3391 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3392 application.SendNotification();
3393 application.Render();
3394 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3395 application.SendNotification();
3396 application.Render();
3398 map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 100;
3399 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3400 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3401 application.SendNotification();
3402 application.Render();
3404 Property::Map mapGet;
3405 mapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
3406 DALI_TEST_EQUALS(map.Count(), mapGet.Count(), TEST_LOCATION);
3407 DALI_TEST_EQUALS(DaliTestCheckMaps(map, mapGet), true, TEST_LOCATION);
3411 int utcDaliTextFieldStyleWhilstSelected(void)
3413 ToolkitTestApplication application;
3414 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
3416 // Change font and styles whilst text is selected whilst word selected
3418 TextField field = TextField::New();
3419 DALI_TEST_CHECK(field);
3420 application.GetScene().Add(field);
3421 LoadMarkerImages(application, field);
3422 // Render and notify
3423 application.SendNotification();
3424 application.Render();
3426 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
3427 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3428 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3429 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3430 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3432 // Avoid a crash when core load gl resources.
3433 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3434 // Render and notify
3435 application.SendNotification();
3436 application.Render();
3438 // Create a tap event to touch the text field.
3439 TestGenerateTap(application, 150.0f, 25.0f);
3440 // Render and notify
3441 application.SendNotification();
3442 application.Render();
3444 // Tap first to get the focus.
3445 TestGenerateTap(application, 1.0f, 25.0f);
3447 // Render and notify
3448 application.SendNotification();
3449 application.Render();
3451 // Double tap to select a word.
3452 TestGenerateTap(application, 1.0f, 25.0f);
3454 // Render and notify
3455 application.SendNotification();
3456 application.Render();
3458 field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
3459 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
3461 Property::Map fontStyleMapSet;
3462 Property::Map fontStyleMapGet;
3464 fontStyleMapSet.Insert("weight", "bold");
3465 fontStyleMapSet.Insert("slant", "italic");
3466 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
3468 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
3469 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3470 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3472 fontStyleMapSet.Clear();
3473 fontStyleMapSet.Insert("width", "expanded");
3474 fontStyleMapSet.Insert("slant", "italic");
3475 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
3477 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
3478 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3479 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3481 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
3482 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3484 field.SetProperty(TextField::Property::TEXT_COLOR, Color::RED);
3485 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::RED, TEST_LOCATION);
3487 fontStyleMapSet.Clear();
3488 fontStyleMapSet.Insert("weight", "bold");
3489 fontStyleMapSet.Insert("slant", "italic");
3491 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
3493 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3494 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3495 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3497 fontStyleMapSet.Clear();
3498 fontStyleMapSet.Insert("width", "expanded");
3500 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
3502 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3503 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3504 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3506 // Press Escape to increase coverage
3507 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3508 application.SendNotification();
3509 application.Render();
3511 DALI_TEST_CHECK(!field.HasKeyInputFocus());
3516 int utcDaliTextFieldEscKeyLoseFocus(void)
3518 ToolkitTestApplication application;
3519 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
3521 // Creates a tap event. After creating a tap event the text field should
3522 // have the focus and add text with key events should be possible.
3524 TextField field = TextField::New();
3525 DALI_TEST_CHECK(field);
3527 application.GetScene().Add(field);
3529 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3530 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3531 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3533 // Avoid a crash when core load gl resources.
3534 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3536 // Render and notify
3537 application.SendNotification();
3538 application.Render();
3540 // Add a key event but as the text field has not the focus it should do nothing.
3541 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3542 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3544 // Render and notify
3545 application.SendNotification();
3546 application.Render();
3548 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
3550 // Create a tap event to touch the text field.
3551 TestGenerateTap(application, 150.0f, 25.0f);
3553 // Render and notify
3554 application.SendNotification();
3555 application.Render();
3557 // Now the text field has the focus, so it can handle the key events.
3558 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3559 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3560 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3561 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3563 // Render and notify
3564 application.SendNotification();
3565 application.Render();
3567 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3569 // Generate a Esc key event. The text field should lose the focus.
3570 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3571 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3573 // Render and notify
3574 application.SendNotification();
3575 application.Render();
3577 DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
3579 // No more text should be introduced
3580 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3581 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3583 // Render and notify
3584 application.SendNotification();
3585 application.Render();
3587 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3592 int utcDaliTextFieldSomeSpecialKeys(void)
3594 ToolkitTestApplication application;
3595 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
3597 // Checks some special keys when the text is selected.
3599 TextField field = TextField::New();
3600 DALI_TEST_CHECK(field);
3601 application.GetScene().Add(field);
3602 LoadMarkerImages(application, field);
3603 // Render and notify
3604 application.SendNotification();
3605 application.Render();
3607 const std::string longText("This is a long text for the size of the text-field.");
3609 field.SetProperty(TextField::Property::TEXT, longText);
3610 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3611 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3612 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3613 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3615 // Avoid a crash when core load gl resources.
3616 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3617 // Render and notify
3618 application.SendNotification();
3619 application.Render();
3621 // Create a tap event to touch the text field.
3622 TestGenerateTap(application, 150.0f, 25.0f);
3624 // Render and notify
3625 application.SendNotification();
3626 application.Render();
3628 // Tap first to get the focus.
3629 TestGenerateTap(application, 1.0f, 25.0f);
3631 // Render and notify
3632 application.SendNotification();
3633 application.Render();
3635 // Double tap to select a word.
3636 TestGenerateTap(application, 1.0f, 25.0f);
3638 // Render and notify
3639 application.SendNotification();
3640 application.Render();
3642 // Generate a Esc key event. The text field should lose the focus.
3643 application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3644 application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3646 // Render and notify
3647 application.SendNotification();
3648 application.Render();
3650 // Generate a Esc key event. The text field should lose the focus.
3651 application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3652 application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3654 // Render and notify
3655 application.SendNotification();
3656 application.Render();
3658 // Generate a Esc key event. The text field should lose the focus.
3659 application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3660 application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3662 // Render and notify
3663 application.SendNotification();
3664 application.Render();
3666 // Generate a Back key event. Nothing happens to the text field.
3667 application.ProcessEvent(GenerateKey("XF86Back", "", "XF86Back", DALI_KEY_BACK, 0, 0, Integration::KeyEvent::DOWN, "XF86Back", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3668 application.ProcessEvent(GenerateKey("XF86Back", "", "XF86Back", DALI_KEY_BACK, 0, 0, Integration::KeyEvent::UP, "XF86Back", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3670 // Render and notify
3671 application.SendNotification();
3672 application.Render();
3674 // The text shouldn't be deleted.
3675 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), longText, TEST_LOCATION);
3680 int utcDaliTextFieldSizeUpdate(void)
3682 ToolkitTestApplication application;
3683 tet_infoline("utcDaliTextFieldSizeUpdate");
3685 // Checks some special keys when the text is selected.
3686 TextField field = TextField::New();
3687 DALI_TEST_CHECK(field);
3688 application.GetScene().Add(field);
3690 float previousHeight = 0.0f;
3691 float currentHeight = 0.0f;
3692 const float fieldWidth = 1920.0f;
3694 // "ㅁ" is bigger then "ኢ"
3695 field.SetProperty(Actor::Property::SIZE, Vector2(fieldWidth, 10.0f));
3696 field.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3697 field.SetResizePolicy(ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT);
3699 field.SetProperty(TextField::Property::TEXT, "ኢ");
3700 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3701 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3703 field.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
3704 KeyboardFocusManager::Get().SetCurrentFocusActor(field);
3706 application.SendNotification();
3707 application.Render();
3709 previousHeight = field.GetHeightForWidth(fieldWidth);
3710 DALI_TEST_EQUALS(previousHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3712 // Add another script characters ( glyph height is defferent )
3713 application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3714 application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3716 application.SendNotification();
3717 application.Render();
3719 currentHeight = field.GetHeightForWidth(fieldWidth);
3720 DALI_TEST_EQUALS(currentHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3721 DALI_TEST_EQUALS((previousHeight < currentHeight), true, TEST_LOCATION);
3726 int utcDaliTextFieldExtremlyLargePointSize(void)
3728 ToolkitTestApplication application;
3729 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
3731 TextField field = TextField::New();
3733 field.SetProperty(TextField::Property::TEXT, "Text");
3734 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3735 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3736 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3737 application.GetScene().Add(field);
3741 field.SetProperty(TextField::Property::POINT_SIZE, 160.0f);
3742 application.SendNotification();
3743 DALI_TEST_CHECK(field);
3747 tet_result(TET_FAIL);
3752 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
3754 ToolkitTestApplication application;
3755 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
3756 TextField field = TextField::New();
3757 DALI_TEST_CHECK(field);
3758 application.GetScene().Add(field);
3760 Property::Map fontStyleMapGet;
3762 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3764 Property::Value* weightValue = NULL;
3765 Property::Value* widthValue = NULL;
3766 Property::Value* slantValue = NULL;
3767 weightValue = fontStyleMapGet.Find("weight");
3768 widthValue = fontStyleMapGet.Find("width");
3769 slantValue = fontStyleMapGet.Find("slant");
3770 DALI_TEST_CHECK(!weightValue);
3771 DALI_TEST_CHECK(!widthValue);
3772 DALI_TEST_CHECK(!slantValue);
3777 int UtcDaliTextFieldSettingPlaceholder(void)
3779 ToolkitTestApplication application;
3780 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
3782 TextField field = TextField::New();
3783 DALI_TEST_CHECK(field);
3784 application.GetScene().Add(field);
3786 // Check the placeholder property with pixel size
3787 Property::Map placeholderPixelSizeMapSet;
3788 Property::Map placeholderPixelSizeMapGet;
3789 Property::Map placeholderFontstyleMap;
3790 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT] = "Setting Placeholder Text";
3791 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3792 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::COLOR] = Color::BLUE;
3793 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3794 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3795 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::ELLIPSIS] = true;
3797 placeholderFontstyleMap.Insert("weight", "bold");
3798 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3799 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
3801 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3802 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
3803 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderPixelSizeMapSet), true, TEST_LOCATION);
3805 // Check the placeholder property with point size
3806 Property::Map placeholderMapSet;
3807 Property::Map placeholderMapGet;
3808 placeholderMapSet[Text::PlaceHolder::Property::TEXT] = "Setting Placeholder Text";
3809 placeholderMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3810 placeholderMapSet[Text::PlaceHolder::Property::COLOR] = Color::RED;
3811 placeholderMapSet[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3812 placeholderMapSet[Text::PlaceHolder::Property::POINT_SIZE] = 12.0f;
3813 placeholderMapSet[Text::PlaceHolder::Property::ELLIPSIS] = false;
3815 // Check the placeholder font style property
3816 placeholderFontstyleMap.Clear();
3818 placeholderFontstyleMap.Insert("weight", "bold");
3819 placeholderFontstyleMap.Insert("width", "condensed");
3820 placeholderFontstyleMap.Insert("slant", "italic");
3821 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3822 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3824 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3825 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3826 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3828 // Reset font style.
3829 placeholderFontstyleMap.Clear();
3830 placeholderFontstyleMap.Insert("weight", "normal");
3831 placeholderFontstyleMap.Insert("slant", "oblique");
3832 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3833 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3835 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3836 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3837 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3839 placeholderFontstyleMap.Clear();
3840 placeholderFontstyleMap.Insert("slant", "roman");
3841 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3842 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3844 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3846 placeholderFontstyleMap.Clear();
3847 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3849 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3850 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3851 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3852 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3857 int UtcDaliTextFieldPlaceholderCoverage(void)
3859 ToolkitTestApplication application;
3860 tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
3862 // mPlaceholderFont is created only once, so create a new control for coverage.
3863 TextField fieldForCoverage = TextField::New();
3864 DALI_TEST_CHECK(fieldForCoverage);
3865 application.GetScene().Add(fieldForCoverage);
3867 // for SetPlaceholderFontFamily() coverage.
3868 Property::Map fontFamilyMap;
3869 fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3870 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
3872 // mPlaceholderFont is created only once, so create a new control for coverage.
3873 fieldForCoverage = TextField::New();
3874 DALI_TEST_CHECK(fieldForCoverage);
3875 application.GetScene().Add(fieldForCoverage);
3877 // for SetPlaceholderTextFontSize coverage.
3878 Property::Map fontSizeMap;
3879 fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3880 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
3882 // mPlaceholderFont is created only once, so create a new control for coverage.
3883 fieldForCoverage = TextField::New();
3884 DALI_TEST_CHECK(fieldForCoverage);
3885 application.GetScene().Add(fieldForCoverage);
3887 // for SetPlaceholderTextFontWeight coverage.
3888 Property::Map fontStyleWeightMap;
3889 Property::Map fontStyleWeightPropertyMap;
3890 fontStyleWeightPropertyMap.Insert("weight", "bold");
3891 fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
3892 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
3894 // mPlaceholderFont is created only once, so create a new control for coverage.
3895 fieldForCoverage = TextField::New();
3896 DALI_TEST_CHECK(fieldForCoverage);
3897 application.GetScene().Add(fieldForCoverage);
3899 // for SetPlaceholderTextFontWidth coverage.
3900 Property::Map fontStyleWidthMap;
3901 Property::Map fontStyleWidthPropertyMap;
3902 fontStyleWidthPropertyMap.Insert("width", "expanded");
3903 fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
3904 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
3906 // mPlaceholderFont is created only once, so create a new control for coverage.
3907 fieldForCoverage = TextField::New();
3908 DALI_TEST_CHECK(fieldForCoverage);
3909 application.GetScene().Add(fieldForCoverage);
3911 // for SetPlaceholderTextFontSlant coverage.
3912 Property::Map fontStyleSlantMap;
3913 Property::Map fontStyleSlantPropertyMap;
3914 fontStyleSlantPropertyMap.Insert("slant", "italic");
3915 fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
3916 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
3921 int UtcDaliTextFieldSetPaddingProperty(void)
3923 ToolkitTestApplication application;
3924 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3926 TextField field = TextField::New();
3927 DALI_TEST_CHECK(field);
3928 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3929 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3930 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3931 application.GetScene().Add(field);
3933 application.SendNotification();
3934 application.Render();
3936 Vector3 originalSize = field.GetNaturalSize();
3938 field.SetProperty(Toolkit::Control::Property::PADDING, Extents(10, 10, 10, 10));
3940 application.SendNotification();
3941 application.Render();
3943 DALI_TEST_EQUALS(field.GetProperty<Extents>(Toolkit::Control::Property::PADDING), Extents(10, 10, 10, 10), TEST_LOCATION);
3945 Vector3 paddingAddedSize = field.GetNaturalSize();
3947 DALI_TEST_EQUALS(originalSize.width + 10 + 10, paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3949 DALI_TEST_EQUALS(originalSize.height + 10 + 10, paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3954 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3956 ToolkitTestApplication application;
3957 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3959 TextField field = TextField::New();
3960 DALI_TEST_CHECK(field);
3961 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3962 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3963 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3964 application.GetScene().Add(field);
3966 application.SendNotification();
3967 application.Render();
3969 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3970 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), true, TEST_LOCATION);
3972 // Check the enable shift selection property
3973 field.SetProperty(DevelTextField::Property::ENABLE_SHIFT_SELECTION, false);
3974 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), false, TEST_LOCATION);
3976 application.SendNotification();
3977 application.Render();
3982 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3984 ToolkitTestApplication application;
3985 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3987 TextField field = TextField::New();
3988 DALI_TEST_CHECK(field);
3989 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3990 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3991 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3992 application.GetScene().Add(field);
3994 application.SendNotification();
3995 application.Render();
3997 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3998 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), true, TEST_LOCATION);
4000 // Check the enable grab handle property
4001 field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE, false);
4002 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), false, TEST_LOCATION);
4004 application.SendNotification();
4005 application.Render();
4010 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
4012 ToolkitTestApplication application;
4013 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
4015 TextField field = TextField::New();
4016 DALI_TEST_CHECK(field);
4017 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4018 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4019 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4020 application.GetScene().Add(field);
4022 application.SendNotification();
4023 application.Render();
4025 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
4026 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), true, TEST_LOCATION);
4028 // Check the match system language direction property
4029 field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
4030 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), false, TEST_LOCATION);
4032 application.SendNotification();
4033 application.Render();
4038 int utcDaliTextFieldLayoutDirectionCoverage(void)
4040 ToolkitTestApplication application;
4041 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
4043 // Creates a tap event. After creating a tap event the text field should
4044 // have the focus and add text with key events should be possible.
4045 TextField field = TextField::New();
4046 DALI_TEST_CHECK(field);
4048 application.GetScene().Add(field);
4050 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4051 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4052 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4054 // Avoid a crash when core load gl resources.
4055 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4057 // Render and notify
4058 application.SendNotification();
4059 application.Render();
4061 // init direction for coverage
4062 // Set horizontal alignment END
4063 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
4065 // Create a tap event to touch the text field.
4066 TestGenerateTap(application, 150.0f, 25.0f);
4068 // Render and notify
4069 application.SendNotification();
4070 application.Render();
4072 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
4073 field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true);
4074 field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
4076 // Set horizontal alignment BEGIN
4077 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
4079 // Create a tap event to touch the text field.
4080 TestGenerateTap(application, 150.0f, 25.0f);
4082 // Render and notify
4083 application.SendNotification();
4084 application.Render();
4086 // Set horizontal alignment CENTER
4087 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
4089 // Create a tap event to touch the text field.
4090 TestGenerateTap(application, 150.0f, 25.0f);
4092 // Render and notify
4093 application.SendNotification();
4094 application.Render();
4096 // Set horizontal alignment END
4097 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
4099 // Create a tap event to touch the text field.
4100 TestGenerateTap(application, 150.0f, 25.0f);
4102 // Render and notify
4103 application.SendNotification();
4104 application.Render();
4106 // Generate a Esc key event. The text field should lose the focus.
4107 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4108 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4110 // Render and notify
4111 application.SendNotification();
4112 application.Render();
4114 DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
4119 int UtcDaliTextFieldGetInputMethodContext(void)
4121 ToolkitTestApplication application;
4122 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
4124 TextField field = TextField::New();
4125 DALI_TEST_CHECK(DevelTextField::GetInputMethodContext(field));
4130 int UtcDaliTextFieldSelectWholeText(void)
4132 ToolkitTestApplication application;
4133 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
4135 TextField textField = TextField::New();
4137 application.GetScene().Add(textField);
4139 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4140 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4141 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4143 // Avoid a crash when core load gl resources.
4144 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4146 application.SendNotification();
4147 application.Render();
4149 DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
4151 DevelTextField::SelectWholeText(textField);
4153 application.SendNotification();
4154 application.Render();
4156 // Nothing should have been selected. The number of children is still 1
4157 DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
4159 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4161 application.SendNotification();
4162 application.Render();
4164 DevelTextField::SelectWholeText(textField);
4166 application.SendNotification();
4167 application.Render();
4169 // Even if resize, selection should remain.
4170 textField.SetProperty(Actor::Property::SIZE, Vector2(150.f, 50.f));
4172 application.SendNotification();
4173 application.Render();
4175 // Should be 2 children, the stencil and the layer
4176 DALI_TEST_EQUALS(2u, textField.GetChildCount(), TEST_LOCATION);
4178 // The offscreen root actor should have two actors: the renderer and the highlight actor.
4179 Actor stencil = textField.GetChildAt(0u);
4181 // The highlight actor is drawn first, so is the first actor in the list
4182 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
4183 DALI_TEST_CHECK(highlight);
4188 int UtcDaliTextFieldSelectText(void)
4190 ToolkitTestApplication application;
4191 tet_infoline(" UtcDaliTextFieldSelectText ");
4193 TextField textField = TextField::New();
4195 application.GetScene().Add(textField);
4197 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4198 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4199 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4201 // Avoid a crash when core load gl resources.
4202 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4204 application.SendNotification();
4205 application.Render();
4207 DevelTextField::SelectText(textField, 0, 5);
4209 application.SendNotification();
4210 application.Render();
4212 // Nothing is selected
4213 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4214 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
4216 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4218 application.SendNotification();
4219 application.Render();
4221 // Hello is selected
4222 DevelTextField::SelectText(textField, 0, 5);
4224 application.SendNotification();
4225 application.Render();
4227 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4228 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4230 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4231 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4233 // world is selected
4234 DevelTextField::SelectText(textField, 6, 11);
4236 application.SendNotification();
4237 application.Render();
4239 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4240 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4242 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4243 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4248 int UtcDaliTextFieldSelectNone(void)
4250 ToolkitTestApplication application;
4251 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
4253 TextField textField = TextField::New();
4255 application.GetScene().Add(textField);
4257 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4258 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4259 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4261 // Avoid a crash when core load gl resources.
4262 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4264 application.SendNotification();
4265 application.Render();
4267 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4269 application.SendNotification();
4270 application.Render();
4272 // Nothing is selected
4273 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4274 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
4276 DevelTextField::SelectWholeText(textField);
4278 application.SendNotification();
4279 application.Render();
4281 // whole text is selected
4282 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4283 DALI_TEST_EQUALS("Hello world", selectedText, TEST_LOCATION);
4285 DevelTextField::SelectNone(textField);
4287 application.SendNotification();
4288 application.Render();
4290 // Nothing is selected
4291 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4292 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
4297 int UtcDaliTextFieldSelectRange(void)
4299 ToolkitTestApplication application;
4300 tet_infoline(" UtcDaliTextFieldSelectRange ");
4302 TextField textField = TextField::New();
4304 application.GetScene().Add(textField);
4306 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4307 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4308 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4310 // Avoid a crash when core load gl resources.
4311 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4313 application.SendNotification();
4314 application.Render();
4316 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4318 application.SendNotification();
4319 application.Render();
4321 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 0);
4322 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 5);
4324 // Hello is selected
4325 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4326 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4328 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4329 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4331 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 6);
4332 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 11);
4334 // world is selected
4335 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4336 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4338 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4339 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4344 int UtcDaliTextFieldEnableEditing(void)
4346 ToolkitTestApplication application;
4347 tet_infoline(" UtcDaliTextFieldEnableEditing ");
4349 TextField textField = TextField::New();
4351 application.GetScene().Add(textField);
4353 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4354 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4355 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4357 // Avoid a crash when core load gl resources.
4358 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4360 application.SendNotification();
4361 application.Render();
4363 textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
4364 DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), true, TEST_LOCATION);
4366 textField.SetKeyInputFocus();
4367 textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, false);
4368 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4370 // Render and notify
4371 application.SendNotification();
4372 application.Render();
4374 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "", TEST_LOCATION);
4375 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), false, TEST_LOCATION);
4377 textField.SetKeyInputFocus();
4378 textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
4379 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4381 // Render and notify
4382 application.SendNotification();
4383 application.Render();
4385 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
4386 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), true, TEST_LOCATION);
4388 // Check the user interaction enabled and for coverage
4389 DevelTextField::SelectWholeText(textField);
4391 // Render and notify
4392 application.SendNotification();
4393 application.Render();
4395 textField.SetKeyInputFocus();
4396 textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false);
4397 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4399 // Render and notify
4400 application.SendNotification();
4401 application.Render();
4403 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
4404 DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), false, TEST_LOCATION);
4409 int UtcDaliToolkitTextFieldFontSizeScale(void)
4411 ToolkitTestApplication application;
4412 tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
4414 TextField textField = TextField::New();
4415 textField.SetProperty(TextField::Property::POINT_SIZE, 30.f);
4416 textField.SetProperty(TextField::Property::TEXT, "Test");
4417 Vector3 nonScaledSize = textField.GetNaturalSize();
4419 TextField textFieldScaled = TextField::New();
4420 textFieldScaled.SetProperty(TextField::Property::POINT_SIZE, 15.f);
4421 textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
4422 textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
4423 Vector3 scaledSize = textFieldScaled.GetNaturalSize();
4425 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4427 textField.SetProperty(TextField::Property::PIXEL_SIZE, 30.f);
4428 textField.SetProperty(TextField::Property::TEXT, "Test");
4429 nonScaledSize = textField.GetNaturalSize();
4431 textFieldScaled.SetProperty(TextField::Property::PIXEL_SIZE, 15.f);
4432 textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
4433 textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
4434 scaledSize = textFieldScaled.GetNaturalSize();
4436 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4441 int UtcDaliTextFieldPrimaryCursorPosition(void)
4443 ToolkitTestApplication application;
4444 tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
4446 TextField textField = TextField::New();
4448 application.GetScene().Add(textField);
4450 textField.SetProperty(TextField::Property::TEXT, "ABCEF");
4451 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4452 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4453 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4455 // Avoid a crash when core load gl resources.
4456 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4458 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4459 application.SendNotification();
4460 application.Render();
4461 textField.SetKeyInputFocus();
4463 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4465 // Render and notify
4466 application.SendNotification();
4467 application.Render();
4469 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCDEF", TEST_LOCATION);
4470 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
4475 // test max length when set after setting long text
4476 int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
4478 ToolkitTestApplication application;
4479 tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
4480 TextField field = TextField::New();
4481 DALI_TEST_CHECK(field);
4483 application.GetScene().Add(field);
4485 field.SetProperty(TextField::Property::TEXT, "123456789");
4487 const int maxNumberOfCharacters = 3;
4488 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
4490 field.SetKeyInputFocus();
4492 // connect to the text max lengh reached signal.
4493 ConnectionTracker* testTracker = new ConnectionTracker();
4494 bool maxLengthReachedSignal = false;
4495 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
4497 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4498 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4500 DALI_TEST_CHECK(maxLengthReachedSignal);
4502 DALI_TEST_EQUALS(field.GetProperty(TextField::Property::TEXT).Get<std::string>(), "123456789", TEST_LOCATION);
4507 int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
4509 ToolkitTestApplication application;
4510 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
4512 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4513 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4514 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4516 // Create a text field
4517 TextField textField = TextField::New();
4519 //Set size to avoid automatic eliding
4520 textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4521 //Set very large font-size using point-size
4522 textField.SetProperty(TextField::Property::POINT_SIZE, 1000);
4523 //Specify font-family
4524 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4525 //Set text to check if appear or not
4526 textField.SetProperty(TextField::Property::TEXT, "A");
4528 application.GetScene().Add(textField);
4530 application.SendNotification();
4531 application.Render();
4532 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4533 Vector3 naturalSize = textField.GetNaturalSize();
4535 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4536 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4541 int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
4543 ToolkitTestApplication application;
4544 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
4546 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4547 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4548 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4550 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4551 // Create a text editor
4552 TextField textField = TextField::New();
4554 //Set size to avoid automatic eliding
4555 textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4556 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4557 textField.SetProperty(TextField::Property::TEXT, "A");
4559 const int numberOfCases = 6;
4560 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
4562 for(int index = 0; index < numberOfCases; index++)
4564 tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
4565 textField.SetProperty(TextField::Property::POINT_SIZE, arrayCases[index]);
4566 application.GetScene().Add(textField);
4567 application.SendNotification();
4568 application.Render();
4569 naturalSize = textField.GetNaturalSize();
4570 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4571 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4577 int UtcDaliToolkitTextFieldEllipsisPositionProperty(void)
4579 ToolkitTestApplication application;
4580 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty ");
4581 TextField textField = TextField::New();
4583 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Default is END");
4584 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4586 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START");
4587 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4588 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4590 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE");
4591 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4592 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4594 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END");
4595 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4596 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4598 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START using integer");
4599 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 1);
4600 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4602 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE using integer");
4603 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 2);
4604 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4606 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END using integer");
4607 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 0);
4608 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4610 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4611 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "START");
4612 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4614 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4615 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "MIDDLE");
4616 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4618 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4619 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "END");
4620 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4622 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4623 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "start");
4624 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4626 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4627 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "middle");
4628 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4630 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4631 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "end");
4632 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4637 int UtcDaliTextFieldCopyText(void)
4639 ToolkitTestApplication application;
4640 tet_infoline(" UtcDaliTextFieldCopyText ");
4642 TextField textField = TextField::New();
4644 std::string selectedText = "";
4645 std::string copiedText = "";
4647 application.GetScene().Add(textField);
4649 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4650 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4651 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4653 // Avoid a crash when core load gl resources.
4654 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4656 application.SendNotification();
4657 application.Render();
4659 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4661 application.SendNotification();
4662 application.Render();
4664 // Hello is selected
4665 DevelTextField::SelectText(textField, 0, 5);
4667 application.SendNotification();
4668 application.Render();
4670 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4671 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4673 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4674 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4677 copiedText = DevelTextField::CopyText(textField);
4678 DALI_TEST_EQUALS("Hello", copiedText, TEST_LOCATION);
4680 // world is selected
4681 DevelTextField::SelectText(textField, 6, 11);
4683 application.SendNotification();
4684 application.Render();
4686 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4687 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4689 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4690 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4693 copiedText = DevelTextField::CopyText(textField);
4694 DALI_TEST_EQUALS("world", copiedText, TEST_LOCATION);
4696 // "lo wo" is selected
4697 DevelTextField::SelectText(textField, 3, 8);
4699 application.SendNotification();
4700 application.Render();
4702 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4703 DALI_TEST_EQUALS("lo wo", selectedText, TEST_LOCATION);
4705 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 3, TEST_LOCATION);
4706 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 8, TEST_LOCATION);
4708 // "lo wo" is copied
4709 copiedText = DevelTextField::CopyText(textField);
4710 DALI_TEST_EQUALS("lo wo", copiedText, TEST_LOCATION);
4715 int UtcDaliTextFieldCutText(void)
4717 ToolkitTestApplication application;
4718 tet_infoline(" UtcDaliTextFieldCutText ");
4720 TextField textField = TextField::New();
4722 std::string selectedText = "";
4724 application.GetScene().Add(textField);
4726 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4727 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4728 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4730 // Avoid a crash when core load gl resources.
4731 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4733 application.SendNotification();
4734 application.Render();
4736 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4738 application.SendNotification();
4739 application.Render();
4741 // Hello is selected
4742 DevelTextField::SelectText(textField, 0, 5);
4744 application.SendNotification();
4745 application.Render();
4747 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4748 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4750 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4751 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4754 DALI_TEST_EQUALS("Hello", DevelTextField::CutText(textField), TEST_LOCATION);
4756 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), " world", TEST_LOCATION);
4759 DevelTextField::SelectText(textField, 0, 2);
4761 application.SendNotification();
4762 application.Render();
4764 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4765 DALI_TEST_EQUALS(" w", selectedText, TEST_LOCATION);
4767 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4768 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4771 DALI_TEST_EQUALS(" w", DevelTextField::CutText(textField), TEST_LOCATION);
4773 application.SendNotification();
4774 application.Render();
4776 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "orld", TEST_LOCATION);
4778 // Test Cut from the middle
4781 DevelTextField::SelectText(textField, 1, 3);
4783 application.SendNotification();
4784 application.Render();
4786 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4787 DALI_TEST_EQUALS("rl", selectedText, TEST_LOCATION);
4789 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4790 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 3, TEST_LOCATION);
4793 DALI_TEST_EQUALS("rl", DevelTextField::CutText(textField), TEST_LOCATION);
4795 application.SendNotification();
4796 application.Render();
4798 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "od", TEST_LOCATION);
4800 // Test Cut from the end
4803 DevelTextField::SelectText(textField, 1, 2);
4805 application.SendNotification();
4806 application.Render();
4808 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4809 DALI_TEST_EQUALS("d", selectedText, TEST_LOCATION);
4811 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4812 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4815 DALI_TEST_EQUALS("d", DevelTextField::CutText(textField), TEST_LOCATION);
4817 application.SendNotification();
4818 application.Render();
4820 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "o", TEST_LOCATION);
4825 int UtcDaliTextFieldPasteText(void)
4827 ToolkitTestApplication application;
4828 tet_infoline(" UtcDaliTextFieldPasteText ");
4830 TextField textField = TextField::New();
4832 application.GetScene().Add(textField);
4834 std::string cutText = "";
4835 std::string copiedText = "";
4837 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4838 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4839 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4841 // Avoid a crash when core load gl resources.
4842 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4844 application.SendNotification();
4845 application.Render();
4847 textField.SetProperty(TextField::Property::TEXT, "Hello World");
4849 application.SendNotification();
4850 application.Render();
4852 // Tap on the text editor
4853 TestGenerateTap(application, 3.0f, 25.0f);
4855 // Render and notify
4856 application.SendNotification();
4857 application.Render();
4859 // Select some text in the right of the current cursor position
4860 DevelTextField::SelectText(textField, 0, 3);
4862 // Render and notify
4863 application.SendNotification();
4864 application.Render();
4866 // Cut the selected text
4867 cutText = DevelTextField::CutText(textField);
4869 // Render and notify
4870 application.SendNotification();
4871 application.Render();
4873 DALI_TEST_EQUALS("Hel", cutText, TEST_LOCATION);
4874 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo World", TEST_LOCATION);
4876 DevelTextField::SelectText(textField, 0, 3);
4878 // Render and notify
4879 application.SendNotification();
4880 application.Render();
4882 // Copy the selected text
4883 copiedText = DevelTextField::CopyText(textField);
4885 // Render and notify
4886 application.SendNotification();
4887 application.Render();
4889 DALI_TEST_EQUALS("lo ", copiedText, TEST_LOCATION);
4890 DALI_TEST_EQUALS("lo World", textField.GetProperty<std::string>(TextField::Property::TEXT), TEST_LOCATION);
4892 // Move the cursor to the end of the line
4893 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4894 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4895 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4896 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4897 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4898 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4899 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4900 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4902 // Render and notify
4903 application.SendNotification();
4904 application.Render();
4906 // Paste the selected text at the current cursor position
4907 DevelTextField::PasteText(textField);
4909 // Render and notify
4910 application.SendNotification();
4911 application.Render();
4913 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo Worldlo ", TEST_LOCATION);
4918 int utcDaliTextFieldCursorPositionChangedSignal(void)
4920 ToolkitTestApplication application;
4921 tet_infoline(" utcDaliTextFieldCursorPositionChangedSignal");
4923 TextField field = TextField::New();
4924 DALI_TEST_CHECK(field);
4926 application.GetScene().Add(field);
4928 // connect to the selection changed signal.
4929 ConnectionTracker* testTracker = new ConnectionTracker();
4930 DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
4931 bool cursorPositionChangedSignal = false;
4932 field.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
4934 field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
4935 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4936 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4937 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4938 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4940 // Avoid a crash when core load gl resources.
4941 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4943 // Render and notify
4944 application.SendNotification();
4945 application.Render();
4947 field.SetKeyInputFocus();
4949 // Tap on the text field
4950 TestGenerateTap(application, 3.0f, 25.0f);
4952 // Render and notify
4953 application.SendNotification();
4954 application.Render();
4956 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4957 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4959 gCursorPositionChangedCallbackCalled = false;
4962 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4964 // Render and notify
4965 application.SendNotification();
4966 application.Render();
4968 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4969 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4971 gCursorPositionChangedCallbackCalled = false;
4974 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4976 // Render and notify
4977 application.SendNotification();
4978 application.Render();
4980 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4981 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4983 gCursorPositionChangedCallbackCalled = false;
4985 //delete one character
4986 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4988 // Render and notify
4989 application.SendNotification();
4990 application.Render();
4992 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4993 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4995 gCursorPositionChangedCallbackCalled = false;
4997 field.SetProperty(TextField::Property::TEXT, "Hello");
4999 // Render and notify
5000 application.SendNotification();
5001 application.Render();
5003 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5004 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
5006 gCursorPositionChangedCallbackCalled = false;
5008 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5010 // Render and notify
5011 application.SendNotification();
5012 application.Render();
5014 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5015 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
5020 int utcDaliTextFieldGeometryEllipsisStart(void)
5022 ToolkitTestApplication application;
5023 tet_infoline(" utcDaliTextFieldGeometryEllipsisStart");
5025 TextField field = TextField::New();
5026 DALI_TEST_CHECK(field);
5028 application.GetScene().Add(field);
5030 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5031 field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
5032 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5033 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5034 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5035 field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
5036 field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
5037 field.SetProperty(TextField::Property::TEXT, "Hello World");
5039 // Avoid a crash when core load gl resources.
5040 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5042 // Render and notify
5043 application.SendNotification();
5044 application.Render();
5046 unsigned int expectedCount = 1;
5047 unsigned int startIndex = 0;
5048 unsigned int endIndex = 10;
5050 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5051 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
5053 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5054 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5056 Vector<Vector2> expectedSizes;
5057 Vector<Vector2> expectedPositions;
5059 expectedPositions.PushBack(Vector2(14, 0));
5060 expectedSizes.PushBack(Vector2(107, 25));
5062 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5067 int utcDaliTextFieldGeometryEllipsisEnd(void)
5069 ToolkitTestApplication application;
5070 tet_infoline(" utcDaliTextFieldGeometryEllipsisEnd");
5072 TextField field = TextField::New();
5073 DALI_TEST_CHECK(field);
5075 application.GetScene().Add(field);
5077 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5078 field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
5079 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5080 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5081 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5082 field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
5083 field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
5084 field.SetProperty(TextField::Property::TEXT, "Hello World");
5086 // Avoid a crash when core load gl resources.
5087 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5089 // Render and notify
5090 application.SendNotification();
5091 application.Render();
5093 unsigned int expectedCount = 1;
5094 unsigned int startIndex = 0;
5095 unsigned int endIndex = 10;
5097 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5098 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
5100 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5101 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5103 Vector<Vector2> expectedSizes;
5104 Vector<Vector2> expectedPositions;
5106 expectedPositions.PushBack(Vector2(-2, 0));
5107 expectedSizes.PushBack(Vector2(123, 25));
5109 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5114 int utcDaliTextFieldGeometryRTL(void)
5116 ToolkitTestApplication application;
5117 tet_infoline(" utcDaliTextFieldGeometryRTL");
5119 TextField field = TextField::New();
5120 DALI_TEST_CHECK(field);
5122 application.GetScene().Add(field);
5124 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5125 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
5126 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5127 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5128 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5129 field.SetProperty(TextField::Property::TEXT, "السطر الاخير");
5131 // Avoid a crash when core load gl resources.
5132 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5134 // Render and notify
5135 application.SendNotification();
5136 application.Render();
5138 unsigned int expectedCount = 1;
5139 unsigned int startIndex = 1;
5140 unsigned int endIndex = 7;
5142 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5143 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
5145 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5146 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5148 Vector<Vector2> expectedSizes;
5149 Vector<Vector2> expectedPositions;
5151 expectedPositions.PushBack(Vector2(38, 0));
5152 expectedSizes.PushBack(Vector2(75, 25));
5154 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5159 int utcDaliTextFieldGeometryGlyphMiddle(void)
5161 ToolkitTestApplication application;
5162 tet_infoline(" utcDaliTextFieldGeometryGlyphMiddle");
5164 TextField field = TextField::New();
5165 DALI_TEST_CHECK(field);
5167 application.GetScene().Add(field);
5169 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5170 field.SetProperty(Actor::Property::SIZE, Vector2(150.f, 200.f));
5171 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5172 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5173 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5174 field.SetProperty(TextField::Property::TEXT, "لا تحتوي على لا");
5176 // Avoid a crash when core load gl resources.
5177 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5179 // Render and notify
5180 application.SendNotification();
5181 application.Render();
5183 unsigned int expectedCount = 1;
5184 unsigned int startIndex = 1;
5185 unsigned int endIndex = 13;
5187 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5188 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
5190 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5191 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5193 Vector<Vector2> expectedSizes;
5194 Vector<Vector2> expectedPositions;
5196 expectedPositions.PushBack(Vector2(6, 0));
5197 expectedSizes.PushBack(Vector2(125, 25));
5199 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5204 int utcDaliTextFieldGeometryNullPtr(void)
5206 ToolkitTestApplication application;
5207 tet_infoline("utcDaliTextFieldGeometryNullPtr");
5209 TextField field = TextField::New();
5210 DALI_TEST_CHECK(field);
5212 application.GetScene().Add(field);
5214 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5215 field.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
5216 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5217 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5218 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5219 field.SetProperty(TextField::Property::TEXT, "");
5221 // Avoid a crash when core load gl resources.
5222 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5224 unsigned int expectedCount = 0;
5225 unsigned int startIndex = 0;
5226 unsigned int endIndex = 0;
5228 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5229 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
5231 // Render and notify
5232 application.SendNotification();
5233 application.Render();
5235 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5236 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5241 int utcDaliTextFieldSelectionClearedSignal(void)
5243 ToolkitTestApplication application;
5244 tet_infoline(" utcDaliTextFieldSelectionClearedSignal");
5246 TextField field = TextField::New();
5247 DALI_TEST_CHECK(field);
5249 application.GetScene().Add(field);
5251 // connect to the selection changed signal.
5252 ConnectionTracker* testTracker = new ConnectionTracker();
5253 DevelTextField::SelectionClearedSignal(field).Connect(&TestSelectionClearedCallback);
5254 bool selectionClearedSignal = false;
5255 field.ConnectSignal(testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal));
5257 field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
5258 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5259 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5260 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5261 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5263 // Avoid a crash when core load gl resources.
5264 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5266 // Render and notify
5267 application.SendNotification();
5268 application.Render();
5270 // Tap on the text editor
5271 TestGenerateTap(application, 3.0f, 25.0f);
5273 // Render and notify
5274 application.SendNotification();
5275 application.Render();
5277 // Move to second line of the text & Select some text in the right of the current cursor position
5278 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5279 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5282 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5284 // Render and notify
5285 application.SendNotification();
5286 application.Render();
5288 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5290 // Render and notify
5291 application.SendNotification();
5292 application.Render();
5294 // Tap on the text editor
5295 TestGenerateTap(application, 3.0f, 25.0f);
5297 // Render and notify
5298 application.SendNotification();
5299 application.Render();
5301 gSelectionClearedCallbackCalled = false;
5303 // Move to second line of the text & select.
5304 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5305 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5308 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5310 // Render and notify
5311 application.SendNotification();
5312 application.Render();
5314 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5316 gSelectionClearedCallbackCalled = false;
5318 // Render and notify
5319 application.SendNotification();
5320 application.Render();
5322 // Move to second line of the text & select.
5323 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5324 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5326 // replace D with selected text
5327 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5329 // Render and notify
5330 application.SendNotification();
5331 application.Render();
5333 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5335 gSelectionClearedCallbackCalled = false;
5337 // Render and notify
5338 application.SendNotification();
5339 application.Render();
5341 DevelTextField::SelectText(field, 1, 3);
5343 // Render and notify
5344 application.SendNotification();
5345 application.Render();
5347 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5349 // Render and notify
5350 application.SendNotification();
5351 application.Render();
5353 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5355 gSelectionClearedCallbackCalled = false;
5357 DevelTextField::SelectText(field, 1, 3);
5359 // Render and notify
5360 application.SendNotification();
5361 application.Render();
5364 DevelTextField::SelectNone(field);
5366 // Render and notify
5367 application.SendNotification();
5368 application.Render();
5370 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5375 int utcDaliTextFieldSelectionStartedSignal(void)
5377 ToolkitTestApplication application;
5378 tet_infoline(" utcDaliTextFieldSelectionStartedSignal");
5380 TextField field = TextField::New();
5381 DALI_TEST_CHECK(field);
5383 application.GetScene().Add(field);
5385 // connect to the selection changed signal.
5386 ConnectionTracker* testTracker = new ConnectionTracker();
5387 DevelTextField::SelectionStartedSignal(field).Connect(&TestSelectionStartedCallback);
5388 bool selectionStartedSignal = false;
5389 field.ConnectSignal(testTracker, "selectionStarted", CallbackFunctor(&selectionStartedSignal));
5391 field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
5392 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5393 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5394 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5395 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5397 // Avoid a crash when core load gl resources.
5398 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5400 // Render and notify
5401 application.SendNotification();
5402 application.Render();
5404 // Tap on the text field
5405 TestGenerateTap(application, 3.0f, 25.0f);
5407 // Render and notify
5408 application.SendNotification();
5409 application.Render();
5411 // Move to second line of the text & Select some text in the right of the current cursor position
5412 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5413 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5415 // Render and notify
5416 application.SendNotification();
5417 application.Render();
5419 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5422 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5424 // Render and notify
5425 application.SendNotification();
5426 application.Render();
5428 gSelectionStartedCallbackCalled = false;
5430 DevelTextField::SelectText(field, 1, 3);
5432 // Render and notify
5433 application.SendNotification();
5434 application.Render();
5436 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5441 int utcDaliTextFieldSelectionChangedSignal(void)
5443 ToolkitTestApplication application;
5444 tet_infoline(" utcDaliTextFieldSelectionChangedSignal");
5446 TextField field = TextField::New();
5447 DALI_TEST_CHECK(field);
5449 application.GetScene().Add(field);
5451 // connect to the selection changed signal.
5452 ConnectionTracker* testTracker = new ConnectionTracker();
5453 DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
5454 bool selectionChangedSignal = false;
5455 field.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
5457 field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
5458 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5459 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5460 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5461 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5463 // Avoid a crash when core load gl resources.
5464 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5466 // Render and notify
5467 application.SendNotification();
5468 application.Render();
5470 // Tap on the text field
5471 TestGenerateTap(application, 3.0f, 25.0f);
5473 // Render and notify
5474 application.SendNotification();
5475 application.Render();
5477 // Select some text in the right of the current cursor position
5478 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5479 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5481 // Render and notify
5482 application.SendNotification();
5483 application.Render();
5485 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5486 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5488 gSelectionChangedCallbackCalled = false;
5490 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5492 // Render and notify
5493 application.SendNotification();
5494 application.Render();
5496 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5497 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5498 DALI_TEST_EQUALS(oldSelectionEnd, 1, TEST_LOCATION);
5500 gSelectionChangedCallbackCalled = false;
5502 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5504 // Render and notify
5505 application.SendNotification();
5506 application.Render();
5508 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5509 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5510 DALI_TEST_EQUALS(oldSelectionEnd, 2, TEST_LOCATION);
5512 gSelectionChangedCallbackCalled = false;
5513 field.SetKeyInputFocus();
5515 // Render and notify
5516 application.SendNotification();
5517 application.Render();
5519 DevelTextField::SelectText(field, 0, 5);
5521 application.SendNotification();
5522 application.Render();
5524 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5525 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5527 gSelectionChangedCallbackCalled = false;
5529 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5531 // Render and notify
5532 application.SendNotification();
5533 application.Render();
5535 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5536 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5537 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
5539 gSelectionChangedCallbackCalled = false;
5542 DevelTextField::SelectWholeText(field);
5544 // Render and notify
5545 application.SendNotification();
5546 application.Render();
5548 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5549 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5551 gSelectionChangedCallbackCalled = false;
5554 DevelTextField::SelectNone(field);
5556 // Render and notify
5557 application.SendNotification();
5558 application.Render();
5560 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5561 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5562 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5567 int UtcDaliToolkitTextFieldStrikethroughGeneration(void)
5569 ToolkitTestApplication application;
5570 tet_infoline(" UtcDaliToolkitTextFieldStrikethroughGeneration");
5572 TextField textField = TextField::New();
5573 textField.SetProperty(TextField::Property::TEXT, "Test");
5574 textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5575 textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5576 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5578 application.GetScene().Add(textField);
5579 application.SendNotification();
5580 application.Render();
5582 Property::Map strikethroughMapSet;
5583 Property::Map strikethroughMapGet;
5585 strikethroughMapSet.Insert("enable", true);
5586 strikethroughMapSet.Insert("color", Color::RED);
5587 strikethroughMapSet.Insert("height", 2.0f);
5589 // Check the strikethrough property
5590 textField.SetProperty(DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet);
5591 strikethroughMapGet = textField.GetProperty<Property::Map>(DevelTextField::Property::STRIKETHROUGH);
5592 textField.SetProperty(TextField::Property::TEXT, "Test1");
5593 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
5594 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
5596 // Render and notify
5597 application.SendNotification();
5598 application.Render();
5600 strikethroughMapSet.Clear();
5601 strikethroughMapGet.Clear();
5606 int UtcDaliToolkitTextFieldInputStrikethroughGeneration(void)
5608 ToolkitTestApplication application;
5609 tet_infoline(" UtcDaliToolkitTextFieldInputStrikethroughGeneration");
5611 TextField textField = TextField::New();
5612 textField.SetProperty(TextField::Property::TEXT, "Test");
5613 textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5614 textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5615 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5617 application.GetScene().Add(textField);
5618 application.SendNotification();
5619 application.Render();
5621 std::string strikethroughSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}");
5623 // Check the strikethrough property
5624 textField.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, strikethroughSettings1);
5625 textField.SetProperty(TextField::Property::TEXT, "Test1");
5626 DALI_TEST_EQUALS(textField.GetProperty<std::string>(DevelTextField::Property::INPUT_STRIKETHROUGH), strikethroughSettings1, TEST_LOCATION);
5628 // Render and notify
5629 application.SendNotification();
5630 application.Render();
5635 int UtcDaliToolkitTextFieldUnderlineTypesGeneration1(void)
5637 ToolkitTestApplication application;
5638 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration1");
5639 TextField field = TextField::New();
5640 field.SetProperty(TextField::Property::TEXT, "Test");
5641 field.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5642 field.SetProperty(TextField::Property::POINT_SIZE, 10);
5643 field.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5645 application.GetScene().Add(field);
5646 application.SendNotification();
5647 application.Render();
5649 Property::Map underlineMapSet;
5650 Property::Map underlineMapGet;
5652 underlineMapSet.Insert("enable", true);
5653 underlineMapSet.Insert("color", Color::RED);
5654 underlineMapSet.Insert("height", 1);
5655 underlineMapSet.Insert("type", Text::Underline::SOLID);
5656 underlineMapSet.Insert("dashWidth", 2);
5657 underlineMapSet.Insert("dashGap", 1);
5659 // Check the underline property
5660 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5662 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5663 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5664 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5666 // Render and notify
5667 application.SendNotification();
5668 application.Render();
5670 underlineMapSet.Clear();
5671 underlineMapGet.Clear();
5673 underlineMapSet.Insert("enable", true);
5674 underlineMapSet.Insert("color", Color::BLUE);
5675 underlineMapSet.Insert("height", 1);
5676 underlineMapSet.Insert("type", Text::Underline::DASHED);
5677 underlineMapSet.Insert("dashWidth", 4);
5678 underlineMapSet.Insert("dashGap", 2);
5680 // Check the dashed underline property
5681 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5683 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5684 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5685 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5687 // Render and notify
5688 application.SendNotification();
5689 application.Render();
5691 underlineMapSet.Clear();
5692 underlineMapGet.Clear();
5694 underlineMapSet.Insert("enable", true);
5695 underlineMapSet.Insert("color", Color::BLUE);
5696 underlineMapSet.Insert("height", 1);
5697 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
5698 underlineMapSet.Insert("dashWidth", 4);
5699 underlineMapSet.Insert("dashGap", 2);
5701 // Check the dashed underline property
5702 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5704 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5705 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5706 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5708 // Render and notify
5709 application.SendNotification();
5710 application.Render();
5712 underlineMapSet.Clear();
5713 underlineMapGet.Clear();
5718 int UtcDaliToolkitTextFieldUnderlineTypesGeneration2(void)
5720 ToolkitTestApplication application;
5721 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration2");
5723 TextField field1 = TextField::New();
5724 field1.SetProperty(TextField::Property::TEXT, "Test");
5725 field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5726 field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5727 field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5729 Property::Map underlineMapSet1;
5730 Property::Map underlineMapGet1;
5732 underlineMapSet1.Insert("enable", true);
5733 underlineMapSet1.Insert("color", Color::RED);
5734 underlineMapSet1.Insert("height", 1);
5735 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5736 underlineMapSet1.Insert("dashWidth", 2);
5737 underlineMapSet1.Insert("dashGap", 1);
5739 // Check the underline property
5740 field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5742 underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5743 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5744 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5746 application.GetScene().Add(field1);
5747 application.SendNotification();
5748 application.Render();
5750 TextField field2 = TextField::New();
5751 field2.SetProperty(TextField::Property::TEXT, "Test");
5752 field2.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5753 field2.SetProperty(TextField::Property::POINT_SIZE, 10);
5754 field2.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5756 Property::Map underlineMapSet2;
5757 Property::Map underlineMapGet2;
5759 underlineMapSet2.Insert("enable", true);
5760 underlineMapSet2.Insert("color", Color::BLUE);
5761 underlineMapSet2.Insert("height", 1);
5762 underlineMapSet2.Insert("type", Text::Underline::DASHED);
5763 underlineMapSet2.Insert("dashWidth", 4);
5764 underlineMapSet2.Insert("dashGap", 2);
5766 // Check the dashed underline property
5767 field2.SetProperty(TextField::Property::UNDERLINE, underlineMapSet2);
5769 underlineMapGet2 = field2.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5770 DALI_TEST_EQUALS(underlineMapGet2.Count(), underlineMapSet2.Count(), TEST_LOCATION);
5771 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet2, underlineMapSet2), true, TEST_LOCATION);
5773 application.GetScene().Add(field2);
5774 application.SendNotification();
5775 application.Render();
5777 TextField field3 = TextField::New();
5778 field3.SetProperty(TextField::Property::TEXT, "Test");
5779 field3.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5780 field3.SetProperty(TextField::Property::POINT_SIZE, 10);
5781 field3.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5783 Property::Map underlineMapSet3;
5784 Property::Map underlineMapGet3;
5786 underlineMapSet3.Insert("enable", true);
5787 underlineMapSet3.Insert("color", Color::BLUE);
5788 underlineMapSet3.Insert("height", 1);
5789 underlineMapSet3.Insert("type", Text::Underline::DOUBLE);
5790 underlineMapSet3.Insert("dashWidth", 4);
5791 underlineMapSet3.Insert("dashGap", 2);
5793 // Check the dashed underline property
5794 field3.SetProperty(TextField::Property::UNDERLINE, underlineMapSet3);
5796 underlineMapGet3 = field3.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5797 DALI_TEST_EQUALS(underlineMapGet3.Count(), underlineMapSet3.Count(), TEST_LOCATION);
5798 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
5800 application.GetScene().Add(field3);
5802 application.SendNotification();
5803 application.Render();
5808 int UtcDaliTextFieldCharacterSpacing(void)
5810 ToolkitTestApplication application;
5811 tet_infoline(" UtcDaliTextFieldCharacterSpacing ");
5813 TextField textField = TextField::New();
5815 textField.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
5817 application.GetScene().Add(textField);
5818 application.SendNotification();
5819 application.Render();
5821 textField.SetProperty(TextField::Property::TEXT, "Hi Experiment");
5822 textField.SetProperty(DevelTextField::Property::CHARACTER_SPACING, 10.f);
5823 DALI_TEST_EQUALS(textField.GetProperty<float>(DevelTextField::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
5825 application.SendNotification();
5826 application.Render();
5831 int UtcDaliToolkitTextFieldUnderlineTypesGeneration3(void)
5833 ToolkitTestApplication application;
5834 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration3");
5836 TextField field1 = TextField::New();
5837 field1.SetProperty(TextField::Property::TEXT, "Test1");
5838 field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5839 field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5840 field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5842 Property::Map underlineMapSet1;
5843 Property::Map underlineMapGet1;
5845 underlineMapSet1.Insert("enable", true);
5846 underlineMapSet1.Insert("color", Color::RED);
5847 underlineMapSet1.Insert("height", 1);
5848 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5849 underlineMapSet1.Insert("dashWidth", 2);
5850 underlineMapSet1.Insert("dashGap", 1);
5852 // Check the underline property
5853 field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5854 //field1.SetProperty( TextField::Property::TEXT, "Test2" );
5856 underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5857 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5858 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5860 application.GetScene().Add(field1);
5861 application.SendNotification();
5862 application.Render();
5867 int UtcDaliToolkitTextfieldParagraphTag(void)
5869 ToolkitTestApplication application;
5870 tet_infoline(" UtcDaliToolkitTextfieldParagraphTag");
5871 TextField fieldNewlineSeparator = TextField::New();
5872 TextField fieldParagraphTag = TextField::New();
5873 DALI_TEST_CHECK(fieldNewlineSeparator);
5874 DALI_TEST_CHECK(fieldParagraphTag);
5876 application.GetScene().Add(fieldNewlineSeparator);
5877 application.GetScene().Add(fieldParagraphTag);
5879 //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
5880 fieldNewlineSeparator.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5881 fieldNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5882 fieldNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5883 fieldNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5884 fieldNewlineSeparator.SetProperty(TextField::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
5886 fieldParagraphTag.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5887 fieldParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5888 fieldParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5889 fieldParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5890 fieldParagraphTag.SetProperty(TextField::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
5892 application.SendNotification();
5893 application.Render();
5895 Vector3 textNaturalSizeNewlineSeparator = fieldNewlineSeparator.GetNaturalSize();
5896 Vector3 textNaturalSizeParagraphTag = fieldParagraphTag.GetNaturalSize();
5898 DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
5900 application.SendNotification();
5901 application.Render();
5906 //Handle Emoji clustering for cursor handling
5907 int utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey(void)
5909 ToolkitTestApplication application;
5910 tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey ");
5911 TextField textField = TextField::New();
5912 DALI_TEST_CHECK(textField);
5914 application.GetScene().Add(textField);
5916 // Avoid a crash when core load gl resources.
5917 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5919 textField.SetProperty(TextField::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
5920 textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5922 // Render and notify
5923 application.SendNotification();
5924 application.Render();
5927 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 10);
5928 application.SendNotification();
5929 application.Render();
5931 // Set focus and remove Emoji
5932 textField.SetKeyInputFocus();
5933 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5935 //Check the changed text and cursor position
5936 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5937 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5939 // Render and notify
5940 application.SendNotification();
5941 application.Render();
5946 int utcDaliTextFieldClusteredEmojiDeletionDeleteKey(void)
5948 ToolkitTestApplication application;
5949 tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionDeleteKey ");
5950 TextField textField = TextField::New();
5951 DALI_TEST_CHECK(textField);
5953 application.GetScene().Add(textField);
5955 // Avoid a crash when core load gl resources.
5956 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5958 textField.SetProperty(TextField::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
5959 textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5961 // Render and notify
5962 application.SendNotification();
5963 application.Render();
5966 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5967 application.SendNotification();
5968 application.Render();
5970 // Set focus and remove Emoji
5971 textField.SetKeyInputFocus();
5972 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5974 //Check the changed text and cursor position
5975 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5976 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5978 // Render and notify
5979 application.SendNotification();
5980 application.Render();
5985 int utcDaliTextFieldPanGesturePropagation(void)
5987 ToolkitTestApplication application;
5988 tet_infoline(" utcDaliTextFieldPanGesturePropagation");
5990 Actor actor = Actor::New();
5991 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
5992 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5993 application.GetScene().Add(actor);
5995 TextField field = TextField::New();
5996 DALI_TEST_CHECK(field);
5998 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
5999 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
6001 field.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
6002 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6003 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6007 // Render and notify
6008 application.SendNotification();
6009 application.Render();
6012 GestureReceivedFunctor functor(data);
6014 PanGestureDetector detector = PanGestureDetector::New();
6015 detector.Attach(actor);
6016 detector.DetectedSignal().Connect(&application, functor);
6018 // Tap first to get the focus.
6019 TestGenerateTap(application, 3.0f, 25.0f, 100);
6021 // Render and notify
6022 application.SendNotification();
6023 application.Render();
6025 // Pan the text field
6026 uint32_t time = 100;
6027 TestStartPan(application, Vector2(40.0f, 50.0f), Vector2(40.0f, 50.0f), time);
6028 TestMovePan(application, Vector2(10.0f, 50.0f), time);
6029 TestEndPan(application, Vector2(40.0f, 50.0f), time);
6030 application.SendNotification();
6031 application.Render();
6033 // The text scrolls because there is text that is scrolling.
6034 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
6037 // Set the size large enough to prevent scrolling.
6038 field.SetProperty(Actor::Property::SIZE, Vector2(700.f, 100.f));
6040 // Render and notify
6041 application.SendNotification();
6042 application.Render();
6045 TestStartPan(application, Vector2(40.0f, 50.0f), Vector2(40.0f, 50.0f), time);
6046 TestMovePan(application, Vector2(10.0f, 50.0f), time);
6047 TestEndPan(application, Vector2(40.0f, 50.0f), time);
6049 // Because scrolling is not possible, the pan gesture is propagated.
6050 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
6056 int utcDaliTextFieldGetTextBoundingRectangle(void)
6058 ToolkitTestApplication application;
6059 tet_infoline(" utcDaliTextFieldGeometryEllipsisMiddle");
6061 TextField field = TextField::New();
6062 DALI_TEST_CHECK(field);
6064 application.GetScene().Add(field);
6066 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
6067 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6068 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6069 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6070 field.SetProperty(TextField::Property::TEXT, "Hello this is the Text Bounding Rectangle TC");
6072 // Avoid a crash when core load gl resources.
6073 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6075 // Render and notify
6076 application.SendNotification();
6077 application.Render();
6079 unsigned int startIndex = 0;
6080 unsigned int endIndex = 15;
6082 Rect<> textBoundingRectangle = DevelTextField::GetTextBoundingRectangle(field, startIndex, endIndex);
6083 Rect<> expectedTextBoundingRectangle = {0, 0, 100, 25};
6085 TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle);
6090 int utcDaliTextFieldDecoratorColor(void)
6092 ToolkitTestApplication application;
6093 tet_infoline(" utcDaliTextFieldDecoratorColor");
6094 TextField textField = TextField::New();
6095 DALI_TEST_CHECK(textField);
6096 LoadMarkerImages(application, textField);
6097 application.GetScene().Add(textField);
6099 // Render and notify
6100 application.SendNotification();
6101 application.Render();
6103 textField.SetProperty(TextField::Property::TEXT, "العالم Hello");
6104 textField.SetProperty(TextField::Property::POINT_SIZE, 10.f);
6105 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
6106 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6107 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6109 // Avoid a crash when core load gl resources.
6110 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6112 application.SendNotification();
6113 application.Render();
6115 textField.SetKeyInputFocus();
6117 application.SendNotification();
6118 application.Render();
6120 // Create a tap event to touch the text field.
6121 TestGenerateTap(application, 1.0f, 25.0f, 100);
6123 // Render and notify
6124 application.SendNotification();
6125 application.Render();
6127 // Double tap to select a word.
6128 TestGenerateTap(application, 1.0f, 25.0f, 200);
6130 application.SendNotification();
6131 application.Render();
6133 // At this point, the text decorator's primary/secondary cursor, grab/left/right handle and highlight actor were all created.
6134 // Check some properties for coverage.
6135 textField.SetProperty(TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED);
6136 DALI_TEST_EQUALS(textField.GetProperty<Vector4>(TextField::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION);
6138 textField.SetProperty(TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE);
6139 DALI_TEST_EQUALS(textField.GetProperty<Vector4>(TextField::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION);
6141 textField.SetProperty(DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN);
6142 DALI_TEST_EQUALS(textField.GetProperty<Vector4>(DevelTextField::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
6144 textField.SetProperty(TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN);
6145 DALI_TEST_EQUALS(textField.GetProperty<Vector4>(TextField::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION);
6147 textField.SetProperty(TextField::Property::CURSOR_WIDTH, 3);
6148 DALI_TEST_EQUALS(textField.GetProperty<int>(TextField::Property::CURSOR_WIDTH), 3, TEST_LOCATION);
6150 application.SendNotification();
6151 application.Render();
6156 int utcDaliTextFieldRemoveFrontInset(void)
6158 ToolkitTestApplication application;
6159 tet_infoline(" utcDaliTextFieldRemoveFrontInset");
6161 TextField field = TextField::New();
6162 DALI_TEST_CHECK(field);
6164 application.GetScene().Add(field);
6165 application.SendNotification();
6166 application.Render();
6168 DevelTextField::SetRemoveFrontInset(field, false);
6169 DALI_TEST_CHECK(!DevelTextField::IsRemoveFrontInset(field));
6174 int utcDaliTextFieldRemoveBackInset(void)
6176 ToolkitTestApplication application;
6177 tet_infoline(" utcDaliTextFieldRemoveBackInset");
6179 TextField field = TextField::New();
6180 DALI_TEST_CHECK(field);
6182 application.GetScene().Add(field);
6183 application.SendNotification();
6184 application.Render();
6186 DevelTextField::SetRemoveBackInset(field, false);
6187 DALI_TEST_CHECK(!DevelTextField::IsRemoveBackInset(field));