2 * Copyright (c) 2024 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali-toolkit-test-suite-utils.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
25 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h>
26 #include <dali-toolkit/devel-api/text/rendering-backend.h>
27 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
28 #include <dali/devel-api/actors/actor-devel.h>
29 #include <dali/devel-api/adaptor-framework/key-devel.h>
30 #include <dali/devel-api/events/pan-gesture-devel.h>
31 #include <dali/devel-api/text-abstraction/font-client.h>
32 #include <dali/integration-api/events/key-event-integ.h>
33 #include <dali/integration-api/events/touch-event-integ.h>
34 #include <dali/public-api/rendering/renderer.h>
35 #include "test-text-geometry-utils.h"
36 #include "toolkit-clipboard.h"
39 using namespace Toolkit;
41 void dali_textfield_startup(void)
43 test_return_value = TET_UNDEF;
46 void dali_textfield_cleanup(void)
48 test_return_value = TET_PASS;
53 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
54 const char* const PROPERTY_NAME_TEXT = "text";
55 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
56 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
57 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
58 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
59 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
60 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
61 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
62 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
63 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
64 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
65 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
66 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
67 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
68 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
69 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
70 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
71 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
72 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
73 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
74 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
75 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
76 const char* const PROPERTY_NAME_SELECTION_POPUP_STYLE = "selectionPopupStyle";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
80 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
81 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
82 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
83 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
84 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
85 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
86 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
87 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
88 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
89 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
90 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
92 const char* const PROPERTY_NAME_UNDERLINE = "underline";
93 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
94 const char* const PROPERTY_NAME_SHADOW = "shadow";
95 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
96 const char* const PROPERTY_NAME_EMBOSS = "emboss";
97 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
98 const char* const PROPERTY_NAME_OUTLINE = "outline";
99 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
100 const char* const PROPERTY_NAME_STRIKETHROUGH = "strikethrough";
101 const char* const PROPERTY_NAME_INPUT_STRIKETHROUGH = "inputStrikethrough";
103 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
104 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
105 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
106 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
107 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
108 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
109 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
110 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
111 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
112 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
113 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
114 const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE = "enableFontSizeScale";
115 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
116 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
118 const char* const PROPERTY_NAME_REMOVE_FRONT_INSET = "removeFrontInset";
119 const char* const PROPERTY_NAME_REMOVE_BACK_INSET = "removeBackInset";
121 const Vector4 PLACEHOLDER_TEXT_COLOR(0.8f, 0.8f, 0.8f, 0.8f);
122 const Dali::Vector4 LIGHT_BLUE(0.75f, 0.96f, 1.f, 1.f); // The text highlight color.
124 const float RENDER_FRAME_INTERVAL = 16.66f;
126 const unsigned int DEFAULT_FONT_SIZE = 1152u;
127 const std::string DEFAULT_FONT_DIR("/resources/fonts");
129 const int KEY_RETURN_CODE = 36;
130 const int KEY_A_CODE = 38;
131 const int KEY_D_CODE = 40;
132 const int KEY_SHIFT_MODIFIER = 257;
134 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
136 static bool gSelectionChangedCallbackCalled;
137 static uint32_t oldSelectionStart;
138 static uint32_t oldSelectionEnd;
139 static bool gSelectionClearedCallbackCalled;
140 static bool gSelectionStartedCallbackCalled;
141 static bool gAnchorClickedCallBackCalled;
142 static bool gAnchorClickedCallBackNotCalled;
143 static bool gTextChangedCallBackCalled;
144 static bool gMaxCharactersCallBackCalled;
145 static bool gInputFilteredAcceptedCallbackCalled;
146 static bool gInputFilteredRejectedCallbackCalled;
147 static bool gInputStyleChangedCallbackCalled;
148 static bool gCursorPositionChangedCallbackCalled;
149 static uint32_t oldCursorPos;
150 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
152 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
154 Integration::Bitmap* bitmap = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD);
155 Integration::ResourcePointer resource(bitmap);
156 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
159 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
163 LoadBitmapResource(app.GetPlatform(), width, height);
165 Property::Map propertyMap;
166 propertyMap["filename"] = "image.png";
167 propertyMap["width"] = width;
168 propertyMap["height"] = height;
169 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap);
170 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap);
171 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap);
172 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap);
173 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap);
174 textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap);
175 textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, "image.png");
176 textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image.png");
180 * Simulate time passed by.
182 * @note this will always process at least 1 frame (1/60 sec)
184 * @param application Test application instance
185 * @param duration Time to pass in milliseconds.
186 * @return The actual time passed in milliseconds
188 static int Wait(ToolkitTestApplication& application, int duration = 0)
192 for(int i = 0; i <= (duration / RENDER_FRAME_INTERVAL); i++)
194 application.SendNotification();
195 application.Render(RENDER_FRAME_INTERVAL);
196 time += RENDER_FRAME_INTERVAL;
202 Dali::Integration::Point GetPointDownInside(Vector2& pos)
204 Dali::Integration::Point point;
205 point.SetState(PointState::DOWN);
206 point.SetScreenPosition(pos);
210 Dali::Integration::Point GetPointUpInside(Vector2& pos)
212 Dali::Integration::Point point;
213 point.SetState(PointState::UP);
214 point.SetScreenPosition(pos);
218 struct CallbackFunctor
220 CallbackFunctor(bool* callbackFlag)
221 : mCallbackFlag(callbackFlag)
227 *mCallbackFlag = true;
232 static void TestSelectionClearedCallback(TextField control)
234 tet_infoline(" TestSelectionClearedCallback");
236 gSelectionClearedCallbackCalled = true;
239 static void TestSelectionStartedCallback(TextField control)
241 tet_infoline(" TestSelectionStartedCallback");
243 gSelectionStartedCallbackCalled = true;
246 static void TestSelectionChangedCallback(TextField control, uint32_t oldStart, uint32_t oldEnd)
248 tet_infoline(" TestSelectionChangedCallback");
250 gSelectionChangedCallbackCalled = true;
251 oldSelectionStart = oldStart;
252 oldSelectionEnd = oldEnd;
255 static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength)
257 tet_infoline(" TestAnchorClickedCallback");
259 gAnchorClickedCallBackNotCalled = false;
261 if(!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
263 gAnchorClickedCallBackCalled = true;
267 static void TestCursorPositionChangedCallback(TextField control, unsigned int oldPos)
269 tet_infoline(" TestCursorPositionChangedCallback");
271 gCursorPositionChangedCallbackCalled = true;
272 oldCursorPos = oldPos;
275 static void TestTextChangedCallback(TextField control)
277 tet_infoline(" TestTextChangedCallback");
279 gTextChangedCallBackCalled = true;
282 static void TestMaxLengthReachedCallback(TextField control)
284 tet_infoline(" TestMaxLengthReachedCallback");
286 gMaxCharactersCallBackCalled = true;
289 static void TestInputFilteredCallback(TextField control, Toolkit::InputFilter::Property::Type type)
291 tet_infoline(" TestInputFilteredCallback");
293 if(type == Toolkit::InputFilter::Property::ACCEPTED)
295 gInputFilteredAcceptedCallbackCalled = true;
297 else if(type == Toolkit::InputFilter::Property::REJECTED)
299 gInputFilteredRejectedCallbackCalled = true;
303 static void TestInputStyleChangedCallback(TextField control, TextField::InputStyle::Mask mask)
305 tet_infoline(" TestInputStyleChangedCallback");
307 gInputStyleChangedCallbackCalled = true;
308 gInputStyleMask = mask;
311 // Generate a KeyEvent to send to Core.
312 Integration::KeyEvent GenerateKey(const std::string& keyName,
313 const std::string& logicalKey,
314 const std::string& keyString,
317 unsigned long timeStamp,
318 const Integration::KeyEvent::State& keyState,
319 const std::string& compose = "",
320 const std::string& deviceName = DEFAULT_DEVICE_NAME,
321 const Device::Class::Type& deviceClass = Device::Class::NONE,
322 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE)
324 return Integration::KeyEvent(keyName,
337 bool DaliTestCheckMaps(const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet)
339 if(fontStyleMapGet.Count() == fontStyleMapSet.Count())
341 for(unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index)
343 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue(index);
345 Property::Value* valueSet = NULL;
346 if(valueGet.first.type == Property::Key::INDEX)
348 valueSet = fontStyleMapSet.Find(valueGet.first.indexKey);
352 // Get Key is a string so searching Set Map for a string key
353 valueSet = fontStyleMapSet.Find(valueGet.first.stringKey);
358 if(valueSet->GetType() == Dali::Property::STRING && (valueGet.second.Get<std::string>() != valueSet->Get<std::string>()))
360 tet_printf("Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str());
363 else if(valueSet->GetType() == Dali::Property::BOOLEAN && (valueGet.second.Get<bool>() != valueSet->Get<bool>()))
365 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>());
368 else if(valueSet->GetType() == Dali::Property::INTEGER && (valueGet.second.Get<int>() != valueSet->Get<int>()))
370 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>());
373 else if(valueSet->GetType() == Dali::Property::FLOAT && (valueGet.second.Get<float>() != valueSet->Get<float>()))
375 tet_printf("Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>());
378 else if(valueSet->GetType() == Dali::Property::VECTOR2 && (valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>()))
380 Vector2 vector2Get = valueGet.second.Get<Vector2>();
381 Vector2 vector2Set = valueSet->Get<Vector2>();
382 tet_printf("Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y);
385 else if(valueSet->GetType() == Dali::Property::VECTOR4 && (valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>()))
387 Vector4 vector4Get = valueGet.second.Get<Vector4>();
388 Vector4 vector4Set = valueSet->Get<Vector4>();
389 tet_printf("Value got : [%f, %f, %f, %f], expected : [%f, %f, %f, %f]", vector4Get.r, vector4Get.g, vector4Get.b, vector4Get.a, vector4Set.r, vector4Set.g, vector4Set.b, vector4Set.a);
395 if(valueGet.first.type == Property::Key::INDEX)
397 tet_printf(" The key %d doesn't exist.", valueGet.first.indexKey);
401 tet_printf(" The key %s doesn't exist.", valueGet.first.stringKey.c_str());
411 // Stores data that is populated in the callback and will be read by the test cases
415 : functorCalled(false),
416 voidFunctorCalled(false),
423 functorCalled = false;
424 voidFunctorCalled = false;
426 receivedGesture.Reset();
432 bool voidFunctorCalled;
433 PanGesture receivedGesture;
437 // Functor that sets the data when called
438 struct GestureReceivedFunctor
440 GestureReceivedFunctor(SignalData& data)
445 void operator()(Actor actor, const PanGesture& pan)
447 signalData.functorCalled = true;
448 signalData.receivedGesture = pan;
449 signalData.pannedActor = actor;
454 signalData.voidFunctorCalled = true;
457 SignalData& signalData;
462 int UtcDaliToolkitTextFieldConstructorP(void)
464 ToolkitTestApplication application;
465 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
467 DALI_TEST_CHECK(!textField);
471 int UtcDaliToolkitTextFieldNewP(void)
473 ToolkitTestApplication application;
474 tet_infoline(" UtcDaliToolkitTextFieldNewP");
475 TextField textField = TextField::New();
476 DALI_TEST_CHECK(textField);
480 int UtcDaliToolkitTextFieldDownCastP(void)
482 ToolkitTestApplication application;
483 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
484 TextField textField1 = TextField::New();
485 BaseHandle object(textField1);
487 TextField textField2 = TextField::DownCast(object);
488 DALI_TEST_CHECK(textField2);
490 TextField textField3 = DownCast<TextField>(object);
491 DALI_TEST_CHECK(textField3);
495 int UtcDaliToolkitTextFieldDownCastN(void)
497 ToolkitTestApplication application;
498 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
499 BaseHandle uninitializedObject;
500 TextField textField1 = TextField::DownCast(uninitializedObject);
501 DALI_TEST_CHECK(!textField1);
503 TextField textField2 = DownCast<TextField>(uninitializedObject);
504 DALI_TEST_CHECK(!textField2);
508 int UtcDaliToolkitTextFieldCopyConstructorP(void)
510 ToolkitTestApplication application;
511 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
512 TextField textField = TextField::New();
513 textField.SetProperty(TextField::Property::TEXT, "Test");
515 TextField copy(textField);
516 DALI_TEST_CHECK(copy);
517 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextField::Property::TEXT) == textField.GetProperty<std::string>(TextField::Property::TEXT));
521 int UtcDaliTextFieldMoveConstructor(void)
523 ToolkitTestApplication application;
525 TextField textField = TextField::New();
526 textField.SetProperty(TextEditor::Property::TEXT, "Test");
527 DALI_TEST_CHECK(textField.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
529 TextField moved = std::move(textField);
530 DALI_TEST_CHECK(moved);
531 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
532 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
533 DALI_TEST_CHECK(!textField);
538 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
540 ToolkitTestApplication application;
541 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
542 TextField textField = TextField::New();
543 textField.SetProperty(TextField::Property::TEXT, "Test");
545 TextField copy = textField;
546 DALI_TEST_CHECK(copy);
547 DALI_TEST_CHECK(copy.GetProperty<std::string>(TextField::Property::TEXT) == textField.GetProperty<std::string>(TextField::Property::TEXT));
551 int UtcDaliTextFieldMoveAssignment(void)
553 ToolkitTestApplication application;
555 TextField textField = TextField::New();
556 textField.SetProperty(TextEditor::Property::TEXT, "Test");
557 DALI_TEST_CHECK(textField.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
560 moved = std::move(textField);
561 DALI_TEST_CHECK(moved);
562 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
563 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextField::Property::TEXT) == "Test");
564 DALI_TEST_CHECK(!textField);
569 int UtcDaliTextFieldNewP(void)
571 ToolkitTestApplication application;
572 tet_infoline(" UtcDaliToolkitTextFieldNewP");
573 TextField textField = TextField::New();
574 DALI_TEST_CHECK(textField);
578 // Positive test case for a method
579 int UtcDaliTextFieldGetPropertyP(void)
581 ToolkitTestApplication application;
582 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
583 TextField field = TextField::New();
584 DALI_TEST_CHECK(field);
586 // Check Property Indices are correct
587 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_RENDERING_BACKEND) == DevelTextField::Property::RENDERING_BACKEND);
588 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_TEXT) == TextField::Property::TEXT);
589 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT) == TextField::Property::PLACEHOLDER_TEXT);
590 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED);
591 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_FAMILY) == TextField::Property::FONT_FAMILY);
592 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_STYLE) == TextField::Property::FONT_STYLE);
593 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_POINT_SIZE) == TextField::Property::POINT_SIZE);
594 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_MAX_LENGTH) == TextField::Property::MAX_LENGTH);
595 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_EXCEED_POLICY) == TextField::Property::EXCEED_POLICY);
596 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_HORIZONTAL_ALIGNMENT) == TextField::Property::HORIZONTAL_ALIGNMENT);
597 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_VERTICAL_ALIGNMENT) == TextField::Property::VERTICAL_ALIGNMENT);
598 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_TEXT_COLOR) == TextField::Property::TEXT_COLOR);
599 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR) == TextField::Property::PLACEHOLDER_TEXT_COLOR);
600 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PRIMARY_CURSOR_COLOR) == TextField::Property::PRIMARY_CURSOR_COLOR);
601 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SECONDARY_CURSOR_COLOR) == TextField::Property::SECONDARY_CURSOR_COLOR);
602 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_CURSOR_BLINK) == TextField::Property::ENABLE_CURSOR_BLINK);
603 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_INTERVAL) == TextField::Property::CURSOR_BLINK_INTERVAL);
604 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_BLINK_DURATION) == TextField::Property::CURSOR_BLINK_DURATION);
605 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_CURSOR_WIDTH) == TextField::Property::CURSOR_WIDTH);
606 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_IMAGE) == TextField::Property::GRAB_HANDLE_IMAGE);
607 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE);
608 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SCROLL_THRESHOLD) == TextField::Property::SCROLL_THRESHOLD);
609 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SCROLL_SPEED) == TextField::Property::SCROLL_SPEED);
610 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT);
611 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT);
612 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT);
613 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT);
614 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT);
615 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT);
616 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR) == TextField::Property::SELECTION_HIGHLIGHT_COLOR);
617 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_DECORATION_BOUNDING_BOX) == TextField::Property::DECORATION_BOUNDING_BOX);
618 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_METHOD_SETTINGS) == TextField::Property::INPUT_METHOD_SETTINGS);
619 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_COLOR) == TextField::Property::INPUT_COLOR);
620 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_MARKUP) == TextField::Property::ENABLE_MARKUP);
621 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_FAMILY) == TextField::Property::INPUT_FONT_FAMILY);
622 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FONT_STYLE) == TextField::Property::INPUT_FONT_STYLE);
623 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_POINT_SIZE) == TextField::Property::INPUT_POINT_SIZE);
624 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_UNDERLINE) == TextField::Property::UNDERLINE);
625 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_UNDERLINE) == TextField::Property::INPUT_UNDERLINE);
626 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SHADOW) == TextField::Property::SHADOW);
627 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_SHADOW) == TextField::Property::INPUT_SHADOW);
628 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_EMBOSS) == TextField::Property::EMBOSS);
629 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_EMBOSS) == TextField::Property::INPUT_EMBOSS);
630 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_OUTLINE) == TextField::Property::OUTLINE);
631 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_OUTLINE) == TextField::Property::INPUT_OUTLINE);
632 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_HIDDEN_INPUT_SETTINGS) == TextField::Property::HIDDEN_INPUT_SETTINGS);
633 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PIXEL_SIZE) == TextField::Property::PIXEL_SIZE);
634 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_SELECTION) == TextField::Property::ENABLE_SELECTION);
635 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_PLACEHOLDER) == TextField::Property::PLACEHOLDER);
636 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ELLIPSIS) == TextField::Property::ELLIPSIS);
637 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_SIZE_SCALE) == DevelTextField::Property::FONT_SIZE_SCALE);
638 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE) == DevelTextField::Property::ENABLE_FONT_SIZE_SCALE);
639 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_SHIFT_SELECTION) == DevelTextField::Property::ENABLE_SHIFT_SELECTION);
640 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE) == DevelTextField::Property::ENABLE_GRAB_HANDLE);
641 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION);
642 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP);
643 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_BACKGROUND) == DevelTextField::Property::BACKGROUND);
644 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_GRAB_HANDLE_COLOR) == DevelTextField::Property::GRAB_HANDLE_COLOR);
645 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_FILTER) == DevelTextField::Property::INPUT_FILTER);
646 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextField::Property::STRIKETHROUGH);
647 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextField::Property::INPUT_STRIKETHROUGH);
648 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_POPUP_STYLE) == DevelTextField::Property::SELECTION_POPUP_STYLE);
649 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_REMOVE_FRONT_INSET) == DevelTextField::Property::REMOVE_FRONT_INSET);
650 DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_REMOVE_BACK_INSET) == DevelTextField::Property::REMOVE_BACK_INSET);
655 bool SetPropertyMapRetrieved(TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue)
658 Property::Map imageMap;
659 imageMap[mapKey] = mapValue;
661 field.SetProperty(property, imageMap);
662 Property::Value propValue = field.GetProperty(property);
663 Property::Map* resultMap = propValue.GetMap();
665 if(resultMap->Find(mapKey)->Get<std::string>() == mapValue)
673 // Positive test case for a method
674 int UtcDaliTextFieldSetPropertyP(void)
676 ToolkitTestApplication application;
677 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
678 TextField field = TextField::New();
679 DALI_TEST_CHECK(field);
680 application.GetScene().Add(field);
682 // Note - we can't check the defaults since the stylesheets are platform-specific
684 // Check the render backend property.
685 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
686 DALI_TEST_EQUALS((DevelText::RenderingType)field.GetProperty<int>(DevelTextField::Property::RENDERING_BACKEND), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION);
688 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED);
689 DALI_TEST_EQUALS((DevelText::RenderingType)field.GetProperty<int>(DevelTextField::Property::RENDERING_BACKEND), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION);
691 // Check text property.
692 field.SetProperty(TextField::Property::TEXT, "Setting Text");
693 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("Setting Text"), TEST_LOCATION);
695 // Check placeholder text properties.
696 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
697 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::PLACEHOLDER_TEXT), std::string("Setting Placeholder Text"), TEST_LOCATION);
699 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused");
700 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::PLACEHOLDER_TEXT_FOCUSED), std::string("Setting Placeholder Text Focused"), TEST_LOCATION);
702 // Check font properties.
703 field.SetProperty(TextField::Property::FONT_FAMILY, "Setting font family");
704 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::FONT_FAMILY), std::string("Setting font family"), TEST_LOCATION);
706 Property::Map fontStyleMapSet;
707 Property::Map fontStyleMapGet;
708 Property::Value* slantValue = NULL;
710 fontStyleMapSet.Insert("weight", "bold");
711 fontStyleMapSet.Insert("width", "condensed");
712 fontStyleMapSet.Insert("slant", "italic");
713 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
715 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
716 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
717 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
719 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
720 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::POINT_SIZE), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
722 field.SetProperty(DevelTextField::Property::FONT_SIZE_SCALE, 2.5f);
723 DALI_TEST_EQUALS(field.GetProperty<float>(DevelTextField::Property::FONT_SIZE_SCALE), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
724 field.SetProperty(DevelTextField::Property::FONT_SIZE_SCALE, 1.0f);
726 field.SetProperty(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, false);
727 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE), false, TEST_LOCATION);
728 field.SetProperty(DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, true);
731 fontStyleMapSet.Clear();
732 fontStyleMapSet.Insert("weight", "normal");
733 fontStyleMapSet.Insert("slant", "oblique");
734 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
736 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
737 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
738 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
740 fontStyleMapSet.Clear();
741 fontStyleMapSet.Insert("slant", "roman");
742 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
743 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
745 // Replace 'roman' for 'normal'.
746 slantValue = fontStyleMapGet.Find("slant");
747 if(NULL != slantValue)
749 if("normal" == slantValue->Get<std::string>())
751 fontStyleMapGet["slant"] = "roman";
754 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
755 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
757 fontStyleMapSet.Clear();
759 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
760 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
761 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
762 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
764 // Check that the MAX_LENGTH property can be correctly set
765 const int maxNumberOfCharacters = 20;
766 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
767 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::MAX_LENGTH), maxNumberOfCharacters, TEST_LOCATION);
769 // Check exceed policy
770 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP);
771 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::EXCEED_POLICY), static_cast<int>(Dali::Toolkit::TextField::EXCEED_POLICY_CLIP), TEST_LOCATION);
772 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
773 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::EXCEED_POLICY), static_cast<int>(Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL), TEST_LOCATION);
775 // Check that the Alignment properties can be correctly set
776 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
777 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::HORIZONTAL_ALIGNMENT), "END", TEST_LOCATION);
778 field.SetProperty(TextField::Property::VERTICAL_ALIGNMENT, "CENTER");
779 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::VERTICAL_ALIGNMENT), "CENTER", TEST_LOCATION);
781 // Check text's color property
782 field.SetProperty(TextField::Property::TEXT_COLOR, Color::WHITE);
783 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::WHITE, TEST_LOCATION);
785 // Check placeholder text's color property.
786 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED);
787 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::PLACEHOLDER_TEXT_COLOR), Color::RED, TEST_LOCATION);
789 // Check cursor properties
790 field.SetProperty(TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED);
791 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION);
792 field.SetProperty(TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE);
793 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION);
795 field.SetProperty(TextField::Property::ENABLE_CURSOR_BLINK, false);
796 DALI_TEST_EQUALS(field.GetProperty<bool>(TextField::Property::ENABLE_CURSOR_BLINK), false, TEST_LOCATION);
797 field.SetProperty(TextField::Property::CURSOR_BLINK_INTERVAL, 1.f);
798 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::CURSOR_BLINK_INTERVAL), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
799 field.SetProperty(TextField::Property::CURSOR_BLINK_DURATION, 10.f);
800 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::CURSOR_BLINK_DURATION), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
801 field.SetProperty(TextField::Property::CURSOR_WIDTH, 1);
802 DALI_TEST_EQUALS(field.GetProperty<int>(TextField::Property::CURSOR_WIDTH), 1, TEST_LOCATION);
804 // Check scroll properties.
805 field.SetProperty(TextField::Property::SCROLL_THRESHOLD, 1.f);
806 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::SCROLL_THRESHOLD), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
807 field.SetProperty(TextField::Property::SCROLL_SPEED, 100.f);
808 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::SCROLL_SPEED), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
810 // Check handle images
811 field.SetProperty(TextField::Property::GRAB_HANDLE_IMAGE, "image1");
812 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::GRAB_HANDLE_IMAGE), "image1", TEST_LOCATION);
813 field.SetProperty(TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2");
814 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::GRAB_HANDLE_PRESSED_IMAGE), "image2", TEST_LOCATION);
815 field.SetProperty(TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3");
817 // Check handle images
818 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage"));
819 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage"));
820 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed"));
821 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed"));
822 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage"));
823 DALI_TEST_CHECK(SetPropertyMapRetrieved(field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage"));
825 // Check the selection popup style
826 const Vector2 popupMaxSize(200.0f, 300.0f);
827 const Vector2 optionDividerSize(30.0f, 5.0f);
828 const Vector4 optionDividerPadding(20.0f, 20.0f, 10.0f, 10.0f);
829 const Vector4 labelPadding(5.0f, 5.0f, 50.0f, 25.0f);
831 Property::Map selectionPopupStyle;
832 selectionPopupStyle.Insert(TextSelectionPopup::Property::POPUP_MAX_SIZE, popupMaxSize);
833 selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE, optionDividerSize);
834 selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING, optionDividerPadding);
835 selectionPopupStyle.Insert(TextSelectionPopup::Property::LABEL_PADDING, labelPadding);
837 field.SetProperty(DevelTextField::Property::SELECTION_POPUP_STYLE, selectionPopupStyle);
839 Property::Map selectionPopupStyleGet;
840 selectionPopupStyleGet = field.GetProperty<Property::Map>(DevelTextField::Property::SELECTION_POPUP_STYLE);
842 Property::Value* popupValue;
843 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::POPUP_MAX_SIZE);
844 DALI_TEST_CHECK(NULL != popupValue);
847 Vector2 popupMaxSizeGet;
848 popupValue->Get(popupMaxSizeGet);
849 DALI_TEST_EQUALS(popupMaxSizeGet, popupMaxSize, TEST_LOCATION);
852 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE);
853 DALI_TEST_CHECK(NULL != popupValue);
856 Vector2 optionDividerSizeGet;
857 popupValue->Get(optionDividerSizeGet);
858 DALI_TEST_EQUALS(optionDividerSizeGet, optionDividerSize, TEST_LOCATION);
861 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING);
862 DALI_TEST_CHECK(NULL != popupValue);
865 Vector4 optionDividerPaddingGet;
866 popupValue->Get(optionDividerPaddingGet);
867 DALI_TEST_EQUALS(optionDividerPaddingGet, optionDividerPadding, TEST_LOCATION);
870 popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::LABEL_PADDING);
871 DALI_TEST_CHECK(NULL != popupValue);
874 Vector4 labelPaddingGet;
875 popupValue->Get(labelPaddingGet);
876 DALI_TEST_EQUALS(labelPaddingGet, labelPadding, TEST_LOCATION);
879 // Reset selection popup style
880 selectionPopupStyle.Clear();
881 field.SetProperty(DevelTextField::Property::SELECTION_POPUP_STYLE, selectionPopupStyle);
883 // Check the highlight color
884 field.SetProperty(TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN);
885 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION);
887 // Decoration bounding box
888 field.SetProperty(TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>(0, 0, 1, 1));
889 DALI_TEST_EQUALS(field.GetProperty<Rect<int> >(TextField::Property::DECORATION_BOUNDING_BOX), Rect<int>(0, 0, 1, 1), TEST_LOCATION);
891 // Check the input method setting
892 Property::Map propertyMap;
893 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
894 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
895 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
896 int inputVariation = 1;
897 propertyMap["PANEL_LAYOUT"] = panelLayout;
898 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
899 propertyMap["BUTTON_ACTION"] = buttonAction;
900 propertyMap["VARIATION"] = inputVariation;
901 field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
903 Property::Value value = field.GetProperty(TextField::Property::INPUT_METHOD_SETTINGS);
905 DALI_TEST_CHECK(value.Get(map));
908 DALI_TEST_CHECK(map["PANEL_LAYOUT"].Get(layout));
909 DALI_TEST_EQUALS(static_cast<int>(panelLayout), layout, TEST_LOCATION);
912 DALI_TEST_CHECK(map["AUTO_CAPITALIZE"].Get(capital));
913 DALI_TEST_EQUALS(static_cast<int>(autoCapital), capital, TEST_LOCATION);
916 DALI_TEST_CHECK(map["BUTTON_ACTION"].Get(action));
917 DALI_TEST_EQUALS(static_cast<int>(buttonAction), action, TEST_LOCATION);
920 DALI_TEST_CHECK(map["VARIATION"].Get(variation));
921 DALI_TEST_EQUALS(inputVariation, variation, TEST_LOCATION);
923 // Check input color property.
924 field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
925 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::INPUT_COLOR), Color::YELLOW, TEST_LOCATION);
927 // Check the enable markup property.
928 DALI_TEST_CHECK(!field.GetProperty<bool>(TextField::Property::ENABLE_MARKUP));
929 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
930 DALI_TEST_CHECK(field.GetProperty<bool>(TextField::Property::ENABLE_MARKUP));
932 // Check input font properties.
933 field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
934 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
936 fontStyleMapSet.Clear();
937 fontStyleMapSet.Insert("weight", "bold");
938 fontStyleMapSet.Insert("width", "condensed");
939 fontStyleMapSet.Insert("slant", "italic");
941 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
942 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
943 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
944 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
946 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
947 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
949 // Reset input font style.
950 fontStyleMapSet.Clear();
951 fontStyleMapSet.Insert("weight", "normal");
952 fontStyleMapSet.Insert("slant", "oblique");
954 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
955 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
956 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
957 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
959 fontStyleMapSet.Clear();
960 fontStyleMapSet.Insert("slant", "roman");
962 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
963 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
965 // Replace 'roman' for 'normal'.
966 slantValue = fontStyleMapGet.Find("slant");
967 if(NULL != slantValue)
969 if("normal" == slantValue->Get<std::string>())
971 fontStyleMapGet["slant"] = "roman";
974 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
975 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
977 fontStyleMapSet.Clear();
979 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
980 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
981 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
982 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
984 Property::Map strikethroughMapSet;
985 Property::Map strikethroughMapGet;
987 strikethroughMapSet.Insert("enable", true);
988 strikethroughMapSet.Insert("color", Color::RED);
989 strikethroughMapSet.Insert("height", 2.0f);
991 // Check the strikethrough property
992 field.SetProperty(DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet);
994 strikethroughMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::STRIKETHROUGH);
995 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
996 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
998 // Check the input strikethrough property
999 field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties");
1000 DALI_TEST_EQUALS(field.GetProperty<std::string>(DevelTextField::Property::INPUT_STRIKETHROUGH), std::string("Strikethrough input properties"), TEST_LOCATION);
1002 Property::Map underlineMapSet;
1003 Property::Map underlineMapGet;
1005 underlineMapSet.Insert("enable", true);
1006 underlineMapSet.Insert("color", Color::RED);
1007 underlineMapSet.Insert("height", 1);
1008 underlineMapSet.Insert("type", Text::Underline::SOLID);
1009 underlineMapSet.Insert("dashWidth", 2);
1010 underlineMapSet.Insert("dashGap", 1);
1012 // Check the underline property
1013 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
1015 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
1016 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
1017 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
1019 // Render and notify
1020 application.SendNotification();
1021 application.Render();
1023 underlineMapSet.Clear();
1024 underlineMapGet.Clear();
1026 underlineMapSet.Insert("enable", true);
1027 underlineMapSet.Insert("color", Color::BLUE);
1028 underlineMapSet.Insert("height", 1);
1029 underlineMapSet.Insert("type", Text::Underline::DASHED);
1030 underlineMapSet.Insert("dashWidth", 4);
1031 underlineMapSet.Insert("dashGap", 2);
1033 // Check the dashed underline property
1034 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
1036 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
1037 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
1038 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
1040 // Render and notify
1041 application.SendNotification();
1042 application.Render();
1044 underlineMapSet.Clear();
1045 underlineMapGet.Clear();
1047 underlineMapSet.Insert("enable", true);
1048 underlineMapSet.Insert("color", Color::BLUE);
1049 underlineMapSet.Insert("height", 4);
1050 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
1051 underlineMapSet.Insert("dashWidth", 4);
1052 underlineMapSet.Insert("dashGap", 2);
1054 // Check the dashed underline property
1055 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
1057 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
1058 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
1059 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
1061 // Render and notify
1062 application.SendNotification();
1063 application.Render();
1065 underlineMapSet.Clear();
1066 underlineMapGet.Clear();
1068 // Check the input underline property
1069 field.SetProperty(TextField::Property::INPUT_UNDERLINE, "Underline input properties");
1070 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_UNDERLINE), std::string("Underline input properties"), TEST_LOCATION);
1072 // Check the shadow property
1073 Property::Map shadowMapSet;
1074 Property::Map shadowMapGet;
1076 shadowMapSet.Insert("color", Color::GREEN);
1077 shadowMapSet.Insert("offset", Vector2(2.0f, 2.0f));
1078 shadowMapSet.Insert("blurRadius", 3.0f);
1080 field.SetProperty(TextField::Property::SHADOW, shadowMapSet);
1082 shadowMapGet = field.GetProperty<Property::Map>(TextField::Property::SHADOW);
1083 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
1084 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet), true, TEST_LOCATION);
1086 // Check the input shadow property
1087 field.SetProperty(TextField::Property::INPUT_SHADOW, "Shadow input properties");
1088 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_SHADOW), std::string("Shadow input properties"), TEST_LOCATION);
1090 // Check the emboss property
1091 field.SetProperty(TextField::Property::EMBOSS, "Emboss properties");
1092 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::EMBOSS), std::string("Emboss properties"), TEST_LOCATION);
1094 // Check the input emboss property
1095 field.SetProperty(TextField::Property::INPUT_EMBOSS, "Emboss input properties");
1096 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_EMBOSS), std::string("Emboss input properties"), TEST_LOCATION);
1098 // Check the outline property
1100 // Test string type first
1101 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
1102 field.SetProperty(TextField::Property::OUTLINE, "Outline properties");
1103 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::OUTLINE), std::string("Outline properties"), TEST_LOCATION);
1105 // Then test the property map type
1106 Property::Map outlineMapSet;
1107 Property::Map outlineMapGet;
1109 outlineMapSet["color"] = Color::RED;
1110 outlineMapSet["width"] = 2.0f;
1112 field.SetProperty(TextField::Property::OUTLINE, outlineMapSet);
1114 outlineMapGet = field.GetProperty<Property::Map>(TextField::Property::OUTLINE);
1115 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
1116 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
1118 // Check the input outline property
1119 field.SetProperty(TextField::Property::INPUT_OUTLINE, "Outline input properties");
1120 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_OUTLINE), std::string("Outline input properties"), TEST_LOCATION);
1122 // Check the hidden input settings property
1123 Property::Map hiddenMapSet;
1124 Property::Map hiddenMapGet;
1125 hiddenMapSet[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL;
1126 hiddenMapSet[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 2;
1127 hiddenMapSet[HiddenInput::Property::SUBSTITUTE_COUNT] = 4;
1128 hiddenMapSet[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
1129 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet);
1131 hiddenMapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
1132 DALI_TEST_EQUALS(hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION);
1133 DALI_TEST_EQUALS(DaliTestCheckMaps(hiddenMapSet, hiddenMapGet), true, TEST_LOCATION);
1135 // Check the pixel size of font
1136 field.SetProperty(TextField::Property::PIXEL_SIZE, 20.f);
1137 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1139 // Check the enable selection property
1140 field.SetProperty(TextField::Property::ENABLE_SELECTION, false);
1141 DALI_TEST_EQUALS(field.GetProperty<bool>(TextField::Property::ENABLE_SELECTION), false, TEST_LOCATION);
1143 // Check the placeholder property with pixel size
1144 Property::Map placeholderPixelSizeMapSet;
1145 Property::Map placeholderPixelSizeMapGet;
1146 Property::Map placeholderFontstyleMap;
1147 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
1148 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
1149 placeholderPixelSizeMapSet["color"] = Color::BLUE;
1150 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
1151 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
1152 placeholderPixelSizeMapSet["ellipsis"] = true;
1154 placeholderFontstyleMap.Insert("weight", "bold");
1155 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
1156 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
1158 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1159 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
1161 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
1162 Property::Map placeholderConversionMap;
1163 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1164 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1165 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1166 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1167 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1168 placeholderConversionMap[Text::PlaceHolder::Property::PIXEL_SIZE] = placeholderPixelSizeMapSet["pixelSize"];
1170 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderConversionMap), true, TEST_LOCATION);
1172 // Check the placeholder property with point size
1173 Property::Map placeholderMapSet;
1174 Property::Map placeholderMapGet;
1175 placeholderMapSet["text"] = "Setting Placeholder Text";
1176 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
1177 placeholderMapSet["color"] = Color::RED;
1178 placeholderMapSet["fontFamily"] = "Arial";
1179 placeholderMapSet["pointSize"] = 12.0f;
1180 placeholderMapSet["ellipsis"] = false;
1182 // Check the placeholder font style property
1183 placeholderFontstyleMap.Clear();
1185 placeholderFontstyleMap.Insert("weight", "bold");
1186 placeholderFontstyleMap.Insert("width", "condensed");
1187 placeholderFontstyleMap.Insert("slant", "italic");
1188 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1189 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1191 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1192 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1194 placeholderConversionMap.Clear();
1195 placeholderConversionMap[Text::PlaceHolder::Property::TEXT] = placeholderPixelSizeMapSet["text"];
1196 placeholderConversionMap[Text::PlaceHolder::Property::TEXT_FOCUSED] = placeholderPixelSizeMapSet["textFocused"];
1197 placeholderConversionMap[Text::PlaceHolder::Property::COLOR] = placeholderPixelSizeMapSet["color"];
1198 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1199 placeholderConversionMap[Text::PlaceHolder::Property::FONT_FAMILY] = placeholderPixelSizeMapSet["fontFamily"];
1200 placeholderConversionMap[Text::PlaceHolder::Property::POINT_SIZE] = placeholderPixelSizeMapSet["pointSize"];
1202 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1204 // Reset font style.
1205 placeholderFontstyleMap.Clear();
1206 placeholderFontstyleMap.Insert("weight", "normal");
1207 placeholderFontstyleMap.Insert("slant", "oblique");
1208 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1209 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1211 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1212 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1214 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1215 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1217 placeholderFontstyleMap.Clear();
1218 placeholderFontstyleMap.Insert("slant", "roman");
1219 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1220 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1222 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1224 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1226 placeholderFontstyleMap.Clear();
1227 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1228 placeholderConversionMap[Text::PlaceHolder::Property::FONT_STYLE] = placeholderPixelSizeMapSet["fontStyle"];
1230 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
1231 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
1232 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
1234 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderConversionMap), true, TEST_LOCATION);
1236 // Check the ellipsis property
1237 DALI_TEST_CHECK(!field.GetProperty<bool>(TextField::Property::ELLIPSIS));
1238 field.SetProperty(TextField::Property::ELLIPSIS, true);
1239 DALI_TEST_CHECK(field.GetProperty<bool>(TextField::Property::ELLIPSIS));
1241 field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1242 DALI_TEST_EQUALS(field.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1244 // Test the ENABLE_GRAB_HANDLE_POPUP property
1245 DALI_TEST_CHECK(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP));
1246 field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false);
1247 DALI_TEST_CHECK(!field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP));
1249 // Check the background property
1250 field.SetProperty(DevelTextField::Property::BACKGROUND, Color::RED);
1251 DALI_TEST_EQUALS(field.GetProperty<Vector4>(DevelTextField::Property::BACKGROUND), Color::RED, TEST_LOCATION);
1253 //Check handle color
1254 field.SetProperty(DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN);
1255 DALI_TEST_EQUALS(field.GetProperty<Vector4>(DevelTextField::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
1257 // Check the input filter property
1258 Property::Map inputFilterMapSet;
1259 Property::Map inputFilterMapGet;
1260 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1261 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1263 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1265 inputFilterMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::INPUT_FILTER);
1266 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1269 inputFilterMapSet.Clear();
1270 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1272 application.SendNotification();
1273 application.Render();
1275 // Check Remove Front/Back Inset Property
1276 DALI_TEST_CHECK(field.GetProperty<bool>(DevelTextField::Property::REMOVE_FRONT_INSET));
1277 field.SetProperty(DevelTextField::Property::REMOVE_FRONT_INSET, false);
1278 DALI_TEST_CHECK(!field.GetProperty<bool>(DevelTextField::Property::REMOVE_FRONT_INSET));
1280 DALI_TEST_CHECK(field.GetProperty<bool>(DevelTextField::Property::REMOVE_BACK_INSET));
1281 field.SetProperty(DevelTextField::Property::REMOVE_BACK_INSET, false);
1282 DALI_TEST_CHECK(!field.GetProperty<bool>(DevelTextField::Property::REMOVE_BACK_INSET));
1284 application.SendNotification();
1285 application.Render();
1291 // Positive Atlas Text Renderer test
1292 int utcDaliTextFieldAtlasRenderP(void)
1294 ToolkitTestApplication application;
1295 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1296 StyleManager styleManager = StyleManager::Get();
1297 styleManager.ApplyDefaultTheme();
1298 TextField field = TextField::New();
1299 DALI_TEST_CHECK(field);
1301 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1303 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1305 application.GetScene().Add(field);
1309 // Render some text with the shared atlas backend
1310 field.SetProperty(DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1311 application.SendNotification();
1312 application.Render();
1316 tet_result(TET_FAIL);
1321 // Positive test for the anchorClicked signal.
1322 int utcDaliTextFieldAnchorClicked01(void)
1324 ToolkitTestApplication application;
1325 tet_infoline(" utcDaliTextFieldAnchorClicked01");
1326 TextField field = TextField::New();
1327 DALI_TEST_CHECK(field);
1329 application.GetScene().Add(field);
1331 // connect to the anchor clicked signal.
1332 ConnectionTracker* testTracker = new ConnectionTracker();
1333 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1334 bool anchorClickedSignal = false;
1335 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1337 gAnchorClickedCallBackCalled = false;
1338 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1339 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1340 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1341 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1342 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1344 application.SendNotification();
1345 application.Render();
1346 field.SetKeyInputFocus();
1348 // Create a tap event to touch the text field.
1349 TestGenerateTap(application, 5.0f, 25.0f);
1350 application.SendNotification();
1351 application.Render();
1353 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1354 DALI_TEST_CHECK(anchorClickedSignal);
1356 gAnchorClickedCallBackNotCalled = true;
1357 // Tap the outside of anchor, callback should not be called.
1358 TestGenerateTap(application, 150.f, 100.f);
1359 application.SendNotification();
1360 application.Render();
1362 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1367 // Positive test for the anchorClicked signal.
1368 int utcDaliTextFieldAnchorClicked02(void)
1370 ToolkitTestApplication application;
1371 tet_infoline(" utcDaliTextFieldAnchorClicked02");
1372 TextField field = TextField::New();
1373 DALI_TEST_CHECK(field);
1375 application.GetScene().Add(field);
1377 // connect to the anchor clicked signal.
1378 ConnectionTracker* testTracker = new ConnectionTracker();
1379 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1380 bool anchorClickedSignal = false;
1381 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1383 gAnchorClickedCallBackCalled = false;
1384 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1385 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1386 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1387 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1388 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1390 application.SendNotification();
1391 application.Render();
1392 field.SetKeyInputFocus();
1394 // Avoid a crash when core load gl resources.
1395 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1397 // Create a tap event to touch the text field.
1398 TestGenerateTap(application, 30.0f, 25.0f, 100);
1399 application.SendNotification();
1400 application.Render();
1402 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1403 DALI_TEST_CHECK(anchorClickedSignal);
1405 // For coverage InsertTextAnchor, RemoveTextAnchor
1406 // first index insert
1407 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1408 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1409 application.SendNotification();
1410 application.Render();
1412 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1413 application.SendNotification();
1414 application.Render();
1416 gAnchorClickedCallBackCalled = false;
1417 // Create a tap event to touch the text field.
1418 TestGenerateTap(application, 30.0f, 25.0f, 700);
1419 application.SendNotification();
1420 field.SetKeyInputFocus();
1422 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1424 // last index insert
1425 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1426 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1427 application.SendNotification();
1428 application.Render();
1430 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1431 application.SendNotification();
1432 application.Render();
1434 gAnchorClickedCallBackCalled = false;
1435 // Create a tap event to touch the text field.
1436 TestGenerateTap(application, 30.0f, 25.0f, 1300);
1437 application.SendNotification();
1438 field.SetKeyInputFocus();
1440 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1443 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1444 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1445 application.SendNotification();
1446 application.Render();
1448 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1449 application.SendNotification();
1450 application.Render();
1452 gAnchorClickedCallBackCalled = false;
1453 // Create a tap event to touch the text field.
1454 TestGenerateTap(application, 30.0f, 25.0f, 1900);
1455 application.SendNotification();
1456 field.SetKeyInputFocus();
1458 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1460 // first index remove
1461 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1462 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1463 application.SendNotification();
1464 application.Render();
1466 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1467 application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1468 application.SendNotification();
1469 application.Render();
1471 gAnchorClickedCallBackCalled = false;
1472 // Create a tap event to touch the text field.
1473 TestGenerateTap(application, 30.0f, 25.0f, 2500);
1474 application.SendNotification();
1475 field.SetKeyInputFocus();
1477 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1479 // last index remove
1480 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1481 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1482 application.SendNotification();
1483 application.Render();
1485 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1486 application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1487 application.SendNotification();
1488 application.Render();
1490 gAnchorClickedCallBackCalled = false;
1491 // Create a tap event to touch the text field.
1492 TestGenerateTap(application, 30.0f, 25.0f, 3100);
1493 application.SendNotification();
1494 application.Render();
1496 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1499 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1500 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1501 application.SendNotification();
1502 application.Render();
1504 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1505 application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1506 application.SendNotification();
1507 application.Render();
1509 gAnchorClickedCallBackCalled = false;
1510 // Create a tap event to touch the text field.
1511 TestGenerateTap(application, 30.0f, 25.0f, 3700);
1512 application.SendNotification();
1513 application.Render();
1515 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1517 // 0 ~ 1 index remove
1518 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1519 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 0);
1520 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 1);
1521 application.SendNotification();
1522 application.Render();
1524 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1525 application.SendNotification();
1526 application.Render();
1528 gAnchorClickedCallBackCalled = false;
1529 // Create a tap event to touch the text field.
1530 TestGenerateTap(application, 30.0f, 25.0f, 4300);
1531 application.SendNotification();
1532 application.Render();
1534 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1536 // 1 ~ 3 index remove
1537 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1538 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 1);
1539 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 3);
1540 application.SendNotification();
1541 application.Render();
1543 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1544 application.SendNotification();
1545 application.Render();
1547 gAnchorClickedCallBackCalled = false;
1548 // Create a tap event to touch the text field.
1549 TestGenerateTap(application, 30.0f, 25.0f, 4900);
1550 application.SendNotification();
1551 application.Render();
1553 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1555 // 3 ~ 4 index remove
1556 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1557 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 3);
1558 field.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 4);
1559 application.SendNotification();
1560 application.Render();
1562 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1563 application.SendNotification();
1564 application.Render();
1566 gAnchorClickedCallBackCalled = false;
1567 // Create a tap event to touch the text field.
1568 TestGenerateTap(application, 30.0f, 25.0f, 5500);
1569 application.SendNotification();
1570 application.Render();
1572 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1574 // Remove front of anchor
1575 field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
1576 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
1577 application.SendNotification();
1578 application.Render();
1580 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1581 application.SendNotification();
1582 application.Render();
1584 // Remove whole text
1585 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1586 DevelTextField::SelectWholeText(field);
1587 application.SendNotification();
1588 application.Render();
1590 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1591 application.SendNotification();
1592 application.Render();
1594 // Remove all with backspace
1595 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1596 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
1597 application.SendNotification();
1598 application.Render();
1600 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1601 application.SendNotification();
1602 application.Render();
1604 // Remove all with delete
1605 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1606 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1607 application.SendNotification();
1608 application.Render();
1610 application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1611 application.SendNotification();
1612 application.Render();
1617 // Positive test for the textChanged signal.
1618 int utcDaliTextFieldTextChangedP(void)
1620 ToolkitTestApplication application;
1621 tet_infoline(" utcDaliTextFieldTextChangedP");
1622 TextField field = TextField::New();
1623 DALI_TEST_CHECK(field);
1625 application.GetScene().Add(field);
1627 // connect to the text changed signal.
1628 ConnectionTracker* testTracker = new ConnectionTracker();
1629 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1630 bool textChangedSignal = false;
1631 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1633 gTextChangedCallBackCalled = false;
1634 field.SetProperty(TextField::Property::TEXT, "ABC");
1635 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1636 DALI_TEST_CHECK(textChangedSignal);
1638 application.SendNotification();
1639 field.SetKeyInputFocus();
1641 gTextChangedCallBackCalled = false;
1642 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1643 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1646 field.SetProperty(TextField::Property::TEXT, "");
1648 // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1649 gTextChangedCallBackCalled = false;
1650 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1651 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1653 // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1654 gTextChangedCallBackCalled = false;
1655 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1656 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1661 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1663 ToolkitTestApplication application;
1664 tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1665 TextField field = TextField::New();
1666 DALI_TEST_CHECK(field);
1668 application.GetScene().Add(field);
1670 // connect to the text changed signal.
1671 ConnectionTracker* testTracker = new ConnectionTracker();
1672 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1673 bool textChangedSignal = false;
1674 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1676 // get InputMethodContext
1678 InputMethodContext::EventData imfEvent;
1679 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1681 field.SetKeyInputFocus();
1682 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1685 gTextChangedCallBackCalled = false;
1686 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "ㅎ", 0, 1);
1687 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1688 application.SendNotification();
1689 application.Render();
1690 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1691 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ㅎ"), TEST_LOCATION);
1693 gTextChangedCallBackCalled = false;
1694 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "호", 0, 1);
1695 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1696 application.SendNotification();
1697 application.Render();
1698 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1699 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("호"), TEST_LOCATION);
1701 gTextChangedCallBackCalled = false;
1702 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "혿", 0, 1);
1703 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1704 application.SendNotification();
1705 application.Render();
1706 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1707 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("혿"), TEST_LOCATION);
1709 gTextChangedCallBackCalled = false;
1710 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "", 0, 1);
1711 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1712 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1714 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "호", 0, 1);
1715 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1716 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1718 imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "두", 1, 2);
1719 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1720 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1722 application.SendNotification();
1723 application.Render();
1724 DALI_TEST_CHECK(gTextChangedCallBackCalled);
1725 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("호두"), TEST_LOCATION);
1730 int utcDaliTextFieldSelectionWithInputMethodContext(void)
1732 ToolkitTestApplication application;
1733 tet_infoline(" utcDaliTextFieldSelectionWithInputMethodContext");
1734 TextField field = TextField::New();
1735 DALI_TEST_CHECK(field);
1737 field.SetProperty(TextField::Property::TEXT, "Hello world");
1739 application.GetScene().Add(field);
1741 // connect to the selection changed signal.
1742 ConnectionTracker* testTracker = new ConnectionTracker();
1743 DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
1744 bool selectionChangedSignal = false;
1745 field.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
1747 // get InputMethodContext
1749 InputMethodContext::EventData imfEvent;
1750 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1752 field.SetKeyInputFocus();
1753 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1756 gSelectionChangedCallbackCalled = false;
1757 imfEvent = InputMethodContext::EventData(InputMethodContext::SELECTION_SET, 1, 4);
1758 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1759 application.SendNotification();
1760 application.Render();
1761 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
1763 DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
1764 DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 4, TEST_LOCATION);
1769 int utcDaliTextFieldPositionWithInputMethodContext(void)
1771 ToolkitTestApplication application;
1772 tet_infoline(" utcDaliTextFieldPositionWithInputMethodContext");
1773 TextField field = TextField::New();
1774 DALI_TEST_CHECK(field);
1776 field.SetProperty(TextField::Property::TEXT, "Hello world");
1778 application.GetScene().Add(field);
1780 // connect to the selection changed signal.
1781 ConnectionTracker* testTracker = new ConnectionTracker();
1782 DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
1783 bool cursorPositionChangedSignal = false;
1784 field.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
1786 // get InputMethodContext
1788 InputMethodContext::EventData imfEvent;
1789 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1791 field.SetKeyInputFocus();
1792 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1795 gCursorPositionChangedCallbackCalled = false;
1796 imfEvent = InputMethodContext::EventData(InputMethodContext::SELECTION_SET, 2, 2);
1797 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1798 application.SendNotification();
1799 application.Render();
1800 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
1802 DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 2, TEST_LOCATION);
1807 int utcDaliTextFieldInputFilterWithInputMethodContext(void)
1809 ToolkitTestApplication application;
1810 tet_infoline(" utcDaliTextFieldInputFilterWithInputMethodContext");
1811 TextField field = TextField::New();
1812 DALI_TEST_CHECK(field);
1814 Property::Map inputFilter;
1815 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1816 inputFilter[InputFilter::Property::REJECTED] = "[5-7]";
1818 // Set input filter to TextField.
1819 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1821 application.GetScene().Add(field);
1823 // connect to the input filtered signal.
1824 ConnectionTracker* testTracker = new ConnectionTracker();
1825 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1826 bool inputFilteredSignal = false;
1827 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1829 // get InputMethodContext
1831 InputMethodContext::EventData imfEvent;
1832 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
1834 field.SetKeyInputFocus();
1835 field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
1838 gInputFilteredAcceptedCallbackCalled = false;
1839 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "Hello1234", 0, 9);
1840 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1841 application.SendNotification();
1842 application.Render();
1843 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1844 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("1234"), TEST_LOCATION);
1846 inputFilteredSignal = false;
1847 gInputFilteredRejectedCallbackCalled = false;
1848 imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "1234567", 0, 7);
1849 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1850 application.SendNotification();
1851 application.Render();
1852 DALI_TEST_CHECK(gInputFilteredRejectedCallbackCalled);
1853 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("12341234"), TEST_LOCATION);
1858 // Negative test for the textChanged signal.
1859 int utcDaliTextFieldTextChangedN(void)
1861 ToolkitTestApplication application;
1862 tet_infoline(" utcDaliTextFieldTextChangedN");
1863 TextField field = TextField::New();
1864 DALI_TEST_CHECK(field);
1866 application.GetScene().Add(field);
1868 // connect to the text changed signal.
1869 ConnectionTracker* testTracker = new ConnectionTracker();
1870 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1871 bool textChangedSignal = false;
1872 field.ConnectSignal(testTracker, "textChanged", CallbackFunctor(&textChangedSignal));
1874 gTextChangedCallBackCalled = false;
1875 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "ABC"); // Setting placeholder, not TEXT
1876 application.SendNotification();
1877 application.Render();
1878 DALI_TEST_CHECK(!gTextChangedCallBackCalled);
1879 DALI_TEST_CHECK(!textChangedSignal);
1884 // Positive test for Max Characters reached signal.
1885 int utcDaliTextFieldMaxCharactersReachedP(void)
1887 ToolkitTestApplication application;
1888 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1889 TextField field = TextField::New();
1890 DALI_TEST_CHECK(field);
1892 application.GetScene().Add(field);
1894 const int maxNumberOfCharacters = 1;
1895 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1897 field.SetKeyInputFocus();
1899 // connect to the text changed signal.
1900 ConnectionTracker* testTracker = new ConnectionTracker();
1901 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1902 bool maxLengthReachedSignal = false;
1903 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1905 gMaxCharactersCallBackCalled = false;
1907 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1908 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1910 DALI_TEST_CHECK(gMaxCharactersCallBackCalled);
1911 DALI_TEST_CHECK(maxLengthReachedSignal);
1916 // Negative test for Max Characters reached signal.
1917 int utcDaliTextFieldMaxCharactersReachedN(void)
1919 ToolkitTestApplication application;
1920 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1921 TextField field = TextField::New();
1922 DALI_TEST_CHECK(field);
1924 application.GetScene().Add(field);
1926 const int maxNumberOfCharacters = 3;
1927 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
1929 field.SetKeyInputFocus();
1931 // connect to the text changed signal.
1932 ConnectionTracker* testTracker = new ConnectionTracker();
1933 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1934 bool maxLengthReachedSignal = false;
1935 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
1937 gMaxCharactersCallBackCalled = false;
1939 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1940 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1942 DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1943 DALI_TEST_CHECK(!maxLengthReachedSignal);
1945 application.ProcessEvent(GenerateKey("Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1947 DALI_TEST_CHECK(!gMaxCharactersCallBackCalled);
1948 DALI_TEST_CHECK(!maxLengthReachedSignal);
1953 // Positive test for Input Filtered signal.
1954 int utcDaliTextFieldInputFilteredP(void)
1956 ToolkitTestApplication application;
1957 tet_infoline(" utcDaliTextFieldInputFilteredP");
1958 TextField field = TextField::New();
1959 DALI_TEST_CHECK(field);
1961 application.GetScene().Add(field);
1963 Property::Map inputFilter;
1965 // Only digit is accepted.
1966 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1968 // Set input filter to TextField.
1969 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1971 field.SetKeyInputFocus();
1973 // connect to the input filtered signal.
1974 ConnectionTracker* testTracker = new ConnectionTracker();
1975 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1976 bool inputFilteredSignal = false;
1977 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1979 gInputFilteredAcceptedCallbackCalled = false;
1981 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1983 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1984 DALI_TEST_CHECK(inputFilteredSignal);
1986 // Word is rejected.
1987 inputFilter[InputFilter::Property::ACCEPTED] = "";
1988 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1990 // Set input filter to TextField.
1991 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1993 field.SetKeyInputFocus();
1995 inputFilteredSignal = false;
1996 gInputFilteredRejectedCallbackCalled = false;
1998 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2000 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
2001 DALI_TEST_CHECK(inputFilteredSignal);
2006 // Negative test for Input Filtered signal.
2007 int utcDaliTextFieldInputFilteredN(void)
2009 ToolkitTestApplication application;
2010 tet_infoline(" utcDaliTextFieldInputFilteredP");
2011 TextField field = TextField::New();
2012 DALI_TEST_CHECK(field);
2014 application.GetScene().Add(field);
2016 Property::Map inputFilter;
2018 // Only word is accepted.
2019 inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
2021 // Set input filter to TextField.
2022 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
2024 field.SetKeyInputFocus();
2026 // connect to the input filtered signal.
2027 ConnectionTracker* testTracker = new ConnectionTracker();
2028 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
2029 bool inputFilteredSignal = false;
2030 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
2032 gInputFilteredAcceptedCallbackCalled = false;
2034 // Key a, d should not be filtered.
2035 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2036 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2037 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2038 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2040 // Backspace, Delete should not be filtered.
2041 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2042 application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2044 // Render and notify
2045 application.SendNotification();
2046 application.Render();
2048 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
2049 DALI_TEST_CHECK(!inputFilteredSignal);
2051 // Digit is rejected.
2052 inputFilter[InputFilter::Property::ACCEPTED] = "";
2053 inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
2055 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
2057 field.SetKeyInputFocus();
2059 inputFilteredSignal = false;
2060 gInputFilteredRejectedCallbackCalled = false;
2062 // Key a, d should not be filtered.
2063 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2064 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2065 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2066 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2068 // Backspace, Delete should not be filtered.
2069 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2070 application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2072 // Render and notify
2073 application.SendNotification();
2074 application.Render();
2076 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
2077 DALI_TEST_CHECK(!inputFilteredSignal);
2082 int utcDaliTextFieldInputStyleChanged01(void)
2084 // The text-field emits signals when the input style changes. These changes of style are
2085 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
2086 // can't be emitted during the size negotiation as the callbacks may update the UI.
2087 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
2088 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
2089 ToolkitTestApplication application;
2090 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
2094 char* pathNamePtr = get_current_dir_name();
2095 const std::string pathName(pathNamePtr);
2098 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2099 fontClient.SetDpi(93u, 93u);
2101 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2102 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2104 TextField field = TextField::New();
2105 DALI_TEST_CHECK(field);
2107 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2108 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2109 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2111 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2112 field.SetProperty(TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
2114 // connect to the text changed signal.
2115 ConnectionTracker* testTracker = new ConnectionTracker();
2116 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2117 bool inputStyleChangedSignal = false;
2118 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2120 application.GetScene().Add(field);
2122 // Render and notify
2123 application.SendNotification();
2124 application.Render();
2126 // Executes the idle callbacks added by the text control on the change of input style.
2127 application.RunIdles();
2129 gInputStyleChangedCallbackCalled = false;
2130 gInputStyleMask = TextField::InputStyle::NONE;
2131 inputStyleChangedSignal = false;
2133 // Create a tap event to touch the text field.
2134 TestGenerateTap(application, 18.0f, 25.0f);
2136 // Render and notify
2137 application.SendNotification();
2138 application.Render();
2140 // Executes the idle callbacks added by the text control on the change of input style.
2141 application.RunIdles();
2143 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2144 if(gInputStyleChangedCallbackCalled)
2146 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE), TEST_LOCATION);
2148 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2149 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2151 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2152 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2154 DALI_TEST_CHECK(inputStyleChangedSignal);
2156 gInputStyleChangedCallbackCalled = false;
2157 gInputStyleMask = TextField::InputStyle::NONE;
2158 inputStyleChangedSignal = false;
2160 // Create a tap event to touch the text field.
2161 TestGenerateTap(application, 30.0f, 25.0f);
2163 // Render and notify
2164 application.SendNotification();
2165 application.Render();
2167 // Executes the idle callbacks added by the text control on the change of input style.
2168 application.RunIdles();
2170 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2171 DALI_TEST_CHECK(!inputStyleChangedSignal);
2173 gInputStyleChangedCallbackCalled = false;
2174 gInputStyleMask = TextField::InputStyle::NONE;
2175 inputStyleChangedSignal = false;
2177 // Create a tap event to touch the text field.
2178 TestGenerateTap(application, 43.0f, 25.0f);
2180 // Render and notify
2181 application.SendNotification();
2182 application.Render();
2184 // Executes the idle callbacks added by the text control on the change of input style.
2185 application.RunIdles();
2187 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2188 if(gInputStyleChangedCallbackCalled)
2190 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR), TEST_LOCATION);
2192 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2193 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2195 DALI_TEST_CHECK(inputStyleChangedSignal);
2197 gInputStyleChangedCallbackCalled = false;
2198 gInputStyleMask = TextField::InputStyle::NONE;
2199 inputStyleChangedSignal = false;
2201 // Create a tap event to touch the text field.
2202 TestGenerateTap(application, 88.0f, 25.0f);
2204 // Render and notify
2205 application.SendNotification();
2206 application.Render();
2208 // Executes the idle callbacks added by the text control on the change of input style.
2209 application.RunIdles();
2211 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2212 if(gInputStyleChangedCallbackCalled)
2214 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2216 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2217 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2219 const Property::Map fontStyleMapGet = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<Property::Map>();
2221 Property::Map fontStyleMapSet;
2222 fontStyleMapSet.Insert("weight", "bold");
2224 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
2225 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
2227 DALI_TEST_CHECK(inputStyleChangedSignal);
2229 gInputStyleChangedCallbackCalled = false;
2230 gInputStyleMask = TextField::InputStyle::NONE;
2231 inputStyleChangedSignal = false;
2233 // Create a tap event to touch the text field.
2234 TestGenerateTap(application, 115.0f, 25.0f);
2236 // Render and notify
2237 application.SendNotification();
2238 application.Render();
2240 // Executes the idle callbacks added by the text control on the change of input style.
2241 application.RunIdles();
2243 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2244 DALI_TEST_CHECK(!inputStyleChangedSignal);
2246 gInputStyleChangedCallbackCalled = false;
2247 gInputStyleMask = TextField::InputStyle::NONE;
2248 inputStyleChangedSignal = false;
2250 // Create a tap event to touch the text field.
2251 TestGenerateTap(application, 164.0f, 25.0f);
2253 // Render and notify
2254 application.SendNotification();
2255 application.Render();
2257 // Executes the idle callbacks added by the text control on the change of input style.
2258 application.RunIdles();
2260 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2261 if(gInputStyleChangedCallbackCalled)
2263 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2265 const std::string style = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<std::string>();
2266 DALI_TEST_CHECK(style.empty());
2268 DALI_TEST_CHECK(inputStyleChangedSignal);
2270 gInputStyleChangedCallbackCalled = false;
2271 gInputStyleMask = TextField::InputStyle::NONE;
2272 inputStyleChangedSignal = false;
2274 // Create a tap event to touch the text field.
2275 TestGenerateTap(application, 191.0f, 25.0f);
2277 // Render and notify
2278 application.SendNotification();
2279 application.Render();
2281 // Executes the idle callbacks added by the text control on the change of input style.
2282 application.RunIdles();
2284 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2285 DALI_TEST_CHECK(!inputStyleChangedSignal);
2290 int utcDaliTextFieldInputStyleChanged02(void)
2292 // The text-field emits signals when the input style changes. These changes of style are
2293 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
2294 // can't be emitted during the size negotiation as the callbacks may update the UI.
2295 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
2296 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
2297 ToolkitTestApplication application;
2298 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
2302 char* pathNamePtr = get_current_dir_name();
2303 const std::string pathName(pathNamePtr);
2306 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2307 fontClient.SetDpi(93u, 93u);
2309 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2310 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2312 TextField field = TextField::New();
2313 DALI_TEST_CHECK(field);
2315 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2316 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2317 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2319 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2320 field.SetProperty(TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='blue'> l</color><color value='green'>lo</color> <font weight='bold'>world</font> demo</font>");
2322 // connect to the text changed signal.
2323 ConnectionTracker* testTracker = new ConnectionTracker();
2324 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2325 bool inputStyleChangedSignal = false;
2326 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2328 application.GetScene().Add(field);
2330 // Render and notify
2331 application.SendNotification();
2332 application.Render();
2334 // Executes the idle callbacks added by the text control on the change of input style.
2335 application.RunIdles();
2337 gInputStyleChangedCallbackCalled = false;
2338 gInputStyleMask = TextField::InputStyle::NONE;
2339 inputStyleChangedSignal = false;
2341 // Create a tap event to touch the text field.
2342 TestGenerateTap(application, 53.0f, 25.0f, 100);
2343 TestGenerateTap(application, 53.0f, 25.0f, 200);
2345 // Render and notify
2346 application.SendNotification();
2347 application.Render();
2349 // Executes the idle callbacks added by the text control on the change of input style.
2350 application.RunIdles();
2352 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2353 if(gInputStyleChangedCallbackCalled)
2355 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2356 static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY |
2357 TextField::InputStyle::POINT_SIZE |
2358 TextField::InputStyle::COLOR),
2361 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2362 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2364 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2365 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2367 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2368 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2370 DALI_TEST_CHECK(inputStyleChangedSignal);
2372 gInputStyleChangedCallbackCalled = false;
2373 gInputStyleMask = TextField::InputStyle::NONE;
2374 inputStyleChangedSignal = false;
2376 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2378 // Render and notify
2379 application.SendNotification();
2380 application.Render();
2382 // Executes the idle callbacks added by the text control on the change of input style.
2383 application.RunIdles();
2385 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2386 if(gInputStyleChangedCallbackCalled)
2388 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2389 static_cast<unsigned int>(TextField::InputStyle::COLOR),
2392 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2393 DALI_TEST_EQUALS(color, Color::BLUE, TEST_LOCATION);
2395 DALI_TEST_CHECK(inputStyleChangedSignal);
2397 gInputStyleChangedCallbackCalled = false;
2398 gInputStyleMask = TextField::InputStyle::NONE;
2399 inputStyleChangedSignal = false;
2401 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2403 // Render and notify
2404 application.SendNotification();
2405 application.Render();
2407 // Executes the idle callbacks added by the text control on the change of input style.
2408 application.RunIdles();
2410 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2411 DALI_TEST_CHECK(!inputStyleChangedSignal);
2413 gInputStyleChangedCallbackCalled = false;
2414 gInputStyleMask = TextField::InputStyle::NONE;
2415 inputStyleChangedSignal = false;
2417 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2419 // Render and notify
2420 application.SendNotification();
2421 application.Render();
2423 // Executes the idle callbacks added by the text control on the change of input style.
2424 application.RunIdles();
2426 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2427 if(gInputStyleChangedCallbackCalled)
2429 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2430 static_cast<unsigned int>(TextField::InputStyle::COLOR),
2433 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2434 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2436 DALI_TEST_CHECK(inputStyleChangedSignal);
2438 gInputStyleChangedCallbackCalled = false;
2439 gInputStyleMask = TextField::InputStyle::NONE;
2440 inputStyleChangedSignal = false;
2442 field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
2444 Property::Map fontStyleMapSet;
2445 fontStyleMapSet.Insert("weight", "thin");
2446 fontStyleMapSet.Insert("width", "condensed");
2447 fontStyleMapSet.Insert("slant", "italic");
2449 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
2450 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 20.f);
2452 field.SetProperty(TextField::Property::INPUT_UNDERLINE, "underline");
2453 field.SetProperty(TextField::Property::INPUT_SHADOW, "shadow");
2454 field.SetProperty(TextField::Property::INPUT_EMBOSS, "emboss");
2455 field.SetProperty(TextField::Property::INPUT_OUTLINE, "outline");
2456 field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "strikethrough");
2458 // Render and notify
2459 application.SendNotification();
2460 application.Render();
2462 // Executes the idle callbacks added by the text control on the change of input style.
2463 application.RunIdles();
2465 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2466 DALI_TEST_CHECK(!inputStyleChangedSignal);
2468 // Create a tap event to touch the text field.
2469 TestGenerateTap(application, 63.0f, 25.0f, 700);
2471 // Render and notify
2472 application.SendNotification();
2473 application.Render();
2475 // Executes the idle callbacks added by the text control on the change of input style.
2476 application.RunIdles();
2478 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2479 if(gInputStyleChangedCallbackCalled)
2481 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
2482 static_cast<unsigned int>(TextField::InputStyle::COLOR |
2483 TextField::InputStyle::POINT_SIZE |
2484 TextField::InputStyle::FONT_STYLE |
2485 TextField::InputStyle::UNDERLINE |
2486 TextField::InputStyle::SHADOW |
2487 TextField::InputStyle::EMBOSS |
2488 TextField::InputStyle::OUTLINE),
2491 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2492 DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
2494 DALI_TEST_CHECK(inputStyleChangedSignal);
2499 int utcDaliTextFieldInputStyleChanged03(void)
2501 // Test InputStyleCahnged signal emitted even if AddIdle failed.
2502 ToolkitTestApplication application;
2503 tet_infoline(" utcDaliTextFieldInputStyleChanged03");
2507 char* pathNamePtr = get_current_dir_name();
2508 const std::string pathName(pathNamePtr);
2511 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2512 fontClient.SetDpi(93u, 93u);
2514 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
2515 fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
2517 TextField field = TextField::New();
2518 DALI_TEST_CHECK(field);
2520 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2521 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2522 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2524 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
2525 field.SetProperty(TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
2527 // connect to the text changed signal.
2528 ConnectionTracker* testTracker = new ConnectionTracker();
2529 field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
2530 bool inputStyleChangedSignal = false;
2531 field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
2533 application.GetScene().Add(field);
2535 // Render and notify
2536 application.SendNotification();
2537 application.Render();
2539 // Executes the idle callbacks added by the text control on the change of input style.
2540 application.RunIdles();
2542 gInputStyleChangedCallbackCalled = false;
2543 gInputStyleMask = TextField::InputStyle::NONE;
2544 inputStyleChangedSignal = false;
2546 // Create a tap event to touch the text field.
2547 TestGenerateTap(application, 18.0f, 25.0f);
2549 // Render and notify
2550 application.SendNotification();
2551 application.Render();
2553 // Executes the idle callbacks added by the text control on the change of input style.
2554 application.RunIdles();
2556 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2557 if(gInputStyleChangedCallbackCalled)
2559 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE), TEST_LOCATION);
2561 const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
2562 DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
2564 const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
2565 DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2567 DALI_TEST_CHECK(inputStyleChangedSignal);
2569 gInputStyleChangedCallbackCalled = false;
2570 gInputStyleMask = TextField::InputStyle::NONE;
2571 inputStyleChangedSignal = false;
2573 // Create a tap event to touch the text field.
2574 TestGenerateTap(application, 30.0f, 25.0f);
2576 // Render and notify
2577 application.SendNotification();
2578 application.Render();
2580 // Executes the idle callbacks added by the text control on the change of input style.
2581 application.RunIdles();
2583 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2584 DALI_TEST_CHECK(!inputStyleChangedSignal);
2586 gInputStyleChangedCallbackCalled = false;
2587 gInputStyleMask = TextField::InputStyle::NONE;
2588 inputStyleChangedSignal = false;
2590 // Create a tap event to touch the text field.
2591 TestGenerateTap(application, 43.0f, 25.0f);
2593 // Render and notify
2594 application.SendNotification();
2595 application.Render();
2597 // Executes the idle callbacks added by the text control on the change of input style.
2598 application.RunIdles();
2600 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2601 if(gInputStyleChangedCallbackCalled)
2603 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR), TEST_LOCATION);
2605 const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
2606 DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
2608 DALI_TEST_CHECK(inputStyleChangedSignal);
2610 gInputStyleChangedCallbackCalled = false;
2611 gInputStyleMask = TextField::InputStyle::NONE;
2612 inputStyleChangedSignal = false;
2614 // Make AddIdle return false.
2615 ToolkitApplication::ADD_IDLE_SUCCESS = false;
2617 // Create a tap event to touch the text field.
2618 TestGenerateTap(application, 88.0f, 25.0f);
2620 // Render and notify
2621 application.SendNotification();
2622 application.Render();
2624 // Execute the idle callbacks.
2625 // And check whether we didn't change of input style.
2626 application.RunIdles();
2628 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2629 DALI_TEST_CHECK(!inputStyleChangedSignal);
2631 gInputStyleChangedCallbackCalled = false;
2632 gInputStyleMask = TextField::InputStyle::NONE;
2633 inputStyleChangedSignal = false;
2635 // Create a tap event to touch the text field.
2636 TestGenerateTap(application, 115.0f, 25.0f);
2638 // Render and notify
2639 application.SendNotification();
2640 application.Render();
2642 // Execute the idle callbacks.
2643 // And check whether we didn't change of input style.
2644 application.RunIdles();
2646 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2647 DALI_TEST_CHECK(!inputStyleChangedSignal);
2649 gInputStyleChangedCallbackCalled = false;
2650 gInputStyleMask = TextField::InputStyle::NONE;
2651 inputStyleChangedSignal = false;
2653 // Revert AddIdle return true.
2654 ToolkitApplication::ADD_IDLE_SUCCESS = true;
2656 // Create a tap event to touch the text field.
2657 TestGenerateTap(application, 164.0f, 25.0f);
2659 // Render and notify
2660 application.SendNotification();
2661 application.Render();
2663 // Executes the idle callbacks added by the text control on the change of input style.
2664 application.RunIdles();
2666 DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
2667 if(gInputStyleChangedCallbackCalled)
2669 DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
2671 const std::string style = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<std::string>();
2672 DALI_TEST_CHECK(style.empty());
2674 DALI_TEST_CHECK(inputStyleChangedSignal);
2676 gInputStyleChangedCallbackCalled = false;
2677 gInputStyleMask = TextField::InputStyle::NONE;
2678 inputStyleChangedSignal = false;
2680 // Create a tap event to touch the text field.
2681 TestGenerateTap(application, 191.0f, 25.0f);
2683 // Render and notify
2684 application.SendNotification();
2685 application.Render();
2687 // Executes the idle callbacks added by the text control on the change of input style.
2688 application.RunIdles();
2690 DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
2691 DALI_TEST_CHECK(!inputStyleChangedSignal);
2696 int utcDaliTextFieldEvent01(void)
2698 ToolkitTestApplication application;
2699 tet_infoline(" utcDaliTextFieldEvent01");
2701 // Creates a tap event. After creating a tap event the text field should
2702 // have the focus and add text with key events should be possible.
2704 TextField field = TextField::New();
2705 DALI_TEST_CHECK(field);
2707 application.GetScene().Add(field);
2709 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2710 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2711 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2713 // Render and notify
2714 application.SendNotification();
2715 application.Render();
2717 // Avoid a crash when core load gl resources.
2718 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2720 // Render and notify
2721 application.SendNotification();
2722 application.Render();
2724 // Add a key event but as the text field has not the focus it should do nothing.
2725 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2727 // Render and notify
2728 application.SendNotification();
2729 application.Render();
2731 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
2733 // Create a tap event to touch the text field.
2734 TestGenerateTap(application, 150.0f, 25.0f);
2736 // Render and notify
2737 application.SendNotification();
2738 application.Render();
2740 // Pressing delete key should be fine even if there is no text in TextField.
2741 application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2742 // Render and notify
2743 application.SendNotification();
2744 application.Render();
2746 // Now the text field has the focus, so it can handle the key events.
2747 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2748 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2750 // Render and notify
2751 application.SendNotification();
2752 application.Render();
2754 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2756 // Create a second text field and send key events to it.
2757 TextField field2 = TextField::New();
2759 field2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2760 field2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2761 field2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
2762 field2.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
2764 application.GetScene().Add(field2);
2766 // Render and notify
2767 application.SendNotification();
2768 application.Render();
2770 // Create a tap event on the second text field.
2771 TestGenerateTap(application, 150.0f, 125.0f);
2773 // Render and notify
2774 application.SendNotification();
2775 application.Render();
2777 // The second text field has the focus. It should handle the key events.
2778 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2779 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2781 // Render and notify
2782 application.SendNotification();
2783 application.Render();
2785 // Check the text has been added to the second text field.
2786 DALI_TEST_EQUALS(field2.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
2791 int utcDaliTextFieldEvent02(void)
2793 ToolkitTestApplication application;
2794 tet_infoline(" utcDaliTextFieldEvent02");
2796 // Checks if the right number of actors are created.
2798 TextField field = TextField::New();
2799 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2800 DALI_TEST_CHECK(field);
2801 LoadMarkerImages(application, field);
2803 application.GetScene().Add(field);
2805 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
2806 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2807 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2809 // Avoid a crash when core load gl resources.
2810 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2812 // Render and notify
2813 application.SendNotification();
2814 application.Render();
2816 // Check there are the expected number of children ( stencil ).
2817 DALI_TEST_EQUALS(field.GetChildCount(), 1u, TEST_LOCATION);
2819 Actor stencil = field.GetChildAt(0u);
2820 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2822 // Create a tap event to touch the text field.
2823 TestGenerateTap(application, 150.0f, 25.0f, 300);
2825 // Render and notify
2826 application.SendNotification();
2827 application.Render();
2829 Actor layer = field.GetChildAt(2u);
2830 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2831 DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
2833 // Now the text field has the focus, so it can handle the key events.
2834 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2835 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2837 // Render and notify
2838 application.SendNotification();
2839 application.Render();
2841 // Checks the cursor and the renderer have been created.
2842 DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
2843 DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
2845 Control cursor = Control::DownCast(layer.GetChildAt(0u));
2846 DALI_TEST_CHECK(cursor);
2848 // The offscreen root actor has a container with all the actors which contain the text renderers.
2849 Actor container = stencil.GetChildAt(0u);
2850 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2852 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2853 DALI_TEST_CHECK(renderer);
2856 // Move the cursor and check the position changes.
2857 Vector3 position1 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2858 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2860 // Render and notify
2861 application.SendNotification();
2862 application.Render();
2864 Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2865 DALI_TEST_CHECK(position2.x < position1.x);
2867 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2869 // Render and notify
2870 application.SendNotification();
2871 application.Render();
2873 Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2874 DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
2876 // Move the cursor to the first position.
2877 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2878 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2880 // Render and notify
2881 application.SendNotification();
2882 application.Render();
2884 Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2886 // Send some taps and check the cursor positions.
2888 // Try to tap at the beginning.
2889 TestGenerateTap(application, 1.0f, 25.0f, 900);
2891 // Render and notify
2892 application.SendNotification();
2893 application.Render();
2895 // Cursor position should be the same than position1.
2896 Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2898 DALI_TEST_EQUALS(position4, position5, TEST_LOCATION); // Should be in the same position2.
2900 // Tap away from the start position.
2901 TestGenerateTap(application, 16.0f, 25.0f, 1500);
2903 // Render and notify
2904 application.SendNotification();
2905 application.Render();
2907 Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2909 DALI_TEST_CHECK(position6.x > position5.x);
2911 // Remove all the text.
2912 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2913 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
2914 field.SetProperty(TextField::Property::TEXT, "");
2916 // Render and notify
2917 application.SendNotification();
2918 application.Render();
2920 // Cursor position should be the same than position2.
2921 Vector3 position7 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
2923 DALI_TEST_EQUALS(position4, position7, TEST_LOCATION); // Should be in the same position2.
2925 // Should not be a renderer, there is only a clipped cursor.
2926 DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
2928 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2929 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2930 field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
2932 application.SendNotification();
2933 application.Render();
2935 // There are renderer and decorator layer
2936 DALI_TEST_EQUALS(field.GetChildCount(), 2u, TEST_LOCATION);
2941 int utcDaliTextFieldEvent03(void)
2943 ToolkitTestApplication application;
2944 tet_infoline(" utcDaliTextFieldEvent03");
2946 // Checks if the highlight actor is created.
2948 TextField field = TextField::New();
2949 DALI_TEST_CHECK(field);
2951 application.GetScene().Add(field);
2953 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
2954 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
2955 field.SetProperty(Actor::Property::SIZE, Vector2(30.f, 50.f));
2956 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2957 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2959 // Avoid a crash when core load gl resources.
2960 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2961 LoadMarkerImages(application, field);
2963 // Render and notify
2964 application.SendNotification();
2965 application.Render();
2967 // Tap first to get the focus.
2968 TestGenerateTap(application, 3.0f, 25.0f, 100);
2970 // Render and notify
2971 application.SendNotification();
2972 application.Render();
2974 // Double tap to select a word.
2975 TestGenerateTap(application, 3.0f, 25.0f, 200);
2977 // Render and notify
2978 application.SendNotification();
2979 application.Render();
2981 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2982 Actor stencil = field.GetChildAt(0u);
2984 // The highlight actor is drawn first, so is the first actor in the list
2985 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
2986 DALI_TEST_CHECK(highlight);
2988 // The offscreen root actor has a container with all the actors which contain the text renderers.
2989 Actor container = stencil.GetChildAt(1u);
2990 for(unsigned int index = 0; index < container.GetChildCount(); ++index)
2992 Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
2993 DALI_TEST_CHECK(renderer);
2999 int utcDaliTextFieldEvent04(void)
3001 ToolkitTestApplication application;
3002 tet_infoline(" utcDaliTextFieldEvent04");
3004 // Checks if the highlight actor is created.
3006 TextField field = TextField::New();
3007 DALI_TEST_CHECK(field);
3008 application.GetScene().Add(field);
3009 LoadMarkerImages(application, field);
3010 // Render and notify
3011 application.SendNotification();
3012 application.Render();
3014 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
3015 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3016 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3017 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3018 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3020 // Avoid a crash when core load gl resources.
3021 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3022 // Render and notify
3023 application.SendNotification();
3024 application.Render();
3026 // Create a tap event to touch the text field.
3027 TestGenerateTap(application, 150.0f, 25.0f);
3028 // Render and notify
3029 application.SendNotification();
3030 application.Render();
3032 // Tap first to get the focus.
3033 TestGenerateTap(application, 1.0f, 25.0f);
3035 // Render and notify
3036 application.SendNotification();
3037 application.Render();
3039 // Double tap to select a word.
3040 TestGenerateTap(application, 1.0f, 25.0f);
3042 // Render and notify
3043 application.SendNotification();
3044 application.Render();
3047 TestGenerateTap(application, 0.0f, 40.0f);
3049 field.SetProperty(TextField::Property::POINT_SIZE, 12.f);
3050 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3055 int utcDaliTextFieldEvent05(void)
3057 ToolkitTestApplication application;
3058 tet_infoline(" utcDaliTextFieldEvent05");
3060 // Checks dragging of cursor/grab handle
3062 TextField field = TextField::New();
3063 DALI_TEST_CHECK(field);
3064 application.GetScene().Add(field);
3065 LoadMarkerImages(application, field);
3066 // Render and notify
3067 application.SendNotification();
3068 application.Render();
3070 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
3071 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3072 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3073 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3074 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3076 // Avoid a crash when core load gl resources.
3077 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3078 // Render and notify
3079 application.SendNotification();
3080 application.Render();
3082 // Create a tap event to touch the text field.
3083 TestGenerateTap(application, 150.0f, 25.0f);
3084 // Render and notify
3085 application.SendNotification();
3086 application.Render();
3088 // Tap first to get the focus.
3089 TestGenerateTap(application, 1.0f, 25.0f);
3091 // Render and notify
3092 application.SendNotification();
3093 application.Render();
3095 // Double tap to select a word.
3096 TestGenerateTap(application, 1.0f, 25.0f);
3098 // Render and notify
3099 application.SendNotification();
3100 application.Render();
3102 Actor stencil = field.GetChildAt(1u);
3106 int utcDaliTextFieldEvent06(void)
3108 ToolkitTestApplication application;
3109 tet_infoline(" utcDaliTextFieldEvent06");
3111 // Checks Longpress when in edit mode
3113 TextField field = TextField::New();
3114 DALI_TEST_CHECK(field);
3115 application.GetScene().Add(field);
3116 LoadMarkerImages(application, field);
3117 // Render and notify
3118 application.SendNotification();
3119 application.Render();
3121 field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
3122 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3123 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3124 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3125 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3127 // Avoid a crash when core load gl resources.
3128 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3129 // Render and notify
3130 application.SendNotification();
3131 application.Render();
3133 // Create a tap event to touch the text field.
3134 TestGenerateTap(application, 150.0f, 25.0f);
3135 // Render and notify
3136 application.SendNotification();
3137 application.Render();
3139 // Tap first to get the focus.
3140 TestGenerateTap(application, 1.0f, 25.0f);
3142 // Render and notify
3143 application.SendNotification();
3144 application.Render();
3147 TestGenerateLongPress(application, 1.0f, 25.0f);
3149 // Render and notify
3150 application.SendNotification();
3151 application.Render();
3156 int utcDaliTextFieldEvent07(void)
3158 ToolkitTestApplication application;
3159 tet_infoline(" utcDaliTextFieldEvent07");
3161 // Checks Longpress to start edit mode
3163 TextField field = TextField::New();
3164 DALI_TEST_CHECK(field);
3165 application.GetScene().Add(field);
3166 LoadMarkerImages(application, field);
3167 // Render and notify
3168 application.SendNotification();
3169 application.Render();
3171 field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
3172 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3173 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3174 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3175 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3176 Property::Map propertyMap;
3177 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
3178 field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
3180 // Avoid a crash when core load gl resources.
3181 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3182 // Render and notify
3183 application.SendNotification();
3184 application.Render();
3187 TestGenerateLongPress(application, 1.0f, 25.0f);
3189 // Render and notify
3190 application.SendNotification();
3191 application.Render();
3196 int utcDaliTextFieldEvent08(void)
3198 ToolkitTestApplication application;
3199 tet_infoline(" utcDaliTextFieldEvent08");
3201 Dali::Clipboard clipboard = Clipboard::Get();
3202 Dali::Clipboard::ClipData data("text/plain;charset=utf-8", "testTextFieldEvent");
3203 clipboard.SetData(data);
3205 // Checks Longpress when only place holder text
3207 TextField field = TextField::New();
3208 DALI_TEST_CHECK(field);
3209 application.GetScene().Add(field);
3210 LoadMarkerImages(application, field);
3211 // Render and notify
3212 application.SendNotification();
3213 application.Render();
3215 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
3216 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3217 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3218 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3219 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3221 // Avoid a crash when core load gl resources.
3222 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3223 // Render and notify
3224 application.SendNotification();
3225 application.Render();
3228 TestGenerateLongPress(application, 1.0f, 25.0f, 20);
3230 // Render and notify
3231 application.SendNotification();
3232 application.Render();
3234 Wait(application, 500);
3236 TestEndLongPress(application, 1.0f, 25.0f, 520);
3239 TestGenerateLongPress(application, 1.0f, 25.0f, 600);
3241 // Render and notify
3242 application.Render();
3244 Wait(application, 500);
3246 Integration::Scene stage = application.GetScene();
3247 Layer layer = stage.GetRootLayer();
3248 Actor actor = layer.FindChildByName("optionPaste");
3252 Vector3 worldPosition = actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION);
3253 Vector2 halfStageSize = stage.GetSize() / 2.0f;
3254 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
3256 Dali::Integration::TouchEvent event;
3257 event = Dali::Integration::TouchEvent();
3258 event.AddPoint(GetPointDownInside(position));
3259 application.ProcessEvent(event);
3261 event = Dali::Integration::TouchEvent();
3262 event.AddPoint(GetPointUpInside(position));
3263 application.ProcessEvent(event);
3265 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("testTextFieldEvent"), TEST_LOCATION);
3267 Dali::Clipboard::ClipData htmlData("application/xhtml+xml", "testTextFieldEventHtml");
3268 clipboard.SetData(htmlData);
3270 field.SetProperty(TextField::Property::TEXT, "");
3272 // Render and notify
3273 application.SendNotification();
3274 application.Render();
3277 TestGenerateLongPress(application, 1.0f, 25.0f, 20);
3279 // Render and notify
3280 application.SendNotification();
3281 application.Render();
3283 Wait(application, 500);
3285 TestEndLongPress(application, 1.0f, 25.0f, 520);
3288 TestGenerateLongPress(application, 1.0f, 25.0f, 600);
3290 // Render and notify
3291 application.Render();
3293 Wait(application, 500);
3295 stage = application.GetScene();
3296 layer = stage.GetRootLayer();
3297 actor = layer.FindChildByName("optionPaste");
3301 Vector3 worldPosition = actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION);
3302 Vector2 halfStageSize = stage.GetSize() / 2.0f;
3303 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
3305 Dali::Integration::TouchEvent event;
3306 event = Dali::Integration::TouchEvent();
3307 event.AddPoint(GetPointDownInside(position));
3308 application.ProcessEvent(event);
3310 event = Dali::Integration::TouchEvent();
3311 event.AddPoint(GetPointUpInside(position));
3312 application.ProcessEvent(event);
3314 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("testTextFieldEventHtml"), TEST_LOCATION);
3319 int utcDaliTextFieldEvent09(void)
3321 ToolkitTestApplication application;
3322 tet_infoline(" utcDaliTextFieldEvent09");
3324 TextField field = TextField::New();
3325 DALI_TEST_CHECK(field);
3326 application.GetScene().Add(field);
3327 LoadMarkerImages(application, field);
3328 // Render and notify
3329 application.SendNotification();
3330 application.Render();
3332 field.SetProperty(TextField::Property::TEXT, "Hello");
3333 field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Placeholder text");
3334 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3335 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3336 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3337 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3339 // Avoid a crash when core load gl resources.
3340 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3342 // Create a tap event to touch the text field.
3343 TestGenerateTap(application, 150.0f, 25.0f);
3344 application.SendNotification();
3345 application.Render();
3348 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_NONE;
3349 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3350 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3351 application.SendNotification();
3352 application.Render();
3353 for(unsigned int index = 0u; index < 6u; ++index)
3355 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3356 application.SendNotification();
3357 application.Render();
3360 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL;
3361 map[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
3362 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3363 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3364 application.SendNotification();
3365 application.Render();
3367 map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_COUNT;
3368 map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
3369 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3370 for(unsigned int index = 0u; index < 5u; ++index)
3372 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3373 application.SendNotification();
3374 application.Render();
3377 map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_COUNT;
3378 map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
3379 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3380 for(unsigned int index = 0u; index < 5u; ++index)
3382 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3383 application.SendNotification();
3384 application.Render();
3387 map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
3388 map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 0;
3389 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3390 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3391 application.SendNotification();
3392 application.Render();
3393 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3394 application.SendNotification();
3395 application.Render();
3397 map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 100;
3398 field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
3399 application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3400 application.SendNotification();
3401 application.Render();
3403 Property::Map mapGet;
3404 mapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
3405 DALI_TEST_EQUALS(map.Count(), mapGet.Count(), TEST_LOCATION);
3406 DALI_TEST_EQUALS(DaliTestCheckMaps(map, mapGet), true, TEST_LOCATION);
3410 int utcDaliTextFieldStyleWhilstSelected(void)
3412 ToolkitTestApplication application;
3413 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
3415 // Change font and styles whilst text is selected whilst word selected
3417 TextField field = TextField::New();
3418 DALI_TEST_CHECK(field);
3419 application.GetScene().Add(field);
3420 LoadMarkerImages(application, field);
3421 // Render and notify
3422 application.SendNotification();
3423 application.Render();
3425 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
3426 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3427 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3428 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3429 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3431 // Avoid a crash when core load gl resources.
3432 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3433 // Render and notify
3434 application.SendNotification();
3435 application.Render();
3437 // Create a tap event to touch the text field.
3438 TestGenerateTap(application, 150.0f, 25.0f);
3439 // Render and notify
3440 application.SendNotification();
3441 application.Render();
3443 // Tap first to get the focus.
3444 TestGenerateTap(application, 1.0f, 25.0f);
3446 // Render and notify
3447 application.SendNotification();
3448 application.Render();
3450 // Double tap to select a word.
3451 TestGenerateTap(application, 1.0f, 25.0f);
3453 // Render and notify
3454 application.SendNotification();
3455 application.Render();
3457 field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
3458 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
3460 Property::Map fontStyleMapSet;
3461 Property::Map fontStyleMapGet;
3463 fontStyleMapSet.Insert("weight", "bold");
3464 fontStyleMapSet.Insert("slant", "italic");
3465 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
3467 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
3468 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3469 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3471 fontStyleMapSet.Clear();
3472 fontStyleMapSet.Insert("width", "expanded");
3473 fontStyleMapSet.Insert("slant", "italic");
3474 field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
3476 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
3477 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3478 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3480 field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
3481 DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3483 field.SetProperty(TextField::Property::TEXT_COLOR, Color::RED);
3484 DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::RED, TEST_LOCATION);
3486 fontStyleMapSet.Clear();
3487 fontStyleMapSet.Insert("weight", "bold");
3488 fontStyleMapSet.Insert("slant", "italic");
3490 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
3492 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3493 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3494 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3496 fontStyleMapSet.Clear();
3497 fontStyleMapSet.Insert("width", "expanded");
3499 field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
3501 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3502 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
3503 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
3505 // Press Escape to increase coverage
3506 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3507 application.SendNotification();
3508 application.Render();
3510 DALI_TEST_CHECK(!field.HasKeyInputFocus());
3515 int utcDaliTextFieldEscKeyLoseFocus(void)
3517 ToolkitTestApplication application;
3518 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
3520 // Creates a tap event. After creating a tap event the text field should
3521 // have the focus and add text with key events should be possible.
3523 TextField field = TextField::New();
3524 DALI_TEST_CHECK(field);
3526 application.GetScene().Add(field);
3528 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3529 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3530 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3532 // Avoid a crash when core load gl resources.
3533 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3535 // Render and notify
3536 application.SendNotification();
3537 application.Render();
3539 // Add a key event but as the text field has not the focus it should do nothing.
3540 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3541 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3543 // Render and notify
3544 application.SendNotification();
3545 application.Render();
3547 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
3549 // Create a tap event to touch the text field.
3550 TestGenerateTap(application, 150.0f, 25.0f);
3552 // Render and notify
3553 application.SendNotification();
3554 application.Render();
3556 // Now the text field has the focus, so it can handle the key events.
3557 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3558 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3559 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3560 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3562 // Render and notify
3563 application.SendNotification();
3564 application.Render();
3566 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3568 // Generate a Esc key event. The text field should lose the focus.
3569 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3570 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3572 // Render and notify
3573 application.SendNotification();
3574 application.Render();
3576 DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
3578 // No more text should be introduced
3579 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3580 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3582 // Render and notify
3583 application.SendNotification();
3584 application.Render();
3586 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
3591 int utcDaliTextFieldSomeSpecialKeys(void)
3593 ToolkitTestApplication application;
3594 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
3596 // Checks some special keys when the text is selected.
3598 TextField field = TextField::New();
3599 DALI_TEST_CHECK(field);
3600 application.GetScene().Add(field);
3601 LoadMarkerImages(application, field);
3602 // Render and notify
3603 application.SendNotification();
3604 application.Render();
3606 const std::string longText("This is a long text for the size of the text-field.");
3608 field.SetProperty(TextField::Property::TEXT, longText);
3609 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
3610 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3611 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3612 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3614 // Avoid a crash when core load gl resources.
3615 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3616 // Render and notify
3617 application.SendNotification();
3618 application.Render();
3620 // Create a tap event to touch the text field.
3621 TestGenerateTap(application, 150.0f, 25.0f);
3623 // Render and notify
3624 application.SendNotification();
3625 application.Render();
3627 // Tap first to get the focus.
3628 TestGenerateTap(application, 1.0f, 25.0f);
3630 // Render and notify
3631 application.SendNotification();
3632 application.Render();
3634 // Double tap to select a word.
3635 TestGenerateTap(application, 1.0f, 25.0f);
3637 // Render and notify
3638 application.SendNotification();
3639 application.Render();
3641 // Generate a Esc key event. The text field should lose the focus.
3642 application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3643 application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3645 // Render and notify
3646 application.SendNotification();
3647 application.Render();
3649 // Generate a Esc key event. The text field should lose the focus.
3650 application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3651 application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3653 // Render and notify
3654 application.SendNotification();
3655 application.Render();
3657 // Generate a Esc key event. The text field should lose the focus.
3658 application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3659 application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3661 // Render and notify
3662 application.SendNotification();
3663 application.Render();
3665 // Generate a Back key event. Nothing happens to the text field.
3666 application.ProcessEvent(GenerateKey("XF86Back", "", "XF86Back", DALI_KEY_BACK, 0, 0, Integration::KeyEvent::DOWN, "XF86Back", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3667 application.ProcessEvent(GenerateKey("XF86Back", "", "XF86Back", DALI_KEY_BACK, 0, 0, Integration::KeyEvent::UP, "XF86Back", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3669 // Render and notify
3670 application.SendNotification();
3671 application.Render();
3673 // The text shouldn't be deleted.
3674 DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), longText, TEST_LOCATION);
3679 int utcDaliTextFieldSizeUpdate(void)
3681 ToolkitTestApplication application;
3682 tet_infoline("utcDaliTextFieldSizeUpdate");
3684 // Checks some special keys when the text is selected.
3685 TextField field = TextField::New();
3686 DALI_TEST_CHECK(field);
3687 application.GetScene().Add(field);
3689 float previousHeight = 0.0f;
3690 float currentHeight = 0.0f;
3691 const float fieldWidth = 1920.0f;
3693 // "ㅁ" is bigger then "ኢ"
3694 field.SetProperty(Actor::Property::SIZE, Vector2(fieldWidth, 10.0f));
3695 field.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3696 field.SetResizePolicy(ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT);
3698 field.SetProperty(TextField::Property::TEXT, "ኢ");
3699 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3700 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3702 field.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
3703 KeyboardFocusManager::Get().SetCurrentFocusActor(field);
3705 application.SendNotification();
3706 application.Render();
3708 previousHeight = field.GetHeightForWidth(fieldWidth);
3709 DALI_TEST_EQUALS(previousHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3711 // Add another script characters ( glyph height is defferent )
3712 application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3713 application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3715 application.SendNotification();
3716 application.Render();
3718 currentHeight = field.GetHeightForWidth(fieldWidth);
3719 DALI_TEST_EQUALS(currentHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
3720 DALI_TEST_EQUALS((previousHeight < currentHeight), true, TEST_LOCATION);
3725 int utcDaliTextFieldExtremlyLargePointSize(void)
3727 ToolkitTestApplication application;
3728 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
3730 TextField field = TextField::New();
3732 field.SetProperty(TextField::Property::TEXT, "Text");
3733 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3734 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3735 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3736 application.GetScene().Add(field);
3740 field.SetProperty(TextField::Property::POINT_SIZE, 160.0f);
3741 application.SendNotification();
3742 DALI_TEST_CHECK(field);
3746 tet_result(TET_FAIL);
3751 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
3753 ToolkitTestApplication application;
3754 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
3755 TextField field = TextField::New();
3756 DALI_TEST_CHECK(field);
3757 application.GetScene().Add(field);
3759 Property::Map fontStyleMapGet;
3761 fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
3763 Property::Value* weightValue = NULL;
3764 Property::Value* widthValue = NULL;
3765 Property::Value* slantValue = NULL;
3766 weightValue = fontStyleMapGet.Find("weight");
3767 widthValue = fontStyleMapGet.Find("width");
3768 slantValue = fontStyleMapGet.Find("slant");
3769 DALI_TEST_CHECK(!weightValue);
3770 DALI_TEST_CHECK(!widthValue);
3771 DALI_TEST_CHECK(!slantValue);
3776 int UtcDaliTextFieldSettingPlaceholder(void)
3778 ToolkitTestApplication application;
3779 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
3781 TextField field = TextField::New();
3782 DALI_TEST_CHECK(field);
3783 application.GetScene().Add(field);
3785 // Check the placeholder property with pixel size
3786 Property::Map placeholderPixelSizeMapSet;
3787 Property::Map placeholderPixelSizeMapGet;
3788 Property::Map placeholderFontstyleMap;
3789 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT] = "Setting Placeholder Text";
3790 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3791 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::COLOR] = Color::BLUE;
3792 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3793 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3794 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::ELLIPSIS] = true;
3796 placeholderFontstyleMap.Insert("weight", "bold");
3797 placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3798 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
3800 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3801 DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
3802 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderPixelSizeMapSet), true, TEST_LOCATION);
3804 // Check the placeholder property with point size
3805 Property::Map placeholderMapSet;
3806 Property::Map placeholderMapGet;
3807 placeholderMapSet[Text::PlaceHolder::Property::TEXT] = "Setting Placeholder Text";
3808 placeholderMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
3809 placeholderMapSet[Text::PlaceHolder::Property::COLOR] = Color::RED;
3810 placeholderMapSet[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3811 placeholderMapSet[Text::PlaceHolder::Property::POINT_SIZE] = 12.0f;
3812 placeholderMapSet[Text::PlaceHolder::Property::ELLIPSIS] = false;
3814 // Check the placeholder font style property
3815 placeholderFontstyleMap.Clear();
3817 placeholderFontstyleMap.Insert("weight", "bold");
3818 placeholderFontstyleMap.Insert("width", "condensed");
3819 placeholderFontstyleMap.Insert("slant", "italic");
3820 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3821 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3823 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3824 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3825 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3827 // Reset font style.
3828 placeholderFontstyleMap.Clear();
3829 placeholderFontstyleMap.Insert("weight", "normal");
3830 placeholderFontstyleMap.Insert("slant", "oblique");
3831 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3832 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3834 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3835 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3836 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3838 placeholderFontstyleMap.Clear();
3839 placeholderFontstyleMap.Insert("slant", "roman");
3840 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3841 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3843 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3845 placeholderFontstyleMap.Clear();
3846 placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
3848 field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
3849 placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
3850 DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
3851 DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
3856 int UtcDaliTextFieldPlaceholderCoverage(void)
3858 ToolkitTestApplication application;
3859 tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
3861 // mPlaceholderFont is created only once, so create a new control for coverage.
3862 TextField fieldForCoverage = TextField::New();
3863 DALI_TEST_CHECK(fieldForCoverage);
3864 application.GetScene().Add(fieldForCoverage);
3866 // for SetPlaceholderFontFamily() coverage.
3867 Property::Map fontFamilyMap;
3868 fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3869 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
3871 // mPlaceholderFont is created only once, so create a new control for coverage.
3872 fieldForCoverage = TextField::New();
3873 DALI_TEST_CHECK(fieldForCoverage);
3874 application.GetScene().Add(fieldForCoverage);
3876 // for SetPlaceholderTextFontSize coverage.
3877 Property::Map fontSizeMap;
3878 fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3879 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
3881 // mPlaceholderFont is created only once, so create a new control for coverage.
3882 fieldForCoverage = TextField::New();
3883 DALI_TEST_CHECK(fieldForCoverage);
3884 application.GetScene().Add(fieldForCoverage);
3886 // for SetPlaceholderTextFontWeight coverage.
3887 Property::Map fontStyleWeightMap;
3888 Property::Map fontStyleWeightPropertyMap;
3889 fontStyleWeightPropertyMap.Insert("weight", "bold");
3890 fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
3891 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
3893 // mPlaceholderFont is created only once, so create a new control for coverage.
3894 fieldForCoverage = TextField::New();
3895 DALI_TEST_CHECK(fieldForCoverage);
3896 application.GetScene().Add(fieldForCoverage);
3898 // for SetPlaceholderTextFontWidth coverage.
3899 Property::Map fontStyleWidthMap;
3900 Property::Map fontStyleWidthPropertyMap;
3901 fontStyleWidthPropertyMap.Insert("width", "expanded");
3902 fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
3903 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
3905 // mPlaceholderFont is created only once, so create a new control for coverage.
3906 fieldForCoverage = TextField::New();
3907 DALI_TEST_CHECK(fieldForCoverage);
3908 application.GetScene().Add(fieldForCoverage);
3910 // for SetPlaceholderTextFontSlant coverage.
3911 Property::Map fontStyleSlantMap;
3912 Property::Map fontStyleSlantPropertyMap;
3913 fontStyleSlantPropertyMap.Insert("slant", "italic");
3914 fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
3915 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
3920 int UtcDaliTextFieldSetPaddingProperty(void)
3922 ToolkitTestApplication application;
3923 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3925 TextField field = TextField::New();
3926 DALI_TEST_CHECK(field);
3927 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3928 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3929 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3930 application.GetScene().Add(field);
3932 application.SendNotification();
3933 application.Render();
3935 Vector3 originalSize = field.GetNaturalSize();
3937 field.SetProperty(Toolkit::Control::Property::PADDING, Extents(10, 10, 10, 10));
3939 application.SendNotification();
3940 application.Render();
3942 DALI_TEST_EQUALS(field.GetProperty<Extents>(Toolkit::Control::Property::PADDING), Extents(10, 10, 10, 10), TEST_LOCATION);
3944 Vector3 paddingAddedSize = field.GetNaturalSize();
3946 DALI_TEST_EQUALS(originalSize.width + 10 + 10, paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3948 DALI_TEST_EQUALS(originalSize.height + 10 + 10, paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3953 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3955 ToolkitTestApplication application;
3956 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3958 TextField field = TextField::New();
3959 DALI_TEST_CHECK(field);
3960 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3961 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3962 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3963 application.GetScene().Add(field);
3965 application.SendNotification();
3966 application.Render();
3968 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3969 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), true, TEST_LOCATION);
3971 // Check the enable shift selection property
3972 field.SetProperty(DevelTextField::Property::ENABLE_SHIFT_SELECTION, false);
3973 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), false, TEST_LOCATION);
3975 application.SendNotification();
3976 application.Render();
3981 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3983 ToolkitTestApplication application;
3984 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3986 TextField field = TextField::New();
3987 DALI_TEST_CHECK(field);
3988 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
3989 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3990 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3991 application.GetScene().Add(field);
3993 application.SendNotification();
3994 application.Render();
3996 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3997 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), true, TEST_LOCATION);
3999 // Check the enable grab handle property
4000 field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE, false);
4001 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), false, TEST_LOCATION);
4003 application.SendNotification();
4004 application.Render();
4009 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
4011 ToolkitTestApplication application;
4012 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
4014 TextField field = TextField::New();
4015 DALI_TEST_CHECK(field);
4016 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4017 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4018 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4019 application.GetScene().Add(field);
4021 application.SendNotification();
4022 application.Render();
4024 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
4025 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), true, TEST_LOCATION);
4027 // Check the match system language direction property
4028 field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
4029 DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), false, TEST_LOCATION);
4031 application.SendNotification();
4032 application.Render();
4037 int utcDaliTextFieldLayoutDirectionCoverage(void)
4039 ToolkitTestApplication application;
4040 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
4042 // Creates a tap event. After creating a tap event the text field should
4043 // have the focus and add text with key events should be possible.
4044 TextField field = TextField::New();
4045 DALI_TEST_CHECK(field);
4047 application.GetScene().Add(field);
4049 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4050 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4051 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4053 // Avoid a crash when core load gl resources.
4054 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4056 // Render and notify
4057 application.SendNotification();
4058 application.Render();
4060 // init direction for coverage
4061 // Set horizontal alignment END
4062 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
4064 // Create a tap event to touch the text field.
4065 TestGenerateTap(application, 150.0f, 25.0f);
4067 // Render and notify
4068 application.SendNotification();
4069 application.Render();
4071 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
4072 field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true);
4073 field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
4075 // Set horizontal alignment BEGIN
4076 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
4078 // Create a tap event to touch the text field.
4079 TestGenerateTap(application, 150.0f, 25.0f);
4081 // Render and notify
4082 application.SendNotification();
4083 application.Render();
4085 // Set horizontal alignment CENTER
4086 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
4088 // Create a tap event to touch the text field.
4089 TestGenerateTap(application, 150.0f, 25.0f);
4091 // Render and notify
4092 application.SendNotification();
4093 application.Render();
4095 // Set horizontal alignment END
4096 field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
4098 // Create a tap event to touch the text field.
4099 TestGenerateTap(application, 150.0f, 25.0f);
4101 // Render and notify
4102 application.SendNotification();
4103 application.Render();
4105 // Generate a Esc key event. The text field should lose the focus.
4106 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4107 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4109 // Render and notify
4110 application.SendNotification();
4111 application.Render();
4113 DALI_TEST_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
4118 int UtcDaliTextFieldGetInputMethodContext(void)
4120 ToolkitTestApplication application;
4121 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
4123 TextField field = TextField::New();
4124 DALI_TEST_CHECK(DevelTextField::GetInputMethodContext(field));
4129 int UtcDaliTextFieldSelectWholeText(void)
4131 ToolkitTestApplication application;
4132 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
4134 TextField textField = TextField::New();
4136 application.GetScene().Add(textField);
4138 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4139 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4140 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4142 // Avoid a crash when core load gl resources.
4143 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4145 application.SendNotification();
4146 application.Render();
4148 DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
4150 DevelTextField::SelectWholeText(textField);
4152 application.SendNotification();
4153 application.Render();
4155 // Nothing should have been selected. The number of children is still 1
4156 DALI_TEST_EQUALS(1u, textField.GetChildCount(), TEST_LOCATION);
4158 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4160 application.SendNotification();
4161 application.Render();
4163 DevelTextField::SelectWholeText(textField);
4165 application.SendNotification();
4166 application.Render();
4168 // Even if resize, selection should remain.
4169 textField.SetProperty(Actor::Property::SIZE, Vector2(150.f, 50.f));
4171 application.SendNotification();
4172 application.Render();
4174 // Should be 2 children, the stencil and the layer
4175 DALI_TEST_EQUALS(2u, textField.GetChildCount(), TEST_LOCATION);
4177 // The offscreen root actor should have two actors: the renderer and the highlight actor.
4178 Actor stencil = textField.GetChildAt(0u);
4180 // The highlight actor is drawn first, so is the first actor in the list
4181 Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
4182 DALI_TEST_CHECK(highlight);
4187 int UtcDaliTextFieldSelectText(void)
4189 ToolkitTestApplication application;
4190 tet_infoline(" UtcDaliTextFieldSelectText ");
4192 TextField textField = TextField::New();
4194 application.GetScene().Add(textField);
4196 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4197 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4198 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4200 // Avoid a crash when core load gl resources.
4201 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4203 application.SendNotification();
4204 application.Render();
4206 DevelTextField::SelectText(textField, 0, 5);
4208 application.SendNotification();
4209 application.Render();
4211 // Nothing is selected
4212 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4213 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
4215 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4217 application.SendNotification();
4218 application.Render();
4220 // Hello is selected
4221 DevelTextField::SelectText(textField, 0, 5);
4223 application.SendNotification();
4224 application.Render();
4226 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4227 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4229 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4230 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4232 // world is selected
4233 DevelTextField::SelectText(textField, 6, 11);
4235 application.SendNotification();
4236 application.Render();
4238 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4239 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4241 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4242 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4247 int UtcDaliTextFieldSelectNone(void)
4249 ToolkitTestApplication application;
4250 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
4252 TextField textField = TextField::New();
4254 application.GetScene().Add(textField);
4256 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4257 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4258 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4260 // Avoid a crash when core load gl resources.
4261 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4263 application.SendNotification();
4264 application.Render();
4266 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4268 application.SendNotification();
4269 application.Render();
4271 // Nothing is selected
4272 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4273 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
4275 DevelTextField::SelectWholeText(textField);
4277 application.SendNotification();
4278 application.Render();
4280 // whole text is selected
4281 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4282 DALI_TEST_EQUALS("Hello world", selectedText, TEST_LOCATION);
4284 DevelTextField::SelectNone(textField);
4286 application.SendNotification();
4287 application.Render();
4289 // Nothing is selected
4290 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4291 DALI_TEST_EQUALS("", selectedText, TEST_LOCATION);
4296 int UtcDaliTextFieldSelectRange(void)
4298 ToolkitTestApplication application;
4299 tet_infoline(" UtcDaliTextFieldSelectRange ");
4301 TextField textField = TextField::New();
4303 application.GetScene().Add(textField);
4305 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4306 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4307 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4309 // Avoid a crash when core load gl resources.
4310 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4312 application.SendNotification();
4313 application.Render();
4315 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4317 application.SendNotification();
4318 application.Render();
4320 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 0);
4321 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 5);
4323 // Hello is selected
4324 std::string selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4325 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4327 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4328 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4330 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_START, 6);
4331 textField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, 11);
4333 // world is selected
4334 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4335 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4337 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4338 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4343 int UtcDaliTextFieldEnableEditing(void)
4345 ToolkitTestApplication application;
4346 tet_infoline(" UtcDaliTextFieldEnableEditing ");
4348 TextField textField = TextField::New();
4350 application.GetScene().Add(textField);
4352 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4353 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4354 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4356 // Avoid a crash when core load gl resources.
4357 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4359 application.SendNotification();
4360 application.Render();
4362 textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
4363 DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), true, TEST_LOCATION);
4365 textField.SetKeyInputFocus();
4366 textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, false);
4367 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4369 // Render and notify
4370 application.SendNotification();
4371 application.Render();
4373 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "", TEST_LOCATION);
4374 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), false, TEST_LOCATION);
4376 textField.SetKeyInputFocus();
4377 textField.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
4378 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4380 // Render and notify
4381 application.SendNotification();
4382 application.Render();
4384 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
4385 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<bool>(), true, TEST_LOCATION);
4387 // Check the user interaction enabled and for coverage
4388 DevelTextField::SelectWholeText(textField);
4390 // Render and notify
4391 application.SendNotification();
4392 application.Render();
4394 textField.SetKeyInputFocus();
4395 textField.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false);
4396 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4398 // Render and notify
4399 application.SendNotification();
4400 application.Render();
4402 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "D", TEST_LOCATION);
4403 DALI_TEST_EQUALS(textField.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED).Get<bool>(), false, TEST_LOCATION);
4408 int UtcDaliToolkitTextFieldFontSizeScale(void)
4410 ToolkitTestApplication application;
4411 tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
4413 TextField textField = TextField::New();
4414 textField.SetProperty(TextField::Property::POINT_SIZE, 30.f);
4415 textField.SetProperty(TextField::Property::TEXT, "Test");
4416 Vector3 nonScaledSize = textField.GetNaturalSize();
4418 TextField textFieldScaled = TextField::New();
4419 textFieldScaled.SetProperty(TextField::Property::POINT_SIZE, 15.f);
4420 textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
4421 textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
4422 Vector3 scaledSize = textFieldScaled.GetNaturalSize();
4424 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4426 textField.SetProperty(TextField::Property::PIXEL_SIZE, 30.f);
4427 textField.SetProperty(TextField::Property::TEXT, "Test");
4428 nonScaledSize = textField.GetNaturalSize();
4430 textFieldScaled.SetProperty(TextField::Property::PIXEL_SIZE, 15.f);
4431 textFieldScaled.SetProperty(Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f);
4432 textFieldScaled.SetProperty(TextField::Property::TEXT, "Test");
4433 scaledSize = textFieldScaled.GetNaturalSize();
4435 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
4440 int UtcDaliTextFieldPrimaryCursorPosition(void)
4442 ToolkitTestApplication application;
4443 tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
4445 TextField textField = TextField::New();
4447 application.GetScene().Add(textField);
4449 textField.SetProperty(TextField::Property::TEXT, "ABCEF");
4450 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4451 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4452 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4454 // Avoid a crash when core load gl resources.
4455 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4457 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4458 application.SendNotification();
4459 application.Render();
4460 textField.SetKeyInputFocus();
4462 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4464 // Render and notify
4465 application.SendNotification();
4466 application.Render();
4468 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCDEF", TEST_LOCATION);
4469 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 4, TEST_LOCATION);
4474 // test max length when set after setting long text
4475 int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
4477 ToolkitTestApplication application;
4478 tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
4479 TextField field = TextField::New();
4480 DALI_TEST_CHECK(field);
4482 application.GetScene().Add(field);
4484 field.SetProperty(TextField::Property::TEXT, "123456789");
4486 const int maxNumberOfCharacters = 3;
4487 field.SetProperty(TextField::Property::MAX_LENGTH, maxNumberOfCharacters);
4489 field.SetKeyInputFocus();
4491 // connect to the text max lengh reached signal.
4492 ConnectionTracker* testTracker = new ConnectionTracker();
4493 bool maxLengthReachedSignal = false;
4494 field.ConnectSignal(testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal));
4496 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4497 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4499 DALI_TEST_CHECK(maxLengthReachedSignal);
4501 DALI_TEST_EQUALS(field.GetProperty(TextField::Property::TEXT).Get<std::string>(), "123456789", TEST_LOCATION);
4506 int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
4508 ToolkitTestApplication application;
4509 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
4511 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4512 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4513 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4515 // Create a text field
4516 TextField textField = TextField::New();
4518 //Set size to avoid automatic eliding
4519 textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4520 //Set very large font-size using point-size
4521 textField.SetProperty(TextField::Property::POINT_SIZE, 1000);
4522 //Specify font-family
4523 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4524 //Set text to check if appear or not
4525 textField.SetProperty(TextField::Property::TEXT, "A");
4527 application.GetScene().Add(textField);
4529 application.SendNotification();
4530 application.Render();
4531 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4532 Vector3 naturalSize = textField.GetNaturalSize();
4534 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4535 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4540 int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
4542 ToolkitTestApplication application;
4543 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
4545 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
4546 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4547 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
4549 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
4550 // Create a text editor
4551 TextField textField = TextField::New();
4553 //Set size to avoid automatic eliding
4554 textField.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
4555 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
4556 textField.SetProperty(TextField::Property::TEXT, "A");
4558 const int numberOfCases = 6;
4559 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
4561 for(int index = 0; index < numberOfCases; index++)
4563 tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
4564 textField.SetProperty(TextField::Property::POINT_SIZE, arrayCases[index]);
4565 application.GetScene().Add(textField);
4566 application.SendNotification();
4567 application.Render();
4568 naturalSize = textField.GetNaturalSize();
4569 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
4570 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
4576 int UtcDaliToolkitTextFieldEllipsisPositionProperty(void)
4578 ToolkitTestApplication application;
4579 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty ");
4580 TextField textField = TextField::New();
4582 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Default is END");
4583 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4585 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START");
4586 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4587 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4589 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE");
4590 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4591 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4593 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END");
4594 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4595 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4597 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START using integer");
4598 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 1);
4599 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4601 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE using integer");
4602 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 2);
4603 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4605 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END using integer");
4606 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 0);
4607 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4609 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4610 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "START");
4611 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4613 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4614 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "MIDDLE");
4615 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4617 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4618 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "END");
4619 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4621 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4622 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "start");
4623 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
4625 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4626 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "middle");
4627 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
4629 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4630 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "end");
4631 DALI_TEST_EQUALS(textField.GetProperty<int>(DevelTextField::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
4636 int UtcDaliTextFieldCopyText(void)
4638 ToolkitTestApplication application;
4639 tet_infoline(" UtcDaliTextFieldCopyText ");
4641 TextField textField = TextField::New();
4643 std::string selectedText = "";
4644 std::string copiedText = "";
4646 application.GetScene().Add(textField);
4648 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4649 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4650 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4652 // Avoid a crash when core load gl resources.
4653 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4655 application.SendNotification();
4656 application.Render();
4658 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4660 application.SendNotification();
4661 application.Render();
4663 // Hello is selected
4664 DevelTextField::SelectText(textField, 0, 5);
4666 application.SendNotification();
4667 application.Render();
4669 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4670 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4672 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4673 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4676 copiedText = DevelTextField::CopyText(textField);
4677 DALI_TEST_EQUALS("Hello", copiedText, TEST_LOCATION);
4679 // world is selected
4680 DevelTextField::SelectText(textField, 6, 11);
4682 application.SendNotification();
4683 application.Render();
4685 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4686 DALI_TEST_EQUALS("world", selectedText, TEST_LOCATION);
4688 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 6, TEST_LOCATION);
4689 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 11, TEST_LOCATION);
4692 copiedText = DevelTextField::CopyText(textField);
4693 DALI_TEST_EQUALS("world", copiedText, TEST_LOCATION);
4695 // "lo wo" is selected
4696 DevelTextField::SelectText(textField, 3, 8);
4698 application.SendNotification();
4699 application.Render();
4701 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4702 DALI_TEST_EQUALS("lo wo", selectedText, TEST_LOCATION);
4704 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 3, TEST_LOCATION);
4705 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 8, TEST_LOCATION);
4707 // "lo wo" is copied
4708 copiedText = DevelTextField::CopyText(textField);
4709 DALI_TEST_EQUALS("lo wo", copiedText, TEST_LOCATION);
4714 int UtcDaliTextFieldCutText(void)
4716 ToolkitTestApplication application;
4717 tet_infoline(" UtcDaliTextFieldCutText ");
4719 TextField textField = TextField::New();
4721 std::string selectedText = "";
4723 application.GetScene().Add(textField);
4725 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4726 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4727 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4729 // Avoid a crash when core load gl resources.
4730 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4732 application.SendNotification();
4733 application.Render();
4735 textField.SetProperty(TextField::Property::TEXT, "Hello world");
4737 application.SendNotification();
4738 application.Render();
4740 // Hello is selected
4741 DevelTextField::SelectText(textField, 0, 5);
4743 application.SendNotification();
4744 application.Render();
4746 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4747 DALI_TEST_EQUALS("Hello", selectedText, TEST_LOCATION);
4749 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4750 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 5, TEST_LOCATION);
4753 DALI_TEST_EQUALS("Hello", DevelTextField::CutText(textField), TEST_LOCATION);
4755 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), " world", TEST_LOCATION);
4758 DevelTextField::SelectText(textField, 0, 2);
4760 application.SendNotification();
4761 application.Render();
4763 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4764 DALI_TEST_EQUALS(" w", selectedText, TEST_LOCATION);
4766 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 0, TEST_LOCATION);
4767 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4770 DALI_TEST_EQUALS(" w", DevelTextField::CutText(textField), TEST_LOCATION);
4772 application.SendNotification();
4773 application.Render();
4775 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "orld", TEST_LOCATION);
4777 // Test Cut from the middle
4780 DevelTextField::SelectText(textField, 1, 3);
4782 application.SendNotification();
4783 application.Render();
4785 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4786 DALI_TEST_EQUALS("rl", selectedText, TEST_LOCATION);
4788 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4789 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 3, TEST_LOCATION);
4792 DALI_TEST_EQUALS("rl", DevelTextField::CutText(textField), TEST_LOCATION);
4794 application.SendNotification();
4795 application.Render();
4797 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "od", TEST_LOCATION);
4799 // Test Cut from the end
4802 DevelTextField::SelectText(textField, 1, 2);
4804 application.SendNotification();
4805 application.Render();
4807 selectedText = textField.GetProperty(DevelTextField::Property::SELECTED_TEXT).Get<std::string>();
4808 DALI_TEST_EQUALS("d", selectedText, TEST_LOCATION);
4810 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>(), 1, TEST_LOCATION);
4811 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>(), 2, TEST_LOCATION);
4814 DALI_TEST_EQUALS("d", DevelTextField::CutText(textField), TEST_LOCATION);
4816 application.SendNotification();
4817 application.Render();
4819 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "o", TEST_LOCATION);
4824 int UtcDaliTextFieldPasteText(void)
4826 ToolkitTestApplication application;
4827 tet_infoline(" UtcDaliTextFieldPasteText ");
4829 TextField textField = TextField::New();
4831 application.GetScene().Add(textField);
4833 std::string cutText = "";
4834 std::string copiedText = "";
4836 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
4837 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4838 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4840 // Avoid a crash when core load gl resources.
4841 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4843 application.SendNotification();
4844 application.Render();
4846 textField.SetProperty(TextField::Property::TEXT, "Hello World");
4848 application.SendNotification();
4849 application.Render();
4851 // Tap on the text editor
4852 TestGenerateTap(application, 3.0f, 25.0f);
4854 // Render and notify
4855 application.SendNotification();
4856 application.Render();
4858 // Select some text in the right of the current cursor position
4859 DevelTextField::SelectText(textField, 0, 3);
4861 // Render and notify
4862 application.SendNotification();
4863 application.Render();
4865 // Cut the selected text
4866 cutText = DevelTextField::CutText(textField);
4868 // Render and notify
4869 application.SendNotification();
4870 application.Render();
4872 DALI_TEST_EQUALS("Hel", cutText, TEST_LOCATION);
4873 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo World", TEST_LOCATION);
4875 DevelTextField::SelectText(textField, 0, 3);
4877 // Render and notify
4878 application.SendNotification();
4879 application.Render();
4881 // Copy the selected text
4882 copiedText = DevelTextField::CopyText(textField);
4884 // Render and notify
4885 application.SendNotification();
4886 application.Render();
4888 DALI_TEST_EQUALS("lo ", copiedText, TEST_LOCATION);
4889 DALI_TEST_EQUALS("lo World", textField.GetProperty<std::string>(TextField::Property::TEXT), TEST_LOCATION);
4891 // Move the cursor to the end of the line
4892 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
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));
4901 // Render and notify
4902 application.SendNotification();
4903 application.Render();
4905 // Paste the selected text at the current cursor position
4906 DevelTextField::PasteText(textField);
4908 // Render and notify
4909 application.SendNotification();
4910 application.Render();
4912 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "lo Worldlo ", TEST_LOCATION);
4917 int utcDaliTextFieldCursorPositionChangedSignal(void)
4919 ToolkitTestApplication application;
4920 tet_infoline(" utcDaliTextFieldCursorPositionChangedSignal");
4922 TextField field = TextField::New();
4923 DALI_TEST_CHECK(field);
4925 application.GetScene().Add(field);
4927 // connect to the selection changed signal.
4928 ConnectionTracker* testTracker = new ConnectionTracker();
4929 DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
4930 bool cursorPositionChangedSignal = false;
4931 field.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal));
4933 field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
4934 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
4935 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
4936 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
4937 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
4939 // Avoid a crash when core load gl resources.
4940 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
4942 // Render and notify
4943 application.SendNotification();
4944 application.Render();
4946 field.SetKeyInputFocus();
4948 // Tap on the text field
4949 TestGenerateTap(application, 3.0f, 25.0f);
4951 // Render and notify
4952 application.SendNotification();
4953 application.Render();
4955 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4956 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4958 gCursorPositionChangedCallbackCalled = false;
4961 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4963 // Render and notify
4964 application.SendNotification();
4965 application.Render();
4967 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4968 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4970 gCursorPositionChangedCallbackCalled = false;
4973 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4975 // Render and notify
4976 application.SendNotification();
4977 application.Render();
4979 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4980 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4982 gCursorPositionChangedCallbackCalled = false;
4984 //delete one character
4985 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
4987 // Render and notify
4988 application.SendNotification();
4989 application.Render();
4991 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4992 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4994 gCursorPositionChangedCallbackCalled = false;
4996 field.SetProperty(TextField::Property::TEXT, "Hello");
4998 // Render and notify
4999 application.SendNotification();
5000 application.Render();
5002 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5003 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
5005 gCursorPositionChangedCallbackCalled = false;
5007 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5009 // Render and notify
5010 application.SendNotification();
5011 application.Render();
5013 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
5014 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
5019 int utcDaliTextFieldGeometryEllipsisStart(void)
5021 ToolkitTestApplication application;
5022 tet_infoline(" utcDaliTextFieldGeometryEllipsisStart");
5024 TextField field = TextField::New();
5025 DALI_TEST_CHECK(field);
5027 application.GetScene().Add(field);
5029 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5030 field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
5031 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5032 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5033 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5034 field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
5035 field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
5036 field.SetProperty(TextField::Property::TEXT, "Hello World");
5038 // Avoid a crash when core load gl resources.
5039 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5041 // Render and notify
5042 application.SendNotification();
5043 application.Render();
5045 unsigned int expectedCount = 1;
5046 unsigned int startIndex = 0;
5047 unsigned int endIndex = 10;
5049 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5050 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
5052 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5053 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5055 Vector<Vector2> expectedSizes;
5056 Vector<Vector2> expectedPositions;
5058 expectedPositions.PushBack(Vector2(14, 0));
5059 expectedSizes.PushBack(Vector2(107, 25));
5061 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5066 int utcDaliTextFieldGeometryEllipsisEnd(void)
5068 ToolkitTestApplication application;
5069 tet_infoline(" utcDaliTextFieldGeometryEllipsisEnd");
5071 TextField field = TextField::New();
5072 DALI_TEST_CHECK(field);
5074 application.GetScene().Add(field);
5076 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5077 field.SetProperty(Actor::Property::SIZE, Vector2(250.f, 50.f));
5078 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5079 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5080 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5081 field.SetProperty(DevelTextField::Property::ELLIPSIS, true);
5082 field.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
5083 field.SetProperty(TextField::Property::TEXT, "Hello World");
5085 // Avoid a crash when core load gl resources.
5086 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5088 // Render and notify
5089 application.SendNotification();
5090 application.Render();
5092 unsigned int expectedCount = 1;
5093 unsigned int startIndex = 0;
5094 unsigned int endIndex = 10;
5096 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5097 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
5099 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5100 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5102 Vector<Vector2> expectedSizes;
5103 Vector<Vector2> expectedPositions;
5105 expectedPositions.PushBack(Vector2(-2, 0));
5106 expectedSizes.PushBack(Vector2(123, 25));
5108 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5113 int utcDaliTextFieldGeometryRTL(void)
5115 ToolkitTestApplication application;
5116 tet_infoline(" utcDaliTextFieldGeometryRTL");
5118 TextField field = TextField::New();
5119 DALI_TEST_CHECK(field);
5121 application.GetScene().Add(field);
5123 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5124 field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
5125 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5126 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5127 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5128 field.SetProperty(TextField::Property::TEXT, "السطر الاخير");
5130 // Avoid a crash when core load gl resources.
5131 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5133 // Render and notify
5134 application.SendNotification();
5135 application.Render();
5137 unsigned int expectedCount = 1;
5138 unsigned int startIndex = 1;
5139 unsigned int endIndex = 7;
5141 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5142 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
5144 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5145 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5147 Vector<Vector2> expectedSizes;
5148 Vector<Vector2> expectedPositions;
5150 expectedPositions.PushBack(Vector2(38, 0));
5151 expectedSizes.PushBack(Vector2(75, 25));
5153 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5158 int utcDaliTextFieldGeometryGlyphMiddle(void)
5160 ToolkitTestApplication application;
5161 tet_infoline(" utcDaliTextFieldGeometryGlyphMiddle");
5163 TextField field = TextField::New();
5164 DALI_TEST_CHECK(field);
5166 application.GetScene().Add(field);
5168 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5169 field.SetProperty(Actor::Property::SIZE, Vector2(150.f, 200.f));
5170 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5171 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5172 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5173 field.SetProperty(TextField::Property::TEXT, "لا تحتوي على لا");
5175 // Avoid a crash when core load gl resources.
5176 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5178 // Render and notify
5179 application.SendNotification();
5180 application.Render();
5182 unsigned int expectedCount = 1;
5183 unsigned int startIndex = 1;
5184 unsigned int endIndex = 13;
5186 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5187 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
5189 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5190 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5192 Vector<Vector2> expectedSizes;
5193 Vector<Vector2> expectedPositions;
5195 expectedPositions.PushBack(Vector2(6, 0));
5196 expectedSizes.PushBack(Vector2(125, 25));
5198 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
5203 int utcDaliTextFieldGeometryNullPtr(void)
5205 ToolkitTestApplication application;
5206 tet_infoline("utcDaliTextFieldGeometryNullPtr");
5208 TextField field = TextField::New();
5209 DALI_TEST_CHECK(field);
5211 application.GetScene().Add(field);
5213 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
5214 field.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
5215 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5216 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5217 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5218 field.SetProperty(TextField::Property::TEXT, "");
5220 // Avoid a crash when core load gl resources.
5221 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5223 unsigned int expectedCount = 0;
5224 unsigned int startIndex = 0;
5225 unsigned int endIndex = 0;
5227 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
5228 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
5230 // Render and notify
5231 application.SendNotification();
5232 application.Render();
5234 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
5235 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
5240 int utcDaliTextFieldSelectionClearedSignal(void)
5242 ToolkitTestApplication application;
5243 tet_infoline(" utcDaliTextFieldSelectionClearedSignal");
5245 TextField field = TextField::New();
5246 DALI_TEST_CHECK(field);
5248 application.GetScene().Add(field);
5250 // connect to the selection changed signal.
5251 ConnectionTracker* testTracker = new ConnectionTracker();
5252 DevelTextField::SelectionClearedSignal(field).Connect(&TestSelectionClearedCallback);
5253 bool selectionClearedSignal = false;
5254 field.ConnectSignal(testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal));
5256 field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
5257 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5258 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5259 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5260 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5262 // Avoid a crash when core load gl resources.
5263 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5265 // Render and notify
5266 application.SendNotification();
5267 application.Render();
5269 // Tap on the text editor
5270 TestGenerateTap(application, 3.0f, 25.0f);
5272 // Render and notify
5273 application.SendNotification();
5274 application.Render();
5276 // Move to second line of the text & Select some text in the right of the current cursor position
5277 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5278 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5281 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5283 // Render and notify
5284 application.SendNotification();
5285 application.Render();
5287 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5289 // Render and notify
5290 application.SendNotification();
5291 application.Render();
5293 // Tap on the text editor
5294 TestGenerateTap(application, 3.0f, 25.0f);
5296 // Render and notify
5297 application.SendNotification();
5298 application.Render();
5300 gSelectionClearedCallbackCalled = false;
5302 // Move to second line of the text & select.
5303 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5304 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5307 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5309 // Render and notify
5310 application.SendNotification();
5311 application.Render();
5313 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5315 gSelectionClearedCallbackCalled = false;
5317 // Render and notify
5318 application.SendNotification();
5319 application.Render();
5321 // Move to second line of the text & select.
5322 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5323 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5325 // replace D with selected text
5326 application.ProcessEvent(GenerateKey("D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5328 // Render and notify
5329 application.SendNotification();
5330 application.Render();
5332 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5334 gSelectionClearedCallbackCalled = false;
5336 // Render and notify
5337 application.SendNotification();
5338 application.Render();
5340 DevelTextField::SelectText(field, 1, 3);
5342 // Render and notify
5343 application.SendNotification();
5344 application.Render();
5346 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5348 // Render and notify
5349 application.SendNotification();
5350 application.Render();
5352 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5354 gSelectionClearedCallbackCalled = false;
5356 DevelTextField::SelectText(field, 1, 3);
5358 // Render and notify
5359 application.SendNotification();
5360 application.Render();
5363 DevelTextField::SelectNone(field);
5365 // Render and notify
5366 application.SendNotification();
5367 application.Render();
5369 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
5374 int utcDaliTextFieldSelectionStartedSignal(void)
5376 ToolkitTestApplication application;
5377 tet_infoline(" utcDaliTextFieldSelectionStartedSignal");
5379 TextField field = TextField::New();
5380 DALI_TEST_CHECK(field);
5382 application.GetScene().Add(field);
5384 // connect to the selection changed signal.
5385 ConnectionTracker* testTracker = new ConnectionTracker();
5386 DevelTextField::SelectionStartedSignal(field).Connect(&TestSelectionStartedCallback);
5387 bool selectionStartedSignal = false;
5388 field.ConnectSignal(testTracker, "selectionStarted", CallbackFunctor(&selectionStartedSignal));
5390 field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
5391 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5392 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5393 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5394 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5396 // Avoid a crash when core load gl resources.
5397 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5399 // Render and notify
5400 application.SendNotification();
5401 application.Render();
5403 // Tap on the text field
5404 TestGenerateTap(application, 3.0f, 25.0f);
5406 // Render and notify
5407 application.SendNotification();
5408 application.Render();
5410 // Move to second line of the text & Select some text in the right of the current cursor position
5411 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5412 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5414 // Render and notify
5415 application.SendNotification();
5416 application.Render();
5418 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5421 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5423 // Render and notify
5424 application.SendNotification();
5425 application.Render();
5427 gSelectionStartedCallbackCalled = false;
5429 DevelTextField::SelectText(field, 1, 3);
5431 // Render and notify
5432 application.SendNotification();
5433 application.Render();
5435 DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
5440 int utcDaliTextFieldSelectionChangedSignal(void)
5442 ToolkitTestApplication application;
5443 tet_infoline(" utcDaliTextFieldSelectionChangedSignal");
5445 TextField field = TextField::New();
5446 DALI_TEST_CHECK(field);
5448 application.GetScene().Add(field);
5450 // connect to the selection changed signal.
5451 ConnectionTracker* testTracker = new ConnectionTracker();
5452 DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
5453 bool selectionChangedSignal = false;
5454 field.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal));
5456 field.SetProperty(TextField::Property::TEXT, "Hello world Hello world");
5457 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
5458 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5459 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5460 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5462 // Avoid a crash when core load gl resources.
5463 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5465 // Render and notify
5466 application.SendNotification();
5467 application.Render();
5469 // Tap on the text field
5470 TestGenerateTap(application, 3.0f, 25.0f);
5472 // Render and notify
5473 application.SendNotification();
5474 application.Render();
5476 // Select some text in the right of the current cursor position
5477 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5478 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5480 // Render and notify
5481 application.SendNotification();
5482 application.Render();
5484 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5485 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5487 gSelectionChangedCallbackCalled = false;
5489 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5491 // Render and notify
5492 application.SendNotification();
5493 application.Render();
5495 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5496 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5497 DALI_TEST_EQUALS(oldSelectionEnd, 1, TEST_LOCATION);
5499 gSelectionChangedCallbackCalled = false;
5501 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5503 // Render and notify
5504 application.SendNotification();
5505 application.Render();
5507 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5508 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5509 DALI_TEST_EQUALS(oldSelectionEnd, 2, TEST_LOCATION);
5511 gSelectionChangedCallbackCalled = false;
5512 field.SetKeyInputFocus();
5514 // Render and notify
5515 application.SendNotification();
5516 application.Render();
5518 DevelTextField::SelectText(field, 0, 5);
5520 application.SendNotification();
5521 application.Render();
5523 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5524 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5526 gSelectionChangedCallbackCalled = false;
5528 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5530 // Render and notify
5531 application.SendNotification();
5532 application.Render();
5534 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5535 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5536 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
5538 gSelectionChangedCallbackCalled = false;
5541 DevelTextField::SelectWholeText(field);
5543 // Render and notify
5544 application.SendNotification();
5545 application.Render();
5547 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5548 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5550 gSelectionChangedCallbackCalled = false;
5553 DevelTextField::SelectNone(field);
5555 // Render and notify
5556 application.SendNotification();
5557 application.Render();
5559 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5560 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5561 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5566 int UtcDaliToolkitTextFieldStrikethroughGeneration(void)
5568 ToolkitTestApplication application;
5569 tet_infoline(" UtcDaliToolkitTextFieldStrikethroughGeneration");
5571 TextField textField = TextField::New();
5572 textField.SetProperty(TextField::Property::TEXT, "Test");
5573 textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5574 textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5575 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5577 application.GetScene().Add(textField);
5578 application.SendNotification();
5579 application.Render();
5581 Property::Map strikethroughMapSet;
5582 Property::Map strikethroughMapGet;
5584 strikethroughMapSet.Insert("enable", true);
5585 strikethroughMapSet.Insert("color", Color::RED);
5586 strikethroughMapSet.Insert("height", 2.0f);
5588 // Check the strikethrough property
5589 textField.SetProperty(DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet);
5590 strikethroughMapGet = textField.GetProperty<Property::Map>(DevelTextField::Property::STRIKETHROUGH);
5591 textField.SetProperty(TextField::Property::TEXT, "Test1");
5592 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
5593 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
5595 // Render and notify
5596 application.SendNotification();
5597 application.Render();
5599 strikethroughMapSet.Clear();
5600 strikethroughMapGet.Clear();
5605 int UtcDaliToolkitTextFieldInputStrikethroughGeneration(void)
5607 ToolkitTestApplication application;
5608 tet_infoline(" UtcDaliToolkitTextFieldInputStrikethroughGeneration");
5610 TextField textField = TextField::New();
5611 textField.SetProperty(TextField::Property::TEXT, "Test");
5612 textField.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5613 textField.SetProperty(TextField::Property::POINT_SIZE, 10);
5614 textField.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5616 application.GetScene().Add(textField);
5617 application.SendNotification();
5618 application.Render();
5620 std::string strikethroughSettings1("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}");
5622 // Check the strikethrough property
5623 textField.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, strikethroughSettings1);
5624 textField.SetProperty(TextField::Property::TEXT, "Test1");
5625 DALI_TEST_EQUALS(textField.GetProperty<std::string>(DevelTextField::Property::INPUT_STRIKETHROUGH), strikethroughSettings1, TEST_LOCATION);
5627 // Render and notify
5628 application.SendNotification();
5629 application.Render();
5634 int UtcDaliToolkitTextFieldUnderlineTypesGeneration1(void)
5636 ToolkitTestApplication application;
5637 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration1");
5638 TextField field = TextField::New();
5639 field.SetProperty(TextField::Property::TEXT, "Test");
5640 field.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5641 field.SetProperty(TextField::Property::POINT_SIZE, 10);
5642 field.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5644 application.GetScene().Add(field);
5645 application.SendNotification();
5646 application.Render();
5648 Property::Map underlineMapSet;
5649 Property::Map underlineMapGet;
5651 underlineMapSet.Insert("enable", true);
5652 underlineMapSet.Insert("color", Color::RED);
5653 underlineMapSet.Insert("height", 1);
5654 underlineMapSet.Insert("type", Text::Underline::SOLID);
5655 underlineMapSet.Insert("dashWidth", 2);
5656 underlineMapSet.Insert("dashGap", 1);
5658 // Check the underline property
5659 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5661 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5662 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5663 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5665 // Render and notify
5666 application.SendNotification();
5667 application.Render();
5669 underlineMapSet.Clear();
5670 underlineMapGet.Clear();
5672 underlineMapSet.Insert("enable", true);
5673 underlineMapSet.Insert("color", Color::BLUE);
5674 underlineMapSet.Insert("height", 1);
5675 underlineMapSet.Insert("type", Text::Underline::DASHED);
5676 underlineMapSet.Insert("dashWidth", 4);
5677 underlineMapSet.Insert("dashGap", 2);
5679 // Check the dashed underline property
5680 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5682 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5683 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5684 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5686 // Render and notify
5687 application.SendNotification();
5688 application.Render();
5690 underlineMapSet.Clear();
5691 underlineMapGet.Clear();
5693 underlineMapSet.Insert("enable", true);
5694 underlineMapSet.Insert("color", Color::BLUE);
5695 underlineMapSet.Insert("height", 1);
5696 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
5697 underlineMapSet.Insert("dashWidth", 4);
5698 underlineMapSet.Insert("dashGap", 2);
5700 // Check the dashed underline property
5701 field.SetProperty(TextField::Property::UNDERLINE, underlineMapSet);
5703 underlineMapGet = field.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5704 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
5705 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
5707 // Render and notify
5708 application.SendNotification();
5709 application.Render();
5711 underlineMapSet.Clear();
5712 underlineMapGet.Clear();
5717 int UtcDaliToolkitTextFieldUnderlineTypesGeneration2(void)
5719 ToolkitTestApplication application;
5720 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration2");
5722 TextField field1 = TextField::New();
5723 field1.SetProperty(TextField::Property::TEXT, "Test");
5724 field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5725 field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5726 field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5728 Property::Map underlineMapSet1;
5729 Property::Map underlineMapGet1;
5731 underlineMapSet1.Insert("enable", true);
5732 underlineMapSet1.Insert("color", Color::RED);
5733 underlineMapSet1.Insert("height", 1);
5734 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5735 underlineMapSet1.Insert("dashWidth", 2);
5736 underlineMapSet1.Insert("dashGap", 1);
5738 // Check the underline property
5739 field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5741 underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5742 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5743 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5745 application.GetScene().Add(field1);
5746 application.SendNotification();
5747 application.Render();
5749 TextField field2 = TextField::New();
5750 field2.SetProperty(TextField::Property::TEXT, "Test");
5751 field2.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5752 field2.SetProperty(TextField::Property::POINT_SIZE, 10);
5753 field2.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5755 Property::Map underlineMapSet2;
5756 Property::Map underlineMapGet2;
5758 underlineMapSet2.Insert("enable", true);
5759 underlineMapSet2.Insert("color", Color::BLUE);
5760 underlineMapSet2.Insert("height", 1);
5761 underlineMapSet2.Insert("type", Text::Underline::DASHED);
5762 underlineMapSet2.Insert("dashWidth", 4);
5763 underlineMapSet2.Insert("dashGap", 2);
5765 // Check the dashed underline property
5766 field2.SetProperty(TextField::Property::UNDERLINE, underlineMapSet2);
5768 underlineMapGet2 = field2.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5769 DALI_TEST_EQUALS(underlineMapGet2.Count(), underlineMapSet2.Count(), TEST_LOCATION);
5770 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet2, underlineMapSet2), true, TEST_LOCATION);
5772 application.GetScene().Add(field2);
5773 application.SendNotification();
5774 application.Render();
5776 TextField field3 = TextField::New();
5777 field3.SetProperty(TextField::Property::TEXT, "Test");
5778 field3.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5779 field3.SetProperty(TextField::Property::POINT_SIZE, 10);
5780 field3.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5782 Property::Map underlineMapSet3;
5783 Property::Map underlineMapGet3;
5785 underlineMapSet3.Insert("enable", true);
5786 underlineMapSet3.Insert("color", Color::BLUE);
5787 underlineMapSet3.Insert("height", 1);
5788 underlineMapSet3.Insert("type", Text::Underline::DOUBLE);
5789 underlineMapSet3.Insert("dashWidth", 4);
5790 underlineMapSet3.Insert("dashGap", 2);
5792 // Check the dashed underline property
5793 field3.SetProperty(TextField::Property::UNDERLINE, underlineMapSet3);
5795 underlineMapGet3 = field3.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5796 DALI_TEST_EQUALS(underlineMapGet3.Count(), underlineMapSet3.Count(), TEST_LOCATION);
5797 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
5799 application.GetScene().Add(field3);
5801 application.SendNotification();
5802 application.Render();
5807 int UtcDaliTextFieldCharacterSpacing(void)
5809 ToolkitTestApplication application;
5810 tet_infoline(" UtcDaliTextFieldCharacterSpacing ");
5812 TextField textField = TextField::New();
5814 textField.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
5816 application.GetScene().Add(textField);
5817 application.SendNotification();
5818 application.Render();
5820 textField.SetProperty(TextField::Property::TEXT, "Hi Experiment");
5821 textField.SetProperty(DevelTextField::Property::CHARACTER_SPACING, 10.f);
5822 DALI_TEST_EQUALS(textField.GetProperty<float>(DevelTextField::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
5824 application.SendNotification();
5825 application.Render();
5830 int UtcDaliToolkitTextFieldUnderlineTypesGeneration3(void)
5832 ToolkitTestApplication application;
5833 tet_infoline(" UtcDaliToolkitTextFieldUnderlineTypesGeneration3");
5835 TextField field1 = TextField::New();
5836 field1.SetProperty(TextField::Property::TEXT, "Test1");
5837 field1.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
5838 field1.SetProperty(TextField::Property::POINT_SIZE, 10);
5839 field1.SetProperty(TextField::Property::FONT_FAMILY, "DejaVu Sans");
5841 Property::Map underlineMapSet1;
5842 Property::Map underlineMapGet1;
5844 underlineMapSet1.Insert("enable", true);
5845 underlineMapSet1.Insert("color", Color::RED);
5846 underlineMapSet1.Insert("height", 1);
5847 underlineMapSet1.Insert("type", Text::Underline::SOLID);
5848 underlineMapSet1.Insert("dashWidth", 2);
5849 underlineMapSet1.Insert("dashGap", 1);
5851 // Check the underline property
5852 field1.SetProperty(TextField::Property::UNDERLINE, underlineMapSet1);
5853 //field1.SetProperty( TextField::Property::TEXT, "Test2" );
5855 underlineMapGet1 = field1.GetProperty<Property::Map>(TextField::Property::UNDERLINE);
5856 DALI_TEST_EQUALS(underlineMapGet1.Count(), underlineMapSet1.Count(), TEST_LOCATION);
5857 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet1, underlineMapSet1), true, TEST_LOCATION);
5859 application.GetScene().Add(field1);
5860 application.SendNotification();
5861 application.Render();
5866 int UtcDaliToolkitTextfieldParagraphTag(void)
5868 ToolkitTestApplication application;
5869 tet_infoline(" UtcDaliToolkitTextfieldParagraphTag");
5870 TextField fieldNewlineSeparator = TextField::New();
5871 TextField fieldParagraphTag = TextField::New();
5872 DALI_TEST_CHECK(fieldNewlineSeparator);
5873 DALI_TEST_CHECK(fieldParagraphTag);
5875 application.GetScene().Add(fieldNewlineSeparator);
5876 application.GetScene().Add(fieldParagraphTag);
5878 //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
5879 fieldNewlineSeparator.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5880 fieldNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5881 fieldNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5882 fieldNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5883 fieldNewlineSeparator.SetProperty(TextField::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
5885 fieldParagraphTag.SetProperty(TextField::Property::ENABLE_MARKUP, true);
5886 fieldParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
5887 fieldParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
5888 fieldParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5889 fieldParagraphTag.SetProperty(TextField::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
5891 application.SendNotification();
5892 application.Render();
5894 Vector3 textNaturalSizeNewlineSeparator = fieldNewlineSeparator.GetNaturalSize();
5895 Vector3 textNaturalSizeParagraphTag = fieldParagraphTag.GetNaturalSize();
5897 DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
5899 application.SendNotification();
5900 application.Render();
5905 //Handle Emoji clustering for cursor handling
5906 int utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey(void)
5908 ToolkitTestApplication application;
5909 tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionBackSpaceKey ");
5910 TextField textField = TextField::New();
5911 DALI_TEST_CHECK(textField);
5913 application.GetScene().Add(textField);
5915 // Avoid a crash when core load gl resources.
5916 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5918 textField.SetProperty(TextField::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
5919 textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5921 // Render and notify
5922 application.SendNotification();
5923 application.Render();
5926 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 10);
5927 application.SendNotification();
5928 application.Render();
5930 // Set focus and remove Emoji
5931 textField.SetKeyInputFocus();
5932 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5934 //Check the changed text and cursor position
5935 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5936 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5938 // Render and notify
5939 application.SendNotification();
5940 application.Render();
5945 int utcDaliTextFieldClusteredEmojiDeletionDeleteKey(void)
5947 ToolkitTestApplication application;
5948 tet_infoline(" utcDaliTextFieldClusteredEmojiDeletionDeleteKey ");
5949 TextField textField = TextField::New();
5950 DALI_TEST_CHECK(textField);
5952 application.GetScene().Add(textField);
5954 // Avoid a crash when core load gl resources.
5955 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
5957 textField.SetProperty(TextField::Property::TEXT, "ABC👨‍👩‍👧‍👦XY");
5958 textField.SetProperty(Dali::Toolkit::TextField::Property::ENABLE_MARKUP, true);
5960 // Render and notify
5961 application.SendNotification();
5962 application.Render();
5965 textField.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
5966 application.SendNotification();
5967 application.Render();
5969 // Set focus and remove Emoji
5970 textField.SetKeyInputFocus();
5971 application.ProcessEvent(GenerateKey("", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5973 //Check the changed text and cursor position
5974 DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::TEXT).Get<std::string>(), "ABCXY", TEST_LOCATION);
5975 DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get<int>(), 3, TEST_LOCATION);
5977 // Render and notify
5978 application.SendNotification();
5979 application.Render();
5984 int utcDaliTextFieldPanGesturePropagation(void)
5986 ToolkitTestApplication application;
5987 tet_infoline(" utcDaliTextFieldPanGesturePropagation");
5989 Actor actor = Actor::New();
5990 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
5991 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
5992 application.GetScene().Add(actor);
5994 TextField field = TextField::New();
5995 DALI_TEST_CHECK(field);
5997 field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
5998 field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
6000 field.SetProperty(Actor::Property::SIZE, Vector2(50.f, 100.f));
6001 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6002 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6006 // Render and notify
6007 application.SendNotification();
6008 application.Render();
6011 GestureReceivedFunctor functor(data);
6013 PanGestureDetector detector = PanGestureDetector::New();
6014 detector.Attach(actor);
6015 detector.DetectedSignal().Connect(&application, functor);
6017 // Tap first to get the focus.
6018 TestGenerateTap(application, 3.0f, 25.0f, 100);
6020 // Render and notify
6021 application.SendNotification();
6022 application.Render();
6024 // Pan the text field
6025 uint32_t time = 100;
6026 TestStartPan(application, Vector2(40.0f, 50.0f), Vector2(40.0f, 50.0f), time);
6027 TestMovePan(application, Vector2(10.0f, 50.0f), time);
6028 TestEndPan(application, Vector2(40.0f, 50.0f), time);
6029 application.SendNotification();
6030 application.Render();
6032 // The text scrolls because there is text that is scrolling.
6033 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
6036 // Set the size large enough to prevent scrolling.
6037 field.SetProperty(Actor::Property::SIZE, Vector2(700.f, 100.f));
6039 // Render and notify
6040 application.SendNotification();
6041 application.Render();
6044 TestStartPan(application, Vector2(40.0f, 50.0f), Vector2(40.0f, 50.0f), time);
6045 TestMovePan(application, Vector2(10.0f, 50.0f), time);
6046 TestEndPan(application, Vector2(40.0f, 50.0f), time);
6048 // Because scrolling is not possible, the pan gesture is propagated.
6049 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
6055 int utcDaliTextFieldGetTextBoundingRectangle(void)
6057 ToolkitTestApplication application;
6058 tet_infoline(" utcDaliTextFieldGeometryEllipsisMiddle");
6060 TextField field = TextField::New();
6061 DALI_TEST_CHECK(field);
6063 application.GetScene().Add(field);
6065 field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
6066 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
6067 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6068 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6069 field.SetProperty(TextField::Property::TEXT, "Hello this is the Text Bounding Rectangle TC");
6071 // Avoid a crash when core load gl resources.
6072 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6074 // Render and notify
6075 application.SendNotification();
6076 application.Render();
6078 unsigned int startIndex = 0;
6079 unsigned int endIndex = 15;
6081 Rect<> textBoundingRectangle = DevelTextField::GetTextBoundingRectangle(field, startIndex, endIndex);
6082 Rect<> expectedTextBoundingRectangle = {0, 0, 100, 25};
6084 TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle);
6089 int utcDaliTextFieldDecoratorColor(void)
6091 ToolkitTestApplication application;
6092 tet_infoline(" utcDaliTextFieldDecoratorColor");
6093 TextField textField = TextField::New();
6094 DALI_TEST_CHECK(textField);
6095 LoadMarkerImages(application, textField);
6096 application.GetScene().Add(textField);
6098 // Render and notify
6099 application.SendNotification();
6100 application.Render();
6102 textField.SetProperty(TextField::Property::TEXT, "العالم Hello");
6103 textField.SetProperty(TextField::Property::POINT_SIZE, 10.f);
6104 textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
6105 textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6106 textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6108 // Avoid a crash when core load gl resources.
6109 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
6111 application.SendNotification();
6112 application.Render();
6114 textField.SetKeyInputFocus();
6116 application.SendNotification();
6117 application.Render();
6119 // Create a tap event to touch the text field.
6120 TestGenerateTap(application, 1.0f, 25.0f, 100);
6122 // Render and notify
6123 application.SendNotification();
6124 application.Render();
6126 // Double tap to select a word.
6127 TestGenerateTap(application, 1.0f, 25.0f, 200);
6129 application.SendNotification();
6130 application.Render();
6132 // At this point, the text decorator's primary/secondary cursor, grab/left/right handle and highlight actor were all created.
6133 // Check some properties for coverage.
6134 textField.SetProperty(TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED);
6135 DALI_TEST_EQUALS(textField.GetProperty<Vector4>(TextField::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION);
6137 textField.SetProperty(TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE);
6138 DALI_TEST_EQUALS(textField.GetProperty<Vector4>(TextField::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION);
6140 textField.SetProperty(DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN);
6141 DALI_TEST_EQUALS(textField.GetProperty<Vector4>(DevelTextField::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION);
6143 textField.SetProperty(TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN);
6144 DALI_TEST_EQUALS(textField.GetProperty<Vector4>(TextField::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION);
6146 textField.SetProperty(TextField::Property::CURSOR_WIDTH, 3);
6147 DALI_TEST_EQUALS(textField.GetProperty<int>(TextField::Property::CURSOR_WIDTH), 3, TEST_LOCATION);
6149 application.SendNotification();
6150 application.Render();
6155 int utcDaliTextFieldRemoveFrontInset(void)
6157 ToolkitTestApplication application;
6158 tet_infoline(" utcDaliTextFieldRemoveFrontInset");
6160 TextField field = TextField::New();
6161 DALI_TEST_CHECK(field);
6163 application.GetScene().Add(field);
6164 application.SendNotification();
6165 application.Render();
6167 DevelTextField::SetRemoveFrontInset(field, false);
6168 DALI_TEST_CHECK(!DevelTextField::IsRemoveFrontInset(field));
6173 int utcDaliTextFieldRemoveBackInset(void)
6175 ToolkitTestApplication application;
6176 tet_infoline(" utcDaliTextFieldRemoveBackInset");
6178 TextField field = TextField::New();
6179 DALI_TEST_CHECK(field);
6181 application.GetScene().Add(field);
6182 application.SendNotification();
6183 application.Render();
6185 DevelTextField::SetRemoveBackInset(field, false);
6186 DALI_TEST_CHECK(!DevelTextField::IsRemoveBackInset(field));