2 * Copyright (c) 2021 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/public-api/rendering/renderer.h>
23 #include <dali/integration-api/events/key-event-integ.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/devel-api/adaptor-framework/key-devel.h>
27 #include <dali/devel-api/text-abstraction/font-client.h>
28 #include <dali-toolkit-test-suite-utils.h>
29 #include <dali-toolkit/dali-toolkit.h>
30 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
31 #include <dali-toolkit/devel-api/text/rendering-backend.h>
32 #include "toolkit-clipboard.h"
33 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
34 #include "test-text-geometry-utils.h"
37 using namespace Toolkit;
39 void dali_textfield_startup(void)
41 test_return_value = TET_UNDEF;
44 void dali_textfield_cleanup(void)
46 test_return_value = TET_PASS;
52 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
53 const char* const PROPERTY_NAME_TEXT = "text";
54 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
55 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
56 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
57 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
58 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
59 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
60 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
61 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
62 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
63 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
64 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
65 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
66 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
67 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
68 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
69 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
70 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
71 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
72 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
73 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
74 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
80 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
81 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
82 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
83 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
84 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
85 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
86 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
87 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
88 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
90 const char* const PROPERTY_NAME_UNDERLINE = "underline";
91 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
92 const char* const PROPERTY_NAME_SHADOW = "shadow";
93 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
94 const char* const PROPERTY_NAME_EMBOSS = "emboss";
95 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
96 const char* const PROPERTY_NAME_OUTLINE = "outline";
97 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
98 const char* const PROPERTY_NAME_STRIKETHROUGH = "strikethrough";
99 const char* const PROPERTY_NAME_INPUT_STRIKETHROUGH = "inputStrikethrough";
101 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
102 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
103 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
104 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
105 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
106 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
107 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
108 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
109 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
110 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
111 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
112 const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE = "enableFontSizeScale";
113 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
114 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
116 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
117 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
119 const float RENDER_FRAME_INTERVAL = 16.66f;
121 const unsigned int DEFAULT_FONT_SIZE = 1152u;
122 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
124 const int KEY_RETURN_CODE = 36;
125 const int KEY_A_CODE = 38;
126 const int KEY_D_CODE = 40;
127 const int KEY_SHIFT_MODIFIER = 257;
129 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
131 static bool gSelectionChangedCallbackCalled;
132 static uint32_t oldSelectionStart;
133 static uint32_t oldSelectionEnd;
134 static bool gSelectionClearedCallbackCalled;
135 static bool gAnchorClickedCallBackCalled;
136 static bool gAnchorClickedCallBackNotCalled;
137 static bool gTextChangedCallBackCalled;
138 static bool gMaxCharactersCallBackCalled;
139 static bool gInputFilteredAcceptedCallbackCalled;
140 static bool gInputFilteredRejectedCallbackCalled;
141 static bool gInputStyleChangedCallbackCalled;
142 static bool gCursorPositionChangedCallbackCalled;
143 static uint32_t oldCursorPos;
144 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
146 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
148 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
149 Integration::ResourcePointer resource(bitmap);
150 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
153 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
157 LoadBitmapResource( app.GetPlatform(), width, height );
159 Property::Map propertyMap;
160 propertyMap["filename"] = "image.png";
161 propertyMap["width"] = width;
162 propertyMap["height"] = height;
163 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
164 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
165 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
166 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
167 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
168 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
169 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
170 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
174 * Simulate time passed by.
176 * @note this will always process at least 1 frame (1/60 sec)
178 * @param application Test application instance
179 * @param duration Time to pass in milliseconds.
180 * @return The actual time passed in milliseconds
182 static int Wait(ToolkitTestApplication& application, int duration = 0)
186 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
188 application.SendNotification();
189 application.Render(RENDER_FRAME_INTERVAL);
190 time += RENDER_FRAME_INTERVAL;
196 Dali::Integration::Point GetPointDownInside( Vector2& pos )
198 Dali::Integration::Point point;
199 point.SetState( PointState::DOWN );
200 point.SetScreenPosition( pos );
204 Dali::Integration::Point GetPointUpInside( Vector2& pos )
206 Dali::Integration::Point point;
207 point.SetState( PointState::UP );
208 point.SetScreenPosition( pos );
212 struct CallbackFunctor
214 CallbackFunctor(bool* callbackFlag)
215 : mCallbackFlag( callbackFlag )
221 *mCallbackFlag = true;
226 static void TestSelectionClearedCallback(TextField control)
228 tet_infoline(" TestSelectionClearedCallback");
230 gSelectionClearedCallbackCalled = true;
233 static void TestSelectionChangedCallback(TextField control, uint32_t oldStart, uint32_t oldEnd)
235 tet_infoline(" TestSelectionChangedCallback");
237 gSelectionChangedCallbackCalled = true;
238 oldSelectionStart = oldStart;
239 oldSelectionEnd = oldEnd;
242 static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength)
244 tet_infoline(" TestAnchorClickedCallback");
246 gAnchorClickedCallBackNotCalled = false;
248 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
250 gAnchorClickedCallBackCalled = true;
254 static void TestCursorPositionChangedCallback( TextField control, unsigned int oldPos )
256 tet_infoline(" TestCursorPositionChangedCallback");
258 gCursorPositionChangedCallbackCalled = true;
259 oldCursorPos = oldPos;
262 static void TestTextChangedCallback( TextField control )
264 tet_infoline(" TestTextChangedCallback");
266 gTextChangedCallBackCalled = true;
269 static void TestMaxLengthReachedCallback( TextField control )
271 tet_infoline(" TestMaxLengthReachedCallback");
273 gMaxCharactersCallBackCalled = true;
276 static void TestInputFilteredCallback(TextField control, Toolkit::InputFilter::Property::Type type)
278 tet_infoline(" TestInputFilteredCallback");
280 if(type == Toolkit::InputFilter::Property::ACCEPTED)
282 gInputFilteredAcceptedCallbackCalled = true;
284 else if(type == Toolkit::InputFilter::Property::REJECTED)
286 gInputFilteredRejectedCallbackCalled = true;
290 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
292 tet_infoline(" TestInputStyleChangedCallback");
294 gInputStyleChangedCallbackCalled = true;
295 gInputStyleMask = mask;
298 // Generate a KeyEvent to send to Core.
299 Integration::KeyEvent GenerateKey( const std::string& keyName,
300 const std::string& logicalKey,
301 const std::string& keyString,
304 unsigned long timeStamp,
305 const Integration::KeyEvent::State& keyState,
306 const std::string& compose = "",
307 const std::string& deviceName = DEFAULT_DEVICE_NAME,
308 const Device::Class::Type& deviceClass = Device::Class::NONE,
309 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
311 return Integration::KeyEvent( keyName,
324 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
326 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
328 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
330 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
332 Property::Value* valueSet = NULL;
333 if ( valueGet.first.type == Property::Key::INDEX )
335 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
339 // Get Key is a string so searching Set Map for a string key
340 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
343 if( NULL != valueSet )
345 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
347 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
350 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
352 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
355 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
357 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
360 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
362 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
365 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
367 Vector2 vector2Get = valueGet.second.Get<Vector2>();
368 Vector2 vector2Set = valueSet->Get<Vector2>();
369 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
372 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
374 Vector4 vector4Get = valueGet.second.Get<Vector4>();
375 Vector4 vector4Set = valueSet->Get<Vector4>();
376 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 );
382 if ( valueGet.first.type == Property::Key::INDEX )
384 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
388 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
400 int UtcDaliToolkitTextFieldConstructorP(void)
402 ToolkitTestApplication application;
403 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
405 DALI_TEST_CHECK( !textField );
409 int UtcDaliToolkitTextFieldNewP(void)
411 ToolkitTestApplication application;
412 tet_infoline(" UtcDaliToolkitTextFieldNewP");
413 TextField textField = TextField::New();
414 DALI_TEST_CHECK( textField );
418 int UtcDaliToolkitTextFieldDownCastP(void)
420 ToolkitTestApplication application;
421 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
422 TextField textField1 = TextField::New();
423 BaseHandle object( textField1 );
425 TextField textField2 = TextField::DownCast( object );
426 DALI_TEST_CHECK( textField2 );
428 TextField textField3 = DownCast< TextField >( object );
429 DALI_TEST_CHECK( textField3 );
433 int UtcDaliToolkitTextFieldDownCastN(void)
435 ToolkitTestApplication application;
436 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
437 BaseHandle uninitializedObject;
438 TextField textField1 = TextField::DownCast( uninitializedObject );
439 DALI_TEST_CHECK( !textField1 );
441 TextField textField2 = DownCast< TextField >( uninitializedObject );
442 DALI_TEST_CHECK( !textField2 );
446 int UtcDaliToolkitTextFieldCopyConstructorP(void)
448 ToolkitTestApplication application;
449 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
450 TextField textField = TextField::New();
451 textField.SetProperty( TextField::Property::TEXT, "Test" );
453 TextField copy( textField );
454 DALI_TEST_CHECK( copy );
455 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
459 int UtcDaliTextFieldMoveConstructor(void)
461 ToolkitTestApplication application;
463 TextField textField = TextField::New();
464 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
465 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
467 TextField moved = std::move( textField );
468 DALI_TEST_CHECK( moved );
469 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
470 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
471 DALI_TEST_CHECK( !textField );
476 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
478 ToolkitTestApplication application;
479 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
480 TextField textField = TextField::New();
481 textField.SetProperty( TextField::Property::TEXT, "Test" );
483 TextField copy = textField;
484 DALI_TEST_CHECK( copy );
485 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
489 int UtcDaliTextFieldMoveAssignment(void)
491 ToolkitTestApplication application;
493 TextField textField = TextField::New();
494 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
495 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
498 moved = std::move( textField );
499 DALI_TEST_CHECK( moved );
500 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
501 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
502 DALI_TEST_CHECK( !textField );
507 int UtcDaliTextFieldNewP(void)
509 ToolkitTestApplication application;
510 tet_infoline(" UtcDaliToolkitTextFieldNewP");
511 TextField textField = TextField::New();
512 DALI_TEST_CHECK( textField );
516 // Positive test case for a method
517 int UtcDaliTextFieldGetPropertyP(void)
519 ToolkitTestApplication application;
520 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
521 TextField field = TextField::New();
522 DALI_TEST_CHECK( field );
524 // Check Property Indices are correct
525 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextField::Property::RENDERING_BACKEND );
526 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
527 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
528 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
529 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
530 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
531 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
532 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
533 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
534 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
535 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
536 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
537 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
538 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
539 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
540 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
541 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
542 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
543 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
544 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
545 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
546 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
547 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
548 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
549 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
550 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
551 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
552 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
553 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
554 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
555 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
556 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
557 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
558 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
559 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
560 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
561 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
562 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
563 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
564 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
565 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
566 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
567 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
568 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
569 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
570 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
571 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
572 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
573 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
574 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
575 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextField::Property::FONT_SIZE_SCALE );
576 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE ) == DevelTextField::Property::ENABLE_FONT_SIZE_SCALE );
577 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
578 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
579 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
580 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP );
581 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextField::Property::BACKGROUND );
582 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextField::Property::GRAB_HANDLE_COLOR );
583 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FILTER ) == DevelTextField::Property::INPUT_FILTER );
584 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_STRIKETHROUGH ) == DevelTextField::Property::STRIKETHROUGH );
585 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_STRIKETHROUGH ) == DevelTextField::Property::INPUT_STRIKETHROUGH );
590 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
593 Property::Map imageMap;
594 imageMap[mapKey] =mapValue;
596 field.SetProperty( property , imageMap );
597 Property::Value propValue = field.GetProperty( property );
598 Property::Map* resultMap = propValue.GetMap();
600 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
608 // Positive test case for a method
609 int UtcDaliTextFieldSetPropertyP(void)
611 ToolkitTestApplication application;
612 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
613 TextField field = TextField::New();
614 DALI_TEST_CHECK( field );
615 application.GetScene().Add( field );
617 // Note - we can't check the defaults since the stylesheets are platform-specific
619 // Check the render backend property.
620 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
621 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
623 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
624 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION );
626 // Check text property.
627 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
628 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
630 // Check placeholder text properties.
631 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
632 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
634 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
635 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
637 // Check font properties.
638 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
639 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
641 Property::Map fontStyleMapSet;
642 Property::Map fontStyleMapGet;
643 Property::Value* slantValue = NULL;
645 fontStyleMapSet.Insert( "weight", "bold" );
646 fontStyleMapSet.Insert( "width", "condensed" );
647 fontStyleMapSet.Insert( "slant", "italic" );
648 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
650 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
651 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
652 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
654 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
655 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
657 field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 2.5f );
658 DALI_TEST_EQUALS( field.GetProperty<float>( DevelTextField::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
659 field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 1.0f );
661 field.SetProperty( DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, false );
662 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_FONT_SIZE_SCALE ), false, TEST_LOCATION );
663 field.SetProperty( DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, true );
666 fontStyleMapSet.Clear();
667 fontStyleMapSet.Insert( "weight", "normal" );
668 fontStyleMapSet.Insert( "slant", "oblique" );
669 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
671 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
672 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
673 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
675 fontStyleMapSet.Clear();
676 fontStyleMapSet.Insert( "slant", "roman" );
677 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
678 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
680 // Replace 'roman' for 'normal'.
681 slantValue = fontStyleMapGet.Find( "slant" );
682 if( NULL != slantValue )
684 if( "normal" == slantValue->Get<std::string>() )
686 fontStyleMapGet["slant"] = "roman";
689 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
690 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
692 fontStyleMapSet.Clear();
694 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
695 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
696 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
697 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
699 // Check that the MAX_LENGTH property can be correctly set
700 const int maxNumberOfCharacters = 20;
701 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
702 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
704 // Check exceed policy
705 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
706 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
707 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
708 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
710 // Check that the Alignment properties can be correctly set
711 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
712 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
713 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
714 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
716 // Check text's color property
717 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
718 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
720 // Check placeholder text's color property.
721 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
722 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
724 // Check cursor properties
725 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
726 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
727 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
728 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
730 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
731 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
732 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
733 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
734 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
735 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
736 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
737 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
739 // Check scroll properties.
740 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
741 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
742 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
743 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
745 // Check handle images
746 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
747 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
748 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
749 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
750 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
752 // Check handle images
753 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
754 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
755 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
756 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
757 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
758 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
760 // Check the highlight color
761 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
762 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
764 // Decoration bounding box
765 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
766 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
768 // Check the input method setting
769 Property::Map propertyMap;
770 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
771 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
772 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
773 int inputVariation = 1;
774 propertyMap["PANEL_LAYOUT"] = panelLayout;
775 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
776 propertyMap["BUTTON_ACTION"] = buttonAction;
777 propertyMap["VARIATION"] = inputVariation;
778 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
780 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
782 DALI_TEST_CHECK( value.Get( map ) );
785 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
786 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
789 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
790 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
793 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
794 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
797 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
798 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
800 // Check input color property.
801 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
802 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
804 // Check the enable markup property.
805 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
806 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
807 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
809 // Check input font properties.
810 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
811 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
813 fontStyleMapSet.Clear();
814 fontStyleMapSet.Insert( "weight", "bold" );
815 fontStyleMapSet.Insert( "width", "condensed" );
816 fontStyleMapSet.Insert( "slant", "italic" );
818 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
819 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
820 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
821 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
823 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
824 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
826 // Reset input font style.
827 fontStyleMapSet.Clear();
828 fontStyleMapSet.Insert( "weight", "normal" );
829 fontStyleMapSet.Insert( "slant", "oblique" );
831 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
832 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
833 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
834 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
836 fontStyleMapSet.Clear();
837 fontStyleMapSet.Insert( "slant", "roman" );
839 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
840 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
842 // Replace 'roman' for 'normal'.
843 slantValue = fontStyleMapGet.Find( "slant" );
844 if( NULL != slantValue )
846 if( "normal" == slantValue->Get<std::string>() )
848 fontStyleMapGet["slant"] = "roman";
851 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
852 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
854 fontStyleMapSet.Clear();
856 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
857 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
858 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
859 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
861 Property::Map strikethroughMapSet;
862 Property::Map strikethroughMapGet;
864 strikethroughMapSet.Insert( "enable", true );
865 strikethroughMapSet.Insert( "color", Color::RED );
866 strikethroughMapSet.Insert( "height", 2.0f );
868 // Check the strikethrough property
869 field.SetProperty( DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet );
871 strikethroughMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::STRIKETHROUGH );
872 DALI_TEST_EQUALS( strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION );
873 DALI_TEST_EQUALS( DaliTestCheckMaps( strikethroughMapGet, strikethroughMapSet ), true, TEST_LOCATION );
875 // Check the input strikethrough property
876 field.SetProperty( DevelTextField::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties" );
877 DALI_TEST_EQUALS( field.GetProperty<std::string>( DevelTextField::Property::INPUT_STRIKETHROUGH ), std::string("Strikethrough input properties"), TEST_LOCATION );
879 Property::Map underlineMapSet;
880 Property::Map underlineMapGet;
882 underlineMapSet.Insert( "enable", true );
883 underlineMapSet.Insert( "color", Color::RED );
884 underlineMapSet.Insert( "height", 1 );
886 // Check the underline property
887 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
889 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
890 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
891 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
893 // Check the input underline property
894 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
895 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
897 // Check the shadow property
898 Property::Map shadowMapSet;
899 Property::Map shadowMapGet;
901 shadowMapSet.Insert( "color", Color::GREEN );
902 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
903 shadowMapSet.Insert( "blurRadius", 3.0f );
905 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
907 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
908 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
909 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
911 // Check the input shadow property
912 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
913 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
915 // Check the emboss property
916 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
917 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
919 // Check the input emboss property
920 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
921 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
923 // Check the outline property
925 // Test string type first
926 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
927 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
928 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
930 // Then test the property map type
931 Property::Map outlineMapSet;
932 Property::Map outlineMapGet;
934 outlineMapSet["color"] = Color::RED;
935 outlineMapSet["width"] = 2.0f;
937 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
939 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
940 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
941 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
943 // Check the input outline property
944 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
945 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
947 // Check the hidden input settings property
948 Property::Map hiddenMapSet;
949 Property::Map hiddenMapGet;
950 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
951 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
952 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
953 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
954 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
956 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
957 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
958 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
960 // Check the pixel size of font
961 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
962 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
964 // Check the enable selection property
965 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
966 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
968 // Check the placeholder property with pixel size
969 Property::Map placeholderPixelSizeMapSet;
970 Property::Map placeholderPixelSizeMapGet;
971 Property::Map placeholderFontstyleMap;
972 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
973 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
974 placeholderPixelSizeMapSet["color"] = Color::BLUE;
975 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
976 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
977 placeholderPixelSizeMapSet["ellipsis"] = true;
979 placeholderFontstyleMap.Insert( "weight", "bold" );
980 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
981 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
983 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
984 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
986 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
987 Property::Map placeholderConversionMap;
988 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
989 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
990 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
991 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
992 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
993 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
995 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
997 // Check the placeholder property with point size
998 Property::Map placeholderMapSet;
999 Property::Map placeholderMapGet;
1000 placeholderMapSet["text"] = "Setting Placeholder Text";
1001 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
1002 placeholderMapSet["color"] = Color::RED;
1003 placeholderMapSet["fontFamily"] = "Arial";
1004 placeholderMapSet["pointSize"] = 12.0f;
1005 placeholderMapSet["ellipsis"] = false;
1007 // Check the placeholder font style property
1008 placeholderFontstyleMap.Clear();
1010 placeholderFontstyleMap.Insert( "weight", "bold" );
1011 placeholderFontstyleMap.Insert( "width", "condensed" );
1012 placeholderFontstyleMap.Insert( "slant", "italic" );
1013 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1014 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1016 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1017 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1019 placeholderConversionMap.Clear();
1020 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
1021 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
1022 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
1023 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1024 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
1025 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
1027 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1029 // Reset font style.
1030 placeholderFontstyleMap.Clear();
1031 placeholderFontstyleMap.Insert( "weight", "normal" );
1032 placeholderFontstyleMap.Insert( "slant", "oblique" );
1033 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1034 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1036 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1037 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1039 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1040 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1042 placeholderFontstyleMap.Clear();
1043 placeholderFontstyleMap.Insert( "slant", "roman" );
1044 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1045 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1047 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1049 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1051 placeholderFontstyleMap.Clear();
1052 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1053 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1055 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1056 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1057 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1059 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1061 // Check the ellipsis property
1062 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1063 field.SetProperty( TextField::Property::ELLIPSIS, true );
1064 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1066 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
1067 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1069 // Test the ENABLE_GRAB_HANDLE_POPUP property
1070 DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1071 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false );
1072 DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1074 // Check the background property
1075 field.SetProperty( DevelTextField::Property::BACKGROUND, Color::RED );
1076 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::BACKGROUND ), Color::RED, TEST_LOCATION );
1078 //Check handle color
1079 field.SetProperty( DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN );
1080 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
1082 // Check the input filter property
1083 Property::Map inputFilterMapSet;
1084 Property::Map inputFilterMapGet;
1085 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1086 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1088 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1090 inputFilterMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::INPUT_FILTER);
1091 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1094 inputFilterMapSet.Clear();
1095 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1097 application.SendNotification();
1098 application.Render();
1103 // Positive Atlas Text Renderer test
1104 int utcDaliTextFieldAtlasRenderP(void)
1106 ToolkitTestApplication application;
1107 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1108 StyleManager styleManager = StyleManager::Get();
1109 styleManager.ApplyDefaultTheme();
1110 TextField field = TextField::New();
1111 DALI_TEST_CHECK( field );
1113 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1115 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1117 application.GetScene().Add( field );
1121 // Render some text with the shared atlas backend
1122 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1123 application.SendNotification();
1124 application.Render();
1128 tet_result(TET_FAIL);
1133 // Positive test for the anchorClicked signal.
1134 int utcDaliTextFieldAnchorClicked01(void)
1136 ToolkitTestApplication application;
1137 tet_infoline(" utcDaliTextFieldAnchorClicked01");
1138 TextField field = TextField::New();
1139 DALI_TEST_CHECK(field);
1141 application.GetScene().Add(field);
1143 // connect to the anchor clicked signal.
1144 ConnectionTracker* testTracker = new ConnectionTracker();
1145 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1146 bool anchorClickedSignal = false;
1147 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1149 gAnchorClickedCallBackCalled = false;
1150 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1151 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1152 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1153 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1154 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1156 application.SendNotification();
1157 application.Render();
1158 field.SetKeyInputFocus();
1160 // Create a tap event to touch the text field.
1161 TestGenerateTap(application, 5.0f, 25.0f);
1162 application.SendNotification();
1163 application.Render();
1165 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1166 DALI_TEST_CHECK(anchorClickedSignal);
1168 gAnchorClickedCallBackNotCalled = true;
1169 // Tap the outside of anchor, callback should not be called.
1170 TestGenerateTap(application, 150.f, 100.f);
1171 application.SendNotification();
1172 application.Render();
1174 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1179 // Positive test for the anchorClicked signal.
1180 int utcDaliTextFieldAnchorClicked02(void)
1182 ToolkitTestApplication application;
1183 tet_infoline(" utcDaliTextFieldAnchorClicked02");
1184 TextField field = TextField::New();
1185 DALI_TEST_CHECK(field);
1187 application.GetScene().Add(field);
1189 // connect to the anchor clicked signal.
1190 ConnectionTracker* testTracker = new ConnectionTracker();
1191 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1192 bool anchorClickedSignal = false;
1193 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1195 gAnchorClickedCallBackCalled = false;
1196 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1197 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1198 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1199 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1200 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1202 application.SendNotification();
1203 application.Render();
1204 field.SetKeyInputFocus();
1206 // Avoid a crash when core load gl resources.
1207 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1209 // Create a tap event to touch the text field.
1210 TestGenerateTap(application, 30.0f, 25.0f, 100);
1211 application.SendNotification();
1212 application.Render();
1214 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1215 DALI_TEST_CHECK(anchorClickedSignal);
1218 // For coverage InsertTextAnchor, RemoveTextAnchor
1219 // first index insert
1220 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1221 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1222 application.SendNotification();
1223 application.Render();
1225 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1226 application.SendNotification();
1227 application.Render();
1229 gAnchorClickedCallBackCalled = false;
1230 // Create a tap event to touch the text field.
1231 TestGenerateTap(application, 30.0f, 25.0f, 700);
1232 application.SendNotification();
1233 field.SetKeyInputFocus();
1235 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1237 // last index insert
1238 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1239 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1240 application.SendNotification();
1241 application.Render();
1243 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1244 application.SendNotification();
1245 application.Render();
1247 gAnchorClickedCallBackCalled = false;
1248 // Create a tap event to touch the text field.
1249 TestGenerateTap(application, 30.0f, 25.0f, 1300);
1250 application.SendNotification();
1251 field.SetKeyInputFocus();
1253 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1256 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1257 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1258 application.SendNotification();
1259 application.Render();
1261 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1262 application.SendNotification();
1263 application.Render();
1265 gAnchorClickedCallBackCalled = false;
1266 // Create a tap event to touch the text field.
1267 TestGenerateTap(application, 30.0f, 25.0f, 1900);
1268 application.SendNotification();
1269 field.SetKeyInputFocus();
1271 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1273 // first index remove
1274 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1275 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1276 application.SendNotification();
1277 application.Render();
1279 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1280 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));
1281 application.SendNotification();
1282 application.Render();
1284 gAnchorClickedCallBackCalled = false;
1285 // Create a tap event to touch the text field.
1286 TestGenerateTap(application, 30.0f, 25.0f, 2500);
1287 application.SendNotification();
1288 field.SetKeyInputFocus();
1290 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1292 // last index remove
1293 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1294 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1295 application.SendNotification();
1296 application.Render();
1298 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1299 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));
1300 application.SendNotification();
1301 application.Render();
1303 gAnchorClickedCallBackCalled = false;
1304 // Create a tap event to touch the text field.
1305 TestGenerateTap(application, 30.0f, 25.0f, 3100);
1306 application.SendNotification();
1307 application.Render();
1309 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1312 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1313 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1314 application.SendNotification();
1315 application.Render();
1317 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1318 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));
1319 application.SendNotification();
1320 application.Render();
1322 gAnchorClickedCallBackCalled = false;
1323 // Create a tap event to touch the text field.
1324 TestGenerateTap(application, 30.0f, 25.0f, 3700);
1325 application.SendNotification();
1326 application.Render();
1328 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1330 // 0 ~ 1 index remove
1331 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1332 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 0);
1333 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 1);
1334 application.SendNotification();
1335 application.Render();
1337 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1338 application.SendNotification();
1339 application.Render();
1341 gAnchorClickedCallBackCalled = false;
1342 // Create a tap event to touch the text field.
1343 TestGenerateTap(application, 30.0f, 25.0f, 4300);
1344 application.SendNotification();
1345 application.Render();
1347 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1349 // 1 ~ 3 index remove
1350 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1351 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 1);
1352 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 3);
1353 application.SendNotification();
1354 application.Render();
1356 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1357 application.SendNotification();
1358 application.Render();
1360 gAnchorClickedCallBackCalled = false;
1361 // Create a tap event to touch the text field.
1362 TestGenerateTap(application, 30.0f, 25.0f, 4900);
1363 application.SendNotification();
1364 application.Render();
1366 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1368 // 3 ~ 4 index remove
1369 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1370 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 3);
1371 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 4);
1372 application.SendNotification();
1373 application.Render();
1375 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1376 application.SendNotification();
1377 application.Render();
1379 gAnchorClickedCallBackCalled = false;
1380 // Create a tap event to touch the text field.
1381 TestGenerateTap(application, 30.0f, 25.0f, 5500);
1382 application.SendNotification();
1383 application.Render();
1385 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1387 // Remove front of anchor
1388 field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
1389 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
1390 application.SendNotification();
1391 application.Render();
1393 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1394 application.SendNotification();
1395 application.Render();
1397 // Remove whole text
1398 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1399 DevelTextField::SelectWholeText(field);
1400 application.SendNotification();
1401 application.Render();
1403 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1404 application.SendNotification();
1405 application.Render();
1407 // Remove all with backspace
1408 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1409 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
1410 application.SendNotification();
1411 application.Render();
1413 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1414 application.SendNotification();
1415 application.Render();
1417 // Remove all with delete
1418 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1419 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1420 application.SendNotification();
1421 application.Render();
1423 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));
1424 application.SendNotification();
1425 application.Render();
1430 // Positive test for the textChanged signal.
1431 int utcDaliTextFieldTextChangedP(void)
1433 ToolkitTestApplication application;
1434 tet_infoline(" utcDaliTextFieldTextChangedP");
1435 TextField field = TextField::New();
1436 DALI_TEST_CHECK( field );
1438 application.GetScene().Add( field );
1440 // connect to the text changed signal.
1441 ConnectionTracker* testTracker = new ConnectionTracker();
1442 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1443 bool textChangedSignal = false;
1444 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1446 gTextChangedCallBackCalled = false;
1447 field.SetProperty( TextField::Property::TEXT, "ABC" );
1448 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1449 DALI_TEST_CHECK( textChangedSignal );
1451 application.SendNotification();
1452 field.SetKeyInputFocus();
1454 gTextChangedCallBackCalled = false;
1455 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1456 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1459 field.SetProperty( TextField::Property::TEXT, "" );
1461 // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1462 gTextChangedCallBackCalled = false;
1463 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1464 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1466 // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1467 gTextChangedCallBackCalled = false;
1468 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1469 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1474 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1476 ToolkitTestApplication application;
1477 tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1478 TextField field = TextField::New();
1479 DALI_TEST_CHECK( field );
1482 application.GetScene().Add( field );
1484 // connect to the text changed signal.
1485 ConnectionTracker* testTracker = new ConnectionTracker();
1486 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1487 bool textChangedSignal = false;
1488 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1491 // get InputMethodContext
1493 InputMethodContext::EventData imfEvent;
1494 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext( field );
1496 field.SetKeyInputFocus();
1497 field.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
1500 gTextChangedCallBackCalled = false;
1501 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1502 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1503 application.SendNotification();
1504 application.Render();
1505 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1506 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1508 gTextChangedCallBackCalled = false;
1509 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1510 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1511 application.SendNotification();
1512 application.Render();
1513 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1514 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호"), TEST_LOCATION );
1516 gTextChangedCallBackCalled = false;
1517 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1518 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1519 application.SendNotification();
1520 application.Render();
1521 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1522 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1524 gTextChangedCallBackCalled = false;
1525 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1526 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1527 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1529 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1530 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1531 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1533 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1534 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1535 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1537 application.SendNotification();
1538 application.Render();
1539 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1540 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1546 // Negative test for the textChanged signal.
1547 int utcDaliTextFieldTextChangedN(void)
1549 ToolkitTestApplication application;
1550 tet_infoline(" utcDaliTextFieldTextChangedN");
1551 TextField field = TextField::New();
1552 DALI_TEST_CHECK( field );
1554 application.GetScene().Add( field );
1556 // connect to the text changed signal.
1557 ConnectionTracker* testTracker = new ConnectionTracker();
1558 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1559 bool textChangedSignal = false;
1560 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1562 gTextChangedCallBackCalled = false;
1563 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1564 application.SendNotification();
1565 application.Render();
1566 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1567 DALI_TEST_CHECK( !textChangedSignal );
1572 // Positive test for Max Characters reached signal.
1573 int utcDaliTextFieldMaxCharactersReachedP(void)
1575 ToolkitTestApplication application;
1576 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1577 TextField field = TextField::New();
1578 DALI_TEST_CHECK( field );
1580 application.GetScene().Add( field );
1582 const int maxNumberOfCharacters = 1;
1583 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1585 field.SetKeyInputFocus();
1587 // connect to the text changed signal.
1588 ConnectionTracker* testTracker = new ConnectionTracker();
1589 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1590 bool maxLengthReachedSignal = false;
1591 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1593 gMaxCharactersCallBackCalled = false;
1595 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1596 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1598 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1599 DALI_TEST_CHECK( maxLengthReachedSignal );
1604 // Negative test for Max Characters reached signal.
1605 int utcDaliTextFieldMaxCharactersReachedN(void)
1607 ToolkitTestApplication application;
1608 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1609 TextField field = TextField::New();
1610 DALI_TEST_CHECK( field );
1612 application.GetScene().Add( field );
1614 const int maxNumberOfCharacters = 3;
1615 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1617 field.SetKeyInputFocus();
1619 // connect to the text changed signal.
1620 ConnectionTracker* testTracker = new ConnectionTracker();
1621 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1622 bool maxLengthReachedSignal = false;
1623 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1625 gMaxCharactersCallBackCalled = false;
1627 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1628 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1630 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1631 DALI_TEST_CHECK( !maxLengthReachedSignal );
1633 application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1635 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1636 DALI_TEST_CHECK( !maxLengthReachedSignal );
1641 // Positive test for Input Filtered signal.
1642 int utcDaliTextFieldInputFilteredP(void)
1644 ToolkitTestApplication application;
1645 tet_infoline(" utcDaliTextFieldInputFilteredP");
1646 TextField field = TextField::New();
1647 DALI_TEST_CHECK(field);
1649 application.GetScene().Add(field);
1651 Property::Map inputFilter;
1653 // Only digit is accepted.
1654 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1656 // Set input filter to TextField.
1657 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1659 field.SetKeyInputFocus();
1661 // connect to the input filtered signal.
1662 ConnectionTracker* testTracker = new ConnectionTracker();
1663 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1664 bool inputFilteredSignal = false;
1665 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1667 gInputFilteredAcceptedCallbackCalled = false;
1669 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ));
1671 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1672 DALI_TEST_CHECK(inputFilteredSignal);
1674 // Word is rejected.
1675 inputFilter[InputFilter::Property::ACCEPTED] = "";
1676 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1678 // Set input filter to TextField.
1679 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1681 field.SetKeyInputFocus();
1683 inputFilteredSignal = false;
1684 gInputFilteredRejectedCallbackCalled = false;
1686 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1688 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1689 DALI_TEST_CHECK(inputFilteredSignal);
1694 // Negative test for Input Filtered signal.
1695 int utcDaliTextFieldInputFilteredN(void)
1697 ToolkitTestApplication application;
1698 tet_infoline(" utcDaliTextFieldInputFilteredP");
1699 TextField field = TextField::New();
1700 DALI_TEST_CHECK(field);
1702 application.GetScene().Add(field);
1704 Property::Map inputFilter;
1706 // Only word is accepted.
1707 inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
1709 // Set input filter to TextField.
1710 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1712 field.SetKeyInputFocus();
1714 // connect to the input filtered signal.
1715 ConnectionTracker* testTracker = new ConnectionTracker();
1716 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1717 bool inputFilteredSignal = false;
1718 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1720 gInputFilteredAcceptedCallbackCalled = false;
1722 // Key a, d should not be filtered.
1723 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1724 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1725 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1726 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1728 // Backspace, Delete should not be filtered.
1729 application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1730 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));
1732 // Render and notify
1733 application.SendNotification();
1734 application.Render();
1736 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1737 DALI_TEST_CHECK(!inputFilteredSignal);
1739 // Digit is rejected.
1740 inputFilter[InputFilter::Property::ACCEPTED] = "";
1741 inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
1743 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1745 field.SetKeyInputFocus();
1747 inputFilteredSignal = false;
1748 gInputFilteredRejectedCallbackCalled = false;
1750 // Key a, d should not be filtered.
1751 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1752 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1753 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1754 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1756 // Backspace, Delete should not be filtered.
1757 application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1758 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));
1760 // Render and notify
1761 application.SendNotification();
1762 application.Render();
1764 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1765 DALI_TEST_CHECK(!inputFilteredSignal);
1770 int utcDaliTextFieldInputStyleChanged01(void)
1772 // The text-field emits signals when the input style changes. These changes of style are
1773 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1774 // can't be emitted during the size negotiation as the callbacks may update the UI.
1775 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1776 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1777 ToolkitTestApplication application;
1778 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1782 char* pathNamePtr = get_current_dir_name();
1783 const std::string pathName( pathNamePtr );
1784 free( pathNamePtr );
1786 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1787 fontClient.SetDpi( 93u, 93u );
1789 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1790 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1792 TextField field = TextField::New();
1793 DALI_TEST_CHECK( field );
1796 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1797 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1798 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1800 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1801 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1803 // connect to the text changed signal.
1804 ConnectionTracker* testTracker = new ConnectionTracker();
1805 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1806 bool inputStyleChangedSignal = false;
1807 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1809 application.GetScene().Add( field );
1811 // Render and notify
1812 application.SendNotification();
1813 application.Render();
1815 // Executes the idle callbacks added by the text control on the change of input style.
1816 application.RunIdles();
1818 gInputStyleChangedCallbackCalled = false;
1819 gInputStyleMask = TextField::InputStyle::NONE;
1820 inputStyleChangedSignal = false;
1822 // Create a tap event to touch the text field.
1823 TestGenerateTap( application, 18.0f, 25.0f );
1825 // Render and notify
1826 application.SendNotification();
1827 application.Render();
1829 // Executes the idle callbacks added by the text control on the change of input style.
1830 application.RunIdles();
1832 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1833 if( gInputStyleChangedCallbackCalled )
1835 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1837 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1838 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1840 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1841 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1843 DALI_TEST_CHECK( inputStyleChangedSignal );
1845 gInputStyleChangedCallbackCalled = false;
1846 gInputStyleMask = TextField::InputStyle::NONE;
1847 inputStyleChangedSignal = false;
1849 // Create a tap event to touch the text field.
1850 TestGenerateTap( application, 30.0f, 25.0f );
1852 // Render and notify
1853 application.SendNotification();
1854 application.Render();
1856 // Executes the idle callbacks added by the text control on the change of input style.
1857 application.RunIdles();
1859 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1860 DALI_TEST_CHECK( !inputStyleChangedSignal );
1862 gInputStyleChangedCallbackCalled = false;
1863 gInputStyleMask = TextField::InputStyle::NONE;
1864 inputStyleChangedSignal = false;
1866 // Create a tap event to touch the text field.
1867 TestGenerateTap( application, 43.0f, 25.0f );
1869 // Render and notify
1870 application.SendNotification();
1871 application.Render();
1873 // Executes the idle callbacks added by the text control on the change of input style.
1874 application.RunIdles();
1876 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1877 if( gInputStyleChangedCallbackCalled )
1879 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1881 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1882 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1884 DALI_TEST_CHECK( inputStyleChangedSignal );
1886 gInputStyleChangedCallbackCalled = false;
1887 gInputStyleMask = TextField::InputStyle::NONE;
1888 inputStyleChangedSignal = false;
1890 // Create a tap event to touch the text field.
1891 TestGenerateTap( application, 88.0f, 25.0f );
1893 // Render and notify
1894 application.SendNotification();
1895 application.Render();
1897 // Executes the idle callbacks added by the text control on the change of input style.
1898 application.RunIdles();
1900 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1901 if( gInputStyleChangedCallbackCalled )
1903 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1905 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1906 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1908 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1910 Property::Map fontStyleMapSet;
1911 fontStyleMapSet.Insert( "weight", "bold" );
1913 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1914 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1916 DALI_TEST_CHECK( inputStyleChangedSignal );
1918 gInputStyleChangedCallbackCalled = false;
1919 gInputStyleMask = TextField::InputStyle::NONE;
1920 inputStyleChangedSignal = false;
1922 // Create a tap event to touch the text field.
1923 TestGenerateTap( application, 115.0f, 25.0f );
1925 // Render and notify
1926 application.SendNotification();
1927 application.Render();
1929 // Executes the idle callbacks added by the text control on the change of input style.
1930 application.RunIdles();
1932 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1933 DALI_TEST_CHECK( !inputStyleChangedSignal );
1935 gInputStyleChangedCallbackCalled = false;
1936 gInputStyleMask = TextField::InputStyle::NONE;
1937 inputStyleChangedSignal = false;
1939 // Create a tap event to touch the text field.
1940 TestGenerateTap( application, 164.0f, 25.0f );
1942 // Render and notify
1943 application.SendNotification();
1944 application.Render();
1946 // Executes the idle callbacks added by the text control on the change of input style.
1947 application.RunIdles();
1949 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1950 if( gInputStyleChangedCallbackCalled )
1952 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1954 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1955 DALI_TEST_CHECK( style.empty() );
1957 DALI_TEST_CHECK( inputStyleChangedSignal );
1959 gInputStyleChangedCallbackCalled = false;
1960 gInputStyleMask = TextField::InputStyle::NONE;
1961 inputStyleChangedSignal = false;
1963 // Create a tap event to touch the text field.
1964 TestGenerateTap( application, 191.0f, 25.0f );
1966 // Render and notify
1967 application.SendNotification();
1968 application.Render();
1970 // Executes the idle callbacks added by the text control on the change of input style.
1971 application.RunIdles();
1973 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1974 DALI_TEST_CHECK( !inputStyleChangedSignal );
1979 int utcDaliTextFieldInputStyleChanged02(void)
1981 // The text-field emits signals when the input style changes. These changes of style are
1982 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1983 // can't be emitted during the size negotiation as the callbacks may update the UI.
1984 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1985 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1986 ToolkitTestApplication application;
1987 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1991 char* pathNamePtr = get_current_dir_name();
1992 const std::string pathName( pathNamePtr );
1993 free( pathNamePtr );
1995 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1996 fontClient.SetDpi( 93u, 93u );
1998 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1999 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
2001 TextField field = TextField::New();
2002 DALI_TEST_CHECK( field );
2004 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2005 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2006 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2008 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
2009 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>" );
2011 // connect to the text changed signal.
2012 ConnectionTracker* testTracker = new ConnectionTracker();
2013 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
2014 bool inputStyleChangedSignal = false;
2015 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
2017 application.GetScene().Add( field );
2019 // Render and notify
2020 application.SendNotification();
2021 application.Render();
2023 // Executes the idle callbacks added by the text control on the change of input style.
2024 application.RunIdles();
2026 gInputStyleChangedCallbackCalled = false;
2027 gInputStyleMask = TextField::InputStyle::NONE;
2028 inputStyleChangedSignal = false;
2030 // Create a tap event to touch the text field.
2031 TestGenerateTap( application, 53.0f, 25.0f, 100 );
2032 TestGenerateTap( application, 53.0f, 25.0f, 200 );
2034 // Render and notify
2035 application.SendNotification();
2036 application.Render();
2038 // Executes the idle callbacks added by the text control on the change of input style.
2039 application.RunIdles();
2041 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2042 if( gInputStyleChangedCallbackCalled )
2044 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2045 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
2046 TextField::InputStyle::POINT_SIZE |
2047 TextField::InputStyle::COLOR ),
2050 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2051 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
2053 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
2054 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
2056 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
2057 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2059 DALI_TEST_CHECK( inputStyleChangedSignal );
2061 gInputStyleChangedCallbackCalled = false;
2062 gInputStyleMask = TextField::InputStyle::NONE;
2063 inputStyleChangedSignal = false;
2065 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2067 // Render and notify
2068 application.SendNotification();
2069 application.Render();
2071 // Executes the idle callbacks added by the text control on the change of input style.
2072 application.RunIdles();
2074 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2075 if( gInputStyleChangedCallbackCalled )
2077 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2078 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
2081 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2082 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
2084 DALI_TEST_CHECK( inputStyleChangedSignal );
2086 gInputStyleChangedCallbackCalled = false;
2087 gInputStyleMask = TextField::InputStyle::NONE;
2088 inputStyleChangedSignal = false;
2090 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2092 // Render and notify
2093 application.SendNotification();
2094 application.Render();
2096 // Executes the idle callbacks added by the text control on the change of input style.
2097 application.RunIdles();
2099 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
2100 DALI_TEST_CHECK( !inputStyleChangedSignal );
2102 gInputStyleChangedCallbackCalled = false;
2103 gInputStyleMask = TextField::InputStyle::NONE;
2104 inputStyleChangedSignal = false;
2106 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2108 // Render and notify
2109 application.SendNotification();
2110 application.Render();
2112 // Executes the idle callbacks added by the text control on the change of input style.
2113 application.RunIdles();
2115 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2116 if( gInputStyleChangedCallbackCalled )
2118 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2119 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
2122 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2123 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
2125 DALI_TEST_CHECK( inputStyleChangedSignal );
2127 gInputStyleChangedCallbackCalled = false;
2128 gInputStyleMask = TextField::InputStyle::NONE;
2129 inputStyleChangedSignal = false;
2131 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
2133 Property::Map fontStyleMapSet;
2134 fontStyleMapSet.Insert( "weight", "thin" );
2135 fontStyleMapSet.Insert( "width", "condensed" );
2136 fontStyleMapSet.Insert( "slant", "italic" );
2138 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2139 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
2141 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
2142 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
2143 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
2144 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
2145 field.SetProperty( DevelTextField::Property::INPUT_STRIKETHROUGH, "strikethrough" );
2147 // Render and notify
2148 application.SendNotification();
2149 application.Render();
2151 // Executes the idle callbacks added by the text control on the change of input style.
2152 application.RunIdles();
2154 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
2155 DALI_TEST_CHECK( !inputStyleChangedSignal );
2157 // Create a tap event to touch the text field.
2158 TestGenerateTap( application, 63.0f, 25.0f, 700 );
2160 // Render and notify
2161 application.SendNotification();
2162 application.Render();
2164 // Executes the idle callbacks added by the text control on the change of input style.
2165 application.RunIdles();
2167 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2168 if( gInputStyleChangedCallbackCalled )
2170 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2171 static_cast<unsigned int>( TextField::InputStyle::COLOR |
2172 TextField::InputStyle::POINT_SIZE |
2173 TextField::InputStyle::FONT_STYLE |
2174 TextField::InputStyle::UNDERLINE |
2175 TextField::InputStyle::SHADOW |
2176 TextField::InputStyle::EMBOSS |
2177 TextField::InputStyle::OUTLINE ),
2180 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2181 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
2183 DALI_TEST_CHECK( inputStyleChangedSignal );
2188 int utcDaliTextFieldEvent01(void)
2190 ToolkitTestApplication application;
2191 tet_infoline(" utcDaliTextFieldEvent01");
2193 // Creates a tap event. After creating a tap event the text field should
2194 // have the focus and add text with key events should be possible.
2196 TextField field = TextField::New();
2197 DALI_TEST_CHECK( field );
2199 application.GetScene().Add( field );
2201 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2202 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2203 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2205 // Render and notify
2206 application.SendNotification();
2207 application.Render();
2209 // Avoid a crash when core load gl resources.
2210 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2212 // Render and notify
2213 application.SendNotification();
2214 application.Render();
2216 // Add a key event but as the text field has not the focus it should do nothing.
2217 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2219 // Render and notify
2220 application.SendNotification();
2221 application.Render();
2223 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2225 // Create a tap event to touch the text field.
2226 TestGenerateTap( application, 150.0f, 25.0f );
2228 // Render and notify
2229 application.SendNotification();
2230 application.Render();
2232 // Pressing delete key should be fine even if there is no text in TextField.
2233 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 ) );
2234 // Render and notify
2235 application.SendNotification();
2236 application.Render();
2238 // Now the text field has the focus, so it can handle the key events.
2239 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2240 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2242 // Render and notify
2243 application.SendNotification();
2244 application.Render();
2246 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2248 // Create a second text field and send key events to it.
2249 TextField field2 = TextField::New();
2251 field2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2252 field2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2253 field2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2254 field2.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
2256 application.GetScene().Add( field2 );
2258 // Render and notify
2259 application.SendNotification();
2260 application.Render();
2262 // Create a tap event on the second text field.
2263 TestGenerateTap( application, 150.0f, 125.0f );
2265 // Render and notify
2266 application.SendNotification();
2267 application.Render();
2269 // The second text field has the focus. It should handle the key events.
2270 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2271 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2273 // Render and notify
2274 application.SendNotification();
2275 application.Render();
2277 // Check the text has been added to the second text field.
2278 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2283 int utcDaliTextFieldEvent02(void)
2285 ToolkitTestApplication application;
2286 tet_infoline(" utcDaliTextFieldEvent02");
2288 // Checks if the right number of actors are created.
2290 TextField field = TextField::New();
2291 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2292 DALI_TEST_CHECK( field );
2293 LoadMarkerImages(application, field);
2295 application.GetScene().Add( field );
2297 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2298 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2299 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2301 // Avoid a crash when core load gl resources.
2302 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2304 // Render and notify
2305 application.SendNotification();
2306 application.Render();
2308 // Check there are the expected number of children ( stencil ).
2309 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
2311 Actor stencil = field.GetChildAt( 0u );
2312 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2314 // Create a tap event to touch the text field.
2315 TestGenerateTap( application, 150.0f, 25.0f, 300 );
2317 // Render and notify
2318 application.SendNotification();
2319 application.Render();
2321 Actor layer = field.GetChildAt( 1u );
2322 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2323 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2325 // Now the text field has the focus, so it can handle the key events.
2326 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2327 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2329 // Render and notify
2330 application.SendNotification();
2331 application.Render();
2333 // Checks the cursor and the renderer have been created.
2334 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2335 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
2337 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
2338 DALI_TEST_CHECK( cursor );
2340 // The offscreen root actor has a container with all the actors which contain the text renderers.
2341 Actor container = stencil.GetChildAt( 0u );
2342 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2344 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2345 DALI_TEST_CHECK( renderer );
2348 // Move the cursor and check the position changes.
2349 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2350 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2352 // Render and notify
2353 application.SendNotification();
2354 application.Render();
2356 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2357 DALI_TEST_CHECK( position2.x < position1.x );
2359 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2361 // Render and notify
2362 application.SendNotification();
2363 application.Render();
2365 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2366 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
2369 // Move the cursor to the first position.
2370 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2371 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2373 // Render and notify
2374 application.SendNotification();
2375 application.Render();
2377 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2379 // Send some taps and check the cursor positions.
2381 // Try to tap at the beginning.
2382 TestGenerateTap( application, 1.0f, 25.0f, 900 );
2384 // Render and notify
2385 application.SendNotification();
2386 application.Render();
2388 // Cursor position should be the same than position1.
2389 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2391 DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
2393 // Tap away from the start position.
2394 TestGenerateTap( application, 16.0f, 25.0f, 1500 );
2396 // Render and notify
2397 application.SendNotification();
2398 application.Render();
2400 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2402 DALI_TEST_CHECK( position6.x > position5.x );
2404 // Remove all the text.
2405 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2406 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2407 field.SetProperty( TextField::Property::TEXT, "" );
2409 // Render and notify
2410 application.SendNotification();
2411 application.Render();
2413 // Cursor position should be the same than position2.
2414 Vector3 position7 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2416 DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
2418 // Should not be a renderer.
2419 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2421 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2422 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2423 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
2425 application.SendNotification();
2426 application.Render();
2428 // There are renderer and decorator layer
2429 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
2434 int utcDaliTextFieldEvent03(void)
2436 ToolkitTestApplication application;
2437 tet_infoline(" utcDaliTextFieldEvent03");
2439 // Checks if the highlight actor is created.
2441 TextField field = TextField::New();
2442 DALI_TEST_CHECK( field );
2444 application.GetScene().Add( field );
2446 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2447 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2448 field.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
2449 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2450 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2452 // Avoid a crash when core load gl resources.
2453 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2454 LoadMarkerImages(application, field);
2456 // Render and notify
2457 application.SendNotification();
2458 application.Render();
2460 // Tap first to get the focus.
2461 TestGenerateTap( application, 3.0f, 25.0f );
2463 // Render and notify
2464 application.SendNotification();
2465 application.Render();
2467 // Double tap to select a word.
2468 TestGenerateTap( application, 3.0f, 25.0f );
2470 // Render and notify
2471 application.SendNotification();
2472 application.Render();
2474 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2475 Actor stencil = field.GetChildAt( 0u );
2477 // The highlight actor is drawn first, so is the first actor in the list
2478 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2479 DALI_TEST_CHECK( highlight );
2481 // The offscreen root actor has a container with all the actors which contain the text renderers.
2482 Actor container = stencil.GetChildAt( 1u );
2483 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2485 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2486 DALI_TEST_CHECK( renderer );
2492 int utcDaliTextFieldEvent04(void)
2494 ToolkitTestApplication application;
2495 tet_infoline(" utcDaliTextFieldEvent04");
2497 // Checks if the highlight actor is created.
2499 TextField field = TextField::New();
2500 DALI_TEST_CHECK( field );
2501 application.GetScene().Add( field );
2502 LoadMarkerImages(application, field);
2503 // Render and notify
2504 application.SendNotification();
2505 application.Render();
2507 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2508 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2509 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2510 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2511 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2513 // Avoid a crash when core load gl resources.
2514 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2515 // Render and notify
2516 application.SendNotification();
2517 application.Render();
2519 // Create a tap event to touch the text field.
2520 TestGenerateTap( application, 150.0f, 25.0f );
2521 // Render and notify
2522 application.SendNotification();
2523 application.Render();
2526 // Tap first to get the focus.
2527 TestGenerateTap( application, 1.0f, 25.0f );
2529 // Render and notify
2530 application.SendNotification();
2531 application.Render();
2533 // Double tap to select a word.
2534 TestGenerateTap( application, 1.0f, 25.0f );
2536 // Render and notify
2537 application.SendNotification();
2538 application.Render();
2541 TestGenerateTap( application, 0.0f, 40.0f );
2545 int utcDaliTextFieldEvent05(void)
2547 ToolkitTestApplication application;
2548 tet_infoline(" utcDaliTextFieldEvent05");
2550 // Checks dragging of cursor/grab handle
2552 TextField field = TextField::New();
2553 DALI_TEST_CHECK( field );
2554 application.GetScene().Add( field );
2555 LoadMarkerImages(application, field);
2556 // Render and notify
2557 application.SendNotification();
2558 application.Render();
2560 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2561 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2562 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2563 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2564 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2566 // Avoid a crash when core load gl resources.
2567 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2568 // Render and notify
2569 application.SendNotification();
2570 application.Render();
2572 // Create a tap event to touch the text field.
2573 TestGenerateTap( application, 150.0f, 25.0f );
2574 // Render and notify
2575 application.SendNotification();
2576 application.Render();
2578 // Tap first to get the focus.
2579 TestGenerateTap( application, 1.0f, 25.0f );
2581 // Render and notify
2582 application.SendNotification();
2583 application.Render();
2585 // Double tap to select a word.
2586 TestGenerateTap( application, 1.0f, 25.0f );
2588 // Render and notify
2589 application.SendNotification();
2590 application.Render();
2592 Actor stencil = field.GetChildAt( 1u );
2596 int utcDaliTextFieldEvent06(void)
2598 ToolkitTestApplication application;
2599 tet_infoline(" utcDaliTextFieldEvent06");
2601 // Checks Longpress when in edit mode
2603 TextField field = TextField::New();
2604 DALI_TEST_CHECK( field );
2605 application.GetScene().Add( field );
2606 LoadMarkerImages(application, field);
2607 // Render and notify
2608 application.SendNotification();
2609 application.Render();
2611 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2612 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2613 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2614 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2615 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2617 // Avoid a crash when core load gl resources.
2618 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2619 // Render and notify
2620 application.SendNotification();
2621 application.Render();
2623 // Create a tap event to touch the text field.
2624 TestGenerateTap( application, 150.0f, 25.0f );
2625 // Render and notify
2626 application.SendNotification();
2627 application.Render();
2630 // Tap first to get the focus.
2631 TestGenerateTap( application, 1.0f, 25.0f );
2633 // Render and notify
2634 application.SendNotification();
2635 application.Render();
2638 TestGenerateLongPress(application, 1.0f, 25.0f);
2640 // Render and notify
2641 application.SendNotification();
2642 application.Render();
2647 int utcDaliTextFieldEvent07(void)
2649 ToolkitTestApplication application;
2650 tet_infoline(" utcDaliTextFieldEvent07");
2652 // Checks Longpress to start edit mode
2654 TextField field = TextField::New();
2655 DALI_TEST_CHECK( field );
2656 application.GetScene().Add( field );
2657 LoadMarkerImages(application, field);
2658 // Render and notify
2659 application.SendNotification();
2660 application.Render();
2662 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2663 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2664 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2665 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2666 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2667 Property::Map propertyMap;
2668 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2669 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2671 // Avoid a crash when core load gl resources.
2672 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2673 // Render and notify
2674 application.SendNotification();
2675 application.Render();
2678 TestGenerateLongPress(application, 1.0f, 25.0f);
2680 // Render and notify
2681 application.SendNotification();
2682 application.Render();
2687 int utcDaliTextFieldEvent08(void)
2689 ToolkitTestApplication application;
2690 tet_infoline(" utcDaliTextFieldEvent08");
2692 Dali::Clipboard clipboard = Clipboard::Get();
2693 clipboard.SetItem("testTextFieldEvent");
2695 // Checks Longpress when only place holder text
2697 TextField field = TextField::New();
2698 DALI_TEST_CHECK( field );
2699 application.GetScene().Add( field );
2700 LoadMarkerImages(application, field);
2701 // Render and notify
2702 application.SendNotification();
2703 application.Render();
2705 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2706 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2707 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2708 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2709 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2711 // Avoid a crash when core load gl resources.
2712 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2713 // Render and notify
2714 application.SendNotification();
2715 application.Render();
2718 TestGenerateLongPress( application, 1.0f, 25.0f, 20 );
2720 // Render and notify
2721 application.SendNotification();
2722 application.Render();
2724 Wait(application, 500);
2726 TestEndLongPress( application, 1.0f, 25.0f, 520 );
2729 TestGenerateLongPress( application, 1.0f, 25.0f, 600 );
2731 // Render and notify
2732 application.Render();
2734 Wait(application, 500);
2736 Integration::Scene stage = application.GetScene();
2737 Layer layer = stage.GetRootLayer();
2738 Actor actor = layer.FindChildByName("optionPaste");
2742 Vector3 worldPosition = actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION );
2743 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2744 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2746 Dali::Integration::TouchEvent event;
2747 event = Dali::Integration::TouchEvent();
2748 event.AddPoint( GetPointDownInside( position ) );
2749 application.ProcessEvent( event );
2751 event = Dali::Integration::TouchEvent();
2752 event.AddPoint( GetPointUpInside( position ) );
2753 application.ProcessEvent( event );
2755 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2760 int utcDaliTextFieldEvent09(void)
2762 ToolkitTestApplication application;
2763 tet_infoline(" utcDaliTextFieldEvent09");
2765 TextField field = TextField::New();
2766 DALI_TEST_CHECK( field );
2767 application.GetScene().Add( field );
2768 LoadMarkerImages(application, field);
2769 // Render and notify
2770 application.SendNotification();
2771 application.Render();
2773 field.SetProperty( TextField::Property::TEXT, "Hello" );
2774 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2775 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2776 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2777 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2779 // Avoid a crash when core load gl resources.
2780 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2782 // Create a tap event to touch the text field.
2783 TestGenerateTap( application, 150.0f, 25.0f );
2784 application.SendNotification();
2785 application.Render();
2788 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2789 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2790 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2791 application.SendNotification();
2792 application.Render();
2794 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2795 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2796 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2797 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2798 application.SendNotification();
2799 application.Render();
2801 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2802 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2803 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2804 for( unsigned int index = 0u; index < 5u; ++index )
2806 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2807 application.SendNotification();
2808 application.Render();
2811 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2812 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2813 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2814 for( unsigned int index = 0u; index < 5u; ++index )
2816 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2817 application.SendNotification();
2818 application.Render();
2821 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2822 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2823 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2824 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2825 application.SendNotification();
2826 application.Render();
2827 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2828 application.SendNotification();
2829 application.Render();
2831 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2832 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2833 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2834 application.SendNotification();
2835 application.Render();
2837 Property::Map mapGet;
2838 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2839 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2840 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2845 int utcDaliTextFieldStyleWhilstSelected(void)
2847 ToolkitTestApplication application;
2848 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2850 // Change font and styles whilst text is selected whilst word selected
2852 TextField field = TextField::New();
2853 DALI_TEST_CHECK( field );
2854 application.GetScene().Add( field );
2855 LoadMarkerImages(application, field);
2856 // Render and notify
2857 application.SendNotification();
2858 application.Render();
2860 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2861 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2862 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2863 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2864 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2866 // Avoid a crash when core load gl resources.
2867 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2868 // Render and notify
2869 application.SendNotification();
2870 application.Render();
2872 // Create a tap event to touch the text field.
2873 TestGenerateTap( application, 150.0f, 25.0f );
2874 // Render and notify
2875 application.SendNotification();
2876 application.Render();
2879 // Tap first to get the focus.
2880 TestGenerateTap( application, 1.0f, 25.0f );
2882 // Render and notify
2883 application.SendNotification();
2884 application.Render();
2886 // Double tap to select a word.
2887 TestGenerateTap( application, 1.0f, 25.0f );
2889 // Render and notify
2890 application.SendNotification();
2891 application.Render();
2893 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2894 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2896 Property::Map fontStyleMapSet;
2897 Property::Map fontStyleMapGet;
2899 fontStyleMapSet.Insert( "weight", "bold" );
2900 fontStyleMapSet.Insert( "slant", "italic" );
2901 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2903 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2904 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2905 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2907 fontStyleMapSet.Clear();
2908 fontStyleMapSet.Insert( "width", "expanded" );
2909 fontStyleMapSet.Insert( "slant", "italic" );
2910 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2912 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2913 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2914 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2916 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2917 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2919 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2920 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2922 fontStyleMapSet.Clear();
2923 fontStyleMapSet.Insert( "weight", "bold" );
2924 fontStyleMapSet.Insert( "slant", "italic" );
2926 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2928 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2929 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2930 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2932 fontStyleMapSet.Clear();
2933 fontStyleMapSet.Insert( "width", "expanded" );
2935 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2937 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2938 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2939 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2941 // Press Escape to increase coverage
2942 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2943 application.SendNotification();
2944 application.Render();
2946 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2951 int utcDaliTextFieldEscKeyLoseFocus(void)
2953 ToolkitTestApplication application;
2954 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2956 // Creates a tap event. After creating a tap event the text field should
2957 // have the focus and add text with key events should be possible.
2959 TextField field = TextField::New();
2960 DALI_TEST_CHECK( field );
2962 application.GetScene().Add( field );
2964 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2965 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2966 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2968 // Avoid a crash when core load gl resources.
2969 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2971 // Render and notify
2972 application.SendNotification();
2973 application.Render();
2975 // Add a key event but as the text field has not the focus it should do nothing.
2976 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2977 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2979 // Render and notify
2980 application.SendNotification();
2981 application.Render();
2983 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2985 // Create a tap event to touch the text field.
2986 TestGenerateTap( application, 150.0f, 25.0f );
2988 // Render and notify
2989 application.SendNotification();
2990 application.Render();
2992 // Now the text field has the focus, so it can handle the key events.
2993 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2994 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2995 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2996 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2998 // Render and notify
2999 application.SendNotification();
3000 application.Render();
3002 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
3004 // Generate a Esc key event. The text field should lose the focus.
3005 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3006 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3008 // Render and notify
3009 application.SendNotification();
3010 application.Render();
3012 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
3014 // No more text should be introduced
3015 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3016 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3018 // Render and notify
3019 application.SendNotification();
3020 application.Render();
3022 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
3027 int utcDaliTextFieldSomeSpecialKeys(void)
3029 ToolkitTestApplication application;
3030 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
3032 // Checks some special keys when the text is selected.
3034 TextField field = TextField::New();
3035 DALI_TEST_CHECK( field );
3036 application.GetScene().Add( field );
3037 LoadMarkerImages(application, field);
3038 // Render and notify
3039 application.SendNotification();
3040 application.Render();
3042 const std::string longText( "This is a long text for the size of the text-field." );
3044 field.SetProperty( TextField::Property::TEXT, longText );
3045 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
3046 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3047 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3048 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3050 // Avoid a crash when core load gl resources.
3051 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3052 // Render and notify
3053 application.SendNotification();
3054 application.Render();
3056 // Create a tap event to touch the text field.
3057 TestGenerateTap( application, 150.0f, 25.0f );
3059 // Render and notify
3060 application.SendNotification();
3061 application.Render();
3063 // Tap first to get the focus.
3064 TestGenerateTap( application, 1.0f, 25.0f );
3066 // Render and notify
3067 application.SendNotification();
3068 application.Render();
3070 // Double tap to select a word.
3071 TestGenerateTap( application, 1.0f, 25.0f );
3073 // Render and notify
3074 application.SendNotification();
3075 application.Render();
3077 // Generate a Esc key event. The text field should lose the focus.
3078 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3079 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3081 // Render and notify
3082 application.SendNotification();
3083 application.Render();
3085 // Generate a Esc key event. The text field should lose the focus.
3086 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3087 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3089 // Render and notify
3090 application.SendNotification();
3091 application.Render();
3093 // Generate a Esc key event. The text field should lose the focus.
3094 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3095 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3097 // Render and notify
3098 application.SendNotification();
3099 application.Render();
3101 // The text shouldn't be deleted.
3102 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
3107 int utcDaliTextFieldSizeUpdate(void)
3109 ToolkitTestApplication application;
3110 tet_infoline("utcDaliTextFieldSizeUpdate");
3112 // Checks some special keys when the text is selected.
3113 TextField field = TextField::New();
3114 DALI_TEST_CHECK( field );
3115 application.GetScene().Add( field );
3117 float previousHeight = 0.0f;
3118 float currentHeight = 0.0f;
3119 const float fieldWidth = 1920.0f;
3122 // "ㅁ" is bigger then "ኢ"
3123 field.SetProperty( Actor::Property::SIZE, Vector2( fieldWidth ,10.0f ) );
3124 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
3125 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
3127 field.SetProperty( TextField::Property::TEXT, "ኢ");
3128 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3129 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3131 field.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
3132 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
3134 application.SendNotification();
3135 application.Render();
3137 previousHeight = field.GetHeightForWidth( fieldWidth );
3138 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
3140 // Add another script characters ( glyph height is defferent )
3141 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3142 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3144 application.SendNotification();
3145 application.Render();
3147 currentHeight = field.GetHeightForWidth( fieldWidth );
3148 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
3149 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
3154 int utcDaliTextFieldExtremlyLargePointSize(void)
3156 ToolkitTestApplication application;
3157 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
3159 TextField field = TextField::New();
3161 field.SetProperty( TextField::Property::TEXT, "Text" );
3162 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3163 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3164 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3165 application.GetScene().Add( field );
3169 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
3170 application.SendNotification();
3171 DALI_TEST_CHECK( field );
3175 tet_result(TET_FAIL);
3180 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
3182 ToolkitTestApplication application;
3183 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
3184 TextField field = TextField::New();
3185 DALI_TEST_CHECK( field );
3186 application.GetScene().Add( field );
3188 Property::Map fontStyleMapGet;
3190 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
3192 Property::Value* weightValue = NULL;
3193 Property::Value* widthValue = NULL;
3194 Property::Value* slantValue = NULL;
3195 weightValue = fontStyleMapGet.Find( "weight" );
3196 widthValue = fontStyleMapGet.Find( "width" );
3197 slantValue = fontStyleMapGet.Find( "slant" );
3198 DALI_TEST_CHECK( !weightValue );
3199 DALI_TEST_CHECK( !widthValue );
3200 DALI_TEST_CHECK( !slantValue );
3205 int UtcDaliTextFieldSettingPlaceholder(void)
3207 ToolkitTestApplication application;
3208 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
3210 TextField field = TextField::New();
3211 DALI_TEST_CHECK( field );
3212 application.GetScene().Add( field );
3214 // Check the placeholder property with pixel size
3215 Property::Map placeholderPixelSizeMapSet;
3216 Property::Map placeholderPixelSizeMapGet;
3217 Property::Map placeholderFontstyleMap;
3218 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
3219 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
3220 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
3221 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
3222 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
3223 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
3225 placeholderFontstyleMap.Insert( "weight", "bold" );
3226 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3227 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
3229 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3230 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
3231 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
3233 // Check the placeholder property with point size
3234 Property::Map placeholderMapSet;
3235 Property::Map placeholderMapGet;
3236 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
3237 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
3238 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
3239 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
3240 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
3241 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
3243 // Check the placeholder font style property
3244 placeholderFontstyleMap.Clear();
3246 placeholderFontstyleMap.Insert( "weight", "bold" );
3247 placeholderFontstyleMap.Insert( "width", "condensed" );
3248 placeholderFontstyleMap.Insert( "slant", "italic" );
3249 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3250 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3252 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3253 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3254 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3256 // Reset font style.
3257 placeholderFontstyleMap.Clear();
3258 placeholderFontstyleMap.Insert( "weight", "normal" );
3259 placeholderFontstyleMap.Insert( "slant", "oblique" );
3260 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3261 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3263 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3264 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3265 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3267 placeholderFontstyleMap.Clear();
3268 placeholderFontstyleMap.Insert( "slant", "roman" );
3269 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3270 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3272 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3274 placeholderFontstyleMap.Clear();
3275 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3277 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3278 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3279 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3280 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3285 int UtcDaliTextFieldPlaceholderCoverage(void)
3287 ToolkitTestApplication application;
3288 tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
3290 // mPlaceholderFont is created only once, so create a new control for coverage.
3291 TextField fieldForCoverage = TextField::New();
3292 DALI_TEST_CHECK(fieldForCoverage);
3293 application.GetScene().Add(fieldForCoverage);
3295 // for SetPlaceholderFontFamily() coverage.
3296 Property::Map fontFamilyMap;
3297 fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3298 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
3300 // mPlaceholderFont is created only once, so create a new control for coverage.
3301 fieldForCoverage = TextField::New();
3302 DALI_TEST_CHECK(fieldForCoverage);
3303 application.GetScene().Add(fieldForCoverage);
3305 // for SetPlaceholderTextFontSize coverage.
3306 Property::Map fontSizeMap;
3307 fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3308 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
3310 // mPlaceholderFont is created only once, so create a new control for coverage.
3311 fieldForCoverage = TextField::New();
3312 DALI_TEST_CHECK(fieldForCoverage);
3313 application.GetScene().Add(fieldForCoverage);
3315 // for SetPlaceholderTextFontWeight coverage.
3316 Property::Map fontStyleWeightMap;
3317 Property::Map fontStyleWeightPropertyMap;
3318 fontStyleWeightPropertyMap.Insert("weight", "bold");
3319 fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
3320 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
3322 // mPlaceholderFont is created only once, so create a new control for coverage.
3323 fieldForCoverage = TextField::New();
3324 DALI_TEST_CHECK(fieldForCoverage);
3325 application.GetScene().Add(fieldForCoverage);
3327 // for SetPlaceholderTextFontWidth coverage.
3328 Property::Map fontStyleWidthMap;
3329 Property::Map fontStyleWidthPropertyMap;
3330 fontStyleWidthPropertyMap.Insert("width", "expanded");
3331 fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
3332 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
3334 // mPlaceholderFont is created only once, so create a new control for coverage.
3335 fieldForCoverage = TextField::New();
3336 DALI_TEST_CHECK(fieldForCoverage);
3337 application.GetScene().Add(fieldForCoverage);
3339 // for SetPlaceholderTextFontSlant coverage.
3340 Property::Map fontStyleSlantMap;
3341 Property::Map fontStyleSlantPropertyMap;
3342 fontStyleSlantPropertyMap.Insert("slant", "italic");
3343 fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
3344 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
3349 int UtcDaliTextFieldSetPaddingProperty(void)
3351 ToolkitTestApplication application;
3352 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3354 TextField field = TextField::New();
3355 DALI_TEST_CHECK( field );
3356 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3357 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3358 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3359 application.GetScene().Add( field );
3361 application.SendNotification();
3362 application.Render();
3364 Vector3 originalSize = field.GetNaturalSize();
3366 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
3368 application.SendNotification();
3369 application.Render();
3371 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
3373 Vector3 paddingAddedSize = field.GetNaturalSize();
3375 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3377 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3382 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3384 ToolkitTestApplication application;
3385 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3387 TextField field = TextField::New();
3388 DALI_TEST_CHECK( field );
3389 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3390 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3391 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3392 application.GetScene().Add( field );
3394 application.SendNotification();
3395 application.Render();
3397 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3398 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
3400 // Check the enable shift selection property
3401 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
3402 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
3404 application.SendNotification();
3405 application.Render();
3410 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3412 ToolkitTestApplication application;
3413 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3415 TextField field = TextField::New();
3416 DALI_TEST_CHECK( field );
3417 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3418 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3419 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3420 application.GetScene().Add( field );
3422 application.SendNotification();
3423 application.Render();
3425 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3426 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
3428 // Check the enable grab handle property
3429 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
3430 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
3432 application.SendNotification();
3433 application.Render();
3438 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
3440 ToolkitTestApplication application;
3441 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
3443 TextField field = TextField::New();
3444 DALI_TEST_CHECK( field );
3445 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3446 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3447 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3448 application.GetScene().Add( field );
3450 application.SendNotification();
3451 application.Render();
3453 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3454 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
3456 // Check the match system language direction property
3457 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
3458 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
3460 application.SendNotification();
3461 application.Render();
3466 int utcDaliTextFieldLayoutDirectionCoverage(void)
3468 ToolkitTestApplication application;
3469 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
3471 // Creates a tap event. After creating a tap event the text field should
3472 // have the focus and add text with key events should be possible.
3473 TextField field = TextField::New();
3474 DALI_TEST_CHECK( field );
3476 application.GetScene().Add( field );
3478 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3479 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3480 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3482 // Avoid a crash when core load gl resources.
3483 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3485 // Render and notify
3486 application.SendNotification();
3487 application.Render();
3489 // init direction for coverage
3490 // Set horizontal alignment END
3491 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3493 // Create a tap event to touch the text field.
3494 TestGenerateTap( application, 150.0f, 25.0f );
3496 // Render and notify
3497 application.SendNotification();
3498 application.Render();
3500 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
3501 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
3502 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
3504 // Set horizontal alignment BEGIN
3505 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
3507 // Create a tap event to touch the text field.
3508 TestGenerateTap( application, 150.0f, 25.0f );
3510 // Render and notify
3511 application.SendNotification();
3512 application.Render();
3514 // Set horizontal alignment CENTER
3515 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
3517 // Create a tap event to touch the text field.
3518 TestGenerateTap( application, 150.0f, 25.0f );
3520 // Render and notify
3521 application.SendNotification();
3522 application.Render();
3524 // Set horizontal alignment END
3525 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3527 // Create a tap event to touch the text field.
3528 TestGenerateTap( application, 150.0f, 25.0f );
3530 // Render and notify
3531 application.SendNotification();
3532 application.Render();
3534 // Generate a Esc key event. The text field should lose the focus.
3535 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3536 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3538 // Render and notify
3539 application.SendNotification();
3540 application.Render();
3542 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
3547 int UtcDaliTextFieldGetInputMethodContext(void)
3549 ToolkitTestApplication application;
3550 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
3552 TextField field = TextField::New();
3553 DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );
3558 int UtcDaliTextFieldSelectWholeText(void)
3560 ToolkitTestApplication application;
3561 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3563 TextField textField = TextField::New();
3565 application.GetScene().Add( textField );
3567 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3568 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3569 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3571 // Avoid a crash when core load gl resources.
3572 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3574 application.SendNotification();
3575 application.Render();
3577 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
3579 DevelTextField::SelectWholeText( textField );
3581 application.SendNotification();
3582 application.Render();
3584 // Nothing should have been selected. The number of children is still 1
3585 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
3587 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3589 application.SendNotification();
3590 application.Render();
3592 DevelTextField::SelectWholeText( textField );
3594 application.SendNotification();
3595 application.Render();
3597 // Even if resize, selection should remain.
3598 textField.SetProperty( Actor::Property::SIZE, Vector2( 150.f, 50.f ) );
3600 application.SendNotification();
3601 application.Render();
3603 // Should be 2 children, the stencil and the layer
3604 DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
3606 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3607 Actor stencil = textField.GetChildAt( 0u );
3609 // The highlight actor is drawn first, so is the first actor in the list
3610 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3611 DALI_TEST_CHECK( highlight );
3616 int UtcDaliTextFieldSelectText(void)
3618 ToolkitTestApplication application;
3619 tet_infoline(" UtcDaliTextFieldSelectText ");
3621 TextField textField = TextField::New();
3623 application.GetScene().Add( textField );
3625 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3626 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3627 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3629 // Avoid a crash when core load gl resources.
3630 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3632 application.SendNotification();
3633 application.Render();
3635 DevelTextField::SelectText( textField, 0, 5 );
3637 application.SendNotification();
3638 application.Render();
3640 // Nothing is selected
3641 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3642 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3644 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3646 application.SendNotification();
3647 application.Render();
3649 // Hello is selected
3650 DevelTextField::SelectText( textField, 0, 5 );
3652 application.SendNotification();
3653 application.Render();
3655 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3656 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3658 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3659 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3661 // world is selected
3662 DevelTextField::SelectText( textField, 6, 11 );
3664 application.SendNotification();
3665 application.Render();
3667 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3668 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3670 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3671 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3676 int UtcDaliTextFieldSelectNone(void)
3678 ToolkitTestApplication application;
3679 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3681 TextField textField = TextField::New();
3683 application.GetScene().Add( textField );
3685 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3686 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3687 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3689 // Avoid a crash when core load gl resources.
3690 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3692 application.SendNotification();
3693 application.Render();
3695 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3697 application.SendNotification();
3698 application.Render();
3700 // Nothing is selected
3701 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3702 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3704 DevelTextField::SelectWholeText( textField );
3706 application.SendNotification();
3707 application.Render();
3709 // whole text is selected
3710 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3711 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3713 DevelTextField::SelectNone( textField );
3715 application.SendNotification();
3716 application.Render();
3718 // Nothing is selected
3719 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3720 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3725 int UtcDaliTextFieldSelectRange(void)
3727 ToolkitTestApplication application;
3728 tet_infoline(" UtcDaliTextFieldSelectRange ");
3730 TextField textField = TextField::New();
3732 application.GetScene().Add( textField );
3734 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3735 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3736 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3738 // Avoid a crash when core load gl resources.
3739 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3741 application.SendNotification();
3742 application.Render();
3744 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3746 application.SendNotification();
3747 application.Render();
3749 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 0);
3750 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 5);
3752 // Hello is selected
3753 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3754 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3756 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3757 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3759 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 6);
3760 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 11);
3762 // world is selected
3763 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3764 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3766 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3767 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3772 int UtcDaliTextFieldEnableEditing(void)
3774 ToolkitTestApplication application;
3775 tet_infoline(" UtcDaliTextFieldEnableEditing ");
3777 TextField textField = TextField::New();
3779 application.GetScene().Add( textField );
3781 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3782 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3783 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3785 // Avoid a crash when core load gl resources.
3786 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3788 application.SendNotification();
3789 application.Render();
3791 textField.SetKeyInputFocus();
3792 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, false );
3793 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3795 // Render and notify
3796 application.SendNotification();
3797 application.Render();
3799 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3800 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3803 textField.SetKeyInputFocus();
3804 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
3805 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3807 // Render and notify
3808 application.SendNotification();
3809 application.Render();
3811 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3812 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3817 int UtcDaliToolkitTextFieldFontSizeScale(void)
3819 ToolkitTestApplication application;
3820 tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
3822 TextField textField = TextField::New();
3823 textField.SetProperty( TextField::Property::POINT_SIZE, 30.f );
3824 textField.SetProperty( TextField::Property::TEXT, "Test" );
3825 Vector3 nonScaledSize = textField.GetNaturalSize();
3827 TextField textFieldScaled = TextField::New();
3828 textFieldScaled.SetProperty( TextField::Property::POINT_SIZE, 15.f );
3829 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3830 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3831 Vector3 scaledSize = textFieldScaled.GetNaturalSize();
3833 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3835 textField.SetProperty( TextField::Property::PIXEL_SIZE, 30.f );
3836 textField.SetProperty( TextField::Property::TEXT, "Test" );
3837 nonScaledSize = textField.GetNaturalSize();
3839 textFieldScaled.SetProperty( TextField::Property::PIXEL_SIZE, 15.f );
3840 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3841 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3842 scaledSize = textFieldScaled.GetNaturalSize();
3844 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3849 int UtcDaliTextFieldPrimaryCursorPosition(void)
3851 ToolkitTestApplication application;
3852 tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
3854 TextField textField = TextField::New();
3856 application.GetScene().Add( textField );
3858 textField.SetProperty( TextField::Property::TEXT, "ABCEF");
3859 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3860 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3861 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3863 // Avoid a crash when core load gl resources.
3864 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3866 textField.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
3867 application.SendNotification();
3868 application.Render();
3869 textField.SetKeyInputFocus();
3871 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3873 // Render and notify
3874 application.SendNotification();
3875 application.Render();
3877 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3878 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3883 // test max length when set after setting long text
3884 int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
3886 ToolkitTestApplication application;
3887 tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
3888 TextField field = TextField::New();
3889 DALI_TEST_CHECK( field );
3891 application.GetScene().Add( field );
3893 field.SetProperty(TextField::Property::TEXT, "123456789");
3895 const int maxNumberOfCharacters = 3;
3896 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
3898 field.SetKeyInputFocus();
3900 // connect to the text max lengh reached signal.
3901 ConnectionTracker* testTracker = new ConnectionTracker();
3902 bool maxLengthReachedSignal = false;
3903 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
3905 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3906 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3908 DALI_TEST_CHECK( maxLengthReachedSignal );
3910 DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "123456789", TEST_LOCATION );
3917 int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
3919 ToolkitTestApplication application;
3920 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
3922 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3923 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3924 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3926 // Create a text field
3927 TextField textField = TextField::New();
3929 //Set size to avoid automatic eliding
3930 textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3931 //Set very large font-size using point-size
3932 textField.SetProperty( TextField::Property::POINT_SIZE, 1000) ;
3933 //Specify font-family
3934 textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
3935 //Set text to check if appear or not
3936 textField.SetProperty( TextField::Property::TEXT, "A");
3938 application.GetScene().Add( textField );
3940 application.SendNotification();
3941 application.Render();
3942 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3943 Vector3 naturalSize = textField.GetNaturalSize();
3945 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3946 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3951 int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
3953 ToolkitTestApplication application;
3954 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
3956 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3957 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3958 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3960 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3961 // Create a text editor
3962 TextField textField = TextField::New();
3964 //Set size to avoid automatic eliding
3965 textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3966 textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
3967 textField.SetProperty( TextField::Property::TEXT, "A");
3969 const int numberOfCases = 6;
3970 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
3972 for (int index=0; index < numberOfCases; index++)
3974 tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
3975 textField.SetProperty( TextField::Property::POINT_SIZE, arrayCases[index]) ;
3976 application.GetScene().Add( textField );
3977 application.SendNotification();
3978 application.Render();
3979 naturalSize = textField.GetNaturalSize();
3980 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3981 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3988 int UtcDaliToolkitTextFieldEllipsisPositionProperty(void)
3990 ToolkitTestApplication application;
3991 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty ");
3992 TextField textField = TextField::New();
3994 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Default is END");
3995 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3997 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START");
3998 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
3999 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4001 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE");
4002 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4003 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4005 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END");
4006 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4007 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4009 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START using integer");
4010 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 1);
4011 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4013 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE using integer");
4014 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 2);
4015 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4017 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END using integer");
4018 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 0);
4019 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4021 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4022 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "START");
4023 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4025 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4026 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "MIDDLE");
4027 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4029 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4030 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "END");
4031 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4033 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4034 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "start");
4035 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4037 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4038 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "middle");
4039 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4041 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4042 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "end");
4043 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4048 int UtcDaliTextFieldCopyText(void)
4050 ToolkitTestApplication application;
4051 tet_infoline(" UtcDaliTextFieldCopyText ");
4053 TextField textField = TextField::New();
4055 std::string selectedText = "";
4056 std::string copiedText = "";
4058 application.GetScene().Add( textField );
4060 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4061 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4062 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4064 // Avoid a crash when core load gl resources.
4065 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4067 application.SendNotification();
4068 application.Render();
4070 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
4072 application.SendNotification();
4073 application.Render();
4075 // Hello is selected
4076 DevelTextField::SelectText( textField, 0, 5 );
4078 application.SendNotification();
4079 application.Render();
4081 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4082 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4084 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4085 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4088 copiedText = DevelTextField::CopyText( textField );
4089 DALI_TEST_EQUALS( "Hello", copiedText, TEST_LOCATION );
4091 // world is selected
4092 DevelTextField::SelectText( textField, 6, 11 );
4094 application.SendNotification();
4095 application.Render();
4097 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4098 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
4100 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
4101 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
4104 copiedText = DevelTextField::CopyText( textField );
4105 DALI_TEST_EQUALS( "world", copiedText, TEST_LOCATION );
4107 // "lo wo" is selected
4108 DevelTextField::SelectText( textField, 3, 8 );
4110 application.SendNotification();
4111 application.Render();
4113 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4114 DALI_TEST_EQUALS( "lo wo", selectedText, TEST_LOCATION );
4116 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 3, TEST_LOCATION );
4117 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 8, TEST_LOCATION );
4119 // "lo wo" is copied
4120 copiedText = DevelTextField::CopyText( textField );
4121 DALI_TEST_EQUALS( "lo wo", copiedText, TEST_LOCATION );
4126 int UtcDaliTextFieldCutText(void)
4128 ToolkitTestApplication application;
4129 tet_infoline(" UtcDaliTextFieldCutText ");
4131 TextField textField = TextField::New();
4133 std::string selectedText = "";
4135 application.GetScene().Add( textField );
4137 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4138 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4139 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4141 // Avoid a crash when core load gl resources.
4142 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4144 application.SendNotification();
4145 application.Render();
4147 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
4149 application.SendNotification();
4150 application.Render();
4152 // Hello is selected
4153 DevelTextField::SelectText( textField, 0, 5 );
4155 application.SendNotification();
4156 application.Render();
4158 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4159 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4161 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4162 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4165 DALI_TEST_EQUALS( "Hello", DevelTextField::CutText( textField ), TEST_LOCATION );
4167 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), " world", TEST_LOCATION );
4170 DevelTextField::SelectText( textField, 0, 2 );
4172 application.SendNotification();
4173 application.Render();
4175 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4176 DALI_TEST_EQUALS( " w", selectedText, TEST_LOCATION );
4178 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4179 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4182 DALI_TEST_EQUALS( " w", DevelTextField::CutText( textField ), TEST_LOCATION );
4184 application.SendNotification();
4185 application.Render();
4187 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "orld", TEST_LOCATION );
4189 // Test Cut from the middle
4192 DevelTextField::SelectText( textField, 1, 3 );
4194 application.SendNotification();
4195 application.Render();
4197 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4198 DALI_TEST_EQUALS( "rl", selectedText, TEST_LOCATION );
4200 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4201 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 3, TEST_LOCATION );
4204 DALI_TEST_EQUALS( "rl", DevelTextField::CutText( textField ), TEST_LOCATION );
4206 application.SendNotification();
4207 application.Render();
4209 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "od", TEST_LOCATION );
4211 // Test Cut from the end
4214 DevelTextField::SelectText( textField, 1, 2 );
4216 application.SendNotification();
4217 application.Render();
4219 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4220 DALI_TEST_EQUALS( "d", selectedText, TEST_LOCATION );
4222 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4223 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4226 DALI_TEST_EQUALS( "d", DevelTextField::CutText( textField ), TEST_LOCATION );
4228 application.SendNotification();
4229 application.Render();
4231 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "o", TEST_LOCATION );
4236 int UtcDaliTextFieldPasteText(void)
4238 ToolkitTestApplication application;
4239 tet_infoline(" UtcDaliTextFieldPasteText ");
4241 TextField textField = TextField::New();
4243 application.GetScene().Add( textField );
4245 std::string cutText = "";
4246 std::string copiedText = "";
4248 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4249 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4250 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4252 // Avoid a crash when core load gl resources.
4253 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4255 application.SendNotification();
4256 application.Render();
4258 textField.SetProperty( TextField::Property::TEXT, "Hello World" );
4260 application.SendNotification();
4261 application.Render();
4263 // Tap on the text editor
4264 TestGenerateTap( application, 3.0f, 25.0f );
4266 // Render and notify
4267 application.SendNotification();
4268 application.Render();
4270 // Select some text in the right of the current cursor position
4271 DevelTextField::SelectText( textField, 0, 3 );
4273 // Render and notify
4274 application.SendNotification();
4275 application.Render();
4277 // Cut the selected text
4278 cutText = DevelTextField::CutText(textField);
4280 // Render and notify
4281 application.SendNotification();
4282 application.Render();
4284 DALI_TEST_EQUALS( "Hel", cutText, TEST_LOCATION );
4285 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "lo World", TEST_LOCATION );
4287 DevelTextField::SelectText( textField, 0, 3 );
4289 // Render and notify
4290 application.SendNotification();
4291 application.Render();
4293 // Copy the selected text
4294 copiedText = DevelTextField::CopyText(textField);
4296 // Render and notify
4297 application.SendNotification();
4298 application.Render();
4300 DALI_TEST_EQUALS( "lo ", copiedText, TEST_LOCATION );
4301 DALI_TEST_EQUALS( "lo World", textField.GetProperty<std::string>( TextField::Property::TEXT ), TEST_LOCATION );
4303 // Move the cursor to the end of the line
4304 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4305 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4306 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4307 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4308 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4309 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4310 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4311 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4313 // Render and notify
4314 application.SendNotification();
4315 application.Render();
4317 // Paste the selected text at the current cursor position
4318 DevelTextField::PasteText(textField);
4320 // Render and notify
4321 application.SendNotification();
4322 application.Render();
4324 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "lo Worldlo ", TEST_LOCATION );
4328 int utcDaliTextFieldCursorPositionChangedSignal(void)
4330 ToolkitTestApplication application;
4331 tet_infoline(" utcDaliTextFieldCursorPositionChangedSignal");
4333 TextField field = TextField::New();
4334 DALI_TEST_CHECK( field );
4336 application.GetScene().Add( field );
4338 // connect to the selection changed signal.
4339 ConnectionTracker* testTracker = new ConnectionTracker();
4340 DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
4341 bool cursorPositionChangedSignal = false;
4342 field.ConnectSignal( testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal) );
4344 field.SetProperty( TextField::Property::TEXT, "Hello world Hello world" );
4345 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
4346 field.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4347 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4348 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4350 // Avoid a crash when core load gl resources.
4351 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4353 // Render and notify
4354 application.SendNotification();
4355 application.Render();
4357 field.SetKeyInputFocus();
4359 // Tap on the text field
4360 TestGenerateTap( application, 3.0f, 25.0f );
4362 // Render and notify
4363 application.SendNotification();
4364 application.Render();
4366 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4367 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4369 gCursorPositionChangedCallbackCalled = false;
4372 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4374 // Render and notify
4375 application.SendNotification();
4376 application.Render();
4378 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4379 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4381 gCursorPositionChangedCallbackCalled = false;
4384 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4386 // Render and notify
4387 application.SendNotification();
4388 application.Render();
4390 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4391 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4393 gCursorPositionChangedCallbackCalled = false;
4395 //delete one character
4396 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4398 // Render and notify
4399 application.SendNotification();
4400 application.Render();
4402 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4403 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4405 gCursorPositionChangedCallbackCalled = false;
4407 field.SetProperty( TextField::Property::TEXT, "Hello" );
4409 // Render and notify
4410 application.SendNotification();
4411 application.Render();
4413 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4414 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4416 gCursorPositionChangedCallbackCalled = false;
4418 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4420 // Render and notify
4421 application.SendNotification();
4422 application.Render();
4424 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4425 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4430 int utcDaliTextFieldGeometryEllipsisStart(void)
4432 ToolkitTestApplication application;
4433 tet_infoline(" utcDaliTextFieldGeometryEllipsisStart");
4435 TextField field = TextField::New();
4436 DALI_TEST_CHECK( field );
4438 application.GetScene().Add( field );
4440 field.SetProperty( TextField::Property::POINT_SIZE, 7.f );
4441 field.SetProperty( Actor::Property::SIZE, Vector2( 250.f, 50.f ) );
4442 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4443 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4444 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
4445 field.SetProperty( DevelTextField::Property::ELLIPSIS, true );
4446 field.SetProperty( DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START );
4447 field.SetProperty( TextField::Property::TEXT, "Hello World" );
4449 // Avoid a crash when core load gl resources.
4450 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4452 // Render and notify
4453 application.SendNotification();
4454 application.Render();
4456 unsigned int expectedCount = 1;
4457 unsigned int startIndex = 0;
4458 unsigned int endIndex = 10;
4460 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4461 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4463 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4464 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4466 Vector<Vector2> expectedSizes;
4467 Vector<Vector2> expectedPositions;
4469 expectedPositions.PushBack(Vector2(14, 0));
4470 expectedSizes.PushBack(Vector2(106, 25));
4472 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4477 int utcDaliTextFieldGeometryEllipsisEnd(void)
4479 ToolkitTestApplication application;
4480 tet_infoline(" utcDaliTextFieldGeometryEllipsisEnd");
4482 TextField field = TextField::New();
4483 DALI_TEST_CHECK( field );
4485 application.GetScene().Add( field );
4487 field.SetProperty( TextField::Property::POINT_SIZE, 7.f );
4488 field.SetProperty( Actor::Property::SIZE, Vector2( 250.f, 50.f ) );
4489 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4490 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4491 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
4492 field.SetProperty( DevelTextField::Property::ELLIPSIS, true );
4493 field.SetProperty( DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END );
4494 field.SetProperty( TextField::Property::TEXT, "Hello World" );
4496 // Avoid a crash when core load gl resources.
4497 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4499 // Render and notify
4500 application.SendNotification();
4501 application.Render();
4503 unsigned int expectedCount = 1;
4504 unsigned int startIndex = 0;
4505 unsigned int endIndex = 10;
4507 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4508 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4510 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4511 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4513 Vector<Vector2> expectedSizes;
4514 Vector<Vector2> expectedPositions;
4516 expectedPositions.PushBack(Vector2(-2, 0));
4517 expectedSizes.PushBack(Vector2(122, 25));
4519 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4524 int utcDaliTextFieldGeometryRTL(void)
4526 ToolkitTestApplication application;
4527 tet_infoline(" utcDaliTextFieldGeometryRTL");
4529 TextField field = TextField::New();
4530 DALI_TEST_CHECK( field );
4532 application.GetScene().Add( field );
4534 field.SetProperty( TextField::Property::POINT_SIZE, 7.f );
4535 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4536 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4537 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4538 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
4539 field.SetProperty( TextField::Property::TEXT, "السطر الاخير" );
4541 // Avoid a crash when core load gl resources.
4542 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4544 // Render and notify
4545 application.SendNotification();
4546 application.Render();
4548 unsigned int expectedCount = 1;
4549 unsigned int startIndex = 1;
4550 unsigned int endIndex = 7;
4552 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4553 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4555 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4556 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4558 Vector<Vector2> expectedSizes;
4559 Vector<Vector2> expectedPositions;
4561 expectedPositions.PushBack(Vector2(38, 0));
4562 expectedSizes.PushBack(Vector2(73, 25));
4564 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4569 int utcDaliTextFieldGeometryGlyphMiddle(void)
4571 ToolkitTestApplication application;
4572 tet_infoline(" utcDaliTextFieldGeometryGlyphMiddle");
4574 TextField field = TextField::New();
4575 DALI_TEST_CHECK( field );
4577 application.GetScene().Add( field );
4579 field.SetProperty( TextField::Property::POINT_SIZE, 7.f );
4580 field.SetProperty( Actor::Property::SIZE, Vector2( 150.f, 200.f ) );
4581 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4582 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4583 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
4584 field.SetProperty( TextField::Property::TEXT, "لا تحتوي على لا" );
4586 // Avoid a crash when core load gl resources.
4587 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4589 // Render and notify
4590 application.SendNotification();
4591 application.Render();
4593 unsigned int expectedCount = 1;
4594 unsigned int startIndex = 1;
4595 unsigned int endIndex = 13;
4597 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4598 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4600 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4601 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4603 Vector<Vector2> expectedSizes;
4604 Vector<Vector2> expectedPositions;
4606 expectedPositions.PushBack(Vector2(6, 0));
4607 expectedSizes.PushBack(Vector2(124, 25));
4609 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4614 int utcDaliTextFieldSelectionClearedSignal(void)
4616 ToolkitTestApplication application;
4617 tet_infoline(" utcDaliTextFieldSelectionClearedSignal");
4619 TextField field = TextField::New();
4620 DALI_TEST_CHECK( field );
4622 application.GetScene().Add( field );
4624 // connect to the selection changed signal.
4625 ConnectionTracker* testTracker = new ConnectionTracker();
4626 DevelTextField::SelectionClearedSignal(field).Connect(&TestSelectionClearedCallback);
4627 bool selectionClearedSignal = false;
4628 field.ConnectSignal( testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal) );
4630 field.SetProperty( TextField::Property::TEXT, "Hello\nworld\nHello world" );
4631 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
4632 field.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4633 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4634 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4636 // Avoid a crash when core load gl resources.
4637 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4639 // Render and notify
4640 application.SendNotification();
4641 application.Render();
4643 // Tap on the text editor
4644 TestGenerateTap( application, 3.0f, 25.0f );
4646 // Render and notify
4647 application.SendNotification();
4648 application.Render();
4650 // Move to second line of the text & Select some text in the right of the current cursor position
4651 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4652 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4655 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4657 // Render and notify
4658 application.SendNotification();
4659 application.Render();
4661 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4663 // Render and notify
4664 application.SendNotification();
4665 application.Render();
4667 // Tap on the text editor
4668 TestGenerateTap( application, 3.0f, 25.0f );
4670 // Render and notify
4671 application.SendNotification();
4672 application.Render();
4674 gSelectionClearedCallbackCalled = false;
4676 // Move to second line of the text & select.
4677 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4678 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4681 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4683 // Render and notify
4684 application.SendNotification();
4685 application.Render();
4687 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4689 gSelectionClearedCallbackCalled = false;
4691 // Render and notify
4692 application.SendNotification();
4693 application.Render();
4695 // Move to second line of the text & select.
4696 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4697 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4699 // replace D with selected text
4700 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4702 // Render and notify
4703 application.SendNotification();
4704 application.Render();
4706 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4708 gSelectionClearedCallbackCalled = false;
4710 // Render and notify
4711 application.SendNotification();
4712 application.Render();
4714 DevelTextField::SelectText( field ,1, 3 );
4716 // Render and notify
4717 application.SendNotification();
4718 application.Render();
4720 field.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4722 // Render and notify
4723 application.SendNotification();
4724 application.Render();
4726 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4728 gSelectionClearedCallbackCalled = false;
4730 DevelTextField::SelectText( field ,1, 3 );
4732 // Render and notify
4733 application.SendNotification();
4734 application.Render();
4737 DevelTextField::SelectNone(field);
4739 // Render and notify
4740 application.SendNotification();
4741 application.Render();
4743 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4748 int utcDaliTextFieldSelectionChangedSignal(void)
4750 ToolkitTestApplication application;
4751 tet_infoline(" utcDaliTextFieldSelectionChangedSignal");
4753 TextField field = TextField::New();
4754 DALI_TEST_CHECK( field );
4756 application.GetScene().Add( field );
4758 // connect to the selection changed signal.
4759 ConnectionTracker* testTracker = new ConnectionTracker();
4760 DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
4761 bool selectionChangedSignal = false;
4762 field.ConnectSignal( testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal) );
4764 field.SetProperty( TextField::Property::TEXT, "Hello world Hello world" );
4765 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
4766 field.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4767 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4768 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4770 // Avoid a crash when core load gl resources.
4771 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4773 // Render and notify
4774 application.SendNotification();
4775 application.Render();
4777 // Tap on the text field
4778 TestGenerateTap( application, 3.0f, 25.0f );
4780 // Render and notify
4781 application.SendNotification();
4782 application.Render();
4784 // Select some text in the right of the current cursor position
4785 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4786 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4788 // Render and notify
4789 application.SendNotification();
4790 application.Render();
4792 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4793 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4795 gSelectionChangedCallbackCalled = false;
4797 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4799 // Render and notify
4800 application.SendNotification();
4801 application.Render();
4803 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4804 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4805 DALI_TEST_EQUALS(oldSelectionEnd, 1, TEST_LOCATION);
4807 gSelectionChangedCallbackCalled = false;
4809 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4811 // Render and notify
4812 application.SendNotification();
4813 application.Render();
4815 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4816 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4817 DALI_TEST_EQUALS(oldSelectionEnd, 2, TEST_LOCATION);
4819 gSelectionChangedCallbackCalled = false;
4820 field.SetKeyInputFocus();
4822 // Render and notify
4823 application.SendNotification();
4824 application.Render();
4826 DevelTextField::SelectText( field ,0, 5 );
4828 application.SendNotification();
4829 application.Render();
4831 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4832 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4834 gSelectionChangedCallbackCalled = false;
4836 field.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4838 // Render and notify
4839 application.SendNotification();
4840 application.Render();
4842 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4843 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4844 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
4846 gSelectionChangedCallbackCalled = false;
4849 DevelTextField::SelectWholeText(field);
4851 // Render and notify
4852 application.SendNotification();
4853 application.Render();
4855 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4856 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4858 gSelectionChangedCallbackCalled = false;
4861 DevelTextField::SelectNone(field);
4863 // Render and notify
4864 application.SendNotification();
4865 application.Render();
4867 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4868 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4869 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
4874 int UtcDaliToolkitTextFieldStrikethroughGeneration(void)
4876 ToolkitTestApplication application;
4877 tet_infoline(" UtcDaliToolkitTextFieldStrikethroughGeneration");
4879 TextField textField = TextField::New();
4880 textField.SetProperty( TextField::Property::TEXT, "Test" );
4881 textField.SetProperty( Actor::Property::SIZE, Vector2( 200.0f, 100.f ) );
4882 textField.SetProperty( TextField::Property::POINT_SIZE, 10) ;
4883 textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
4885 application.GetScene().Add( textField );
4886 application.SendNotification();
4887 application.Render();
4889 Property::Map strikethroughMapSet;
4890 Property::Map strikethroughMapGet;
4892 strikethroughMapSet.Insert( "enable", true );
4893 strikethroughMapSet.Insert( "color", Color::RED );
4894 strikethroughMapSet.Insert( "height", 2.0f );
4896 // Check the strikethrough property
4897 textField.SetProperty( DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet );
4898 strikethroughMapGet = textField.GetProperty<Property::Map>( DevelTextField::Property::STRIKETHROUGH );
4899 textField.SetProperty( TextField::Property::TEXT, "Test1" );
4900 DALI_TEST_EQUALS( strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION );
4901 DALI_TEST_EQUALS( DaliTestCheckMaps( strikethroughMapGet, strikethroughMapSet ), true, TEST_LOCATION );
4903 // Render and notify
4904 application.SendNotification();
4905 application.Render();
4907 strikethroughMapSet.Clear();
4908 strikethroughMapGet.Clear();
4913 int UtcDaliToolkitTextFieldInputStrikethroughGeneration(void)
4915 ToolkitTestApplication application;
4916 tet_infoline(" UtcDaliToolkitTextFieldInputStrikethroughGeneration");
4918 TextField textField = TextField::New();
4919 textField.SetProperty( TextField::Property::TEXT, "Test" );
4920 textField.SetProperty( Actor::Property::SIZE, Vector2( 200.0f, 100.f ) );
4921 textField.SetProperty( TextField::Property::POINT_SIZE, 10) ;
4922 textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
4924 application.GetScene().Add( textField );
4925 application.SendNotification();
4926 application.Render();
4928 std::string strikethroughSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}" );
4930 // Check the strikethrough property
4931 textField.SetProperty( DevelTextField::Property::INPUT_STRIKETHROUGH, strikethroughSettings1 );
4932 textField.SetProperty( TextField::Property::TEXT, "Test1" );
4933 DALI_TEST_EQUALS( textField.GetProperty<std::string>( DevelTextField::Property::INPUT_STRIKETHROUGH ), strikethroughSettings1, TEST_LOCATION );
4935 // Render and notify
4936 application.SendNotification();
4937 application.Render();