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"
35 using namespace Toolkit;
37 void dali_textfield_startup(void)
39 test_return_value = TET_UNDEF;
42 void dali_textfield_cleanup(void)
44 test_return_value = TET_PASS;
50 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
51 const char* const PROPERTY_NAME_TEXT = "text";
52 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
53 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
54 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
55 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
56 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
57 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
58 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
59 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
60 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
61 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
62 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
63 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
64 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
65 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
66 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
67 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
68 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
69 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
70 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
71 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
72 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
73 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
80 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
81 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
82 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
83 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
84 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
85 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
86 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
88 const char* const PROPERTY_NAME_UNDERLINE = "underline";
89 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
90 const char* const PROPERTY_NAME_SHADOW = "shadow";
91 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
92 const char* const PROPERTY_NAME_EMBOSS = "emboss";
93 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
94 const char* const PROPERTY_NAME_OUTLINE = "outline";
95 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
97 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
98 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
99 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
100 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
101 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
102 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
103 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
104 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
105 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
106 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
107 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
108 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
109 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
111 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
112 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
114 const float RENDER_FRAME_INTERVAL = 16.66f;
116 const unsigned int DEFAULT_FONT_SIZE = 1152u;
117 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
119 const int KEY_RETURN_CODE = 36;
120 const int KEY_A_CODE = 38;
121 const int KEY_D_CODE = 40;
123 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
125 static bool gAnchorClickedCallBackCalled;
126 static bool gAnchorClickedCallBackNotCalled;
127 static bool gTextChangedCallBackCalled;
128 static bool gMaxCharactersCallBackCalled;
129 static bool gInputFilteredAcceptedCallbackCalled;
130 static bool gInputFilteredRejectedCallbackCalled;
131 static bool gInputStyleChangedCallbackCalled;
132 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
134 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
136 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
137 Integration::ResourcePointer resource(bitmap);
138 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
141 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
145 LoadBitmapResource( app.GetPlatform(), width, height );
147 Property::Map propertyMap;
148 propertyMap["filename"] = "image.png";
149 propertyMap["width"] = width;
150 propertyMap["height"] = height;
151 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
152 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
153 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
154 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
155 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
156 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
157 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
158 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
162 * Simulate time passed by.
164 * @note this will always process at least 1 frame (1/60 sec)
166 * @param application Test application instance
167 * @param duration Time to pass in milliseconds.
168 * @return The actual time passed in milliseconds
170 static int Wait(ToolkitTestApplication& application, int duration = 0)
174 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
176 application.SendNotification();
177 application.Render(RENDER_FRAME_INTERVAL);
178 time += RENDER_FRAME_INTERVAL;
184 Dali::Integration::Point GetPointDownInside( Vector2& pos )
186 Dali::Integration::Point point;
187 point.SetState( PointState::DOWN );
188 point.SetScreenPosition( pos );
192 Dali::Integration::Point GetPointUpInside( Vector2& pos )
194 Dali::Integration::Point point;
195 point.SetState( PointState::UP );
196 point.SetScreenPosition( pos );
200 struct CallbackFunctor
202 CallbackFunctor(bool* callbackFlag)
203 : mCallbackFlag( callbackFlag )
209 *mCallbackFlag = true;
214 static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength)
216 tet_infoline(" TestAnchorClickedCallback");
218 gAnchorClickedCallBackNotCalled = false;
220 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
222 gAnchorClickedCallBackCalled = true;
226 static void TestTextChangedCallback( TextField control )
228 tet_infoline(" TestTextChangedCallback");
230 gTextChangedCallBackCalled = true;
233 static void TestMaxLengthReachedCallback( TextField control )
235 tet_infoline(" TestMaxLengthReachedCallback");
237 gMaxCharactersCallBackCalled = true;
240 static void TestInputFilteredCallback(TextField control, Toolkit::InputFilter::Property::Type type)
242 tet_infoline(" TestInputFilteredCallback");
244 if(type == Toolkit::InputFilter::Property::ACCEPTED)
246 gInputFilteredAcceptedCallbackCalled = true;
248 else if(type == Toolkit::InputFilter::Property::REJECTED)
250 gInputFilteredRejectedCallbackCalled = true;
254 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
256 tet_infoline(" TestInputStyleChangedCallback");
258 gInputStyleChangedCallbackCalled = true;
259 gInputStyleMask = mask;
262 // Generate a KeyEvent to send to Core.
263 Integration::KeyEvent GenerateKey( const std::string& keyName,
264 const std::string& logicalKey,
265 const std::string& keyString,
268 unsigned long timeStamp,
269 const Integration::KeyEvent::State& keyState,
270 const std::string& compose = "",
271 const std::string& deviceName = DEFAULT_DEVICE_NAME,
272 const Device::Class::Type& deviceClass = Device::Class::NONE,
273 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
275 return Integration::KeyEvent( keyName,
288 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
290 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
292 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
294 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
296 Property::Value* valueSet = NULL;
297 if ( valueGet.first.type == Property::Key::INDEX )
299 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
303 // Get Key is a string so searching Set Map for a string key
304 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
307 if( NULL != valueSet )
309 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
311 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
314 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
316 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
319 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
321 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
324 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
326 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
329 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
331 Vector2 vector2Get = valueGet.second.Get<Vector2>();
332 Vector2 vector2Set = valueSet->Get<Vector2>();
333 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
336 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
338 Vector4 vector4Get = valueGet.second.Get<Vector4>();
339 Vector4 vector4Set = valueSet->Get<Vector4>();
340 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 );
346 if ( valueGet.first.type == Property::Key::INDEX )
348 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
352 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
364 int UtcDaliToolkitTextFieldConstructorP(void)
366 ToolkitTestApplication application;
367 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
369 DALI_TEST_CHECK( !textField );
373 int UtcDaliToolkitTextFieldNewP(void)
375 ToolkitTestApplication application;
376 tet_infoline(" UtcDaliToolkitTextFieldNewP");
377 TextField textField = TextField::New();
378 DALI_TEST_CHECK( textField );
382 int UtcDaliToolkitTextFieldDownCastP(void)
384 ToolkitTestApplication application;
385 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
386 TextField textField1 = TextField::New();
387 BaseHandle object( textField1 );
389 TextField textField2 = TextField::DownCast( object );
390 DALI_TEST_CHECK( textField2 );
392 TextField textField3 = DownCast< TextField >( object );
393 DALI_TEST_CHECK( textField3 );
397 int UtcDaliToolkitTextFieldDownCastN(void)
399 ToolkitTestApplication application;
400 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
401 BaseHandle uninitializedObject;
402 TextField textField1 = TextField::DownCast( uninitializedObject );
403 DALI_TEST_CHECK( !textField1 );
405 TextField textField2 = DownCast< TextField >( uninitializedObject );
406 DALI_TEST_CHECK( !textField2 );
410 int UtcDaliToolkitTextFieldCopyConstructorP(void)
412 ToolkitTestApplication application;
413 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
414 TextField textField = TextField::New();
415 textField.SetProperty( TextField::Property::TEXT, "Test" );
417 TextField copy( textField );
418 DALI_TEST_CHECK( copy );
419 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
423 int UtcDaliTextFieldMoveConstructor(void)
425 ToolkitTestApplication application;
427 TextField textField = TextField::New();
428 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
429 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
431 TextField moved = std::move( textField );
432 DALI_TEST_CHECK( moved );
433 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
434 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
435 DALI_TEST_CHECK( !textField );
440 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
442 ToolkitTestApplication application;
443 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
444 TextField textField = TextField::New();
445 textField.SetProperty( TextField::Property::TEXT, "Test" );
447 TextField copy = textField;
448 DALI_TEST_CHECK( copy );
449 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
453 int UtcDaliTextFieldMoveAssignment(void)
455 ToolkitTestApplication application;
457 TextField textField = TextField::New();
458 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
459 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
462 moved = std::move( textField );
463 DALI_TEST_CHECK( moved );
464 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
465 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
466 DALI_TEST_CHECK( !textField );
471 int UtcDaliTextFieldNewP(void)
473 ToolkitTestApplication application;
474 tet_infoline(" UtcDaliToolkitTextFieldNewP");
475 TextField textField = TextField::New();
476 DALI_TEST_CHECK( textField );
480 // Positive test case for a method
481 int UtcDaliTextFieldGetPropertyP(void)
483 ToolkitTestApplication application;
484 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
485 TextField field = TextField::New();
486 DALI_TEST_CHECK( field );
488 // Check Property Indices are correct
489 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextField::Property::RENDERING_BACKEND );
490 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
491 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
492 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
493 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
494 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
495 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
496 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
497 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
498 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
499 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
500 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
501 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
502 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
503 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
504 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
505 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
506 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
507 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
508 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
509 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
510 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
511 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
512 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
513 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
514 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
515 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
516 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
517 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
518 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
519 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
520 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
521 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
522 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
523 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
524 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
525 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
526 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
527 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
528 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
529 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
530 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
531 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
532 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
533 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
534 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
535 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
536 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
537 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
538 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
539 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextField::Property::FONT_SIZE_SCALE );
540 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
541 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
542 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
543 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP );
544 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextField::Property::BACKGROUND );
545 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextField::Property::GRAB_HANDLE_COLOR );
546 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FILTER ) == DevelTextField::Property::INPUT_FILTER );
551 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
554 Property::Map imageMap;
555 imageMap[mapKey] =mapValue;
557 field.SetProperty( property , imageMap );
558 Property::Value propValue = field.GetProperty( property );
559 Property::Map* resultMap = propValue.GetMap();
561 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
569 // Positive test case for a method
570 int UtcDaliTextFieldSetPropertyP(void)
572 ToolkitTestApplication application;
573 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
574 TextField field = TextField::New();
575 DALI_TEST_CHECK( field );
576 application.GetScene().Add( field );
578 // Note - we can't check the defaults since the stylesheets are platform-specific
580 // Check the render backend property.
581 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
582 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
584 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
585 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION );
587 // Check text property.
588 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
589 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
591 // Check placeholder text properties.
592 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
593 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
595 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
596 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
598 // Check font properties.
599 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
600 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
602 Property::Map fontStyleMapSet;
603 Property::Map fontStyleMapGet;
604 Property::Value* slantValue = NULL;
606 fontStyleMapSet.Insert( "weight", "bold" );
607 fontStyleMapSet.Insert( "width", "condensed" );
608 fontStyleMapSet.Insert( "slant", "italic" );
609 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
611 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
612 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
613 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
615 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
616 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
618 field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 2.5f );
619 DALI_TEST_EQUALS( field.GetProperty<float>( DevelTextField::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
620 field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 1.0f );
623 fontStyleMapSet.Clear();
624 fontStyleMapSet.Insert( "weight", "normal" );
625 fontStyleMapSet.Insert( "slant", "oblique" );
626 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
628 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
629 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
630 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
632 fontStyleMapSet.Clear();
633 fontStyleMapSet.Insert( "slant", "roman" );
634 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
635 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
637 // Replace 'roman' for 'normal'.
638 slantValue = fontStyleMapGet.Find( "slant" );
639 if( NULL != slantValue )
641 if( "normal" == slantValue->Get<std::string>() )
643 fontStyleMapGet["slant"] = "roman";
646 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
647 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
649 fontStyleMapSet.Clear();
651 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
652 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
653 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
654 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
656 // Check that the MAX_LENGTH property can be correctly set
657 const int maxNumberOfCharacters = 20;
658 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
659 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
661 // Check exceed policy
662 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
663 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
664 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
665 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
667 // Check that the Alignment properties can be correctly set
668 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
669 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
670 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
671 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
673 // Check text's color property
674 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
675 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
677 // Check placeholder text's color property.
678 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
679 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
681 // Check cursor properties
682 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
683 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
684 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
685 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
687 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
688 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
689 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
690 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
691 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
692 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
693 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
694 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
696 // Check scroll properties.
697 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
698 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
699 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
700 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
702 // Check handle images
703 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
704 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
705 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
706 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
707 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
709 // Check handle images
710 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
711 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
712 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
713 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
714 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
715 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
717 // Check the highlight color
718 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
719 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
721 // Decoration bounding box
722 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
723 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
725 // Check the input method setting
726 Property::Map propertyMap;
727 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
728 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
729 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
730 int inputVariation = 1;
731 propertyMap["PANEL_LAYOUT"] = panelLayout;
732 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
733 propertyMap["BUTTON_ACTION"] = buttonAction;
734 propertyMap["VARIATION"] = inputVariation;
735 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
737 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
739 DALI_TEST_CHECK( value.Get( map ) );
742 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
743 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
746 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
747 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
750 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
751 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
754 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
755 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
757 // Check input color property.
758 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
759 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
761 // Check the enable markup property.
762 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
763 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
764 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
766 // Check input font properties.
767 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
768 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
770 fontStyleMapSet.Clear();
771 fontStyleMapSet.Insert( "weight", "bold" );
772 fontStyleMapSet.Insert( "width", "condensed" );
773 fontStyleMapSet.Insert( "slant", "italic" );
775 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
776 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
777 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
778 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
780 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
781 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
783 // Reset input font style.
784 fontStyleMapSet.Clear();
785 fontStyleMapSet.Insert( "weight", "normal" );
786 fontStyleMapSet.Insert( "slant", "oblique" );
788 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
789 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
790 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
791 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
793 fontStyleMapSet.Clear();
794 fontStyleMapSet.Insert( "slant", "roman" );
796 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
797 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
799 // Replace 'roman' for 'normal'.
800 slantValue = fontStyleMapGet.Find( "slant" );
801 if( NULL != slantValue )
803 if( "normal" == slantValue->Get<std::string>() )
805 fontStyleMapGet["slant"] = "roman";
808 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
809 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
811 fontStyleMapSet.Clear();
813 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
814 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
815 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
816 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
818 Property::Map underlineMapSet;
819 Property::Map underlineMapGet;
821 underlineMapSet.Insert( "enable", true );
822 underlineMapSet.Insert( "color", Color::RED );
823 underlineMapSet.Insert( "height", 1 );
825 // Check the underline property
826 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
828 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
829 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
830 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
832 // Check the input underline property
833 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
834 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
836 // Check the shadow property
837 Property::Map shadowMapSet;
838 Property::Map shadowMapGet;
840 shadowMapSet.Insert( "color", Color::GREEN );
841 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
842 shadowMapSet.Insert( "blurRadius", 3.0f );
844 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
846 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
847 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
848 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
850 // Check the input shadow property
851 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
852 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
854 // Check the emboss property
855 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
856 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
858 // Check the input emboss property
859 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
860 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
862 // Check the outline property
864 // Test string type first
865 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
866 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
867 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
869 // Then test the property map type
870 Property::Map outlineMapSet;
871 Property::Map outlineMapGet;
873 outlineMapSet["color"] = Color::RED;
874 outlineMapSet["width"] = 2.0f;
876 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
878 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
879 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
880 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
882 // Check the input outline property
883 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
884 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
886 // Check the hidden input settings property
887 Property::Map hiddenMapSet;
888 Property::Map hiddenMapGet;
889 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
890 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
891 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
892 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
893 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
895 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
896 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
897 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
899 // Check the pixel size of font
900 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
901 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
903 // Check the enable selection property
904 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
905 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
907 // Check the placeholder property with pixel size
908 Property::Map placeholderPixelSizeMapSet;
909 Property::Map placeholderPixelSizeMapGet;
910 Property::Map placeholderFontstyleMap;
911 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
912 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
913 placeholderPixelSizeMapSet["color"] = Color::BLUE;
914 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
915 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
916 placeholderPixelSizeMapSet["ellipsis"] = true;
918 placeholderFontstyleMap.Insert( "weight", "bold" );
919 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
920 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
922 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
923 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
925 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
926 Property::Map placeholderConversionMap;
927 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
928 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
929 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
930 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
931 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
932 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
934 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
936 // Check the placeholder property with point size
937 Property::Map placeholderMapSet;
938 Property::Map placeholderMapGet;
939 placeholderMapSet["text"] = "Setting Placeholder Text";
940 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
941 placeholderMapSet["color"] = Color::RED;
942 placeholderMapSet["fontFamily"] = "Arial";
943 placeholderMapSet["pointSize"] = 12.0f;
944 placeholderMapSet["ellipsis"] = false;
946 // Check the placeholder font style property
947 placeholderFontstyleMap.Clear();
949 placeholderFontstyleMap.Insert( "weight", "bold" );
950 placeholderFontstyleMap.Insert( "width", "condensed" );
951 placeholderFontstyleMap.Insert( "slant", "italic" );
952 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
953 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
955 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
956 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
958 placeholderConversionMap.Clear();
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::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
966 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
969 placeholderFontstyleMap.Clear();
970 placeholderFontstyleMap.Insert( "weight", "normal" );
971 placeholderFontstyleMap.Insert( "slant", "oblique" );
972 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
973 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
975 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
976 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
978 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
979 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
981 placeholderFontstyleMap.Clear();
982 placeholderFontstyleMap.Insert( "slant", "roman" );
983 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
984 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
986 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
988 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
990 placeholderFontstyleMap.Clear();
991 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
992 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
994 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
995 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
996 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
998 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1000 // Check the ellipsis property
1001 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1002 field.SetProperty( TextField::Property::ELLIPSIS, true );
1003 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1005 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
1006 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1008 // Test the ENABLE_GRAB_HANDLE_POPUP property
1009 DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1010 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false );
1011 DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1013 // Check the background property
1014 field.SetProperty( DevelTextField::Property::BACKGROUND, Color::RED );
1015 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::BACKGROUND ), Color::RED, TEST_LOCATION );
1017 //Check handle color
1018 field.SetProperty( DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN );
1019 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
1021 // Check the input filter property
1022 Property::Map inputFilterMapSet;
1023 Property::Map inputFilterMapGet;
1024 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1025 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1027 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1029 inputFilterMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::INPUT_FILTER);
1030 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1033 inputFilterMapSet.Clear();
1034 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1036 application.SendNotification();
1037 application.Render();
1042 // Positive Atlas Text Renderer test
1043 int utcDaliTextFieldAtlasRenderP(void)
1045 ToolkitTestApplication application;
1046 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1047 StyleManager styleManager = StyleManager::Get();
1048 styleManager.ApplyDefaultTheme();
1049 TextField field = TextField::New();
1050 DALI_TEST_CHECK( field );
1052 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1054 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1056 application.GetScene().Add( field );
1060 // Render some text with the shared atlas backend
1061 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1062 application.SendNotification();
1063 application.Render();
1067 tet_result(TET_FAIL);
1072 // Positive test for the anchorClicked signal.
1073 int utcDaliTextFieldAnchorClicked01(void)
1075 ToolkitTestApplication application;
1076 tet_infoline(" utcDaliTextFieldAnchorClicked01");
1077 TextField field = TextField::New();
1078 DALI_TEST_CHECK(field);
1080 application.GetScene().Add(field);
1082 // connect to the anchor clicked signal.
1083 ConnectionTracker* testTracker = new ConnectionTracker();
1084 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1085 bool anchorClickedSignal = false;
1086 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1088 gAnchorClickedCallBackCalled = false;
1089 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1090 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1091 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1092 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1093 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1095 application.SendNotification();
1096 application.Render();
1097 field.SetKeyInputFocus();
1099 // Create a tap event to touch the text field.
1100 TestGenerateTap(application, 5.0f, 25.0f);
1101 application.SendNotification();
1102 application.Render();
1104 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1105 DALI_TEST_CHECK(anchorClickedSignal);
1107 gAnchorClickedCallBackNotCalled = true;
1108 // Tap the outside of anchor, callback should not be called.
1109 TestGenerateTap(application, 150.f, 100.f);
1110 application.SendNotification();
1111 application.Render();
1113 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1118 // Positive test for the anchorClicked signal.
1119 int utcDaliTextFieldAnchorClicked02(void)
1121 ToolkitTestApplication application;
1122 tet_infoline(" utcDaliTextFieldAnchorClicked02");
1123 TextField field = TextField::New();
1124 DALI_TEST_CHECK(field);
1126 application.GetScene().Add(field);
1128 // connect to the anchor clicked signal.
1129 ConnectionTracker* testTracker = new ConnectionTracker();
1130 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1131 bool anchorClickedSignal = false;
1132 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1134 gAnchorClickedCallBackCalled = false;
1135 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1136 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1137 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1138 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1139 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1141 application.SendNotification();
1142 application.Render();
1143 field.SetKeyInputFocus();
1145 // Avoid a crash when core load gl resources.
1146 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1148 // Create a tap event to touch the text field.
1149 TestGenerateTap(application, 30.0f, 25.0f, 100);
1150 application.SendNotification();
1151 application.Render();
1153 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1154 DALI_TEST_CHECK(anchorClickedSignal);
1157 // For coverage InsertTextAnchor, RemoveTextAnchor
1158 // first index insert
1159 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1160 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1161 application.SendNotification();
1162 application.Render();
1164 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1165 application.SendNotification();
1166 application.Render();
1168 gAnchorClickedCallBackCalled = false;
1169 // Create a tap event to touch the text field.
1170 TestGenerateTap(application, 30.0f, 25.0f, 700);
1171 application.SendNotification();
1172 field.SetKeyInputFocus();
1174 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1176 // last index insert
1177 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1178 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1179 application.SendNotification();
1180 application.Render();
1182 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1183 application.SendNotification();
1184 application.Render();
1186 gAnchorClickedCallBackCalled = false;
1187 // Create a tap event to touch the text field.
1188 TestGenerateTap(application, 30.0f, 25.0f, 1300);
1189 application.SendNotification();
1190 field.SetKeyInputFocus();
1192 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1195 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1196 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1197 application.SendNotification();
1198 application.Render();
1200 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1201 application.SendNotification();
1202 application.Render();
1204 gAnchorClickedCallBackCalled = false;
1205 // Create a tap event to touch the text field.
1206 TestGenerateTap(application, 30.0f, 25.0f, 1900);
1207 application.SendNotification();
1208 field.SetKeyInputFocus();
1210 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1212 // first index remove
1213 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1214 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1215 application.SendNotification();
1216 application.Render();
1218 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1219 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));
1220 application.SendNotification();
1221 application.Render();
1223 gAnchorClickedCallBackCalled = false;
1224 // Create a tap event to touch the text field.
1225 TestGenerateTap(application, 30.0f, 25.0f, 2500);
1226 application.SendNotification();
1227 field.SetKeyInputFocus();
1229 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1231 // last index remove
1232 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1233 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1234 application.SendNotification();
1235 application.Render();
1237 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1238 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));
1239 application.SendNotification();
1240 application.Render();
1242 gAnchorClickedCallBackCalled = false;
1243 // Create a tap event to touch the text field.
1244 TestGenerateTap(application, 30.0f, 25.0f, 3100);
1245 application.SendNotification();
1246 application.Render();
1248 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1251 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1252 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1253 application.SendNotification();
1254 application.Render();
1256 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1257 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));
1258 application.SendNotification();
1259 application.Render();
1261 gAnchorClickedCallBackCalled = false;
1262 // Create a tap event to touch the text field.
1263 TestGenerateTap(application, 30.0f, 25.0f, 3700);
1264 application.SendNotification();
1265 application.Render();
1267 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1269 // 0 ~ 1 index remove
1270 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1271 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 0);
1272 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 1);
1273 application.SendNotification();
1274 application.Render();
1276 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1277 application.SendNotification();
1278 application.Render();
1280 gAnchorClickedCallBackCalled = false;
1281 // Create a tap event to touch the text field.
1282 TestGenerateTap(application, 30.0f, 25.0f, 4300);
1283 application.SendNotification();
1284 application.Render();
1286 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1288 // 1 ~ 3 index remove
1289 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1290 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 1);
1291 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 3);
1292 application.SendNotification();
1293 application.Render();
1295 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1296 application.SendNotification();
1297 application.Render();
1299 gAnchorClickedCallBackCalled = false;
1300 // Create a tap event to touch the text field.
1301 TestGenerateTap(application, 30.0f, 25.0f, 4900);
1302 application.SendNotification();
1303 application.Render();
1305 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1307 // 3 ~ 4 index remove
1308 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1309 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 3);
1310 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 4);
1311 application.SendNotification();
1312 application.Render();
1314 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1315 application.SendNotification();
1316 application.Render();
1318 gAnchorClickedCallBackCalled = false;
1319 // Create a tap event to touch the text field.
1320 TestGenerateTap(application, 30.0f, 25.0f, 5500);
1321 application.SendNotification();
1322 application.Render();
1324 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1326 // Remove front of anchor
1327 field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
1328 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
1329 application.SendNotification();
1330 application.Render();
1332 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1333 application.SendNotification();
1334 application.Render();
1336 // Remove whole text
1337 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1338 DevelTextField::SelectWholeText(field);
1339 application.SendNotification();
1340 application.Render();
1342 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1343 application.SendNotification();
1344 application.Render();
1346 // Remove all with backspace
1347 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1348 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
1349 application.SendNotification();
1350 application.Render();
1352 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1353 application.SendNotification();
1354 application.Render();
1356 // Remove all with delete
1357 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1358 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1359 application.SendNotification();
1360 application.Render();
1362 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));
1363 application.SendNotification();
1364 application.Render();
1369 // Positive test for the textChanged signal.
1370 int utcDaliTextFieldTextChangedP(void)
1372 ToolkitTestApplication application;
1373 tet_infoline(" utcDaliTextFieldTextChangedP");
1374 TextField field = TextField::New();
1375 DALI_TEST_CHECK( field );
1377 application.GetScene().Add( field );
1379 // connect to the text changed signal.
1380 ConnectionTracker* testTracker = new ConnectionTracker();
1381 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1382 bool textChangedSignal = false;
1383 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1385 gTextChangedCallBackCalled = false;
1386 field.SetProperty( TextField::Property::TEXT, "ABC" );
1387 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1388 DALI_TEST_CHECK( textChangedSignal );
1390 application.SendNotification();
1391 field.SetKeyInputFocus();
1393 gTextChangedCallBackCalled = false;
1394 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1395 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1398 field.SetProperty( TextField::Property::TEXT, "" );
1400 // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1401 gTextChangedCallBackCalled = false;
1402 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1403 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1405 // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1406 gTextChangedCallBackCalled = false;
1407 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1408 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1413 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1415 ToolkitTestApplication application;
1416 tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1417 TextField field = TextField::New();
1418 DALI_TEST_CHECK( field );
1421 application.GetScene().Add( field );
1423 // connect to the text changed signal.
1424 ConnectionTracker* testTracker = new ConnectionTracker();
1425 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1426 bool textChangedSignal = false;
1427 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1430 // get InputMethodContext
1432 InputMethodContext::EventData imfEvent;
1433 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext( field );
1435 field.SetKeyInputFocus();
1436 field.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
1439 gTextChangedCallBackCalled = false;
1440 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1441 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1442 application.SendNotification();
1443 application.Render();
1444 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1445 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1447 gTextChangedCallBackCalled = false;
1448 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1449 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1450 application.SendNotification();
1451 application.Render();
1452 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1453 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호"), TEST_LOCATION );
1455 gTextChangedCallBackCalled = false;
1456 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1457 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1458 application.SendNotification();
1459 application.Render();
1460 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1461 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1463 gTextChangedCallBackCalled = false;
1464 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1465 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1466 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1468 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1469 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1470 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1472 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1473 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1474 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1476 application.SendNotification();
1477 application.Render();
1478 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1479 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1485 // Negative test for the textChanged signal.
1486 int utcDaliTextFieldTextChangedN(void)
1488 ToolkitTestApplication application;
1489 tet_infoline(" utcDaliTextFieldTextChangedN");
1490 TextField field = TextField::New();
1491 DALI_TEST_CHECK( field );
1493 application.GetScene().Add( field );
1495 // connect to the text changed signal.
1496 ConnectionTracker* testTracker = new ConnectionTracker();
1497 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1498 bool textChangedSignal = false;
1499 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1501 gTextChangedCallBackCalled = false;
1502 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1503 application.SendNotification();
1504 application.Render();
1505 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1506 DALI_TEST_CHECK( !textChangedSignal );
1511 // Positive test for Max Characters reached signal.
1512 int utcDaliTextFieldMaxCharactersReachedP(void)
1514 ToolkitTestApplication application;
1515 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1516 TextField field = TextField::New();
1517 DALI_TEST_CHECK( field );
1519 application.GetScene().Add( field );
1521 const int maxNumberOfCharacters = 1;
1522 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1524 field.SetKeyInputFocus();
1526 // connect to the text changed signal.
1527 ConnectionTracker* testTracker = new ConnectionTracker();
1528 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1529 bool maxLengthReachedSignal = false;
1530 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1532 gMaxCharactersCallBackCalled = false;
1534 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1535 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1537 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1538 DALI_TEST_CHECK( maxLengthReachedSignal );
1543 // Negative test for Max Characters reached signal.
1544 int utcDaliTextFieldMaxCharactersReachedN(void)
1546 ToolkitTestApplication application;
1547 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1548 TextField field = TextField::New();
1549 DALI_TEST_CHECK( field );
1551 application.GetScene().Add( field );
1553 const int maxNumberOfCharacters = 3;
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 );
1572 application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1574 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1575 DALI_TEST_CHECK( !maxLengthReachedSignal );
1580 // Positive test for Input Filtered signal.
1581 int utcDaliTextFieldInputFilteredP(void)
1583 ToolkitTestApplication application;
1584 tet_infoline(" utcDaliTextFieldInputFilteredP");
1585 TextField field = TextField::New();
1586 DALI_TEST_CHECK(field);
1588 application.GetScene().Add(field);
1590 Property::Map inputFilter;
1592 // Only digit is accepted.
1593 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1595 // Set input filter to TextField.
1596 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1598 field.SetKeyInputFocus();
1600 // connect to the input filtered signal.
1601 ConnectionTracker* testTracker = new ConnectionTracker();
1602 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1603 bool inputFilteredSignal = false;
1604 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1606 gInputFilteredAcceptedCallbackCalled = false;
1608 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ));
1610 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1611 DALI_TEST_CHECK(inputFilteredSignal);
1613 // Word is rejected.
1614 inputFilter[InputFilter::Property::ACCEPTED] = "";
1615 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1617 // Set input filter to TextField.
1618 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1620 field.SetKeyInputFocus();
1622 inputFilteredSignal = false;
1623 gInputFilteredRejectedCallbackCalled = false;
1625 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1627 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1628 DALI_TEST_CHECK(inputFilteredSignal);
1633 // Negative test for Input Filtered signal.
1634 int utcDaliTextFieldInputFilteredN(void)
1636 ToolkitTestApplication application;
1637 tet_infoline(" utcDaliTextFieldInputFilteredP");
1638 TextField field = TextField::New();
1639 DALI_TEST_CHECK(field);
1641 application.GetScene().Add(field);
1643 Property::Map inputFilter;
1645 // Only word is accepted.
1646 inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
1648 // Set input filter to TextField.
1649 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1651 field.SetKeyInputFocus();
1653 // connect to the input filtered signal.
1654 ConnectionTracker* testTracker = new ConnectionTracker();
1655 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1656 bool inputFilteredSignal = false;
1657 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1659 gInputFilteredAcceptedCallbackCalled = false;
1661 // Key a, d should not be filtered.
1662 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1663 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1664 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1665 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1667 // Backspace, Delete should not be filtered.
1668 application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1669 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));
1671 // Render and notify
1672 application.SendNotification();
1673 application.Render();
1675 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1676 DALI_TEST_CHECK(!inputFilteredSignal);
1678 // Digit is rejected.
1679 inputFilter[InputFilter::Property::ACCEPTED] = "";
1680 inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
1682 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1684 field.SetKeyInputFocus();
1686 inputFilteredSignal = false;
1687 gInputFilteredRejectedCallbackCalled = false;
1689 // Key a, d should not be filtered.
1690 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1691 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1692 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1693 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1695 // Backspace, Delete should not be filtered.
1696 application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1697 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));
1699 // Render and notify
1700 application.SendNotification();
1701 application.Render();
1703 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1704 DALI_TEST_CHECK(!inputFilteredSignal);
1709 int utcDaliTextFieldInputStyleChanged01(void)
1711 // The text-field emits signals when the input style changes. These changes of style are
1712 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1713 // can't be emitted during the size negotiation as the callbacks may update the UI.
1714 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1715 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1716 ToolkitTestApplication application;
1717 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1721 char* pathNamePtr = get_current_dir_name();
1722 const std::string pathName( pathNamePtr );
1723 free( pathNamePtr );
1725 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1726 fontClient.SetDpi( 93u, 93u );
1728 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1729 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1731 TextField field = TextField::New();
1732 DALI_TEST_CHECK( field );
1735 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1736 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1737 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1739 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1740 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1742 // connect to the text changed signal.
1743 ConnectionTracker* testTracker = new ConnectionTracker();
1744 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1745 bool inputStyleChangedSignal = false;
1746 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1748 application.GetScene().Add( field );
1750 // Render and notify
1751 application.SendNotification();
1752 application.Render();
1754 // Executes the idle callbacks added by the text control on the change of input style.
1755 application.RunIdles();
1757 gInputStyleChangedCallbackCalled = false;
1758 gInputStyleMask = TextField::InputStyle::NONE;
1759 inputStyleChangedSignal = false;
1761 // Create a tap event to touch the text field.
1762 TestGenerateTap( application, 18.0f, 25.0f );
1764 // Render and notify
1765 application.SendNotification();
1766 application.Render();
1768 // Executes the idle callbacks added by the text control on the change of input style.
1769 application.RunIdles();
1771 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1772 if( gInputStyleChangedCallbackCalled )
1774 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1776 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1777 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1779 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1780 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1782 DALI_TEST_CHECK( inputStyleChangedSignal );
1784 gInputStyleChangedCallbackCalled = false;
1785 gInputStyleMask = TextField::InputStyle::NONE;
1786 inputStyleChangedSignal = false;
1788 // Create a tap event to touch the text field.
1789 TestGenerateTap( application, 30.0f, 25.0f );
1791 // Render and notify
1792 application.SendNotification();
1793 application.Render();
1795 // Executes the idle callbacks added by the text control on the change of input style.
1796 application.RunIdles();
1798 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1799 DALI_TEST_CHECK( !inputStyleChangedSignal );
1801 gInputStyleChangedCallbackCalled = false;
1802 gInputStyleMask = TextField::InputStyle::NONE;
1803 inputStyleChangedSignal = false;
1805 // Create a tap event to touch the text field.
1806 TestGenerateTap( application, 43.0f, 25.0f );
1808 // Render and notify
1809 application.SendNotification();
1810 application.Render();
1812 // Executes the idle callbacks added by the text control on the change of input style.
1813 application.RunIdles();
1815 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1816 if( gInputStyleChangedCallbackCalled )
1818 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1820 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1821 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1823 DALI_TEST_CHECK( inputStyleChangedSignal );
1825 gInputStyleChangedCallbackCalled = false;
1826 gInputStyleMask = TextField::InputStyle::NONE;
1827 inputStyleChangedSignal = false;
1829 // Create a tap event to touch the text field.
1830 TestGenerateTap( application, 88.0f, 25.0f );
1832 // Render and notify
1833 application.SendNotification();
1834 application.Render();
1836 // Executes the idle callbacks added by the text control on the change of input style.
1837 application.RunIdles();
1839 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1840 if( gInputStyleChangedCallbackCalled )
1842 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1844 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1845 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1847 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1849 Property::Map fontStyleMapSet;
1850 fontStyleMapSet.Insert( "weight", "bold" );
1852 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1853 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, 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, 115.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 DALI_TEST_CHECK( !inputStyleChangedSignal );
1874 gInputStyleChangedCallbackCalled = false;
1875 gInputStyleMask = TextField::InputStyle::NONE;
1876 inputStyleChangedSignal = false;
1878 // Create a tap event to touch the text field.
1879 TestGenerateTap( application, 164.0f, 25.0f );
1881 // Render and notify
1882 application.SendNotification();
1883 application.Render();
1885 // Executes the idle callbacks added by the text control on the change of input style.
1886 application.RunIdles();
1888 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1889 if( gInputStyleChangedCallbackCalled )
1891 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1893 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1894 DALI_TEST_CHECK( style.empty() );
1896 DALI_TEST_CHECK( inputStyleChangedSignal );
1898 gInputStyleChangedCallbackCalled = false;
1899 gInputStyleMask = TextField::InputStyle::NONE;
1900 inputStyleChangedSignal = false;
1902 // Create a tap event to touch the text field.
1903 TestGenerateTap( application, 191.0f, 25.0f );
1905 // Render and notify
1906 application.SendNotification();
1907 application.Render();
1909 // Executes the idle callbacks added by the text control on the change of input style.
1910 application.RunIdles();
1912 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1913 DALI_TEST_CHECK( !inputStyleChangedSignal );
1918 int utcDaliTextFieldInputStyleChanged02(void)
1920 // The text-field emits signals when the input style changes. These changes of style are
1921 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1922 // can't be emitted during the size negotiation as the callbacks may update the UI.
1923 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1924 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1925 ToolkitTestApplication application;
1926 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1930 char* pathNamePtr = get_current_dir_name();
1931 const std::string pathName( pathNamePtr );
1932 free( pathNamePtr );
1934 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1935 fontClient.SetDpi( 93u, 93u );
1937 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1938 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1940 TextField field = TextField::New();
1941 DALI_TEST_CHECK( field );
1943 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1944 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1945 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1947 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1948 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>" );
1950 // connect to the text changed signal.
1951 ConnectionTracker* testTracker = new ConnectionTracker();
1952 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1953 bool inputStyleChangedSignal = false;
1954 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1956 application.GetScene().Add( field );
1958 // Render and notify
1959 application.SendNotification();
1960 application.Render();
1962 // Executes the idle callbacks added by the text control on the change of input style.
1963 application.RunIdles();
1965 gInputStyleChangedCallbackCalled = false;
1966 gInputStyleMask = TextField::InputStyle::NONE;
1967 inputStyleChangedSignal = false;
1969 // Create a tap event to touch the text field.
1970 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1971 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1973 // Render and notify
1974 application.SendNotification();
1975 application.Render();
1977 // Executes the idle callbacks added by the text control on the change of input style.
1978 application.RunIdles();
1980 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1981 if( gInputStyleChangedCallbackCalled )
1983 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1984 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1985 TextField::InputStyle::POINT_SIZE |
1986 TextField::InputStyle::COLOR ),
1989 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1990 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1992 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1993 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1995 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1996 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1998 DALI_TEST_CHECK( inputStyleChangedSignal );
2000 gInputStyleChangedCallbackCalled = false;
2001 gInputStyleMask = TextField::InputStyle::NONE;
2002 inputStyleChangedSignal = false;
2004 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2006 // Render and notify
2007 application.SendNotification();
2008 application.Render();
2010 // Executes the idle callbacks added by the text control on the change of input style.
2011 application.RunIdles();
2013 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2014 if( gInputStyleChangedCallbackCalled )
2016 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2017 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
2020 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2021 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
2023 DALI_TEST_CHECK( inputStyleChangedSignal );
2025 gInputStyleChangedCallbackCalled = false;
2026 gInputStyleMask = TextField::InputStyle::NONE;
2027 inputStyleChangedSignal = false;
2029 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2031 // Render and notify
2032 application.SendNotification();
2033 application.Render();
2035 // Executes the idle callbacks added by the text control on the change of input style.
2036 application.RunIdles();
2038 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
2039 DALI_TEST_CHECK( !inputStyleChangedSignal );
2041 gInputStyleChangedCallbackCalled = false;
2042 gInputStyleMask = TextField::InputStyle::NONE;
2043 inputStyleChangedSignal = false;
2045 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2047 // Render and notify
2048 application.SendNotification();
2049 application.Render();
2051 // Executes the idle callbacks added by the text control on the change of input style.
2052 application.RunIdles();
2054 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2055 if( gInputStyleChangedCallbackCalled )
2057 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2058 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
2061 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2062 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
2064 DALI_TEST_CHECK( inputStyleChangedSignal );
2066 gInputStyleChangedCallbackCalled = false;
2067 gInputStyleMask = TextField::InputStyle::NONE;
2068 inputStyleChangedSignal = false;
2070 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
2072 Property::Map fontStyleMapSet;
2073 fontStyleMapSet.Insert( "weight", "thin" );
2074 fontStyleMapSet.Insert( "width", "condensed" );
2075 fontStyleMapSet.Insert( "slant", "italic" );
2077 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2078 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
2080 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
2081 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
2082 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
2083 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
2085 // Render and notify
2086 application.SendNotification();
2087 application.Render();
2089 // Executes the idle callbacks added by the text control on the change of input style.
2090 application.RunIdles();
2092 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
2093 DALI_TEST_CHECK( !inputStyleChangedSignal );
2095 // Create a tap event to touch the text field.
2096 TestGenerateTap( application, 63.0f, 25.0f, 700 );
2098 // Render and notify
2099 application.SendNotification();
2100 application.Render();
2102 // Executes the idle callbacks added by the text control on the change of input style.
2103 application.RunIdles();
2105 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2106 if( gInputStyleChangedCallbackCalled )
2108 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2109 static_cast<unsigned int>( TextField::InputStyle::COLOR |
2110 TextField::InputStyle::POINT_SIZE |
2111 TextField::InputStyle::FONT_STYLE |
2112 TextField::InputStyle::UNDERLINE |
2113 TextField::InputStyle::SHADOW |
2114 TextField::InputStyle::EMBOSS |
2115 TextField::InputStyle::OUTLINE ),
2118 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2119 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
2121 DALI_TEST_CHECK( inputStyleChangedSignal );
2126 int utcDaliTextFieldEvent01(void)
2128 ToolkitTestApplication application;
2129 tet_infoline(" utcDaliTextFieldEvent01");
2131 // Creates a tap event. After creating a tap event the text field should
2132 // have the focus and add text with key events should be possible.
2134 TextField field = TextField::New();
2135 DALI_TEST_CHECK( field );
2137 application.GetScene().Add( field );
2139 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2140 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2141 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2143 // Render and notify
2144 application.SendNotification();
2145 application.Render();
2147 // Avoid a crash when core load gl resources.
2148 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2150 // Render and notify
2151 application.SendNotification();
2152 application.Render();
2154 // Add a key event but as the text field has not the focus it should do nothing.
2155 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2157 // Render and notify
2158 application.SendNotification();
2159 application.Render();
2161 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2163 // Create a tap event to touch the text field.
2164 TestGenerateTap( application, 150.0f, 25.0f );
2166 // Render and notify
2167 application.SendNotification();
2168 application.Render();
2170 // Pressing delete key should be fine even if there is no text in TextField.
2171 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 ) );
2172 // Render and notify
2173 application.SendNotification();
2174 application.Render();
2176 // Now the text field has the focus, so it can handle the key events.
2177 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2178 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2180 // Render and notify
2181 application.SendNotification();
2182 application.Render();
2184 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2186 // Create a second text field and send key events to it.
2187 TextField field2 = TextField::New();
2189 field2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2190 field2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2191 field2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2192 field2.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
2194 application.GetScene().Add( field2 );
2196 // Render and notify
2197 application.SendNotification();
2198 application.Render();
2200 // Create a tap event on the second text field.
2201 TestGenerateTap( application, 150.0f, 125.0f );
2203 // Render and notify
2204 application.SendNotification();
2205 application.Render();
2207 // The second text field has the focus. It should handle the key events.
2208 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2209 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2211 // Render and notify
2212 application.SendNotification();
2213 application.Render();
2215 // Check the text has been added to the second text field.
2216 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2221 int utcDaliTextFieldEvent02(void)
2223 ToolkitTestApplication application;
2224 tet_infoline(" utcDaliTextFieldEvent02");
2226 // Checks if the right number of actors are created.
2228 TextField field = TextField::New();
2229 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2230 DALI_TEST_CHECK( field );
2231 LoadMarkerImages(application, field);
2233 application.GetScene().Add( field );
2235 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2236 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2237 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2239 // Avoid a crash when core load gl resources.
2240 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2242 // Render and notify
2243 application.SendNotification();
2244 application.Render();
2246 // Check there are the expected number of children ( stencil ).
2247 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
2249 Actor stencil = field.GetChildAt( 0u );
2250 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2252 // Create a tap event to touch the text field.
2253 TestGenerateTap( application, 150.0f, 25.0f, 300 );
2255 // Render and notify
2256 application.SendNotification();
2257 application.Render();
2259 Actor layer = field.GetChildAt( 1u );
2260 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2261 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2263 // Now the text field has the focus, so it can handle the key events.
2264 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2265 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2267 // Render and notify
2268 application.SendNotification();
2269 application.Render();
2271 // Checks the cursor and the renderer have been created.
2272 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2273 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
2275 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
2276 DALI_TEST_CHECK( cursor );
2278 // The offscreen root actor has a container with all the actors which contain the text renderers.
2279 Actor container = stencil.GetChildAt( 0u );
2280 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2282 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2283 DALI_TEST_CHECK( renderer );
2286 // Move the cursor and check the position changes.
2287 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2288 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2290 // Render and notify
2291 application.SendNotification();
2292 application.Render();
2294 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2295 DALI_TEST_CHECK( position2.x < position1.x );
2297 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2299 // Render and notify
2300 application.SendNotification();
2301 application.Render();
2303 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2304 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
2307 // Move the cursor to the first position.
2308 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2309 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2311 // Render and notify
2312 application.SendNotification();
2313 application.Render();
2315 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2317 // Send some taps and check the cursor positions.
2319 // Try to tap at the beginning.
2320 TestGenerateTap( application, 1.0f, 25.0f, 900 );
2322 // Render and notify
2323 application.SendNotification();
2324 application.Render();
2326 // Cursor position should be the same than position1.
2327 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2329 DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
2331 // Tap away from the start position.
2332 TestGenerateTap( application, 16.0f, 25.0f, 1500 );
2334 // Render and notify
2335 application.SendNotification();
2336 application.Render();
2338 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2340 DALI_TEST_CHECK( position6.x > position5.x );
2342 // Remove all the text.
2343 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2344 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2345 field.SetProperty( TextField::Property::TEXT, "" );
2347 // Render and notify
2348 application.SendNotification();
2349 application.Render();
2351 // Cursor position should be the same than position2.
2352 Vector3 position7 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2354 DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
2356 // Should not be a renderer.
2357 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2359 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2360 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2361 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
2363 application.SendNotification();
2364 application.Render();
2366 // There are renderer and decorator layer
2367 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
2372 int utcDaliTextFieldEvent03(void)
2374 ToolkitTestApplication application;
2375 tet_infoline(" utcDaliTextFieldEvent03");
2377 // Checks if the highlight actor is created.
2379 TextField field = TextField::New();
2380 DALI_TEST_CHECK( field );
2382 application.GetScene().Add( field );
2384 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2385 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2386 field.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
2387 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2388 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2390 // Avoid a crash when core load gl resources.
2391 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2392 LoadMarkerImages(application, field);
2394 // Render and notify
2395 application.SendNotification();
2396 application.Render();
2398 // Tap first to get the focus.
2399 TestGenerateTap( application, 3.0f, 25.0f );
2401 // Render and notify
2402 application.SendNotification();
2403 application.Render();
2405 // Double tap to select a word.
2406 TestGenerateTap( application, 3.0f, 25.0f );
2408 // Render and notify
2409 application.SendNotification();
2410 application.Render();
2412 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2413 Actor stencil = field.GetChildAt( 0u );
2415 // The highlight actor is drawn first, so is the first actor in the list
2416 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2417 DALI_TEST_CHECK( highlight );
2419 // The offscreen root actor has a container with all the actors which contain the text renderers.
2420 Actor container = stencil.GetChildAt( 1u );
2421 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2423 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2424 DALI_TEST_CHECK( renderer );
2430 int utcDaliTextFieldEvent04(void)
2432 ToolkitTestApplication application;
2433 tet_infoline(" utcDaliTextFieldEvent04");
2435 // Checks if the highlight actor is created.
2437 TextField field = TextField::New();
2438 DALI_TEST_CHECK( field );
2439 application.GetScene().Add( field );
2440 LoadMarkerImages(application, field);
2441 // Render and notify
2442 application.SendNotification();
2443 application.Render();
2445 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2446 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2447 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2448 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2449 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2451 // Avoid a crash when core load gl resources.
2452 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2453 // Render and notify
2454 application.SendNotification();
2455 application.Render();
2457 // Create a tap event to touch the text field.
2458 TestGenerateTap( application, 150.0f, 25.0f );
2459 // Render and notify
2460 application.SendNotification();
2461 application.Render();
2464 // Tap first to get the focus.
2465 TestGenerateTap( application, 1.0f, 25.0f );
2467 // Render and notify
2468 application.SendNotification();
2469 application.Render();
2471 // Double tap to select a word.
2472 TestGenerateTap( application, 1.0f, 25.0f );
2474 // Render and notify
2475 application.SendNotification();
2476 application.Render();
2479 TestGenerateTap( application, 0.0f, 40.0f );
2483 int utcDaliTextFieldEvent05(void)
2485 ToolkitTestApplication application;
2486 tet_infoline(" utcDaliTextFieldEvent05");
2488 // Checks dragging of cursor/grab handle
2490 TextField field = TextField::New();
2491 DALI_TEST_CHECK( field );
2492 application.GetScene().Add( field );
2493 LoadMarkerImages(application, field);
2494 // Render and notify
2495 application.SendNotification();
2496 application.Render();
2498 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2499 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2500 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2501 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2502 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2504 // Avoid a crash when core load gl resources.
2505 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2506 // Render and notify
2507 application.SendNotification();
2508 application.Render();
2510 // Create a tap event to touch the text field.
2511 TestGenerateTap( application, 150.0f, 25.0f );
2512 // Render and notify
2513 application.SendNotification();
2514 application.Render();
2516 // Tap first to get the focus.
2517 TestGenerateTap( application, 1.0f, 25.0f );
2519 // Render and notify
2520 application.SendNotification();
2521 application.Render();
2523 // Double tap to select a word.
2524 TestGenerateTap( application, 1.0f, 25.0f );
2526 // Render and notify
2527 application.SendNotification();
2528 application.Render();
2530 Actor stencil = field.GetChildAt( 1u );
2534 int utcDaliTextFieldEvent06(void)
2536 ToolkitTestApplication application;
2537 tet_infoline(" utcDaliTextFieldEvent06");
2539 // Checks Longpress when in edit mode
2541 TextField field = TextField::New();
2542 DALI_TEST_CHECK( field );
2543 application.GetScene().Add( field );
2544 LoadMarkerImages(application, field);
2545 // Render and notify
2546 application.SendNotification();
2547 application.Render();
2549 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2550 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2551 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2552 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2553 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2555 // Avoid a crash when core load gl resources.
2556 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2557 // Render and notify
2558 application.SendNotification();
2559 application.Render();
2561 // Create a tap event to touch the text field.
2562 TestGenerateTap( application, 150.0f, 25.0f );
2563 // Render and notify
2564 application.SendNotification();
2565 application.Render();
2568 // Tap first to get the focus.
2569 TestGenerateTap( application, 1.0f, 25.0f );
2571 // Render and notify
2572 application.SendNotification();
2573 application.Render();
2576 TestGenerateLongPress(application, 1.0f, 25.0f);
2578 // Render and notify
2579 application.SendNotification();
2580 application.Render();
2585 int utcDaliTextFieldEvent07(void)
2587 ToolkitTestApplication application;
2588 tet_infoline(" utcDaliTextFieldEvent07");
2590 // Checks Longpress to start edit mode
2592 TextField field = TextField::New();
2593 DALI_TEST_CHECK( field );
2594 application.GetScene().Add( field );
2595 LoadMarkerImages(application, field);
2596 // Render and notify
2597 application.SendNotification();
2598 application.Render();
2600 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2601 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2602 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2603 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2604 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2605 Property::Map propertyMap;
2606 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2607 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2609 // Avoid a crash when core load gl resources.
2610 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2611 // Render and notify
2612 application.SendNotification();
2613 application.Render();
2616 TestGenerateLongPress(application, 1.0f, 25.0f);
2618 // Render and notify
2619 application.SendNotification();
2620 application.Render();
2625 int utcDaliTextFieldEvent08(void)
2627 ToolkitTestApplication application;
2628 tet_infoline(" utcDaliTextFieldEvent08");
2630 Dali::Clipboard clipboard = Clipboard::Get();
2631 clipboard.SetItem("testTextFieldEvent");
2633 // Checks Longpress when only place holder text
2635 TextField field = TextField::New();
2636 DALI_TEST_CHECK( field );
2637 application.GetScene().Add( field );
2638 LoadMarkerImages(application, field);
2639 // Render and notify
2640 application.SendNotification();
2641 application.Render();
2643 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2644 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2645 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2646 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2647 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2649 // Avoid a crash when core load gl resources.
2650 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2651 // Render and notify
2652 application.SendNotification();
2653 application.Render();
2656 TestGenerateLongPress( application, 1.0f, 25.0f, 20 );
2658 // Render and notify
2659 application.SendNotification();
2660 application.Render();
2662 Wait(application, 500);
2664 TestEndLongPress( application, 1.0f, 25.0f, 520 );
2667 TestGenerateLongPress( application, 1.0f, 25.0f, 600 );
2669 // Render and notify
2670 application.Render();
2672 Wait(application, 500);
2674 Integration::Scene stage = application.GetScene();
2675 Layer layer = stage.GetRootLayer();
2676 Actor actor = layer.FindChildByName("optionPaste");
2680 Vector3 worldPosition = actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION );
2681 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2682 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2684 Dali::Integration::TouchEvent event;
2685 event = Dali::Integration::TouchEvent();
2686 event.AddPoint( GetPointDownInside( position ) );
2687 application.ProcessEvent( event );
2689 event = Dali::Integration::TouchEvent();
2690 event.AddPoint( GetPointUpInside( position ) );
2691 application.ProcessEvent( event );
2693 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2698 int utcDaliTextFieldEvent09(void)
2700 ToolkitTestApplication application;
2701 tet_infoline(" utcDaliTextFieldEvent09");
2703 TextField field = TextField::New();
2704 DALI_TEST_CHECK( field );
2705 application.GetScene().Add( field );
2706 LoadMarkerImages(application, field);
2707 // Render and notify
2708 application.SendNotification();
2709 application.Render();
2711 field.SetProperty( TextField::Property::TEXT, "Hello" );
2712 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2713 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2714 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2715 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2717 // Avoid a crash when core load gl resources.
2718 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2720 // Create a tap event to touch the text field.
2721 TestGenerateTap( application, 150.0f, 25.0f );
2722 application.SendNotification();
2723 application.Render();
2726 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2727 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2728 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2729 application.SendNotification();
2730 application.Render();
2732 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2733 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2734 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2735 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2736 application.SendNotification();
2737 application.Render();
2739 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2740 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2741 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2742 for( unsigned int index = 0u; index < 5u; ++index )
2744 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2745 application.SendNotification();
2746 application.Render();
2749 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2750 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2751 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2752 for( unsigned int index = 0u; index < 5u; ++index )
2754 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2755 application.SendNotification();
2756 application.Render();
2759 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2760 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2761 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2762 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2763 application.SendNotification();
2764 application.Render();
2765 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2766 application.SendNotification();
2767 application.Render();
2769 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2770 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2771 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2772 application.SendNotification();
2773 application.Render();
2775 Property::Map mapGet;
2776 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2777 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2778 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2783 int utcDaliTextFieldStyleWhilstSelected(void)
2785 ToolkitTestApplication application;
2786 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2788 // Change font and styles whilst text is selected whilst word selected
2790 TextField field = TextField::New();
2791 DALI_TEST_CHECK( field );
2792 application.GetScene().Add( field );
2793 LoadMarkerImages(application, field);
2794 // Render and notify
2795 application.SendNotification();
2796 application.Render();
2798 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2799 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2800 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2801 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2802 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2804 // Avoid a crash when core load gl resources.
2805 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2806 // Render and notify
2807 application.SendNotification();
2808 application.Render();
2810 // Create a tap event to touch the text field.
2811 TestGenerateTap( application, 150.0f, 25.0f );
2812 // Render and notify
2813 application.SendNotification();
2814 application.Render();
2817 // Tap first to get the focus.
2818 TestGenerateTap( application, 1.0f, 25.0f );
2820 // Render and notify
2821 application.SendNotification();
2822 application.Render();
2824 // Double tap to select a word.
2825 TestGenerateTap( application, 1.0f, 25.0f );
2827 // Render and notify
2828 application.SendNotification();
2829 application.Render();
2831 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2832 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2834 Property::Map fontStyleMapSet;
2835 Property::Map fontStyleMapGet;
2837 fontStyleMapSet.Insert( "weight", "bold" );
2838 fontStyleMapSet.Insert( "slant", "italic" );
2839 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2841 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2842 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2843 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2845 fontStyleMapSet.Clear();
2846 fontStyleMapSet.Insert( "width", "expanded" );
2847 fontStyleMapSet.Insert( "slant", "italic" );
2848 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2850 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2851 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2852 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2854 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2855 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2857 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2858 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2860 fontStyleMapSet.Clear();
2861 fontStyleMapSet.Insert( "weight", "bold" );
2862 fontStyleMapSet.Insert( "slant", "italic" );
2864 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2866 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2867 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2868 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2870 fontStyleMapSet.Clear();
2871 fontStyleMapSet.Insert( "width", "expanded" );
2873 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2875 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2876 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2877 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2879 // Press Escape to increase coverage
2880 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2881 application.SendNotification();
2882 application.Render();
2884 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2889 int utcDaliTextFieldEscKeyLoseFocus(void)
2891 ToolkitTestApplication application;
2892 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2894 // Creates a tap event. After creating a tap event the text field should
2895 // have the focus and add text with key events should be possible.
2897 TextField field = TextField::New();
2898 DALI_TEST_CHECK( field );
2900 application.GetScene().Add( field );
2902 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2903 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2904 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2906 // Avoid a crash when core load gl resources.
2907 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2909 // Render and notify
2910 application.SendNotification();
2911 application.Render();
2913 // Add a key event but as the text field has not the focus it should do nothing.
2914 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2915 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2917 // Render and notify
2918 application.SendNotification();
2919 application.Render();
2921 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2923 // Create a tap event to touch the text field.
2924 TestGenerateTap( application, 150.0f, 25.0f );
2926 // Render and notify
2927 application.SendNotification();
2928 application.Render();
2930 // Now the text field has the focus, so it can handle the key events.
2931 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2932 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2933 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2934 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2936 // Render and notify
2937 application.SendNotification();
2938 application.Render();
2940 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2942 // Generate a Esc key event. The text field should lose the focus.
2943 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2944 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2946 // Render and notify
2947 application.SendNotification();
2948 application.Render();
2950 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2952 // No more text should be introduced
2953 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2954 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2956 // Render and notify
2957 application.SendNotification();
2958 application.Render();
2960 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2965 int utcDaliTextFieldSomeSpecialKeys(void)
2967 ToolkitTestApplication application;
2968 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2970 // Checks some special keys when the text is selected.
2972 TextField field = TextField::New();
2973 DALI_TEST_CHECK( field );
2974 application.GetScene().Add( field );
2975 LoadMarkerImages(application, field);
2976 // Render and notify
2977 application.SendNotification();
2978 application.Render();
2980 const std::string longText( "This is a long text for the size of the text-field." );
2982 field.SetProperty( TextField::Property::TEXT, longText );
2983 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2984 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2985 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2986 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2988 // Avoid a crash when core load gl resources.
2989 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2990 // Render and notify
2991 application.SendNotification();
2992 application.Render();
2994 // Create a tap event to touch the text field.
2995 TestGenerateTap( application, 150.0f, 25.0f );
2997 // Render and notify
2998 application.SendNotification();
2999 application.Render();
3001 // Tap first to get the focus.
3002 TestGenerateTap( application, 1.0f, 25.0f );
3004 // Render and notify
3005 application.SendNotification();
3006 application.Render();
3008 // Double tap to select a word.
3009 TestGenerateTap( application, 1.0f, 25.0f );
3011 // Render and notify
3012 application.SendNotification();
3013 application.Render();
3015 // Generate a Esc key event. The text field should lose the focus.
3016 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3017 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3019 // Render and notify
3020 application.SendNotification();
3021 application.Render();
3023 // Generate a Esc key event. The text field should lose the focus.
3024 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3025 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3027 // Render and notify
3028 application.SendNotification();
3029 application.Render();
3031 // Generate a Esc key event. The text field should lose the focus.
3032 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3033 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3035 // Render and notify
3036 application.SendNotification();
3037 application.Render();
3039 // The text shouldn't be deleted.
3040 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
3045 int utcDaliTextFieldSizeUpdate(void)
3047 ToolkitTestApplication application;
3048 tet_infoline("utcDaliTextFieldSizeUpdate");
3050 // Checks some special keys when the text is selected.
3051 TextField field = TextField::New();
3052 DALI_TEST_CHECK( field );
3053 application.GetScene().Add( field );
3055 float previousHeight = 0.0f;
3056 float currentHeight = 0.0f;
3057 const float fieldWidth = 1920.0f;
3060 // "ㅁ" is bigger then "ኢ"
3061 field.SetProperty( Actor::Property::SIZE, Vector2( fieldWidth ,10.0f ) );
3062 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
3063 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
3065 field.SetProperty( TextField::Property::TEXT, "ኢ");
3066 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3067 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3069 field.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
3070 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
3072 application.SendNotification();
3073 application.Render();
3075 previousHeight = field.GetHeightForWidth( fieldWidth );
3076 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
3078 // Add another script characters ( glyph height is defferent )
3079 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3080 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3082 application.SendNotification();
3083 application.Render();
3085 currentHeight = field.GetHeightForWidth( fieldWidth );
3086 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
3087 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
3092 int utcDaliTextFieldExtremlyLargePointSize(void)
3094 ToolkitTestApplication application;
3095 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
3097 TextField field = TextField::New();
3099 field.SetProperty( TextField::Property::TEXT, "Text" );
3100 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3101 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3102 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3103 application.GetScene().Add( field );
3107 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
3108 application.SendNotification();
3109 DALI_TEST_CHECK( field );
3113 tet_result(TET_FAIL);
3118 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
3120 ToolkitTestApplication application;
3121 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
3122 TextField field = TextField::New();
3123 DALI_TEST_CHECK( field );
3124 application.GetScene().Add( field );
3126 Property::Map fontStyleMapGet;
3128 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
3130 Property::Value* weightValue = NULL;
3131 Property::Value* widthValue = NULL;
3132 Property::Value* slantValue = NULL;
3133 weightValue = fontStyleMapGet.Find( "weight" );
3134 widthValue = fontStyleMapGet.Find( "width" );
3135 slantValue = fontStyleMapGet.Find( "slant" );
3136 DALI_TEST_CHECK( !weightValue );
3137 DALI_TEST_CHECK( !widthValue );
3138 DALI_TEST_CHECK( !slantValue );
3143 int UtcDaliTextFieldSettingPlaceholder(void)
3145 ToolkitTestApplication application;
3146 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
3148 TextField field = TextField::New();
3149 DALI_TEST_CHECK( field );
3150 application.GetScene().Add( field );
3152 // Check the placeholder property with pixel size
3153 Property::Map placeholderPixelSizeMapSet;
3154 Property::Map placeholderPixelSizeMapGet;
3155 Property::Map placeholderFontstyleMap;
3156 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
3157 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
3158 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
3159 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
3160 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
3161 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
3163 placeholderFontstyleMap.Insert( "weight", "bold" );
3164 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3165 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
3167 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3168 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
3169 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
3171 // Check the placeholder property with point size
3172 Property::Map placeholderMapSet;
3173 Property::Map placeholderMapGet;
3174 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
3175 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
3176 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
3177 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
3178 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
3179 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
3181 // Check the placeholder font style property
3182 placeholderFontstyleMap.Clear();
3184 placeholderFontstyleMap.Insert( "weight", "bold" );
3185 placeholderFontstyleMap.Insert( "width", "condensed" );
3186 placeholderFontstyleMap.Insert( "slant", "italic" );
3187 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3188 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3190 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3191 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3192 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3194 // Reset font style.
3195 placeholderFontstyleMap.Clear();
3196 placeholderFontstyleMap.Insert( "weight", "normal" );
3197 placeholderFontstyleMap.Insert( "slant", "oblique" );
3198 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3199 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3201 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3202 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3203 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3205 placeholderFontstyleMap.Clear();
3206 placeholderFontstyleMap.Insert( "slant", "roman" );
3207 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3208 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3210 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3212 placeholderFontstyleMap.Clear();
3213 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3215 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3216 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3217 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3218 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3223 int UtcDaliTextFieldSetPaddingProperty(void)
3225 ToolkitTestApplication application;
3226 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3228 TextField field = TextField::New();
3229 DALI_TEST_CHECK( field );
3230 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3231 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3232 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3233 application.GetScene().Add( field );
3235 application.SendNotification();
3236 application.Render();
3238 Vector3 originalSize = field.GetNaturalSize();
3240 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
3242 application.SendNotification();
3243 application.Render();
3245 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
3247 Vector3 paddingAddedSize = field.GetNaturalSize();
3249 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3251 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3256 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3258 ToolkitTestApplication application;
3259 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3261 TextField field = TextField::New();
3262 DALI_TEST_CHECK( field );
3263 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3264 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3265 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3266 application.GetScene().Add( field );
3268 application.SendNotification();
3269 application.Render();
3271 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3272 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
3274 // Check the enable shift selection property
3275 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
3276 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
3278 application.SendNotification();
3279 application.Render();
3284 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3286 ToolkitTestApplication application;
3287 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3289 TextField field = TextField::New();
3290 DALI_TEST_CHECK( field );
3291 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3292 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3293 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3294 application.GetScene().Add( field );
3296 application.SendNotification();
3297 application.Render();
3299 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3300 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
3302 // Check the enable grab handle property
3303 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
3304 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
3306 application.SendNotification();
3307 application.Render();
3312 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
3314 ToolkitTestApplication application;
3315 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
3317 TextField field = TextField::New();
3318 DALI_TEST_CHECK( field );
3319 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3320 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3321 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3322 application.GetScene().Add( field );
3324 application.SendNotification();
3325 application.Render();
3327 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3328 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
3330 // Check the match system language direction property
3331 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
3332 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
3334 application.SendNotification();
3335 application.Render();
3340 int utcDaliTextFieldLayoutDirectionCoverage(void)
3342 ToolkitTestApplication application;
3343 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
3345 // Creates a tap event. After creating a tap event the text field should
3346 // have the focus and add text with key events should be possible.
3347 TextField field = TextField::New();
3348 DALI_TEST_CHECK( field );
3350 application.GetScene().Add( field );
3352 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3353 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3354 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3356 // Avoid a crash when core load gl resources.
3357 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3359 // Render and notify
3360 application.SendNotification();
3361 application.Render();
3363 // init direction for coverage
3364 // Set horizontal alignment END
3365 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3367 // Create a tap event to touch the text field.
3368 TestGenerateTap( application, 150.0f, 25.0f );
3370 // Render and notify
3371 application.SendNotification();
3372 application.Render();
3374 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
3375 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
3376 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
3378 // Set horizontal alignment BEGIN
3379 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
3381 // Create a tap event to touch the text field.
3382 TestGenerateTap( application, 150.0f, 25.0f );
3384 // Render and notify
3385 application.SendNotification();
3386 application.Render();
3388 // Set horizontal alignment CENTER
3389 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
3391 // Create a tap event to touch the text field.
3392 TestGenerateTap( application, 150.0f, 25.0f );
3394 // Render and notify
3395 application.SendNotification();
3396 application.Render();
3398 // Set horizontal alignment END
3399 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3401 // Create a tap event to touch the text field.
3402 TestGenerateTap( application, 150.0f, 25.0f );
3404 // Render and notify
3405 application.SendNotification();
3406 application.Render();
3408 // Generate a Esc key event. The text field should lose the focus.
3409 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3410 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3412 // Render and notify
3413 application.SendNotification();
3414 application.Render();
3416 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
3421 int UtcDaliTextFieldGetInputMethodContext(void)
3423 ToolkitTestApplication application;
3424 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
3426 TextField field = TextField::New();
3427 DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );
3432 int UtcDaliTextFieldSelectWholeText(void)
3434 ToolkitTestApplication application;
3435 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3437 TextField textField = TextField::New();
3439 application.GetScene().Add( textField );
3441 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3442 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3443 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3445 // Avoid a crash when core load gl resources.
3446 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3448 application.SendNotification();
3449 application.Render();
3451 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
3453 DevelTextField::SelectWholeText( textField );
3455 application.SendNotification();
3456 application.Render();
3458 // Nothing should have been selected. The number of children is still 1
3459 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
3461 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3463 application.SendNotification();
3464 application.Render();
3466 DevelTextField::SelectWholeText( textField );
3468 application.SendNotification();
3469 application.Render();
3471 // Should be 2 children, the stencil and the layer
3472 DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
3474 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3475 Actor stencil = textField.GetChildAt( 0u );
3477 // The highlight actor is drawn first, so is the first actor in the list
3478 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3479 DALI_TEST_CHECK( highlight );
3484 int UtcDaliTextFieldSelectNone(void)
3486 ToolkitTestApplication application;
3487 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3489 TextField textField = TextField::New();
3491 application.GetScene().Add( textField );
3493 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3494 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3495 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3497 // Avoid a crash when core load gl resources.
3498 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3500 application.SendNotification();
3501 application.Render();
3503 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3505 application.SendNotification();
3506 application.Render();
3508 // Nothing is selected
3509 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3510 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3512 DevelTextField::SelectWholeText( textField );
3514 application.SendNotification();
3515 application.Render();
3517 // whole text is selected
3518 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3519 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3521 DevelTextField::SelectNone( textField );
3523 application.SendNotification();
3524 application.Render();
3526 // Nothing is selected
3527 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3528 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3533 int UtcDaliTextFieldSelectRange(void)
3535 ToolkitTestApplication application;
3536 tet_infoline(" UtcDaliTextFieldSelectRange ");
3538 TextField textField = TextField::New();
3540 application.GetScene().Add( textField );
3542 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3543 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3544 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3546 // Avoid a crash when core load gl resources.
3547 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3549 application.SendNotification();
3550 application.Render();
3552 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3554 application.SendNotification();
3555 application.Render();
3557 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 0);
3558 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 5);
3560 // Hello is selected
3561 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3562 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3564 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3565 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3567 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 6);
3568 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 11);
3570 // world is selected
3571 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3572 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3574 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3575 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3580 int UtcDaliTextFieldEnableEditing(void)
3582 ToolkitTestApplication application;
3583 tet_infoline(" UtcDaliTextFieldEnableEditing ");
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 textField.SetKeyInputFocus();
3600 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, false );
3601 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3603 // Render and notify
3604 application.SendNotification();
3605 application.Render();
3607 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3608 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3611 textField.SetKeyInputFocus();
3612 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
3613 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3615 // Render and notify
3616 application.SendNotification();
3617 application.Render();
3619 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3620 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3625 int UtcDaliToolkitTextFieldFontSizeScale(void)
3627 ToolkitTestApplication application;
3628 tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
3630 TextField textField = TextField::New();
3631 textField.SetProperty( TextField::Property::POINT_SIZE, 30.f );
3632 textField.SetProperty( TextField::Property::TEXT, "Test" );
3633 Vector3 nonScaledSize = textField.GetNaturalSize();
3635 TextField textFieldScaled = TextField::New();
3636 textFieldScaled.SetProperty( TextField::Property::POINT_SIZE, 15.f );
3637 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3638 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3639 Vector3 scaledSize = textFieldScaled.GetNaturalSize();
3641 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3643 textField.SetProperty( TextField::Property::PIXEL_SIZE, 30.f );
3644 textField.SetProperty( TextField::Property::TEXT, "Test" );
3645 nonScaledSize = textField.GetNaturalSize();
3647 textFieldScaled.SetProperty( TextField::Property::PIXEL_SIZE, 15.f );
3648 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3649 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3650 scaledSize = textFieldScaled.GetNaturalSize();
3652 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3657 int UtcDaliTextFieldPrimaryCursorPosition(void)
3659 ToolkitTestApplication application;
3660 tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
3662 TextField textField = TextField::New();
3664 application.GetScene().Add( textField );
3666 textField.SetProperty( TextField::Property::TEXT, "ABCEF");
3667 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3668 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3669 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3671 // Avoid a crash when core load gl resources.
3672 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3674 textField.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
3675 application.SendNotification();
3676 application.Render();
3678 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3680 // Render and notify
3681 application.SendNotification();
3682 application.Render();
3684 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3685 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3690 // test max length when set after setting long text
3691 int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
3693 ToolkitTestApplication application;
3694 tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
3695 TextField field = TextField::New();
3696 DALI_TEST_CHECK( field );
3698 application.GetScene().Add( field );
3700 field.SetProperty(TextField::Property::TEXT, "123456789");
3702 const int maxNumberOfCharacters = 3;
3703 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
3705 field.SetKeyInputFocus();
3707 // connect to the text max lengh reached signal.
3708 ConnectionTracker* testTracker = new ConnectionTracker();
3709 bool maxLengthReachedSignal = false;
3710 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
3712 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3713 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3715 DALI_TEST_CHECK( maxLengthReachedSignal );
3717 DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "123456789", TEST_LOCATION );
3724 int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
3726 ToolkitTestApplication application;
3727 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
3729 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3730 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3731 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3733 // Create a text field
3734 TextField textField = TextField::New();
3736 //Set size to avoid automatic eliding
3737 textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3738 //Set very large font-size using point-size
3739 textField.SetProperty( TextField::Property::POINT_SIZE, 1000) ;
3740 //Specify font-family
3741 textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
3742 //Set text to check if appear or not
3743 textField.SetProperty( TextField::Property::TEXT, "A");
3745 application.GetScene().Add( textField );
3747 application.SendNotification();
3748 application.Render();
3749 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3750 Vector3 naturalSize = textField.GetNaturalSize();
3752 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3753 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3758 int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
3760 ToolkitTestApplication application;
3761 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
3763 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3764 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3765 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3767 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3768 // Create a text editor
3769 TextField textField = TextField::New();
3771 //Set size to avoid automatic eliding
3772 textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3773 textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
3774 textField.SetProperty( TextField::Property::TEXT, "A");
3776 const int numberOfCases = 6;
3777 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
3779 for (int index=0; index < numberOfCases; index++)
3781 tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
3782 textField.SetProperty( TextField::Property::POINT_SIZE, arrayCases[index]) ;
3783 application.GetScene().Add( textField );
3784 application.SendNotification();
3785 application.Render();
3786 naturalSize = textField.GetNaturalSize();
3787 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3788 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );