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 );