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>
36 using namespace Toolkit;
38 void dali_textfield_startup(void)
40 test_return_value = TET_UNDEF;
43 void dali_textfield_cleanup(void)
45 test_return_value = TET_PASS;
51 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
52 const char* const PROPERTY_NAME_TEXT = "text";
53 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
54 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
55 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
56 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
57 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
58 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
59 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
60 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
61 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
62 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
63 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
64 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
65 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
66 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
67 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
68 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
69 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
70 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
71 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
72 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
73 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
79 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
80 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
81 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
82 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
83 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
84 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
85 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
86 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
87 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
89 const char* const PROPERTY_NAME_UNDERLINE = "underline";
90 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
91 const char* const PROPERTY_NAME_SHADOW = "shadow";
92 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
93 const char* const PROPERTY_NAME_EMBOSS = "emboss";
94 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
95 const char* const PROPERTY_NAME_OUTLINE = "outline";
96 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
98 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
99 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
100 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
101 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
102 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
103 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
104 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
105 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
106 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
107 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
108 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
109 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
110 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
112 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
113 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
115 const float RENDER_FRAME_INTERVAL = 16.66f;
117 const unsigned int DEFAULT_FONT_SIZE = 1152u;
118 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
120 const int KEY_RETURN_CODE = 36;
121 const int KEY_A_CODE = 38;
122 const int KEY_D_CODE = 40;
123 const int KEY_SHIFT_MODIFIER = 257;
125 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
127 static bool gSelectionChangedCallbackCalled;
128 static uint32_t oldSelectionStart;
129 static uint32_t oldSelectionEnd;
130 static bool gSelectionClearedCallbackCalled;
131 static bool gAnchorClickedCallBackCalled;
132 static bool gAnchorClickedCallBackNotCalled;
133 static bool gTextChangedCallBackCalled;
134 static bool gMaxCharactersCallBackCalled;
135 static bool gInputFilteredAcceptedCallbackCalled;
136 static bool gInputFilteredRejectedCallbackCalled;
137 static bool gInputStyleChangedCallbackCalled;
138 static bool gCursorPositionChangedCallbackCalled;
139 static uint32_t oldCursorPos;
140 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
142 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
144 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
145 Integration::ResourcePointer resource(bitmap);
146 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
149 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
153 LoadBitmapResource( app.GetPlatform(), width, height );
155 Property::Map propertyMap;
156 propertyMap["filename"] = "image.png";
157 propertyMap["width"] = width;
158 propertyMap["height"] = height;
159 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
160 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
161 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
162 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
163 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
164 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
165 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
166 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
170 * Simulate time passed by.
172 * @note this will always process at least 1 frame (1/60 sec)
174 * @param application Test application instance
175 * @param duration Time to pass in milliseconds.
176 * @return The actual time passed in milliseconds
178 static int Wait(ToolkitTestApplication& application, int duration = 0)
182 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
184 application.SendNotification();
185 application.Render(RENDER_FRAME_INTERVAL);
186 time += RENDER_FRAME_INTERVAL;
192 Dali::Integration::Point GetPointDownInside( Vector2& pos )
194 Dali::Integration::Point point;
195 point.SetState( PointState::DOWN );
196 point.SetScreenPosition( pos );
200 Dali::Integration::Point GetPointUpInside( Vector2& pos )
202 Dali::Integration::Point point;
203 point.SetState( PointState::UP );
204 point.SetScreenPosition( pos );
208 struct CallbackFunctor
210 CallbackFunctor(bool* callbackFlag)
211 : mCallbackFlag( callbackFlag )
217 *mCallbackFlag = true;
222 static void TestSelectionClearedCallback(TextField control)
224 tet_infoline(" TestSelectionClearedCallback");
226 gSelectionClearedCallbackCalled = true;
229 static void TestSelectionChangedCallback(TextField control, uint32_t oldStart, uint32_t oldEnd)
231 tet_infoline(" TestSelectionChangedCallback");
233 gSelectionChangedCallbackCalled = true;
234 oldSelectionStart = oldStart;
235 oldSelectionEnd = oldEnd;
238 static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength)
240 tet_infoline(" TestAnchorClickedCallback");
242 gAnchorClickedCallBackNotCalled = false;
244 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
246 gAnchorClickedCallBackCalled = true;
250 static void TestCursorPositionChangedCallback( TextField control, unsigned int oldPos )
252 tet_infoline(" TestCursorPositionChangedCallback");
254 gCursorPositionChangedCallbackCalled = true;
255 oldCursorPos = oldPos;
258 static void TestTextChangedCallback( TextField control )
260 tet_infoline(" TestTextChangedCallback");
262 gTextChangedCallBackCalled = true;
265 static void TestMaxLengthReachedCallback( TextField control )
267 tet_infoline(" TestMaxLengthReachedCallback");
269 gMaxCharactersCallBackCalled = true;
272 static void TestInputFilteredCallback(TextField control, Toolkit::InputFilter::Property::Type type)
274 tet_infoline(" TestInputFilteredCallback");
276 if(type == Toolkit::InputFilter::Property::ACCEPTED)
278 gInputFilteredAcceptedCallbackCalled = true;
280 else if(type == Toolkit::InputFilter::Property::REJECTED)
282 gInputFilteredRejectedCallbackCalled = true;
286 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
288 tet_infoline(" TestInputStyleChangedCallback");
290 gInputStyleChangedCallbackCalled = true;
291 gInputStyleMask = mask;
294 // Generate a KeyEvent to send to Core.
295 Integration::KeyEvent GenerateKey( const std::string& keyName,
296 const std::string& logicalKey,
297 const std::string& keyString,
300 unsigned long timeStamp,
301 const Integration::KeyEvent::State& keyState,
302 const std::string& compose = "",
303 const std::string& deviceName = DEFAULT_DEVICE_NAME,
304 const Device::Class::Type& deviceClass = Device::Class::NONE,
305 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
307 return Integration::KeyEvent( keyName,
320 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
322 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
324 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
326 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
328 Property::Value* valueSet = NULL;
329 if ( valueGet.first.type == Property::Key::INDEX )
331 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
335 // Get Key is a string so searching Set Map for a string key
336 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
339 if( NULL != valueSet )
341 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
343 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
346 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
348 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
351 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
353 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
356 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
358 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
361 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
363 Vector2 vector2Get = valueGet.second.Get<Vector2>();
364 Vector2 vector2Set = valueSet->Get<Vector2>();
365 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
368 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
370 Vector4 vector4Get = valueGet.second.Get<Vector4>();
371 Vector4 vector4Set = valueSet->Get<Vector4>();
372 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 );
378 if ( valueGet.first.type == Property::Key::INDEX )
380 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
384 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
396 int UtcDaliToolkitTextFieldConstructorP(void)
398 ToolkitTestApplication application;
399 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
401 DALI_TEST_CHECK( !textField );
405 int UtcDaliToolkitTextFieldNewP(void)
407 ToolkitTestApplication application;
408 tet_infoline(" UtcDaliToolkitTextFieldNewP");
409 TextField textField = TextField::New();
410 DALI_TEST_CHECK( textField );
414 int UtcDaliToolkitTextFieldDownCastP(void)
416 ToolkitTestApplication application;
417 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
418 TextField textField1 = TextField::New();
419 BaseHandle object( textField1 );
421 TextField textField2 = TextField::DownCast( object );
422 DALI_TEST_CHECK( textField2 );
424 TextField textField3 = DownCast< TextField >( object );
425 DALI_TEST_CHECK( textField3 );
429 int UtcDaliToolkitTextFieldDownCastN(void)
431 ToolkitTestApplication application;
432 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
433 BaseHandle uninitializedObject;
434 TextField textField1 = TextField::DownCast( uninitializedObject );
435 DALI_TEST_CHECK( !textField1 );
437 TextField textField2 = DownCast< TextField >( uninitializedObject );
438 DALI_TEST_CHECK( !textField2 );
442 int UtcDaliToolkitTextFieldCopyConstructorP(void)
444 ToolkitTestApplication application;
445 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
446 TextField textField = TextField::New();
447 textField.SetProperty( TextField::Property::TEXT, "Test" );
449 TextField copy( textField );
450 DALI_TEST_CHECK( copy );
451 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
455 int UtcDaliTextFieldMoveConstructor(void)
457 ToolkitTestApplication application;
459 TextField textField = TextField::New();
460 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
461 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
463 TextField moved = std::move( textField );
464 DALI_TEST_CHECK( moved );
465 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
466 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
467 DALI_TEST_CHECK( !textField );
472 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
474 ToolkitTestApplication application;
475 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
476 TextField textField = TextField::New();
477 textField.SetProperty( TextField::Property::TEXT, "Test" );
479 TextField copy = textField;
480 DALI_TEST_CHECK( copy );
481 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
485 int UtcDaliTextFieldMoveAssignment(void)
487 ToolkitTestApplication application;
489 TextField textField = TextField::New();
490 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
491 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
494 moved = std::move( textField );
495 DALI_TEST_CHECK( moved );
496 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
497 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
498 DALI_TEST_CHECK( !textField );
503 int UtcDaliTextFieldNewP(void)
505 ToolkitTestApplication application;
506 tet_infoline(" UtcDaliToolkitTextFieldNewP");
507 TextField textField = TextField::New();
508 DALI_TEST_CHECK( textField );
512 // Positive test case for a method
513 int UtcDaliTextFieldGetPropertyP(void)
515 ToolkitTestApplication application;
516 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
517 TextField field = TextField::New();
518 DALI_TEST_CHECK( field );
520 // Check Property Indices are correct
521 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextField::Property::RENDERING_BACKEND );
522 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
523 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
524 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
525 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
526 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
527 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
528 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
529 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
530 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
531 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
532 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
533 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
534 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
535 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
536 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
537 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
538 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
539 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
540 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
541 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
542 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
543 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
544 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
545 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
546 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
547 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
548 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
549 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
550 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
551 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
552 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
553 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
554 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
555 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
556 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
557 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
558 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
559 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
560 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
561 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
562 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
563 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
564 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
565 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
566 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
567 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
568 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
569 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
570 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
571 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextField::Property::FONT_SIZE_SCALE );
572 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
573 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
574 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
575 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP );
576 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextField::Property::BACKGROUND );
577 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextField::Property::GRAB_HANDLE_COLOR );
578 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FILTER ) == DevelTextField::Property::INPUT_FILTER );
583 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
586 Property::Map imageMap;
587 imageMap[mapKey] =mapValue;
589 field.SetProperty( property , imageMap );
590 Property::Value propValue = field.GetProperty( property );
591 Property::Map* resultMap = propValue.GetMap();
593 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
601 // Positive test case for a method
602 int UtcDaliTextFieldSetPropertyP(void)
604 ToolkitTestApplication application;
605 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
606 TextField field = TextField::New();
607 DALI_TEST_CHECK( field );
608 application.GetScene().Add( field );
610 // Note - we can't check the defaults since the stylesheets are platform-specific
612 // Check the render backend property.
613 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
614 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
616 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
617 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION );
619 // Check text property.
620 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
621 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
623 // Check placeholder text properties.
624 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
625 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
627 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
628 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
630 // Check font properties.
631 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
632 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
634 Property::Map fontStyleMapSet;
635 Property::Map fontStyleMapGet;
636 Property::Value* slantValue = NULL;
638 fontStyleMapSet.Insert( "weight", "bold" );
639 fontStyleMapSet.Insert( "width", "condensed" );
640 fontStyleMapSet.Insert( "slant", "italic" );
641 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
643 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
644 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
645 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
647 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
648 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
650 field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 2.5f );
651 DALI_TEST_EQUALS( field.GetProperty<float>( DevelTextField::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
652 field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 1.0f );
655 fontStyleMapSet.Clear();
656 fontStyleMapSet.Insert( "weight", "normal" );
657 fontStyleMapSet.Insert( "slant", "oblique" );
658 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
660 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
661 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
662 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
664 fontStyleMapSet.Clear();
665 fontStyleMapSet.Insert( "slant", "roman" );
666 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
667 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
669 // Replace 'roman' for 'normal'.
670 slantValue = fontStyleMapGet.Find( "slant" );
671 if( NULL != slantValue )
673 if( "normal" == slantValue->Get<std::string>() )
675 fontStyleMapGet["slant"] = "roman";
678 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
679 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
681 fontStyleMapSet.Clear();
683 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
684 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
685 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
686 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
688 // Check that the MAX_LENGTH property can be correctly set
689 const int maxNumberOfCharacters = 20;
690 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
691 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
693 // Check exceed policy
694 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
695 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
696 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
697 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
699 // Check that the Alignment properties can be correctly set
700 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
701 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
702 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
703 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
705 // Check text's color property
706 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
707 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
709 // Check placeholder text's color property.
710 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
711 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
713 // Check cursor properties
714 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
715 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
716 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
717 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
719 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
720 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
721 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
722 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
723 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
724 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
725 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
726 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
728 // Check scroll properties.
729 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
730 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
731 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
732 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
734 // Check handle images
735 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
736 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
737 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
738 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
739 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
741 // Check handle images
742 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
743 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
744 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
745 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
746 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
747 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
749 // Check the highlight color
750 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
751 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
753 // Decoration bounding box
754 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
755 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
757 // Check the input method setting
758 Property::Map propertyMap;
759 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
760 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
761 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
762 int inputVariation = 1;
763 propertyMap["PANEL_LAYOUT"] = panelLayout;
764 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
765 propertyMap["BUTTON_ACTION"] = buttonAction;
766 propertyMap["VARIATION"] = inputVariation;
767 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
769 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
771 DALI_TEST_CHECK( value.Get( map ) );
774 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
775 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
778 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
779 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
782 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
783 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
786 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
787 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
789 // Check input color property.
790 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
791 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
793 // Check the enable markup property.
794 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
795 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
796 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
798 // Check input font properties.
799 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
800 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
802 fontStyleMapSet.Clear();
803 fontStyleMapSet.Insert( "weight", "bold" );
804 fontStyleMapSet.Insert( "width", "condensed" );
805 fontStyleMapSet.Insert( "slant", "italic" );
807 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
808 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
809 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
810 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
812 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
813 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
815 // Reset input font style.
816 fontStyleMapSet.Clear();
817 fontStyleMapSet.Insert( "weight", "normal" );
818 fontStyleMapSet.Insert( "slant", "oblique" );
820 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
821 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
822 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
823 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
825 fontStyleMapSet.Clear();
826 fontStyleMapSet.Insert( "slant", "roman" );
828 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
829 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
831 // Replace 'roman' for 'normal'.
832 slantValue = fontStyleMapGet.Find( "slant" );
833 if( NULL != slantValue )
835 if( "normal" == slantValue->Get<std::string>() )
837 fontStyleMapGet["slant"] = "roman";
840 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
841 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
843 fontStyleMapSet.Clear();
845 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
846 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
847 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
848 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
850 Property::Map underlineMapSet;
851 Property::Map underlineMapGet;
853 underlineMapSet.Insert( "enable", true );
854 underlineMapSet.Insert( "color", Color::RED );
855 underlineMapSet.Insert( "height", 1 );
857 // Check the underline property
858 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
860 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
861 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
862 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
864 // Check the input underline property
865 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
866 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
868 // Check the shadow property
869 Property::Map shadowMapSet;
870 Property::Map shadowMapGet;
872 shadowMapSet.Insert( "color", Color::GREEN );
873 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
874 shadowMapSet.Insert( "blurRadius", 3.0f );
876 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
878 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
879 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
880 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
882 // Check the input shadow property
883 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
884 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
886 // Check the emboss property
887 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
888 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
890 // Check the input emboss property
891 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
892 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
894 // Check the outline property
896 // Test string type first
897 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
898 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
899 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
901 // Then test the property map type
902 Property::Map outlineMapSet;
903 Property::Map outlineMapGet;
905 outlineMapSet["color"] = Color::RED;
906 outlineMapSet["width"] = 2.0f;
908 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
910 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
911 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
912 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
914 // Check the input outline property
915 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
916 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
918 // Check the hidden input settings property
919 Property::Map hiddenMapSet;
920 Property::Map hiddenMapGet;
921 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
922 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
923 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
924 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
925 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
927 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
928 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
929 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
931 // Check the pixel size of font
932 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
933 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
935 // Check the enable selection property
936 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
937 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
939 // Check the placeholder property with pixel size
940 Property::Map placeholderPixelSizeMapSet;
941 Property::Map placeholderPixelSizeMapGet;
942 Property::Map placeholderFontstyleMap;
943 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
944 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
945 placeholderPixelSizeMapSet["color"] = Color::BLUE;
946 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
947 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
948 placeholderPixelSizeMapSet["ellipsis"] = true;
950 placeholderFontstyleMap.Insert( "weight", "bold" );
951 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
952 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
954 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
955 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
957 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
958 Property::Map placeholderConversionMap;
959 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
960 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
961 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
962 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
963 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
964 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
966 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
968 // Check the placeholder property with point size
969 Property::Map placeholderMapSet;
970 Property::Map placeholderMapGet;
971 placeholderMapSet["text"] = "Setting Placeholder Text";
972 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
973 placeholderMapSet["color"] = Color::RED;
974 placeholderMapSet["fontFamily"] = "Arial";
975 placeholderMapSet["pointSize"] = 12.0f;
976 placeholderMapSet["ellipsis"] = false;
978 // Check the placeholder font style property
979 placeholderFontstyleMap.Clear();
981 placeholderFontstyleMap.Insert( "weight", "bold" );
982 placeholderFontstyleMap.Insert( "width", "condensed" );
983 placeholderFontstyleMap.Insert( "slant", "italic" );
984 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
985 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
987 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
988 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
990 placeholderConversionMap.Clear();
991 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
992 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
993 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
994 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
995 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
996 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
998 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1000 // Reset font style.
1001 placeholderFontstyleMap.Clear();
1002 placeholderFontstyleMap.Insert( "weight", "normal" );
1003 placeholderFontstyleMap.Insert( "slant", "oblique" );
1004 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1005 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1007 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1008 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1010 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1011 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1013 placeholderFontstyleMap.Clear();
1014 placeholderFontstyleMap.Insert( "slant", "roman" );
1015 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1016 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1018 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1020 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1022 placeholderFontstyleMap.Clear();
1023 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1024 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1026 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1027 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1028 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1030 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1032 // Check the ellipsis property
1033 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1034 field.SetProperty( TextField::Property::ELLIPSIS, true );
1035 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1037 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
1038 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1040 // Test the ENABLE_GRAB_HANDLE_POPUP property
1041 DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1042 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false );
1043 DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1045 // Check the background property
1046 field.SetProperty( DevelTextField::Property::BACKGROUND, Color::RED );
1047 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::BACKGROUND ), Color::RED, TEST_LOCATION );
1049 //Check handle color
1050 field.SetProperty( DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN );
1051 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
1053 // Check the input filter property
1054 Property::Map inputFilterMapSet;
1055 Property::Map inputFilterMapGet;
1056 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1057 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1059 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1061 inputFilterMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::INPUT_FILTER);
1062 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1065 inputFilterMapSet.Clear();
1066 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1068 application.SendNotification();
1069 application.Render();
1074 // Positive Atlas Text Renderer test
1075 int utcDaliTextFieldAtlasRenderP(void)
1077 ToolkitTestApplication application;
1078 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1079 StyleManager styleManager = StyleManager::Get();
1080 styleManager.ApplyDefaultTheme();
1081 TextField field = TextField::New();
1082 DALI_TEST_CHECK( field );
1084 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1086 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1088 application.GetScene().Add( field );
1092 // Render some text with the shared atlas backend
1093 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1094 application.SendNotification();
1095 application.Render();
1099 tet_result(TET_FAIL);
1104 // Positive test for the anchorClicked signal.
1105 int utcDaliTextFieldAnchorClicked01(void)
1107 ToolkitTestApplication application;
1108 tet_infoline(" utcDaliTextFieldAnchorClicked01");
1109 TextField field = TextField::New();
1110 DALI_TEST_CHECK(field);
1112 application.GetScene().Add(field);
1114 // connect to the anchor clicked signal.
1115 ConnectionTracker* testTracker = new ConnectionTracker();
1116 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1117 bool anchorClickedSignal = false;
1118 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1120 gAnchorClickedCallBackCalled = false;
1121 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1122 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1123 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1124 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1125 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1127 application.SendNotification();
1128 application.Render();
1129 field.SetKeyInputFocus();
1131 // Create a tap event to touch the text field.
1132 TestGenerateTap(application, 5.0f, 25.0f);
1133 application.SendNotification();
1134 application.Render();
1136 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1137 DALI_TEST_CHECK(anchorClickedSignal);
1139 gAnchorClickedCallBackNotCalled = true;
1140 // Tap the outside of anchor, callback should not be called.
1141 TestGenerateTap(application, 150.f, 100.f);
1142 application.SendNotification();
1143 application.Render();
1145 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1150 // Positive test for the anchorClicked signal.
1151 int utcDaliTextFieldAnchorClicked02(void)
1153 ToolkitTestApplication application;
1154 tet_infoline(" utcDaliTextFieldAnchorClicked02");
1155 TextField field = TextField::New();
1156 DALI_TEST_CHECK(field);
1158 application.GetScene().Add(field);
1160 // connect to the anchor clicked signal.
1161 ConnectionTracker* testTracker = new ConnectionTracker();
1162 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1163 bool anchorClickedSignal = false;
1164 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1166 gAnchorClickedCallBackCalled = false;
1167 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1168 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1169 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1170 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1171 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1173 application.SendNotification();
1174 application.Render();
1175 field.SetKeyInputFocus();
1177 // Avoid a crash when core load gl resources.
1178 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1180 // Create a tap event to touch the text field.
1181 TestGenerateTap(application, 30.0f, 25.0f, 100);
1182 application.SendNotification();
1183 application.Render();
1185 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1186 DALI_TEST_CHECK(anchorClickedSignal);
1189 // For coverage InsertTextAnchor, RemoveTextAnchor
1190 // first index insert
1191 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1192 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1193 application.SendNotification();
1194 application.Render();
1196 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1197 application.SendNotification();
1198 application.Render();
1200 gAnchorClickedCallBackCalled = false;
1201 // Create a tap event to touch the text field.
1202 TestGenerateTap(application, 30.0f, 25.0f, 700);
1203 application.SendNotification();
1204 field.SetKeyInputFocus();
1206 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1208 // last index insert
1209 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1210 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1211 application.SendNotification();
1212 application.Render();
1214 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1215 application.SendNotification();
1216 application.Render();
1218 gAnchorClickedCallBackCalled = false;
1219 // Create a tap event to touch the text field.
1220 TestGenerateTap(application, 30.0f, 25.0f, 1300);
1221 application.SendNotification();
1222 field.SetKeyInputFocus();
1224 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1227 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1228 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1229 application.SendNotification();
1230 application.Render();
1232 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1233 application.SendNotification();
1234 application.Render();
1236 gAnchorClickedCallBackCalled = false;
1237 // Create a tap event to touch the text field.
1238 TestGenerateTap(application, 30.0f, 25.0f, 1900);
1239 application.SendNotification();
1240 field.SetKeyInputFocus();
1242 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1244 // first index remove
1245 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1246 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1247 application.SendNotification();
1248 application.Render();
1250 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1251 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));
1252 application.SendNotification();
1253 application.Render();
1255 gAnchorClickedCallBackCalled = false;
1256 // Create a tap event to touch the text field.
1257 TestGenerateTap(application, 30.0f, 25.0f, 2500);
1258 application.SendNotification();
1259 field.SetKeyInputFocus();
1261 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1263 // last index remove
1264 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1265 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1266 application.SendNotification();
1267 application.Render();
1269 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1270 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));
1271 application.SendNotification();
1272 application.Render();
1274 gAnchorClickedCallBackCalled = false;
1275 // Create a tap event to touch the text field.
1276 TestGenerateTap(application, 30.0f, 25.0f, 3100);
1277 application.SendNotification();
1278 application.Render();
1280 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1283 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1284 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1285 application.SendNotification();
1286 application.Render();
1288 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1289 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));
1290 application.SendNotification();
1291 application.Render();
1293 gAnchorClickedCallBackCalled = false;
1294 // Create a tap event to touch the text field.
1295 TestGenerateTap(application, 30.0f, 25.0f, 3700);
1296 application.SendNotification();
1297 application.Render();
1299 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1301 // 0 ~ 1 index remove
1302 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1303 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 0);
1304 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 1);
1305 application.SendNotification();
1306 application.Render();
1308 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1309 application.SendNotification();
1310 application.Render();
1312 gAnchorClickedCallBackCalled = false;
1313 // Create a tap event to touch the text field.
1314 TestGenerateTap(application, 30.0f, 25.0f, 4300);
1315 application.SendNotification();
1316 application.Render();
1318 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1320 // 1 ~ 3 index remove
1321 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1322 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 1);
1323 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 3);
1324 application.SendNotification();
1325 application.Render();
1327 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1328 application.SendNotification();
1329 application.Render();
1331 gAnchorClickedCallBackCalled = false;
1332 // Create a tap event to touch the text field.
1333 TestGenerateTap(application, 30.0f, 25.0f, 4900);
1334 application.SendNotification();
1335 application.Render();
1337 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1339 // 3 ~ 4 index remove
1340 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1341 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 3);
1342 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 4);
1343 application.SendNotification();
1344 application.Render();
1346 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1347 application.SendNotification();
1348 application.Render();
1350 gAnchorClickedCallBackCalled = false;
1351 // Create a tap event to touch the text field.
1352 TestGenerateTap(application, 30.0f, 25.0f, 5500);
1353 application.SendNotification();
1354 application.Render();
1356 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1358 // Remove front of anchor
1359 field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
1360 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
1361 application.SendNotification();
1362 application.Render();
1364 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1365 application.SendNotification();
1366 application.Render();
1368 // Remove whole text
1369 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1370 DevelTextField::SelectWholeText(field);
1371 application.SendNotification();
1372 application.Render();
1374 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1375 application.SendNotification();
1376 application.Render();
1378 // Remove all with backspace
1379 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1380 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
1381 application.SendNotification();
1382 application.Render();
1384 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1385 application.SendNotification();
1386 application.Render();
1388 // Remove all with delete
1389 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1390 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1391 application.SendNotification();
1392 application.Render();
1394 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));
1395 application.SendNotification();
1396 application.Render();
1401 // Positive test for the textChanged signal.
1402 int utcDaliTextFieldTextChangedP(void)
1404 ToolkitTestApplication application;
1405 tet_infoline(" utcDaliTextFieldTextChangedP");
1406 TextField field = TextField::New();
1407 DALI_TEST_CHECK( field );
1409 application.GetScene().Add( field );
1411 // connect to the text changed signal.
1412 ConnectionTracker* testTracker = new ConnectionTracker();
1413 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1414 bool textChangedSignal = false;
1415 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1417 gTextChangedCallBackCalled = false;
1418 field.SetProperty( TextField::Property::TEXT, "ABC" );
1419 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1420 DALI_TEST_CHECK( textChangedSignal );
1422 application.SendNotification();
1423 field.SetKeyInputFocus();
1425 gTextChangedCallBackCalled = false;
1426 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1427 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1430 field.SetProperty( TextField::Property::TEXT, "" );
1432 // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1433 gTextChangedCallBackCalled = false;
1434 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1435 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1437 // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1438 gTextChangedCallBackCalled = false;
1439 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1440 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1445 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1447 ToolkitTestApplication application;
1448 tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1449 TextField field = TextField::New();
1450 DALI_TEST_CHECK( field );
1453 application.GetScene().Add( field );
1455 // connect to the text changed signal.
1456 ConnectionTracker* testTracker = new ConnectionTracker();
1457 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1458 bool textChangedSignal = false;
1459 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1462 // get InputMethodContext
1464 InputMethodContext::EventData imfEvent;
1465 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext( field );
1467 field.SetKeyInputFocus();
1468 field.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
1471 gTextChangedCallBackCalled = false;
1472 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1473 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1474 application.SendNotification();
1475 application.Render();
1476 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1477 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1479 gTextChangedCallBackCalled = false;
1480 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1481 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1482 application.SendNotification();
1483 application.Render();
1484 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1485 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호"), TEST_LOCATION );
1487 gTextChangedCallBackCalled = false;
1488 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1489 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1490 application.SendNotification();
1491 application.Render();
1492 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1493 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1495 gTextChangedCallBackCalled = false;
1496 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1497 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1498 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1500 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1501 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1502 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1504 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1505 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1506 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1508 application.SendNotification();
1509 application.Render();
1510 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1511 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1517 // Negative test for the textChanged signal.
1518 int utcDaliTextFieldTextChangedN(void)
1520 ToolkitTestApplication application;
1521 tet_infoline(" utcDaliTextFieldTextChangedN");
1522 TextField field = TextField::New();
1523 DALI_TEST_CHECK( field );
1525 application.GetScene().Add( field );
1527 // connect to the text changed signal.
1528 ConnectionTracker* testTracker = new ConnectionTracker();
1529 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1530 bool textChangedSignal = false;
1531 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1533 gTextChangedCallBackCalled = false;
1534 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1535 application.SendNotification();
1536 application.Render();
1537 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1538 DALI_TEST_CHECK( !textChangedSignal );
1543 // Positive test for Max Characters reached signal.
1544 int utcDaliTextFieldMaxCharactersReachedP(void)
1546 ToolkitTestApplication application;
1547 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1548 TextField field = TextField::New();
1549 DALI_TEST_CHECK( field );
1551 application.GetScene().Add( field );
1553 const int maxNumberOfCharacters = 1;
1554 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1556 field.SetKeyInputFocus();
1558 // connect to the text changed signal.
1559 ConnectionTracker* testTracker = new ConnectionTracker();
1560 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1561 bool maxLengthReachedSignal = false;
1562 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1564 gMaxCharactersCallBackCalled = false;
1566 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1567 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1569 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1570 DALI_TEST_CHECK( maxLengthReachedSignal );
1575 // Negative test for Max Characters reached signal.
1576 int utcDaliTextFieldMaxCharactersReachedN(void)
1578 ToolkitTestApplication application;
1579 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1580 TextField field = TextField::New();
1581 DALI_TEST_CHECK( field );
1583 application.GetScene().Add( field );
1585 const int maxNumberOfCharacters = 3;
1586 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1588 field.SetKeyInputFocus();
1590 // connect to the text changed signal.
1591 ConnectionTracker* testTracker = new ConnectionTracker();
1592 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1593 bool maxLengthReachedSignal = false;
1594 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1596 gMaxCharactersCallBackCalled = false;
1598 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1599 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1601 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1602 DALI_TEST_CHECK( !maxLengthReachedSignal );
1604 application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1606 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1607 DALI_TEST_CHECK( !maxLengthReachedSignal );
1612 // Positive test for Input Filtered signal.
1613 int utcDaliTextFieldInputFilteredP(void)
1615 ToolkitTestApplication application;
1616 tet_infoline(" utcDaliTextFieldInputFilteredP");
1617 TextField field = TextField::New();
1618 DALI_TEST_CHECK(field);
1620 application.GetScene().Add(field);
1622 Property::Map inputFilter;
1624 // Only digit is accepted.
1625 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1627 // Set input filter to TextField.
1628 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1630 field.SetKeyInputFocus();
1632 // connect to the input filtered signal.
1633 ConnectionTracker* testTracker = new ConnectionTracker();
1634 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1635 bool inputFilteredSignal = false;
1636 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1638 gInputFilteredAcceptedCallbackCalled = false;
1640 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ));
1642 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1643 DALI_TEST_CHECK(inputFilteredSignal);
1645 // Word is rejected.
1646 inputFilter[InputFilter::Property::ACCEPTED] = "";
1647 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1649 // Set input filter to TextField.
1650 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1652 field.SetKeyInputFocus();
1654 inputFilteredSignal = false;
1655 gInputFilteredRejectedCallbackCalled = false;
1657 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1659 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1660 DALI_TEST_CHECK(inputFilteredSignal);
1665 // Negative test for Input Filtered signal.
1666 int utcDaliTextFieldInputFilteredN(void)
1668 ToolkitTestApplication application;
1669 tet_infoline(" utcDaliTextFieldInputFilteredP");
1670 TextField field = TextField::New();
1671 DALI_TEST_CHECK(field);
1673 application.GetScene().Add(field);
1675 Property::Map inputFilter;
1677 // Only word is accepted.
1678 inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
1680 // Set input filter to TextField.
1681 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1683 field.SetKeyInputFocus();
1685 // connect to the input filtered signal.
1686 ConnectionTracker* testTracker = new ConnectionTracker();
1687 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1688 bool inputFilteredSignal = false;
1689 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1691 gInputFilteredAcceptedCallbackCalled = false;
1693 // Key a, d should not be filtered.
1694 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1695 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1696 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1697 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1699 // Backspace, Delete should not be filtered.
1700 application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1701 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));
1703 // Render and notify
1704 application.SendNotification();
1705 application.Render();
1707 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1708 DALI_TEST_CHECK(!inputFilteredSignal);
1710 // Digit is rejected.
1711 inputFilter[InputFilter::Property::ACCEPTED] = "";
1712 inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
1714 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1716 field.SetKeyInputFocus();
1718 inputFilteredSignal = false;
1719 gInputFilteredRejectedCallbackCalled = false;
1721 // Key a, d should not be filtered.
1722 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1723 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1724 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1725 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1727 // Backspace, Delete should not be filtered.
1728 application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1729 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));
1731 // Render and notify
1732 application.SendNotification();
1733 application.Render();
1735 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1736 DALI_TEST_CHECK(!inputFilteredSignal);
1741 int utcDaliTextFieldInputStyleChanged01(void)
1743 // The text-field emits signals when the input style changes. These changes of style are
1744 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1745 // can't be emitted during the size negotiation as the callbacks may update the UI.
1746 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1747 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1748 ToolkitTestApplication application;
1749 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1753 char* pathNamePtr = get_current_dir_name();
1754 const std::string pathName( pathNamePtr );
1755 free( pathNamePtr );
1757 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1758 fontClient.SetDpi( 93u, 93u );
1760 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1761 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1763 TextField field = TextField::New();
1764 DALI_TEST_CHECK( field );
1767 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1768 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1769 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1771 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1772 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1774 // connect to the text changed signal.
1775 ConnectionTracker* testTracker = new ConnectionTracker();
1776 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1777 bool inputStyleChangedSignal = false;
1778 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1780 application.GetScene().Add( field );
1782 // Render and notify
1783 application.SendNotification();
1784 application.Render();
1786 // Executes the idle callbacks added by the text control on the change of input style.
1787 application.RunIdles();
1789 gInputStyleChangedCallbackCalled = false;
1790 gInputStyleMask = TextField::InputStyle::NONE;
1791 inputStyleChangedSignal = false;
1793 // Create a tap event to touch the text field.
1794 TestGenerateTap( application, 18.0f, 25.0f );
1796 // Render and notify
1797 application.SendNotification();
1798 application.Render();
1800 // Executes the idle callbacks added by the text control on the change of input style.
1801 application.RunIdles();
1803 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1804 if( gInputStyleChangedCallbackCalled )
1806 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1808 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1809 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1811 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1812 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1814 DALI_TEST_CHECK( inputStyleChangedSignal );
1816 gInputStyleChangedCallbackCalled = false;
1817 gInputStyleMask = TextField::InputStyle::NONE;
1818 inputStyleChangedSignal = false;
1820 // Create a tap event to touch the text field.
1821 TestGenerateTap( application, 30.0f, 25.0f );
1823 // Render and notify
1824 application.SendNotification();
1825 application.Render();
1827 // Executes the idle callbacks added by the text control on the change of input style.
1828 application.RunIdles();
1830 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1831 DALI_TEST_CHECK( !inputStyleChangedSignal );
1833 gInputStyleChangedCallbackCalled = false;
1834 gInputStyleMask = TextField::InputStyle::NONE;
1835 inputStyleChangedSignal = false;
1837 // Create a tap event to touch the text field.
1838 TestGenerateTap( application, 43.0f, 25.0f );
1840 // Render and notify
1841 application.SendNotification();
1842 application.Render();
1844 // Executes the idle callbacks added by the text control on the change of input style.
1845 application.RunIdles();
1847 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1848 if( gInputStyleChangedCallbackCalled )
1850 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1852 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1853 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1855 DALI_TEST_CHECK( inputStyleChangedSignal );
1857 gInputStyleChangedCallbackCalled = false;
1858 gInputStyleMask = TextField::InputStyle::NONE;
1859 inputStyleChangedSignal = false;
1861 // Create a tap event to touch the text field.
1862 TestGenerateTap( application, 88.0f, 25.0f );
1864 // Render and notify
1865 application.SendNotification();
1866 application.Render();
1868 // Executes the idle callbacks added by the text control on the change of input style.
1869 application.RunIdles();
1871 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1872 if( gInputStyleChangedCallbackCalled )
1874 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1876 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1877 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1879 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1881 Property::Map fontStyleMapSet;
1882 fontStyleMapSet.Insert( "weight", "bold" );
1884 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1885 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1887 DALI_TEST_CHECK( inputStyleChangedSignal );
1889 gInputStyleChangedCallbackCalled = false;
1890 gInputStyleMask = TextField::InputStyle::NONE;
1891 inputStyleChangedSignal = false;
1893 // Create a tap event to touch the text field.
1894 TestGenerateTap( application, 115.0f, 25.0f );
1896 // Render and notify
1897 application.SendNotification();
1898 application.Render();
1900 // Executes the idle callbacks added by the text control on the change of input style.
1901 application.RunIdles();
1903 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1904 DALI_TEST_CHECK( !inputStyleChangedSignal );
1906 gInputStyleChangedCallbackCalled = false;
1907 gInputStyleMask = TextField::InputStyle::NONE;
1908 inputStyleChangedSignal = false;
1910 // Create a tap event to touch the text field.
1911 TestGenerateTap( application, 164.0f, 25.0f );
1913 // Render and notify
1914 application.SendNotification();
1915 application.Render();
1917 // Executes the idle callbacks added by the text control on the change of input style.
1918 application.RunIdles();
1920 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1921 if( gInputStyleChangedCallbackCalled )
1923 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1925 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1926 DALI_TEST_CHECK( style.empty() );
1928 DALI_TEST_CHECK( inputStyleChangedSignal );
1930 gInputStyleChangedCallbackCalled = false;
1931 gInputStyleMask = TextField::InputStyle::NONE;
1932 inputStyleChangedSignal = false;
1934 // Create a tap event to touch the text field.
1935 TestGenerateTap( application, 191.0f, 25.0f );
1937 // Render and notify
1938 application.SendNotification();
1939 application.Render();
1941 // Executes the idle callbacks added by the text control on the change of input style.
1942 application.RunIdles();
1944 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1945 DALI_TEST_CHECK( !inputStyleChangedSignal );
1950 int utcDaliTextFieldInputStyleChanged02(void)
1952 // The text-field emits signals when the input style changes. These changes of style are
1953 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1954 // can't be emitted during the size negotiation as the callbacks may update the UI.
1955 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1956 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1957 ToolkitTestApplication application;
1958 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1962 char* pathNamePtr = get_current_dir_name();
1963 const std::string pathName( pathNamePtr );
1964 free( pathNamePtr );
1966 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1967 fontClient.SetDpi( 93u, 93u );
1969 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1970 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1972 TextField field = TextField::New();
1973 DALI_TEST_CHECK( field );
1975 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1976 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1977 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1979 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1980 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>" );
1982 // connect to the text changed signal.
1983 ConnectionTracker* testTracker = new ConnectionTracker();
1984 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1985 bool inputStyleChangedSignal = false;
1986 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1988 application.GetScene().Add( field );
1990 // Render and notify
1991 application.SendNotification();
1992 application.Render();
1994 // Executes the idle callbacks added by the text control on the change of input style.
1995 application.RunIdles();
1997 gInputStyleChangedCallbackCalled = false;
1998 gInputStyleMask = TextField::InputStyle::NONE;
1999 inputStyleChangedSignal = false;
2001 // Create a tap event to touch the text field.
2002 TestGenerateTap( application, 53.0f, 25.0f, 100 );
2003 TestGenerateTap( application, 53.0f, 25.0f, 200 );
2005 // Render and notify
2006 application.SendNotification();
2007 application.Render();
2009 // Executes the idle callbacks added by the text control on the change of input style.
2010 application.RunIdles();
2012 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2013 if( gInputStyleChangedCallbackCalled )
2015 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2016 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
2017 TextField::InputStyle::POINT_SIZE |
2018 TextField::InputStyle::COLOR ),
2021 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2022 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
2024 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
2025 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
2027 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
2028 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2030 DALI_TEST_CHECK( inputStyleChangedSignal );
2032 gInputStyleChangedCallbackCalled = false;
2033 gInputStyleMask = TextField::InputStyle::NONE;
2034 inputStyleChangedSignal = false;
2036 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2038 // Render and notify
2039 application.SendNotification();
2040 application.Render();
2042 // Executes the idle callbacks added by the text control on the change of input style.
2043 application.RunIdles();
2045 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2046 if( gInputStyleChangedCallbackCalled )
2048 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2049 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
2052 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2053 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
2055 DALI_TEST_CHECK( inputStyleChangedSignal );
2057 gInputStyleChangedCallbackCalled = false;
2058 gInputStyleMask = TextField::InputStyle::NONE;
2059 inputStyleChangedSignal = false;
2061 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2063 // Render and notify
2064 application.SendNotification();
2065 application.Render();
2067 // Executes the idle callbacks added by the text control on the change of input style.
2068 application.RunIdles();
2070 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
2071 DALI_TEST_CHECK( !inputStyleChangedSignal );
2073 gInputStyleChangedCallbackCalled = false;
2074 gInputStyleMask = TextField::InputStyle::NONE;
2075 inputStyleChangedSignal = false;
2077 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2079 // Render and notify
2080 application.SendNotification();
2081 application.Render();
2083 // Executes the idle callbacks added by the text control on the change of input style.
2084 application.RunIdles();
2086 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2087 if( gInputStyleChangedCallbackCalled )
2089 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2090 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
2093 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2094 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
2096 DALI_TEST_CHECK( inputStyleChangedSignal );
2098 gInputStyleChangedCallbackCalled = false;
2099 gInputStyleMask = TextField::InputStyle::NONE;
2100 inputStyleChangedSignal = false;
2102 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
2104 Property::Map fontStyleMapSet;
2105 fontStyleMapSet.Insert( "weight", "thin" );
2106 fontStyleMapSet.Insert( "width", "condensed" );
2107 fontStyleMapSet.Insert( "slant", "italic" );
2109 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2110 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
2112 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
2113 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
2114 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
2115 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
2117 // Render and notify
2118 application.SendNotification();
2119 application.Render();
2121 // Executes the idle callbacks added by the text control on the change of input style.
2122 application.RunIdles();
2124 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
2125 DALI_TEST_CHECK( !inputStyleChangedSignal );
2127 // Create a tap event to touch the text field.
2128 TestGenerateTap( application, 63.0f, 25.0f, 700 );
2130 // Render and notify
2131 application.SendNotification();
2132 application.Render();
2134 // Executes the idle callbacks added by the text control on the change of input style.
2135 application.RunIdles();
2137 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2138 if( gInputStyleChangedCallbackCalled )
2140 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2141 static_cast<unsigned int>( TextField::InputStyle::COLOR |
2142 TextField::InputStyle::POINT_SIZE |
2143 TextField::InputStyle::FONT_STYLE |
2144 TextField::InputStyle::UNDERLINE |
2145 TextField::InputStyle::SHADOW |
2146 TextField::InputStyle::EMBOSS |
2147 TextField::InputStyle::OUTLINE ),
2150 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2151 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
2153 DALI_TEST_CHECK( inputStyleChangedSignal );
2158 int utcDaliTextFieldEvent01(void)
2160 ToolkitTestApplication application;
2161 tet_infoline(" utcDaliTextFieldEvent01");
2163 // Creates a tap event. After creating a tap event the text field should
2164 // have the focus and add text with key events should be possible.
2166 TextField field = TextField::New();
2167 DALI_TEST_CHECK( field );
2169 application.GetScene().Add( field );
2171 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2172 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2173 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2175 // Render and notify
2176 application.SendNotification();
2177 application.Render();
2179 // Avoid a crash when core load gl resources.
2180 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2182 // Render and notify
2183 application.SendNotification();
2184 application.Render();
2186 // Add a key event but as the text field has not the focus it should do nothing.
2187 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2189 // Render and notify
2190 application.SendNotification();
2191 application.Render();
2193 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2195 // Create a tap event to touch the text field.
2196 TestGenerateTap( application, 150.0f, 25.0f );
2198 // Render and notify
2199 application.SendNotification();
2200 application.Render();
2202 // Pressing delete key should be fine even if there is no text in TextField.
2203 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 ) );
2204 // Render and notify
2205 application.SendNotification();
2206 application.Render();
2208 // Now the text field has the focus, so it can handle the key events.
2209 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2210 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2212 // Render and notify
2213 application.SendNotification();
2214 application.Render();
2216 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2218 // Create a second text field and send key events to it.
2219 TextField field2 = TextField::New();
2221 field2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2222 field2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2223 field2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2224 field2.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
2226 application.GetScene().Add( field2 );
2228 // Render and notify
2229 application.SendNotification();
2230 application.Render();
2232 // Create a tap event on the second text field.
2233 TestGenerateTap( application, 150.0f, 125.0f );
2235 // Render and notify
2236 application.SendNotification();
2237 application.Render();
2239 // The second text field has the focus. It should handle the key events.
2240 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2241 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2243 // Render and notify
2244 application.SendNotification();
2245 application.Render();
2247 // Check the text has been added to the second text field.
2248 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2253 int utcDaliTextFieldEvent02(void)
2255 ToolkitTestApplication application;
2256 tet_infoline(" utcDaliTextFieldEvent02");
2258 // Checks if the right number of actors are created.
2260 TextField field = TextField::New();
2261 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2262 DALI_TEST_CHECK( field );
2263 LoadMarkerImages(application, field);
2265 application.GetScene().Add( field );
2267 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2268 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2269 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2271 // Avoid a crash when core load gl resources.
2272 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2274 // Render and notify
2275 application.SendNotification();
2276 application.Render();
2278 // Check there are the expected number of children ( stencil ).
2279 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
2281 Actor stencil = field.GetChildAt( 0u );
2282 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2284 // Create a tap event to touch the text field.
2285 TestGenerateTap( application, 150.0f, 25.0f, 300 );
2287 // Render and notify
2288 application.SendNotification();
2289 application.Render();
2291 Actor layer = field.GetChildAt( 1u );
2292 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2293 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2295 // Now the text field has the focus, so it can handle the key events.
2296 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2297 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2299 // Render and notify
2300 application.SendNotification();
2301 application.Render();
2303 // Checks the cursor and the renderer have been created.
2304 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2305 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
2307 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
2308 DALI_TEST_CHECK( cursor );
2310 // The offscreen root actor has a container with all the actors which contain the text renderers.
2311 Actor container = stencil.GetChildAt( 0u );
2312 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2314 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2315 DALI_TEST_CHECK( renderer );
2318 // Move the cursor and check the position changes.
2319 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2320 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2322 // Render and notify
2323 application.SendNotification();
2324 application.Render();
2326 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2327 DALI_TEST_CHECK( position2.x < position1.x );
2329 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2331 // Render and notify
2332 application.SendNotification();
2333 application.Render();
2335 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2336 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
2339 // Move the cursor to the first position.
2340 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2341 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2343 // Render and notify
2344 application.SendNotification();
2345 application.Render();
2347 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2349 // Send some taps and check the cursor positions.
2351 // Try to tap at the beginning.
2352 TestGenerateTap( application, 1.0f, 25.0f, 900 );
2354 // Render and notify
2355 application.SendNotification();
2356 application.Render();
2358 // Cursor position should be the same than position1.
2359 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2361 DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
2363 // Tap away from the start position.
2364 TestGenerateTap( application, 16.0f, 25.0f, 1500 );
2366 // Render and notify
2367 application.SendNotification();
2368 application.Render();
2370 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2372 DALI_TEST_CHECK( position6.x > position5.x );
2374 // Remove all the text.
2375 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2376 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2377 field.SetProperty( TextField::Property::TEXT, "" );
2379 // Render and notify
2380 application.SendNotification();
2381 application.Render();
2383 // Cursor position should be the same than position2.
2384 Vector3 position7 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2386 DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
2388 // Should not be a renderer.
2389 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2391 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2392 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2393 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
2395 application.SendNotification();
2396 application.Render();
2398 // There are renderer and decorator layer
2399 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
2404 int utcDaliTextFieldEvent03(void)
2406 ToolkitTestApplication application;
2407 tet_infoline(" utcDaliTextFieldEvent03");
2409 // Checks if the highlight actor is created.
2411 TextField field = TextField::New();
2412 DALI_TEST_CHECK( field );
2414 application.GetScene().Add( field );
2416 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2417 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2418 field.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
2419 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2420 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2422 // Avoid a crash when core load gl resources.
2423 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2424 LoadMarkerImages(application, field);
2426 // Render and notify
2427 application.SendNotification();
2428 application.Render();
2430 // Tap first to get the focus.
2431 TestGenerateTap( application, 3.0f, 25.0f );
2433 // Render and notify
2434 application.SendNotification();
2435 application.Render();
2437 // Double tap to select a word.
2438 TestGenerateTap( application, 3.0f, 25.0f );
2440 // Render and notify
2441 application.SendNotification();
2442 application.Render();
2444 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2445 Actor stencil = field.GetChildAt( 0u );
2447 // The highlight actor is drawn first, so is the first actor in the list
2448 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2449 DALI_TEST_CHECK( highlight );
2451 // The offscreen root actor has a container with all the actors which contain the text renderers.
2452 Actor container = stencil.GetChildAt( 1u );
2453 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2455 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2456 DALI_TEST_CHECK( renderer );
2462 int utcDaliTextFieldEvent04(void)
2464 ToolkitTestApplication application;
2465 tet_infoline(" utcDaliTextFieldEvent04");
2467 // Checks if the highlight actor is created.
2469 TextField field = TextField::New();
2470 DALI_TEST_CHECK( field );
2471 application.GetScene().Add( field );
2472 LoadMarkerImages(application, field);
2473 // Render and notify
2474 application.SendNotification();
2475 application.Render();
2477 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2478 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2479 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2480 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2481 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2483 // Avoid a crash when core load gl resources.
2484 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2485 // Render and notify
2486 application.SendNotification();
2487 application.Render();
2489 // Create a tap event to touch the text field.
2490 TestGenerateTap( application, 150.0f, 25.0f );
2491 // Render and notify
2492 application.SendNotification();
2493 application.Render();
2496 // Tap first to get the focus.
2497 TestGenerateTap( application, 1.0f, 25.0f );
2499 // Render and notify
2500 application.SendNotification();
2501 application.Render();
2503 // Double tap to select a word.
2504 TestGenerateTap( application, 1.0f, 25.0f );
2506 // Render and notify
2507 application.SendNotification();
2508 application.Render();
2511 TestGenerateTap( application, 0.0f, 40.0f );
2515 int utcDaliTextFieldEvent05(void)
2517 ToolkitTestApplication application;
2518 tet_infoline(" utcDaliTextFieldEvent05");
2520 // Checks dragging of cursor/grab handle
2522 TextField field = TextField::New();
2523 DALI_TEST_CHECK( field );
2524 application.GetScene().Add( field );
2525 LoadMarkerImages(application, field);
2526 // Render and notify
2527 application.SendNotification();
2528 application.Render();
2530 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2531 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2532 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2533 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2534 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2536 // Avoid a crash when core load gl resources.
2537 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2538 // Render and notify
2539 application.SendNotification();
2540 application.Render();
2542 // Create a tap event to touch the text field.
2543 TestGenerateTap( application, 150.0f, 25.0f );
2544 // Render and notify
2545 application.SendNotification();
2546 application.Render();
2548 // Tap first to get the focus.
2549 TestGenerateTap( application, 1.0f, 25.0f );
2551 // Render and notify
2552 application.SendNotification();
2553 application.Render();
2555 // Double tap to select a word.
2556 TestGenerateTap( application, 1.0f, 25.0f );
2558 // Render and notify
2559 application.SendNotification();
2560 application.Render();
2562 Actor stencil = field.GetChildAt( 1u );
2566 int utcDaliTextFieldEvent06(void)
2568 ToolkitTestApplication application;
2569 tet_infoline(" utcDaliTextFieldEvent06");
2571 // Checks Longpress when in edit mode
2573 TextField field = TextField::New();
2574 DALI_TEST_CHECK( field );
2575 application.GetScene().Add( field );
2576 LoadMarkerImages(application, field);
2577 // Render and notify
2578 application.SendNotification();
2579 application.Render();
2581 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2582 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2583 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2584 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2585 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2587 // Avoid a crash when core load gl resources.
2588 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2589 // Render and notify
2590 application.SendNotification();
2591 application.Render();
2593 // Create a tap event to touch the text field.
2594 TestGenerateTap( application, 150.0f, 25.0f );
2595 // Render and notify
2596 application.SendNotification();
2597 application.Render();
2600 // Tap first to get the focus.
2601 TestGenerateTap( application, 1.0f, 25.0f );
2603 // Render and notify
2604 application.SendNotification();
2605 application.Render();
2608 TestGenerateLongPress(application, 1.0f, 25.0f);
2610 // Render and notify
2611 application.SendNotification();
2612 application.Render();
2617 int utcDaliTextFieldEvent07(void)
2619 ToolkitTestApplication application;
2620 tet_infoline(" utcDaliTextFieldEvent07");
2622 // Checks Longpress to start edit mode
2624 TextField field = TextField::New();
2625 DALI_TEST_CHECK( field );
2626 application.GetScene().Add( field );
2627 LoadMarkerImages(application, field);
2628 // Render and notify
2629 application.SendNotification();
2630 application.Render();
2632 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2633 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2634 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2635 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2636 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2637 Property::Map propertyMap;
2638 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2639 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2641 // Avoid a crash when core load gl resources.
2642 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2643 // Render and notify
2644 application.SendNotification();
2645 application.Render();
2648 TestGenerateLongPress(application, 1.0f, 25.0f);
2650 // Render and notify
2651 application.SendNotification();
2652 application.Render();
2657 int utcDaliTextFieldEvent08(void)
2659 ToolkitTestApplication application;
2660 tet_infoline(" utcDaliTextFieldEvent08");
2662 Dali::Clipboard clipboard = Clipboard::Get();
2663 clipboard.SetItem("testTextFieldEvent");
2665 // Checks Longpress when only place holder text
2667 TextField field = TextField::New();
2668 DALI_TEST_CHECK( field );
2669 application.GetScene().Add( field );
2670 LoadMarkerImages(application, field);
2671 // Render and notify
2672 application.SendNotification();
2673 application.Render();
2675 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2676 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2677 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2678 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2679 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2681 // Avoid a crash when core load gl resources.
2682 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2683 // Render and notify
2684 application.SendNotification();
2685 application.Render();
2688 TestGenerateLongPress( application, 1.0f, 25.0f, 20 );
2690 // Render and notify
2691 application.SendNotification();
2692 application.Render();
2694 Wait(application, 500);
2696 TestEndLongPress( application, 1.0f, 25.0f, 520 );
2699 TestGenerateLongPress( application, 1.0f, 25.0f, 600 );
2701 // Render and notify
2702 application.Render();
2704 Wait(application, 500);
2706 Integration::Scene stage = application.GetScene();
2707 Layer layer = stage.GetRootLayer();
2708 Actor actor = layer.FindChildByName("optionPaste");
2712 Vector3 worldPosition = actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION );
2713 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2714 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2716 Dali::Integration::TouchEvent event;
2717 event = Dali::Integration::TouchEvent();
2718 event.AddPoint( GetPointDownInside( position ) );
2719 application.ProcessEvent( event );
2721 event = Dali::Integration::TouchEvent();
2722 event.AddPoint( GetPointUpInside( position ) );
2723 application.ProcessEvent( event );
2725 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2730 int utcDaliTextFieldEvent09(void)
2732 ToolkitTestApplication application;
2733 tet_infoline(" utcDaliTextFieldEvent09");
2735 TextField field = TextField::New();
2736 DALI_TEST_CHECK( field );
2737 application.GetScene().Add( field );
2738 LoadMarkerImages(application, field);
2739 // Render and notify
2740 application.SendNotification();
2741 application.Render();
2743 field.SetProperty( TextField::Property::TEXT, "Hello" );
2744 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2745 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2746 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2747 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2749 // Avoid a crash when core load gl resources.
2750 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2752 // Create a tap event to touch the text field.
2753 TestGenerateTap( application, 150.0f, 25.0f );
2754 application.SendNotification();
2755 application.Render();
2758 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2759 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2760 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2761 application.SendNotification();
2762 application.Render();
2764 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2765 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2766 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2767 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2768 application.SendNotification();
2769 application.Render();
2771 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2772 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2773 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2774 for( unsigned int index = 0u; index < 5u; ++index )
2776 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2777 application.SendNotification();
2778 application.Render();
2781 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2782 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2783 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2784 for( unsigned int index = 0u; index < 5u; ++index )
2786 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2787 application.SendNotification();
2788 application.Render();
2791 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2792 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2793 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2794 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2795 application.SendNotification();
2796 application.Render();
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::SHOW_LAST_CHARACTER_DURATION ] = 100;
2802 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2803 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2804 application.SendNotification();
2805 application.Render();
2807 Property::Map mapGet;
2808 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2809 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2810 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2815 int utcDaliTextFieldStyleWhilstSelected(void)
2817 ToolkitTestApplication application;
2818 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2820 // Change font and styles whilst text is selected whilst word selected
2822 TextField field = TextField::New();
2823 DALI_TEST_CHECK( field );
2824 application.GetScene().Add( field );
2825 LoadMarkerImages(application, field);
2826 // Render and notify
2827 application.SendNotification();
2828 application.Render();
2830 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2831 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2832 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2833 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2834 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2836 // Avoid a crash when core load gl resources.
2837 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2838 // Render and notify
2839 application.SendNotification();
2840 application.Render();
2842 // Create a tap event to touch the text field.
2843 TestGenerateTap( application, 150.0f, 25.0f );
2844 // Render and notify
2845 application.SendNotification();
2846 application.Render();
2849 // Tap first to get the focus.
2850 TestGenerateTap( application, 1.0f, 25.0f );
2852 // Render and notify
2853 application.SendNotification();
2854 application.Render();
2856 // Double tap to select a word.
2857 TestGenerateTap( application, 1.0f, 25.0f );
2859 // Render and notify
2860 application.SendNotification();
2861 application.Render();
2863 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2864 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2866 Property::Map fontStyleMapSet;
2867 Property::Map fontStyleMapGet;
2869 fontStyleMapSet.Insert( "weight", "bold" );
2870 fontStyleMapSet.Insert( "slant", "italic" );
2871 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2873 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2874 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2875 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2877 fontStyleMapSet.Clear();
2878 fontStyleMapSet.Insert( "width", "expanded" );
2879 fontStyleMapSet.Insert( "slant", "italic" );
2880 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2882 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2883 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2884 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2886 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2887 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2889 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2890 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2892 fontStyleMapSet.Clear();
2893 fontStyleMapSet.Insert( "weight", "bold" );
2894 fontStyleMapSet.Insert( "slant", "italic" );
2896 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2898 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2899 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2900 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2902 fontStyleMapSet.Clear();
2903 fontStyleMapSet.Insert( "width", "expanded" );
2905 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2907 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2908 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2909 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2911 // Press Escape to increase coverage
2912 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2913 application.SendNotification();
2914 application.Render();
2916 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2921 int utcDaliTextFieldEscKeyLoseFocus(void)
2923 ToolkitTestApplication application;
2924 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2926 // Creates a tap event. After creating a tap event the text field should
2927 // have the focus and add text with key events should be possible.
2929 TextField field = TextField::New();
2930 DALI_TEST_CHECK( field );
2932 application.GetScene().Add( field );
2934 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2935 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2936 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2938 // Avoid a crash when core load gl resources.
2939 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2941 // Render and notify
2942 application.SendNotification();
2943 application.Render();
2945 // Add a key event but as the text field has not the focus it should do nothing.
2946 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2947 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2949 // Render and notify
2950 application.SendNotification();
2951 application.Render();
2953 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2955 // Create a tap event to touch the text field.
2956 TestGenerateTap( application, 150.0f, 25.0f );
2958 // Render and notify
2959 application.SendNotification();
2960 application.Render();
2962 // Now the text field has the focus, so it can handle the key events.
2963 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2964 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2965 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2966 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2968 // Render and notify
2969 application.SendNotification();
2970 application.Render();
2972 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2974 // Generate a Esc key event. The text field should lose the focus.
2975 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2976 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2978 // Render and notify
2979 application.SendNotification();
2980 application.Render();
2982 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2984 // No more text should be introduced
2985 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2986 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2988 // Render and notify
2989 application.SendNotification();
2990 application.Render();
2992 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2997 int utcDaliTextFieldSomeSpecialKeys(void)
2999 ToolkitTestApplication application;
3000 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
3002 // Checks some special keys when the text is selected.
3004 TextField field = TextField::New();
3005 DALI_TEST_CHECK( field );
3006 application.GetScene().Add( field );
3007 LoadMarkerImages(application, field);
3008 // Render and notify
3009 application.SendNotification();
3010 application.Render();
3012 const std::string longText( "This is a long text for the size of the text-field." );
3014 field.SetProperty( TextField::Property::TEXT, longText );
3015 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
3016 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3017 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3018 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3020 // Avoid a crash when core load gl resources.
3021 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3022 // Render and notify
3023 application.SendNotification();
3024 application.Render();
3026 // Create a tap event to touch the text field.
3027 TestGenerateTap( application, 150.0f, 25.0f );
3029 // Render and notify
3030 application.SendNotification();
3031 application.Render();
3033 // Tap first to get the focus.
3034 TestGenerateTap( application, 1.0f, 25.0f );
3036 // Render and notify
3037 application.SendNotification();
3038 application.Render();
3040 // Double tap to select a word.
3041 TestGenerateTap( application, 1.0f, 25.0f );
3043 // Render and notify
3044 application.SendNotification();
3045 application.Render();
3047 // Generate a Esc key event. The text field should lose the focus.
3048 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3049 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3051 // Render and notify
3052 application.SendNotification();
3053 application.Render();
3055 // Generate a Esc key event. The text field should lose the focus.
3056 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3057 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3059 // Render and notify
3060 application.SendNotification();
3061 application.Render();
3063 // Generate a Esc key event. The text field should lose the focus.
3064 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3065 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3067 // Render and notify
3068 application.SendNotification();
3069 application.Render();
3071 // The text shouldn't be deleted.
3072 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
3077 int utcDaliTextFieldSizeUpdate(void)
3079 ToolkitTestApplication application;
3080 tet_infoline("utcDaliTextFieldSizeUpdate");
3082 // Checks some special keys when the text is selected.
3083 TextField field = TextField::New();
3084 DALI_TEST_CHECK( field );
3085 application.GetScene().Add( field );
3087 float previousHeight = 0.0f;
3088 float currentHeight = 0.0f;
3089 const float fieldWidth = 1920.0f;
3092 // "ㅁ" is bigger then "ኢ"
3093 field.SetProperty( Actor::Property::SIZE, Vector2( fieldWidth ,10.0f ) );
3094 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
3095 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
3097 field.SetProperty( TextField::Property::TEXT, "ኢ");
3098 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3099 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3101 field.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
3102 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
3104 application.SendNotification();
3105 application.Render();
3107 previousHeight = field.GetHeightForWidth( fieldWidth );
3108 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
3110 // Add another script characters ( glyph height is defferent )
3111 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3112 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3114 application.SendNotification();
3115 application.Render();
3117 currentHeight = field.GetHeightForWidth( fieldWidth );
3118 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
3119 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
3124 int utcDaliTextFieldExtremlyLargePointSize(void)
3126 ToolkitTestApplication application;
3127 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
3129 TextField field = TextField::New();
3131 field.SetProperty( TextField::Property::TEXT, "Text" );
3132 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3133 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3134 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3135 application.GetScene().Add( field );
3139 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
3140 application.SendNotification();
3141 DALI_TEST_CHECK( field );
3145 tet_result(TET_FAIL);
3150 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
3152 ToolkitTestApplication application;
3153 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
3154 TextField field = TextField::New();
3155 DALI_TEST_CHECK( field );
3156 application.GetScene().Add( field );
3158 Property::Map fontStyleMapGet;
3160 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
3162 Property::Value* weightValue = NULL;
3163 Property::Value* widthValue = NULL;
3164 Property::Value* slantValue = NULL;
3165 weightValue = fontStyleMapGet.Find( "weight" );
3166 widthValue = fontStyleMapGet.Find( "width" );
3167 slantValue = fontStyleMapGet.Find( "slant" );
3168 DALI_TEST_CHECK( !weightValue );
3169 DALI_TEST_CHECK( !widthValue );
3170 DALI_TEST_CHECK( !slantValue );
3175 int UtcDaliTextFieldSettingPlaceholder(void)
3177 ToolkitTestApplication application;
3178 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
3180 TextField field = TextField::New();
3181 DALI_TEST_CHECK( field );
3182 application.GetScene().Add( field );
3184 // Check the placeholder property with pixel size
3185 Property::Map placeholderPixelSizeMapSet;
3186 Property::Map placeholderPixelSizeMapGet;
3187 Property::Map placeholderFontstyleMap;
3188 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
3189 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
3190 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
3191 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
3192 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
3193 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
3195 placeholderFontstyleMap.Insert( "weight", "bold" );
3196 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3197 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
3199 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3200 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
3201 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
3203 // Check the placeholder property with point size
3204 Property::Map placeholderMapSet;
3205 Property::Map placeholderMapGet;
3206 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
3207 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
3208 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
3209 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
3210 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
3211 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
3213 // Check the placeholder font style property
3214 placeholderFontstyleMap.Clear();
3216 placeholderFontstyleMap.Insert( "weight", "bold" );
3217 placeholderFontstyleMap.Insert( "width", "condensed" );
3218 placeholderFontstyleMap.Insert( "slant", "italic" );
3219 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3220 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3222 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3223 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3224 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3226 // Reset font style.
3227 placeholderFontstyleMap.Clear();
3228 placeholderFontstyleMap.Insert( "weight", "normal" );
3229 placeholderFontstyleMap.Insert( "slant", "oblique" );
3230 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3231 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3233 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3234 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3235 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3237 placeholderFontstyleMap.Clear();
3238 placeholderFontstyleMap.Insert( "slant", "roman" );
3239 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3240 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3242 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3244 placeholderFontstyleMap.Clear();
3245 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3247 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3248 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3249 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3250 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3255 int UtcDaliTextFieldPlaceholderCoverage(void)
3257 ToolkitTestApplication application;
3258 tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
3260 // mPlaceholderFont is created only once, so create a new control for coverage.
3261 TextField fieldForCoverage = TextField::New();
3262 DALI_TEST_CHECK(fieldForCoverage);
3263 application.GetScene().Add(fieldForCoverage);
3265 // for SetPlaceholderFontFamily() coverage.
3266 Property::Map fontFamilyMap;
3267 fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3268 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
3270 // mPlaceholderFont is created only once, so create a new control for coverage.
3271 fieldForCoverage = TextField::New();
3272 DALI_TEST_CHECK(fieldForCoverage);
3273 application.GetScene().Add(fieldForCoverage);
3275 // for SetPlaceholderTextFontSize coverage.
3276 Property::Map fontSizeMap;
3277 fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3278 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
3280 // mPlaceholderFont is created only once, so create a new control for coverage.
3281 fieldForCoverage = TextField::New();
3282 DALI_TEST_CHECK(fieldForCoverage);
3283 application.GetScene().Add(fieldForCoverage);
3285 // for SetPlaceholderTextFontWeight coverage.
3286 Property::Map fontStyleWeightMap;
3287 Property::Map fontStyleWeightPropertyMap;
3288 fontStyleWeightPropertyMap.Insert("weight", "bold");
3289 fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
3290 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
3292 // mPlaceholderFont is created only once, so create a new control for coverage.
3293 fieldForCoverage = TextField::New();
3294 DALI_TEST_CHECK(fieldForCoverage);
3295 application.GetScene().Add(fieldForCoverage);
3297 // for SetPlaceholderTextFontWidth coverage.
3298 Property::Map fontStyleWidthMap;
3299 Property::Map fontStyleWidthPropertyMap;
3300 fontStyleWidthPropertyMap.Insert("width", "expanded");
3301 fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
3302 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
3304 // mPlaceholderFont is created only once, so create a new control for coverage.
3305 fieldForCoverage = TextField::New();
3306 DALI_TEST_CHECK(fieldForCoverage);
3307 application.GetScene().Add(fieldForCoverage);
3309 // for SetPlaceholderTextFontSlant coverage.
3310 Property::Map fontStyleSlantMap;
3311 Property::Map fontStyleSlantPropertyMap;
3312 fontStyleSlantPropertyMap.Insert("slant", "italic");
3313 fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
3314 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
3319 int UtcDaliTextFieldSetPaddingProperty(void)
3321 ToolkitTestApplication application;
3322 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3324 TextField field = TextField::New();
3325 DALI_TEST_CHECK( field );
3326 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3327 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3328 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3329 application.GetScene().Add( field );
3331 application.SendNotification();
3332 application.Render();
3334 Vector3 originalSize = field.GetNaturalSize();
3336 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
3338 application.SendNotification();
3339 application.Render();
3341 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
3343 Vector3 paddingAddedSize = field.GetNaturalSize();
3345 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3347 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3352 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3354 ToolkitTestApplication application;
3355 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3357 TextField field = TextField::New();
3358 DALI_TEST_CHECK( field );
3359 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3360 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3361 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3362 application.GetScene().Add( field );
3364 application.SendNotification();
3365 application.Render();
3367 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3368 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
3370 // Check the enable shift selection property
3371 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
3372 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
3374 application.SendNotification();
3375 application.Render();
3380 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3382 ToolkitTestApplication application;
3383 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3385 TextField field = TextField::New();
3386 DALI_TEST_CHECK( field );
3387 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3388 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3389 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3390 application.GetScene().Add( field );
3392 application.SendNotification();
3393 application.Render();
3395 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3396 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
3398 // Check the enable grab handle property
3399 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
3400 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
3402 application.SendNotification();
3403 application.Render();
3408 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
3410 ToolkitTestApplication application;
3411 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
3413 TextField field = TextField::New();
3414 DALI_TEST_CHECK( field );
3415 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3416 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3417 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3418 application.GetScene().Add( field );
3420 application.SendNotification();
3421 application.Render();
3423 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3424 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
3426 // Check the match system language direction property
3427 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
3428 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
3430 application.SendNotification();
3431 application.Render();
3436 int utcDaliTextFieldLayoutDirectionCoverage(void)
3438 ToolkitTestApplication application;
3439 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
3441 // Creates a tap event. After creating a tap event the text field should
3442 // have the focus and add text with key events should be possible.
3443 TextField field = TextField::New();
3444 DALI_TEST_CHECK( field );
3446 application.GetScene().Add( field );
3448 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3449 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3450 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3452 // Avoid a crash when core load gl resources.
3453 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3455 // Render and notify
3456 application.SendNotification();
3457 application.Render();
3459 // init direction for coverage
3460 // Set horizontal alignment END
3461 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3463 // Create a tap event to touch the text field.
3464 TestGenerateTap( application, 150.0f, 25.0f );
3466 // Render and notify
3467 application.SendNotification();
3468 application.Render();
3470 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
3471 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
3472 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
3474 // Set horizontal alignment BEGIN
3475 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
3477 // Create a tap event to touch the text field.
3478 TestGenerateTap( application, 150.0f, 25.0f );
3480 // Render and notify
3481 application.SendNotification();
3482 application.Render();
3484 // Set horizontal alignment CENTER
3485 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
3487 // Create a tap event to touch the text field.
3488 TestGenerateTap( application, 150.0f, 25.0f );
3490 // Render and notify
3491 application.SendNotification();
3492 application.Render();
3494 // Set horizontal alignment END
3495 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3497 // Create a tap event to touch the text field.
3498 TestGenerateTap( application, 150.0f, 25.0f );
3500 // Render and notify
3501 application.SendNotification();
3502 application.Render();
3504 // Generate a Esc key event. The text field should lose the focus.
3505 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3506 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3508 // Render and notify
3509 application.SendNotification();
3510 application.Render();
3512 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
3517 int UtcDaliTextFieldGetInputMethodContext(void)
3519 ToolkitTestApplication application;
3520 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
3522 TextField field = TextField::New();
3523 DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );
3528 int UtcDaliTextFieldSelectWholeText(void)
3530 ToolkitTestApplication application;
3531 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3533 TextField textField = TextField::New();
3535 application.GetScene().Add( textField );
3537 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3538 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3539 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3541 // Avoid a crash when core load gl resources.
3542 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3544 application.SendNotification();
3545 application.Render();
3547 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
3549 DevelTextField::SelectWholeText( textField );
3551 application.SendNotification();
3552 application.Render();
3554 // Nothing should have been selected. The number of children is still 1
3555 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
3557 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3559 application.SendNotification();
3560 application.Render();
3562 DevelTextField::SelectWholeText( textField );
3564 application.SendNotification();
3565 application.Render();
3567 // Should be 2 children, the stencil and the layer
3568 DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
3570 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3571 Actor stencil = textField.GetChildAt( 0u );
3573 // The highlight actor is drawn first, so is the first actor in the list
3574 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3575 DALI_TEST_CHECK( highlight );
3580 int UtcDaliTextFieldSelectText(void)
3582 ToolkitTestApplication application;
3583 tet_infoline(" UtcDaliTextFieldSelectText ");
3585 TextField textField = TextField::New();
3587 application.GetScene().Add( textField );
3589 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3590 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3591 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3593 // Avoid a crash when core load gl resources.
3594 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3596 application.SendNotification();
3597 application.Render();
3599 DevelTextField::SelectText( textField, 0, 5 );
3601 application.SendNotification();
3602 application.Render();
3604 // Nothing is selected
3605 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3606 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3608 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3610 application.SendNotification();
3611 application.Render();
3613 // Hello is selected
3614 DevelTextField::SelectText( textField, 0, 5 );
3616 application.SendNotification();
3617 application.Render();
3619 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3620 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3622 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3623 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3625 // world is selected
3626 DevelTextField::SelectText( textField, 6, 11 );
3628 application.SendNotification();
3629 application.Render();
3631 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3632 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3634 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3635 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3640 int UtcDaliTextFieldSelectNone(void)
3642 ToolkitTestApplication application;
3643 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3645 TextField textField = TextField::New();
3647 application.GetScene().Add( textField );
3649 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3650 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3651 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3653 // Avoid a crash when core load gl resources.
3654 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3656 application.SendNotification();
3657 application.Render();
3659 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3661 application.SendNotification();
3662 application.Render();
3664 // Nothing is selected
3665 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3666 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3668 DevelTextField::SelectWholeText( textField );
3670 application.SendNotification();
3671 application.Render();
3673 // whole text is selected
3674 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3675 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3677 DevelTextField::SelectNone( textField );
3679 application.SendNotification();
3680 application.Render();
3682 // Nothing is selected
3683 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3684 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3689 int UtcDaliTextFieldSelectRange(void)
3691 ToolkitTestApplication application;
3692 tet_infoline(" UtcDaliTextFieldSelectRange ");
3694 TextField textField = TextField::New();
3696 application.GetScene().Add( textField );
3698 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3699 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3700 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3702 // Avoid a crash when core load gl resources.
3703 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3705 application.SendNotification();
3706 application.Render();
3708 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3710 application.SendNotification();
3711 application.Render();
3713 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 0);
3714 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 5);
3716 // Hello is selected
3717 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3718 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3720 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3721 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3723 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 6);
3724 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 11);
3726 // world is selected
3727 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3728 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3730 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3731 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3736 int UtcDaliTextFieldEnableEditing(void)
3738 ToolkitTestApplication application;
3739 tet_infoline(" UtcDaliTextFieldEnableEditing ");
3741 TextField textField = TextField::New();
3743 application.GetScene().Add( textField );
3745 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3746 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3747 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3749 // Avoid a crash when core load gl resources.
3750 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3752 application.SendNotification();
3753 application.Render();
3755 textField.SetKeyInputFocus();
3756 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, false );
3757 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3759 // Render and notify
3760 application.SendNotification();
3761 application.Render();
3763 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3764 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3767 textField.SetKeyInputFocus();
3768 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
3769 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3771 // Render and notify
3772 application.SendNotification();
3773 application.Render();
3775 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3776 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3781 int UtcDaliToolkitTextFieldFontSizeScale(void)
3783 ToolkitTestApplication application;
3784 tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
3786 TextField textField = TextField::New();
3787 textField.SetProperty( TextField::Property::POINT_SIZE, 30.f );
3788 textField.SetProperty( TextField::Property::TEXT, "Test" );
3789 Vector3 nonScaledSize = textField.GetNaturalSize();
3791 TextField textFieldScaled = TextField::New();
3792 textFieldScaled.SetProperty( TextField::Property::POINT_SIZE, 15.f );
3793 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3794 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3795 Vector3 scaledSize = textFieldScaled.GetNaturalSize();
3797 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3799 textField.SetProperty( TextField::Property::PIXEL_SIZE, 30.f );
3800 textField.SetProperty( TextField::Property::TEXT, "Test" );
3801 nonScaledSize = textField.GetNaturalSize();
3803 textFieldScaled.SetProperty( TextField::Property::PIXEL_SIZE, 15.f );
3804 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3805 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3806 scaledSize = textFieldScaled.GetNaturalSize();
3808 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3813 int UtcDaliTextFieldPrimaryCursorPosition(void)
3815 ToolkitTestApplication application;
3816 tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
3818 TextField textField = TextField::New();
3820 application.GetScene().Add( textField );
3822 textField.SetProperty( TextField::Property::TEXT, "ABCEF");
3823 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3824 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3825 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3827 // Avoid a crash when core load gl resources.
3828 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3830 textField.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
3831 application.SendNotification();
3832 application.Render();
3833 textField.SetKeyInputFocus();
3835 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3837 // Render and notify
3838 application.SendNotification();
3839 application.Render();
3841 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3842 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3847 // test max length when set after setting long text
3848 int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
3850 ToolkitTestApplication application;
3851 tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
3852 TextField field = TextField::New();
3853 DALI_TEST_CHECK( field );
3855 application.GetScene().Add( field );
3857 field.SetProperty(TextField::Property::TEXT, "123456789");
3859 const int maxNumberOfCharacters = 3;
3860 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
3862 field.SetKeyInputFocus();
3864 // connect to the text max lengh reached signal.
3865 ConnectionTracker* testTracker = new ConnectionTracker();
3866 bool maxLengthReachedSignal = false;
3867 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
3869 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3870 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3872 DALI_TEST_CHECK( maxLengthReachedSignal );
3874 DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "123456789", TEST_LOCATION );
3881 int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
3883 ToolkitTestApplication application;
3884 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
3886 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3887 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3888 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3890 // Create a text field
3891 TextField textField = TextField::New();
3893 //Set size to avoid automatic eliding
3894 textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3895 //Set very large font-size using point-size
3896 textField.SetProperty( TextField::Property::POINT_SIZE, 1000) ;
3897 //Specify font-family
3898 textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
3899 //Set text to check if appear or not
3900 textField.SetProperty( TextField::Property::TEXT, "A");
3902 application.GetScene().Add( textField );
3904 application.SendNotification();
3905 application.Render();
3906 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3907 Vector3 naturalSize = textField.GetNaturalSize();
3909 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3910 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3915 int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
3917 ToolkitTestApplication application;
3918 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
3920 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3921 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3922 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3924 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3925 // Create a text editor
3926 TextField textField = TextField::New();
3928 //Set size to avoid automatic eliding
3929 textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3930 textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
3931 textField.SetProperty( TextField::Property::TEXT, "A");
3933 const int numberOfCases = 6;
3934 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
3936 for (int index=0; index < numberOfCases; index++)
3938 tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
3939 textField.SetProperty( TextField::Property::POINT_SIZE, arrayCases[index]) ;
3940 application.GetScene().Add( textField );
3941 application.SendNotification();
3942 application.Render();
3943 naturalSize = textField.GetNaturalSize();
3944 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3945 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3952 int UtcDaliToolkitTextFieldEllipsisPositionProperty(void)
3954 ToolkitTestApplication application;
3955 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty ");
3956 TextField textField = TextField::New();
3958 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Default is END");
3959 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3961 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START");
3962 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
3963 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3965 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE");
3966 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
3967 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3969 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END");
3970 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
3971 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3973 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START using integer");
3974 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 1);
3975 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3977 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE using integer");
3978 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 2);
3979 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3981 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END using integer");
3982 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 0);
3983 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3985 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
3986 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "START");
3987 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3989 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
3990 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "MIDDLE");
3991 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3993 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
3994 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "END");
3995 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3997 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
3998 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "start");
3999 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4001 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4002 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "middle");
4003 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4005 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4006 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "end");
4007 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4012 int UtcDaliTextFieldCopyText(void)
4014 ToolkitTestApplication application;
4015 tet_infoline(" UtcDaliTextFieldCopyText ");
4017 TextField textField = TextField::New();
4019 std::string selectedText = "";
4020 std::string copiedText = "";
4022 application.GetScene().Add( textField );
4024 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4025 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4026 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4028 // Avoid a crash when core load gl resources.
4029 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4031 application.SendNotification();
4032 application.Render();
4034 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
4036 application.SendNotification();
4037 application.Render();
4039 // Hello is selected
4040 DevelTextField::SelectText( textField, 0, 5 );
4042 application.SendNotification();
4043 application.Render();
4045 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4046 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4048 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4049 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4052 copiedText = DevelTextField::CopyText( textField );
4053 DALI_TEST_EQUALS( "Hello", copiedText, TEST_LOCATION );
4055 // world is selected
4056 DevelTextField::SelectText( textField, 6, 11 );
4058 application.SendNotification();
4059 application.Render();
4061 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4062 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
4064 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
4065 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
4068 copiedText = DevelTextField::CopyText( textField );
4069 DALI_TEST_EQUALS( "world", copiedText, TEST_LOCATION );
4071 // "lo wo" is selected
4072 DevelTextField::SelectText( textField, 3, 8 );
4074 application.SendNotification();
4075 application.Render();
4077 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4078 DALI_TEST_EQUALS( "lo wo", selectedText, TEST_LOCATION );
4080 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 3, TEST_LOCATION );
4081 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 8, TEST_LOCATION );
4083 // "lo wo" is copied
4084 copiedText = DevelTextField::CopyText( textField );
4085 DALI_TEST_EQUALS( "lo wo", copiedText, TEST_LOCATION );
4090 int UtcDaliTextFieldCutText(void)
4092 ToolkitTestApplication application;
4093 tet_infoline(" UtcDaliTextFieldCutText ");
4095 TextField textField = TextField::New();
4097 std::string selectedText = "";
4099 application.GetScene().Add( textField );
4101 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4102 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4103 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4105 // Avoid a crash when core load gl resources.
4106 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4108 application.SendNotification();
4109 application.Render();
4111 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
4113 application.SendNotification();
4114 application.Render();
4116 // Hello is selected
4117 DevelTextField::SelectText( textField, 0, 5 );
4119 application.SendNotification();
4120 application.Render();
4122 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4123 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4125 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4126 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4129 DALI_TEST_EQUALS( "Hello", DevelTextField::CutText( textField ), TEST_LOCATION );
4131 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), " world", TEST_LOCATION );
4134 DevelTextField::SelectText( textField, 0, 2 );
4136 application.SendNotification();
4137 application.Render();
4139 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4140 DALI_TEST_EQUALS( " w", selectedText, TEST_LOCATION );
4142 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4143 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4146 DALI_TEST_EQUALS( " w", DevelTextField::CutText( textField ), TEST_LOCATION );
4148 application.SendNotification();
4149 application.Render();
4151 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "orld", TEST_LOCATION );
4153 // Test Cut from the middle
4156 DevelTextField::SelectText( textField, 1, 3 );
4158 application.SendNotification();
4159 application.Render();
4161 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4162 DALI_TEST_EQUALS( "rl", selectedText, TEST_LOCATION );
4164 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4165 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 3, TEST_LOCATION );
4168 DALI_TEST_EQUALS( "rl", DevelTextField::CutText( textField ), TEST_LOCATION );
4170 application.SendNotification();
4171 application.Render();
4173 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "od", TEST_LOCATION );
4175 // Test Cut from the end
4178 DevelTextField::SelectText( textField, 1, 2 );
4180 application.SendNotification();
4181 application.Render();
4183 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4184 DALI_TEST_EQUALS( "d", selectedText, TEST_LOCATION );
4186 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4187 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4190 DALI_TEST_EQUALS( "d", DevelTextField::CutText( textField ), TEST_LOCATION );
4192 application.SendNotification();
4193 application.Render();
4195 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "o", TEST_LOCATION );
4200 int UtcDaliTextFieldPasteText(void)
4202 ToolkitTestApplication application;
4203 tet_infoline(" UtcDaliTextFieldPasteText ");
4205 TextField textField = TextField::New();
4207 application.GetScene().Add( textField );
4209 std::string cutText = "";
4210 std::string copiedText = "";
4212 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4213 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4214 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4216 // Avoid a crash when core load gl resources.
4217 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4219 application.SendNotification();
4220 application.Render();
4222 textField.SetProperty( TextField::Property::TEXT, "Hello World" );
4224 application.SendNotification();
4225 application.Render();
4227 // Tap on the text editor
4228 TestGenerateTap( application, 3.0f, 25.0f );
4230 // Render and notify
4231 application.SendNotification();
4232 application.Render();
4234 // Select some text in the right of the current cursor position
4235 DevelTextField::SelectText( textField, 0, 3 );
4237 // Render and notify
4238 application.SendNotification();
4239 application.Render();
4241 // Cut the selected text
4242 cutText = DevelTextField::CutText(textField);
4244 // Render and notify
4245 application.SendNotification();
4246 application.Render();
4248 DALI_TEST_EQUALS( "Hel", cutText, TEST_LOCATION );
4249 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "lo World", TEST_LOCATION );
4251 DevelTextField::SelectText( textField, 0, 3 );
4253 // Render and notify
4254 application.SendNotification();
4255 application.Render();
4257 // Copy the selected text
4258 copiedText = DevelTextField::CopyText(textField);
4260 // Render and notify
4261 application.SendNotification();
4262 application.Render();
4264 DALI_TEST_EQUALS( "lo ", copiedText, TEST_LOCATION );
4265 DALI_TEST_EQUALS( "lo World", textField.GetProperty<std::string>( TextField::Property::TEXT ), TEST_LOCATION );
4267 // Move the cursor to the end of the line
4268 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4269 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4270 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4271 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4272 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4273 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4274 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4275 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4277 // Render and notify
4278 application.SendNotification();
4279 application.Render();
4281 // Paste the selected text at the current cursor position
4282 DevelTextField::PasteText(textField);
4284 // Render and notify
4285 application.SendNotification();
4286 application.Render();
4288 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "lo Worldlo ", TEST_LOCATION );
4292 int utcDaliTextFieldCursorPositionChangedSignal(void)
4294 ToolkitTestApplication application;
4295 tet_infoline(" utcDaliTextFieldCursorPositionChangedSignal");
4297 TextField field = TextField::New();
4298 DALI_TEST_CHECK( field );
4300 application.GetScene().Add( field );
4302 // connect to the selection changed signal.
4303 ConnectionTracker* testTracker = new ConnectionTracker();
4304 DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
4305 bool cursorPositionChangedSignal = false;
4306 field.ConnectSignal( testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal) );
4308 field.SetProperty( TextField::Property::TEXT, "Hello world Hello world" );
4309 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
4310 field.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4311 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4312 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4314 // Avoid a crash when core load gl resources.
4315 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4317 // Render and notify
4318 application.SendNotification();
4319 application.Render();
4321 field.SetKeyInputFocus();
4323 // Tap on the text field
4324 TestGenerateTap( application, 3.0f, 25.0f );
4326 // Render and notify
4327 application.SendNotification();
4328 application.Render();
4330 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4331 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4333 gCursorPositionChangedCallbackCalled = false;
4336 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4338 // Render and notify
4339 application.SendNotification();
4340 application.Render();
4342 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4343 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4345 gCursorPositionChangedCallbackCalled = false;
4348 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4350 // Render and notify
4351 application.SendNotification();
4352 application.Render();
4354 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4355 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4357 gCursorPositionChangedCallbackCalled = false;
4359 //delete one character
4360 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4362 // Render and notify
4363 application.SendNotification();
4364 application.Render();
4366 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4367 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4369 gCursorPositionChangedCallbackCalled = false;
4371 field.SetProperty( TextField::Property::TEXT, "Hello" );
4373 // Render and notify
4374 application.SendNotification();
4375 application.Render();
4377 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4378 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4380 gCursorPositionChangedCallbackCalled = false;
4382 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4384 // Render and notify
4385 application.SendNotification();
4386 application.Render();
4388 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4389 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4394 int utcDaliTextFieldSelectionClearedSignal(void)
4396 ToolkitTestApplication application;
4397 tet_infoline(" utcDaliTextFieldSelectionClearedSignal");
4399 TextField field = TextField::New();
4400 DALI_TEST_CHECK( field );
4402 application.GetScene().Add( field );
4404 // connect to the selection changed signal.
4405 ConnectionTracker* testTracker = new ConnectionTracker();
4406 DevelTextField::SelectionClearedSignal(field).Connect(&TestSelectionClearedCallback);
4407 bool selectionClearedSignal = false;
4408 field.ConnectSignal( testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal) );
4410 field.SetProperty( TextField::Property::TEXT, "Hello\nworld\nHello world" );
4411 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
4412 field.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4413 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4414 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4416 // Avoid a crash when core load gl resources.
4417 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4419 // Render and notify
4420 application.SendNotification();
4421 application.Render();
4423 // Tap on the text editor
4424 TestGenerateTap( application, 3.0f, 25.0f );
4426 // Render and notify
4427 application.SendNotification();
4428 application.Render();
4430 // Move to second line of the text & Select some text in the right of the current cursor position
4431 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4432 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4435 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4437 // Render and notify
4438 application.SendNotification();
4439 application.Render();
4441 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4443 // Render and notify
4444 application.SendNotification();
4445 application.Render();
4447 // Tap on the text editor
4448 TestGenerateTap( application, 3.0f, 25.0f );
4450 // Render and notify
4451 application.SendNotification();
4452 application.Render();
4454 gSelectionClearedCallbackCalled = false;
4456 // Move to second line of the text & select.
4457 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4458 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4461 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4463 // Render and notify
4464 application.SendNotification();
4465 application.Render();
4467 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4469 gSelectionClearedCallbackCalled = false;
4471 // Render and notify
4472 application.SendNotification();
4473 application.Render();
4475 // Move to second line of the text & select.
4476 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4477 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4479 // replace D with selected text
4480 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4482 // Render and notify
4483 application.SendNotification();
4484 application.Render();
4486 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4488 gSelectionClearedCallbackCalled = false;
4490 // Render and notify
4491 application.SendNotification();
4492 application.Render();
4494 DevelTextField::SelectText( field ,1, 3 );
4496 // Render and notify
4497 application.SendNotification();
4498 application.Render();
4500 field.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4502 // Render and notify
4503 application.SendNotification();
4504 application.Render();
4506 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4508 gSelectionClearedCallbackCalled = false;
4510 DevelTextField::SelectText( field ,1, 3 );
4512 // Render and notify
4513 application.SendNotification();
4514 application.Render();
4517 DevelTextField::SelectNone(field);
4519 // Render and notify
4520 application.SendNotification();
4521 application.Render();
4523 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4528 int utcDaliTextFieldSelectionChangedSignal(void)
4530 ToolkitTestApplication application;
4531 tet_infoline(" utcDaliTextFieldSelectionChangedSignal");
4533 TextField field = TextField::New();
4534 DALI_TEST_CHECK( field );
4536 application.GetScene().Add( field );
4538 // connect to the selection changed signal.
4539 ConnectionTracker* testTracker = new ConnectionTracker();
4540 DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
4541 bool selectionChangedSignal = false;
4542 field.ConnectSignal( testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal) );
4544 field.SetProperty( TextField::Property::TEXT, "Hello world Hello world" );
4545 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
4546 field.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4547 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4548 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4550 // Avoid a crash when core load gl resources.
4551 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4553 // Render and notify
4554 application.SendNotification();
4555 application.Render();
4557 // Tap on the text field
4558 TestGenerateTap( application, 3.0f, 25.0f );
4560 // Render and notify
4561 application.SendNotification();
4562 application.Render();
4564 // Select some text in the right of the current cursor position
4565 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4566 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4568 // Render and notify
4569 application.SendNotification();
4570 application.Render();
4572 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4573 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4575 gSelectionChangedCallbackCalled = false;
4577 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4579 // Render and notify
4580 application.SendNotification();
4581 application.Render();
4583 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4584 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4585 DALI_TEST_EQUALS(oldSelectionEnd, 1, TEST_LOCATION);
4587 gSelectionChangedCallbackCalled = false;
4589 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4591 // Render and notify
4592 application.SendNotification();
4593 application.Render();
4595 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4596 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4597 DALI_TEST_EQUALS(oldSelectionEnd, 2, TEST_LOCATION);
4599 gSelectionChangedCallbackCalled = false;
4600 field.SetKeyInputFocus();
4602 // Render and notify
4603 application.SendNotification();
4604 application.Render();
4606 DevelTextField::SelectText( field ,0, 5 );
4608 application.SendNotification();
4609 application.Render();
4611 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4612 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4614 gSelectionChangedCallbackCalled = false;
4616 field.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4618 // Render and notify
4619 application.SendNotification();
4620 application.Render();
4622 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4623 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4624 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
4626 gSelectionChangedCallbackCalled = false;
4629 DevelTextField::SelectWholeText(field);
4631 // Render and notify
4632 application.SendNotification();
4633 application.Render();
4635 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4636 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4638 gSelectionChangedCallbackCalled = false;
4641 DevelTextField::SelectNone(field);
4643 // Render and notify
4644 application.SendNotification();
4645 application.Render();
4647 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4648 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4649 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);