2 * Copyright (c) 2019 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 "toolkit-clipboard.h"
34 using namespace Toolkit;
36 void dali_textfield_startup(void)
38 test_return_value = TET_UNDEF;
41 void dali_textfield_cleanup(void)
43 test_return_value = TET_PASS;
49 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
50 const char* const PROPERTY_NAME_TEXT = "text";
51 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
52 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
53 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
54 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
55 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
56 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
57 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
58 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
59 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
60 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
61 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
62 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
63 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
64 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
65 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
66 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
67 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
68 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
69 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
70 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
71 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
72 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
73 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
78 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
79 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
80 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
81 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
82 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
83 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
84 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
85 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
87 const char* const PROPERTY_NAME_UNDERLINE = "underline";
88 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
89 const char* const PROPERTY_NAME_SHADOW = "shadow";
90 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
91 const char* const PROPERTY_NAME_EMBOSS = "emboss";
92 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
93 const char* const PROPERTY_NAME_OUTLINE = "outline";
94 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
96 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
97 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
98 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
99 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
100 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
101 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
102 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
103 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
104 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
106 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
107 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
109 const float RENDER_FRAME_INTERVAL = 16.66f;
111 const unsigned int DEFAULT_FONT_SIZE = 1152u;
112 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
114 const int KEY_RETURN_CODE = 36;
115 const int KEY_A_CODE = 38;
116 const int KEY_D_CODE = 40;
118 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
120 static bool gTextChangedCallBackCalled;
121 static bool gMaxCharactersCallBackCalled;
122 static bool gInputStyleChangedCallbackCalled;
123 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
125 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
127 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
128 Integration::ResourcePointer resource(bitmap);
129 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
132 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
136 LoadBitmapResource( app.GetPlatform(), width, height );
138 Property::Map propertyMap;
139 propertyMap["filename"] = "image.png";
140 propertyMap["width"] = width;
141 propertyMap["height"] = height;
142 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
143 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
144 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
145 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
146 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
147 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
148 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
149 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
153 * Simulate time passed by.
155 * @note this will always process at least 1 frame (1/60 sec)
157 * @param application Test application instance
158 * @param duration Time to pass in milliseconds.
159 * @return The actual time passed in milliseconds
161 static int Wait(ToolkitTestApplication& application, int duration = 0)
165 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
167 application.SendNotification();
168 application.Render(RENDER_FRAME_INTERVAL);
169 time += RENDER_FRAME_INTERVAL;
175 Dali::Integration::Point GetPointDownInside( Vector2& pos )
177 Dali::Integration::Point point;
178 point.SetState( PointState::DOWN );
179 point.SetScreenPosition( pos );
183 Dali::Integration::Point GetPointUpInside( Vector2& pos )
185 Dali::Integration::Point point;
186 point.SetState( PointState::UP );
187 point.SetScreenPosition( pos );
191 struct CallbackFunctor
193 CallbackFunctor(bool* callbackFlag)
194 : mCallbackFlag( callbackFlag )
200 *mCallbackFlag = true;
205 static void TestTextChangedCallback( TextField control )
207 tet_infoline(" TestTextChangedCallback");
209 gTextChangedCallBackCalled = true;
212 static void TestMaxLengthReachedCallback( TextField control )
214 tet_infoline(" TestMaxLengthReachedCallback");
216 gMaxCharactersCallBackCalled = true;
219 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
221 tet_infoline(" TestInputStyleChangedCallback");
223 gInputStyleChangedCallbackCalled = true;
224 gInputStyleMask = mask;
227 // Generate a KeyEvent to send to Core.
228 Integration::KeyEvent GenerateKey( const std::string& keyName,
229 const std::string& logicalKey,
230 const std::string& keyString,
233 unsigned long timeStamp,
234 const Integration::KeyEvent::State& keyState,
235 const std::string& compose = "",
236 const std::string& deviceName = DEFAULT_DEVICE_NAME,
237 const Device::Class::Type& deviceClass = Device::Class::NONE,
238 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
240 return Integration::KeyEvent( keyName,
253 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
255 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
257 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
259 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
261 Property::Value* valueSet = NULL;
262 if ( valueGet.first.type == Property::Key::INDEX )
264 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
268 // Get Key is a string so searching Set Map for a string key
269 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
272 if( NULL != valueSet )
274 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
276 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
279 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
281 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
284 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
286 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
289 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
291 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
294 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
296 Vector2 vector2Get = valueGet.second.Get<Vector2>();
297 Vector2 vector2Set = valueSet->Get<Vector2>();
298 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
301 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
303 Vector4 vector4Get = valueGet.second.Get<Vector4>();
304 Vector4 vector4Set = valueSet->Get<Vector4>();
305 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 );
311 if ( valueGet.first.type == Property::Key::INDEX )
313 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
317 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
329 int UtcDaliToolkitTextFieldConstructorP(void)
331 ToolkitTestApplication application;
332 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
334 DALI_TEST_CHECK( !textField );
338 int UtcDaliToolkitTextFieldNewP(void)
340 ToolkitTestApplication application;
341 tet_infoline(" UtcDaliToolkitTextFieldNewP");
342 TextField textField = TextField::New();
343 DALI_TEST_CHECK( textField );
347 int UtcDaliToolkitTextFieldDownCastP(void)
349 ToolkitTestApplication application;
350 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
351 TextField textField1 = TextField::New();
352 BaseHandle object( textField1 );
354 TextField textField2 = TextField::DownCast( object );
355 DALI_TEST_CHECK( textField2 );
357 TextField textField3 = DownCast< TextField >( object );
358 DALI_TEST_CHECK( textField3 );
362 int UtcDaliToolkitTextFieldDownCastN(void)
364 ToolkitTestApplication application;
365 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
366 BaseHandle uninitializedObject;
367 TextField textField1 = TextField::DownCast( uninitializedObject );
368 DALI_TEST_CHECK( !textField1 );
370 TextField textField2 = DownCast< TextField >( uninitializedObject );
371 DALI_TEST_CHECK( !textField2 );
375 int UtcDaliToolkitTextFieldCopyConstructorP(void)
377 ToolkitTestApplication application;
378 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
379 TextField textField = TextField::New();
380 textField.SetProperty( TextField::Property::TEXT, "Test" );
382 TextField copy( textField );
383 DALI_TEST_CHECK( copy );
384 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
388 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
390 ToolkitTestApplication application;
391 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
392 TextField textField = TextField::New();
393 textField.SetProperty( TextField::Property::TEXT, "Test" );
395 TextField copy = textField;
396 DALI_TEST_CHECK( copy );
397 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
401 int UtcDaliTextFieldNewP(void)
403 ToolkitTestApplication application;
404 tet_infoline(" UtcDaliToolkitTextFieldNewP");
405 TextField textField = TextField::New();
406 DALI_TEST_CHECK( textField );
410 // Positive test case for a method
411 int UtcDaliTextFieldGetPropertyP(void)
413 ToolkitTestApplication application;
414 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
415 TextField field = TextField::New();
416 DALI_TEST_CHECK( field );
418 // Check Property Indices are correct
419 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
420 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
421 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
422 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
423 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
424 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
425 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
426 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
427 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
428 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
429 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
430 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
431 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
432 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
433 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
434 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
435 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
436 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
437 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
438 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
439 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
440 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
441 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
442 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
443 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
444 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
445 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
446 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
447 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
448 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
449 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
450 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
451 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
452 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
453 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
454 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
455 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
456 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
457 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
458 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
459 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
460 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
461 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
462 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
463 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
464 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
465 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
466 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
467 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
468 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
469 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
470 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
471 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
472 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP );
477 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
480 Property::Map imageMap;
481 imageMap[mapKey] =mapValue;
483 field.SetProperty( property , imageMap );
484 Property::Value propValue = field.GetProperty( property );
485 Property::Map* resultMap = propValue.GetMap();
487 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
495 // Positive test case for a method
496 int UtcDaliTextFieldSetPropertyP(void)
498 ToolkitTestApplication application;
499 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
500 TextField field = TextField::New();
501 DALI_TEST_CHECK( field );
502 Stage::GetCurrent().Add( field );
504 // Note - we can't check the defaults since the stylesheets are platform-specific
506 // Check the render backend property.
507 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
508 DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
510 // Check text property.
511 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
512 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
514 // Check placeholder text properties.
515 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
516 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
518 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
519 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
521 // Check font properties.
522 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
523 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
525 Property::Map fontStyleMapSet;
526 Property::Map fontStyleMapGet;
527 Property::Value* slantValue = NULL;
529 fontStyleMapSet.Insert( "weight", "bold" );
530 fontStyleMapSet.Insert( "width", "condensed" );
531 fontStyleMapSet.Insert( "slant", "italic" );
532 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
534 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
535 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
536 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
538 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
539 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
542 fontStyleMapSet.Clear();
543 fontStyleMapSet.Insert( "weight", "normal" );
544 fontStyleMapSet.Insert( "slant", "oblique" );
545 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
547 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
548 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
549 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
551 fontStyleMapSet.Clear();
552 fontStyleMapSet.Insert( "slant", "roman" );
553 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
554 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
556 // Replace 'roman' for 'normal'.
557 slantValue = fontStyleMapGet.Find( "slant" );
558 if( NULL != slantValue )
560 if( "normal" == slantValue->Get<std::string>() )
562 fontStyleMapGet["slant"] = "roman";
565 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
566 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
568 fontStyleMapSet.Clear();
570 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
571 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
572 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
573 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
575 // Check that the MAX_LENGTH property can be correctly set
576 const int maxNumberOfCharacters = 20;
577 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
578 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
580 // Check exceed policy
581 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
582 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
583 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
584 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
586 // Check that the Alignment properties can be correctly set
587 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
588 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
589 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
590 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
592 // Check text's color property
593 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
594 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
596 // Check placeholder text's color property.
597 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
598 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
600 // Check cursor properties
601 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
602 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
603 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
604 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
606 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
607 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
608 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
609 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
610 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
611 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
612 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
613 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
615 // Check scroll properties.
616 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
617 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
618 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
619 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
621 // Check handle images
622 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
623 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
624 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
625 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
626 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
628 // Check handle images
629 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
630 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
631 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
632 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
633 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
634 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
636 // Check the highlight color
637 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
638 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
640 // Decoration bounding box
641 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
642 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
644 // Check the input method setting
645 Property::Map propertyMap;
646 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
647 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
648 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
649 int inputVariation = 1;
650 propertyMap["PANEL_LAYOUT"] = panelLayout;
651 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
652 propertyMap["BUTTON_ACTION"] = buttonAction;
653 propertyMap["VARIATION"] = inputVariation;
654 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
656 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
658 DALI_TEST_CHECK( value.Get( map ) );
661 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
662 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
665 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
666 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
669 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
670 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
673 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
674 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
676 // Check input color property.
677 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
678 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
680 // Check the enable markup property.
681 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
682 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
683 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
685 // Check input font properties.
686 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
687 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
689 fontStyleMapSet.Clear();
690 fontStyleMapSet.Insert( "weight", "bold" );
691 fontStyleMapSet.Insert( "width", "condensed" );
692 fontStyleMapSet.Insert( "slant", "italic" );
694 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
695 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
696 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
697 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
699 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
700 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
702 // Reset input font style.
703 fontStyleMapSet.Clear();
704 fontStyleMapSet.Insert( "weight", "normal" );
705 fontStyleMapSet.Insert( "slant", "oblique" );
707 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
708 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
709 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
710 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
712 fontStyleMapSet.Clear();
713 fontStyleMapSet.Insert( "slant", "roman" );
715 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
716 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
718 // Replace 'roman' for 'normal'.
719 slantValue = fontStyleMapGet.Find( "slant" );
720 if( NULL != slantValue )
722 if( "normal" == slantValue->Get<std::string>() )
724 fontStyleMapGet["slant"] = "roman";
727 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
728 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
730 fontStyleMapSet.Clear();
732 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
733 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
734 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
735 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
737 Property::Map underlineMapSet;
738 Property::Map underlineMapGet;
740 underlineMapSet.Insert( "enable", true );
741 underlineMapSet.Insert( "color", Color::RED );
742 underlineMapSet.Insert( "height", 1 );
744 // Check the underline property
745 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
747 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
748 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
749 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
751 // Check the input underline property
752 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
753 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
755 // Check the shadow property
756 Property::Map shadowMapSet;
757 Property::Map shadowMapGet;
759 shadowMapSet.Insert( "color", Color::GREEN );
760 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
761 shadowMapSet.Insert( "blurRadius", 3.0f );
763 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
765 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
766 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
767 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
769 // Check the input shadow property
770 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
771 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
773 // Check the emboss property
774 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
775 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
777 // Check the input emboss property
778 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
779 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
781 // Check the outline property
783 // Test string type first
784 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
785 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
786 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
788 // Then test the property map type
789 Property::Map outlineMapSet;
790 Property::Map outlineMapGet;
792 outlineMapSet["color"] = Color::RED;
793 outlineMapSet["width"] = 2.0f;
795 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
797 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
798 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
799 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
801 // Check the input outline property
802 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
803 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
805 // Check the hidden input settings property
806 Property::Map hiddenMapSet;
807 Property::Map hiddenMapGet;
808 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
809 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
810 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
811 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
812 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
814 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
815 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
816 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
818 // Check the pixel size of font
819 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
820 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
822 // Check the enable selection property
823 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
824 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
826 // Check the placeholder property with pixel size
827 Property::Map placeholderPixelSizeMapSet;
828 Property::Map placeholderPixelSizeMapGet;
829 Property::Map placeholderFontstyleMap;
830 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
831 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
832 placeholderPixelSizeMapSet["color"] = Color::BLUE;
833 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
834 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
835 placeholderPixelSizeMapSet["ellipsis"] = true;
837 placeholderFontstyleMap.Insert( "weight", "bold" );
838 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
839 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
841 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
842 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
844 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
845 Property::Map placeholderConversionMap;
846 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
847 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
848 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
849 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
850 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
851 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
853 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
855 // Check the placeholder property with point size
856 Property::Map placeholderMapSet;
857 Property::Map placeholderMapGet;
858 placeholderMapSet["text"] = "Setting Placeholder Text";
859 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
860 placeholderMapSet["color"] = Color::RED;
861 placeholderMapSet["fontFamily"] = "Arial";
862 placeholderMapSet["pointSize"] = 12.0f;
863 placeholderMapSet["ellipsis"] = false;
865 // Check the placeholder font style property
866 placeholderFontstyleMap.Clear();
868 placeholderFontstyleMap.Insert( "weight", "bold" );
869 placeholderFontstyleMap.Insert( "width", "condensed" );
870 placeholderFontstyleMap.Insert( "slant", "italic" );
871 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
872 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
874 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
875 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
877 placeholderConversionMap.Clear();
878 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
879 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
880 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
881 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
882 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
883 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
885 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
888 placeholderFontstyleMap.Clear();
889 placeholderFontstyleMap.Insert( "weight", "normal" );
890 placeholderFontstyleMap.Insert( "slant", "oblique" );
891 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
892 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
894 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
895 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
897 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
898 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
900 placeholderFontstyleMap.Clear();
901 placeholderFontstyleMap.Insert( "slant", "roman" );
902 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
903 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
905 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
907 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
909 placeholderFontstyleMap.Clear();
910 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
911 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
913 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
914 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
915 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
917 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
919 // Check the ellipsis property
920 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
921 field.SetProperty( TextField::Property::ELLIPSIS, true );
922 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
924 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
925 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
927 // Test the ENABLE_GRAB_HANDLE_POPUP property
928 DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
929 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false );
930 DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
932 application.SendNotification();
933 application.Render();
938 // Positive Atlas Text Renderer test
939 int utcDaliTextFieldAtlasRenderP(void)
941 ToolkitTestApplication application;
942 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
943 StyleManager styleManager = StyleManager::Get();
944 styleManager.ApplyDefaultTheme();
945 TextField field = TextField::New();
946 DALI_TEST_CHECK( field );
948 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
950 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
952 Stage::GetCurrent().Add( field );
956 // Render some text with the shared atlas backend
957 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
958 application.SendNotification();
959 application.Render();
963 tet_result(TET_FAIL);
968 // Positive test for the textChanged signal.
969 int utcDaliTextFieldTextChangedP(void)
971 ToolkitTestApplication application;
972 tet_infoline(" utcDaliTextFieldTextChangedP");
973 TextField field = TextField::New();
974 DALI_TEST_CHECK( field );
976 Stage::GetCurrent().Add( field );
978 // connect to the text changed signal.
979 ConnectionTracker* testTracker = new ConnectionTracker();
980 field.TextChangedSignal().Connect(&TestTextChangedCallback);
981 bool textChangedSignal = false;
982 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
984 gTextChangedCallBackCalled = false;
985 field.SetProperty( TextField::Property::TEXT, "ABC" );
986 DALI_TEST_CHECK( gTextChangedCallBackCalled );
987 DALI_TEST_CHECK( textChangedSignal );
989 application.SendNotification();
991 field.SetKeyInputFocus();
993 gTextChangedCallBackCalled = false;
994 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
995 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1000 // Negative test for the textChanged signal.
1001 int utcDaliTextFieldTextChangedN(void)
1003 ToolkitTestApplication application;
1004 tet_infoline(" utcDaliTextFieldTextChangedN");
1005 TextField field = TextField::New();
1006 DALI_TEST_CHECK( field );
1008 Stage::GetCurrent().Add( field );
1010 // connect to the text changed signal.
1011 ConnectionTracker* testTracker = new ConnectionTracker();
1012 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1013 bool textChangedSignal = false;
1014 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1016 gTextChangedCallBackCalled = false;
1017 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1018 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1019 DALI_TEST_CHECK( !textChangedSignal );
1024 // Positive test for Max Characters reached signal.
1025 int utcDaliTextFieldMaxCharactersReachedP(void)
1027 ToolkitTestApplication application;
1028 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1029 TextField field = TextField::New();
1030 DALI_TEST_CHECK( field );
1032 Stage::GetCurrent().Add( field );
1034 const int maxNumberOfCharacters = 1;
1035 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1037 field.SetKeyInputFocus();
1039 // connect to the text changed signal.
1040 ConnectionTracker* testTracker = new ConnectionTracker();
1041 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1042 bool maxLengthReachedSignal = false;
1043 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1045 gMaxCharactersCallBackCalled = false;
1047 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1048 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1050 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1051 DALI_TEST_CHECK( maxLengthReachedSignal );
1056 // Negative test for Max Characters reached signal.
1057 int utcDaliTextFieldMaxCharactersReachedN(void)
1059 ToolkitTestApplication application;
1060 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1061 TextField field = TextField::New();
1062 DALI_TEST_CHECK( field );
1064 Stage::GetCurrent().Add( field );
1066 const int maxNumberOfCharacters = 3;
1067 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1069 field.SetKeyInputFocus();
1071 // connect to the text changed signal.
1072 ConnectionTracker* testTracker = new ConnectionTracker();
1073 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1074 bool maxLengthReachedSignal = false;
1075 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1077 gMaxCharactersCallBackCalled = false;
1079 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1080 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1082 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1083 DALI_TEST_CHECK( !maxLengthReachedSignal );
1085 application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::Down, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1087 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1088 DALI_TEST_CHECK( !maxLengthReachedSignal );
1093 int utcDaliTextFieldInputStyleChanged01(void)
1095 // The text-field emits signals when the input style changes. These changes of style are
1096 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1097 // can't be emitted during the size negotiation as the callbacks may update the UI.
1098 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1099 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1100 ToolkitTestApplication application;
1101 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1105 char* pathNamePtr = get_current_dir_name();
1106 const std::string pathName( pathNamePtr );
1107 free( pathNamePtr );
1109 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1110 fontClient.SetDpi( 93u, 93u );
1112 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1113 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1115 TextField field = TextField::New();
1116 DALI_TEST_CHECK( field );
1119 field.SetSize( 300.f, 50.f );
1120 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1121 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1123 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1124 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1126 // connect to the text changed signal.
1127 ConnectionTracker* testTracker = new ConnectionTracker();
1128 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1129 bool inputStyleChangedSignal = false;
1130 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1132 Stage::GetCurrent().Add( field );
1134 // Render and notify
1135 application.SendNotification();
1136 application.Render();
1138 // Executes the idle callbacks added by the text control on the change of input style.
1139 application.RunIdles();
1141 gInputStyleChangedCallbackCalled = false;
1142 gInputStyleMask = TextField::InputStyle::NONE;
1143 inputStyleChangedSignal = false;
1145 // Create a tap event to touch the text field.
1146 TestGenerateTap( application, 18.0f, 25.0f );
1148 // Render and notify
1149 application.SendNotification();
1150 application.Render();
1152 // Executes the idle callbacks added by the text control on the change of input style.
1153 application.RunIdles();
1155 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1156 if( gInputStyleChangedCallbackCalled )
1158 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1160 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1161 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1163 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1164 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1166 DALI_TEST_CHECK( inputStyleChangedSignal );
1168 gInputStyleChangedCallbackCalled = false;
1169 gInputStyleMask = TextField::InputStyle::NONE;
1170 inputStyleChangedSignal = false;
1172 // Create a tap event to touch the text field.
1173 TestGenerateTap( application, 30.0f, 25.0f );
1175 // Render and notify
1176 application.SendNotification();
1177 application.Render();
1179 // Executes the idle callbacks added by the text control on the change of input style.
1180 application.RunIdles();
1182 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1183 DALI_TEST_CHECK( !inputStyleChangedSignal );
1185 gInputStyleChangedCallbackCalled = false;
1186 gInputStyleMask = TextField::InputStyle::NONE;
1187 inputStyleChangedSignal = false;
1189 // Create a tap event to touch the text field.
1190 TestGenerateTap( application, 43.0f, 25.0f );
1192 // Render and notify
1193 application.SendNotification();
1194 application.Render();
1196 // Executes the idle callbacks added by the text control on the change of input style.
1197 application.RunIdles();
1199 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1200 if( gInputStyleChangedCallbackCalled )
1202 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1204 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1205 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1207 DALI_TEST_CHECK( inputStyleChangedSignal );
1209 gInputStyleChangedCallbackCalled = false;
1210 gInputStyleMask = TextField::InputStyle::NONE;
1211 inputStyleChangedSignal = false;
1213 // Create a tap event to touch the text field.
1214 TestGenerateTap( application, 88.0f, 25.0f );
1216 // Render and notify
1217 application.SendNotification();
1218 application.Render();
1220 // Executes the idle callbacks added by the text control on the change of input style.
1221 application.RunIdles();
1223 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1224 if( gInputStyleChangedCallbackCalled )
1226 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1228 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1229 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1231 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1233 Property::Map fontStyleMapSet;
1234 fontStyleMapSet.Insert( "weight", "bold" );
1236 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1237 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1239 DALI_TEST_CHECK( inputStyleChangedSignal );
1241 gInputStyleChangedCallbackCalled = false;
1242 gInputStyleMask = TextField::InputStyle::NONE;
1243 inputStyleChangedSignal = false;
1245 // Create a tap event to touch the text field.
1246 TestGenerateTap( application, 115.0f, 25.0f );
1248 // Render and notify
1249 application.SendNotification();
1250 application.Render();
1252 // Executes the idle callbacks added by the text control on the change of input style.
1253 application.RunIdles();
1255 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1256 DALI_TEST_CHECK( !inputStyleChangedSignal );
1258 gInputStyleChangedCallbackCalled = false;
1259 gInputStyleMask = TextField::InputStyle::NONE;
1260 inputStyleChangedSignal = false;
1262 // Create a tap event to touch the text field.
1263 TestGenerateTap( application, 164.0f, 25.0f );
1265 // Render and notify
1266 application.SendNotification();
1267 application.Render();
1269 // Executes the idle callbacks added by the text control on the change of input style.
1270 application.RunIdles();
1272 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1273 if( gInputStyleChangedCallbackCalled )
1275 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1277 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1278 DALI_TEST_CHECK( style.empty() );
1280 DALI_TEST_CHECK( inputStyleChangedSignal );
1282 gInputStyleChangedCallbackCalled = false;
1283 gInputStyleMask = TextField::InputStyle::NONE;
1284 inputStyleChangedSignal = false;
1286 // Create a tap event to touch the text field.
1287 TestGenerateTap( application, 191.0f, 25.0f );
1289 // Render and notify
1290 application.SendNotification();
1291 application.Render();
1293 // Executes the idle callbacks added by the text control on the change of input style.
1294 application.RunIdles();
1296 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1297 DALI_TEST_CHECK( !inputStyleChangedSignal );
1302 int utcDaliTextFieldInputStyleChanged02(void)
1304 // The text-field emits signals when the input style changes. These changes of style are
1305 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1306 // can't be emitted during the size negotiation as the callbacks may update the UI.
1307 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1308 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1309 ToolkitTestApplication application;
1310 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1314 char* pathNamePtr = get_current_dir_name();
1315 const std::string pathName( pathNamePtr );
1316 free( pathNamePtr );
1318 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1319 fontClient.SetDpi( 93u, 93u );
1321 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1322 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1324 TextField field = TextField::New();
1325 DALI_TEST_CHECK( field );
1327 field.SetSize( 300.f, 50.f );
1328 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1329 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1331 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1332 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>" );
1334 // connect to the text changed signal.
1335 ConnectionTracker* testTracker = new ConnectionTracker();
1336 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1337 bool inputStyleChangedSignal = false;
1338 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1340 Stage::GetCurrent().Add( field );
1342 // Render and notify
1343 application.SendNotification();
1344 application.Render();
1346 // Executes the idle callbacks added by the text control on the change of input style.
1347 application.RunIdles();
1349 gInputStyleChangedCallbackCalled = false;
1350 gInputStyleMask = TextField::InputStyle::NONE;
1351 inputStyleChangedSignal = false;
1353 // Create a tap event to touch the text field.
1354 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1355 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1357 // Render and notify
1358 application.SendNotification();
1359 application.Render();
1361 // Executes the idle callbacks added by the text control on the change of input style.
1362 application.RunIdles();
1364 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1365 if( gInputStyleChangedCallbackCalled )
1367 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1368 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1369 TextField::InputStyle::POINT_SIZE |
1370 TextField::InputStyle::COLOR ),
1373 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1374 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1376 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1377 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1379 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1380 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1382 DALI_TEST_CHECK( inputStyleChangedSignal );
1384 gInputStyleChangedCallbackCalled = false;
1385 gInputStyleMask = TextField::InputStyle::NONE;
1386 inputStyleChangedSignal = false;
1388 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1390 // Render and notify
1391 application.SendNotification();
1392 application.Render();
1394 // Executes the idle callbacks added by the text control on the change of input style.
1395 application.RunIdles();
1397 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1398 if( gInputStyleChangedCallbackCalled )
1400 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1401 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1404 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1405 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1407 DALI_TEST_CHECK( inputStyleChangedSignal );
1409 gInputStyleChangedCallbackCalled = false;
1410 gInputStyleMask = TextField::InputStyle::NONE;
1411 inputStyleChangedSignal = false;
1413 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1415 // Render and notify
1416 application.SendNotification();
1417 application.Render();
1419 // Executes the idle callbacks added by the text control on the change of input style.
1420 application.RunIdles();
1422 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1423 DALI_TEST_CHECK( !inputStyleChangedSignal );
1425 gInputStyleChangedCallbackCalled = false;
1426 gInputStyleMask = TextField::InputStyle::NONE;
1427 inputStyleChangedSignal = false;
1429 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1431 // Render and notify
1432 application.SendNotification();
1433 application.Render();
1435 // Executes the idle callbacks added by the text control on the change of input style.
1436 application.RunIdles();
1438 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1439 if( gInputStyleChangedCallbackCalled )
1441 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1442 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1445 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1446 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1448 DALI_TEST_CHECK( inputStyleChangedSignal );
1450 gInputStyleChangedCallbackCalled = false;
1451 gInputStyleMask = TextField::InputStyle::NONE;
1452 inputStyleChangedSignal = false;
1454 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1456 Property::Map fontStyleMapSet;
1457 fontStyleMapSet.Insert( "weight", "thin" );
1458 fontStyleMapSet.Insert( "width", "condensed" );
1459 fontStyleMapSet.Insert( "slant", "italic" );
1461 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1462 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1464 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1465 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1466 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1467 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1469 // Render and notify
1470 application.SendNotification();
1471 application.Render();
1473 // Executes the idle callbacks added by the text control on the change of input style.
1474 application.RunIdles();
1476 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1477 DALI_TEST_CHECK( !inputStyleChangedSignal );
1479 // Create a tap event to touch the text field.
1480 TestGenerateTap( application, 63.0f, 25.0f, 300 );
1482 // Render and notify
1483 application.SendNotification();
1484 application.Render();
1486 // Executes the idle callbacks added by the text control on the change of input style.
1487 application.RunIdles();
1489 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1490 if( gInputStyleChangedCallbackCalled )
1492 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1493 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1494 TextField::InputStyle::POINT_SIZE |
1495 TextField::InputStyle::FONT_STYLE |
1496 TextField::InputStyle::UNDERLINE |
1497 TextField::InputStyle::SHADOW |
1498 TextField::InputStyle::EMBOSS |
1499 TextField::InputStyle::OUTLINE ),
1502 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1503 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1505 DALI_TEST_CHECK( inputStyleChangedSignal );
1510 int utcDaliTextFieldEvent01(void)
1512 ToolkitTestApplication application;
1513 tet_infoline(" utcDaliTextFieldEvent01");
1515 // Creates a tap event. After creating a tap event the text field should
1516 // have the focus and add text with key events should be possible.
1518 TextField field = TextField::New();
1519 DALI_TEST_CHECK( field );
1521 Stage::GetCurrent().Add( field );
1523 field.SetSize( 300.f, 50.f );
1524 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1525 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1527 // Render and notify
1528 application.SendNotification();
1529 application.Render();
1531 // Avoid a crash when core load gl resources.
1532 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1534 // Render and notify
1535 application.SendNotification();
1536 application.Render();
1538 // Add a key event but as the text field has not the focus it should do nothing.
1539 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1541 // Render and notify
1542 application.SendNotification();
1543 application.Render();
1545 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1547 // Create a tap event to touch the text field.
1548 TestGenerateTap( application, 150.0f, 25.0f );
1550 // Render and notify
1551 application.SendNotification();
1552 application.Render();
1554 // Pressing delete key should be fine even if there is no text in TextField.
1555 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 ) );
1556 // Render and notify
1557 application.SendNotification();
1558 application.Render();
1560 // Now the text field has the focus, so it can handle the key events.
1561 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1562 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1564 // Render and notify
1565 application.SendNotification();
1566 application.Render();
1568 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1570 // Create a second text field and send key events to it.
1571 TextField field2 = TextField::New();
1573 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1574 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1575 field2.SetSize( 100.f, 100.0f );
1576 field2.SetPosition( 100.0f, 100.0f );
1578 Stage::GetCurrent().Add( field2 );
1580 // Render and notify
1581 application.SendNotification();
1582 application.Render();
1584 // Create a tap event on the second text field.
1585 TestGenerateTap( application, 150.0f, 125.0f );
1587 // Render and notify
1588 application.SendNotification();
1589 application.Render();
1591 // The second text field has the focus. It should handle the key events.
1592 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1593 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1595 // Render and notify
1596 application.SendNotification();
1597 application.Render();
1599 // Check the text has been added to the second text field.
1600 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1605 int utcDaliTextFieldEvent02(void)
1607 ToolkitTestApplication application;
1608 tet_infoline(" utcDaliTextFieldEvent02");
1610 // Checks if the right number of actors are created.
1612 TextField field = TextField::New();
1613 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1614 DALI_TEST_CHECK( field );
1615 LoadMarkerImages(application, field);
1617 Stage::GetCurrent().Add( field );
1619 field.SetSize( 300.0f, 50.0f );
1620 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1621 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1623 // Avoid a crash when core load gl resources.
1624 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1626 // Render and notify
1627 application.SendNotification();
1628 application.Render();
1630 // Check there are the expected number of children ( stencil ).
1631 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1633 Actor stencil = field.GetChildAt( 0u );
1634 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1636 // Create a tap event to touch the text field.
1637 TestGenerateTap( application, 150.0f, 25.0f, 300 );
1639 // Render and notify
1640 application.SendNotification();
1641 application.Render();
1643 Actor layer = field.GetChildAt( 1u );
1644 DALI_TEST_CHECK( layer.IsLayer() );
1646 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1647 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1649 // Now the text field has the focus, so it can handle the key events.
1650 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1651 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1653 // Render and notify
1654 application.SendNotification();
1655 application.Render();
1657 // Checks the cursor and the renderer have been created.
1658 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1659 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1661 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1662 DALI_TEST_CHECK( cursor );
1664 // The offscreen root actor has a container with all the actors which contain the text renderers.
1665 Actor container = stencil.GetChildAt( 0u );
1666 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1668 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1669 DALI_TEST_CHECK( renderer );
1672 // Move the cursor and check the position changes.
1673 Vector3 position1 = cursor.GetCurrentPosition();
1674 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1676 // Render and notify
1677 application.SendNotification();
1678 application.Render();
1680 Vector3 position2 = cursor.GetCurrentPosition();
1681 DALI_TEST_CHECK( position2.x < position1.x );
1683 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1685 // Render and notify
1686 application.SendNotification();
1687 application.Render();
1689 Vector3 position3 = cursor.GetCurrentPosition();
1690 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1693 // Move the cursor to the first position.
1694 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1695 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1697 // Render and notify
1698 application.SendNotification();
1699 application.Render();
1701 Vector3 position4 = cursor.GetCurrentPosition();
1703 // Send some taps and check the cursor positions.
1705 // Try to tap at the beginning.
1706 TestGenerateTap( application, 1.0f, 25.0f, 900 );
1708 // Render and notify
1709 application.SendNotification();
1710 application.Render();
1712 // Cursor position should be the same than position1.
1713 Vector3 position5 = cursor.GetCurrentPosition();
1715 DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
1717 // Tap away from the start position.
1718 TestGenerateTap( application, 16.0f, 25.0f, 1500 );
1720 // Render and notify
1721 application.SendNotification();
1722 application.Render();
1724 Vector3 position6 = cursor.GetCurrentPosition();
1726 DALI_TEST_CHECK( position6.x > position5.x );
1728 // Remove all the text.
1729 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1730 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1731 field.SetProperty( TextField::Property::TEXT, "" );
1733 // Render and notify
1734 application.SendNotification();
1735 application.Render();
1737 // Cursor position should be the same than position2.
1738 Vector3 position7 = cursor.GetCurrentPosition();
1740 DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
1742 // Should not be a renderer.
1743 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1745 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1746 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1747 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1749 application.SendNotification();
1750 application.Render();
1752 // There are renderer and decorator layer
1753 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1758 int utcDaliTextFieldEvent03(void)
1760 ToolkitTestApplication application;
1761 tet_infoline(" utcDaliTextFieldEvent03");
1763 // Checks if the highlight actor is created.
1765 TextField field = TextField::New();
1766 DALI_TEST_CHECK( field );
1768 Stage::GetCurrent().Add( field );
1770 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1771 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1772 field.SetSize( 30.f, 50.f );
1773 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1774 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1776 // Avoid a crash when core load gl resources.
1777 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1778 LoadMarkerImages(application, field);
1780 // Render and notify
1781 application.SendNotification();
1782 application.Render();
1784 // Tap first to get the focus.
1785 TestGenerateTap( application, 3.0f, 25.0f );
1787 // Render and notify
1788 application.SendNotification();
1789 application.Render();
1791 // Double tap to select a word.
1792 TestGenerateTap( application, 3.0f, 25.0f );
1794 // Render and notify
1795 application.SendNotification();
1796 application.Render();
1798 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1799 Actor stencil = field.GetChildAt( 0u );
1801 // The highlight actor is drawn first, so is the first actor in the list
1802 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1803 DALI_TEST_CHECK( highlight );
1805 // The offscreen root actor has a container with all the actors which contain the text renderers.
1806 Actor container = stencil.GetChildAt( 1u );
1807 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1809 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1810 DALI_TEST_CHECK( renderer );
1816 int utcDaliTextFieldEvent04(void)
1818 ToolkitTestApplication application;
1819 tet_infoline(" utcDaliTextFieldEvent04");
1821 // Checks if the highlight actor is created.
1823 TextField field = TextField::New();
1824 DALI_TEST_CHECK( field );
1825 Stage::GetCurrent().Add( field );
1826 LoadMarkerImages(application, field);
1827 // Render and notify
1828 application.SendNotification();
1829 application.Render();
1831 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1832 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1833 field.SetSize( 300.f, 50.f );
1834 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1835 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1837 // Avoid a crash when core load gl resources.
1838 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1839 // Render and notify
1840 application.SendNotification();
1841 application.Render();
1843 // Create a tap event to touch the text field.
1844 TestGenerateTap( application, 150.0f, 25.0f );
1845 // Render and notify
1846 application.SendNotification();
1847 application.Render();
1850 // Tap first to get the focus.
1851 TestGenerateTap( application, 1.0f, 25.0f );
1853 // Render and notify
1854 application.SendNotification();
1855 application.Render();
1857 // Double tap to select a word.
1858 TestGenerateTap( application, 1.0f, 25.0f );
1860 // Render and notify
1861 application.SendNotification();
1862 application.Render();
1865 TestGenerateTap( application, 0.0f, 40.0f );
1869 int utcDaliTextFieldEvent05(void)
1871 ToolkitTestApplication application;
1872 tet_infoline(" utcDaliTextFieldEvent05");
1874 // Checks dragging of cursor/grab handle
1876 TextField field = TextField::New();
1877 DALI_TEST_CHECK( field );
1878 Stage::GetCurrent().Add( field );
1879 LoadMarkerImages(application, field);
1880 // Render and notify
1881 application.SendNotification();
1882 application.Render();
1884 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1885 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1886 field.SetSize( 300.f, 50.f );
1887 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1888 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1890 // Avoid a crash when core load gl resources.
1891 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1892 // Render and notify
1893 application.SendNotification();
1894 application.Render();
1896 // Create a tap event to touch the text field.
1897 TestGenerateTap( application, 150.0f, 25.0f );
1898 // Render and notify
1899 application.SendNotification();
1900 application.Render();
1902 // Tap first to get the focus.
1903 TestGenerateTap( application, 1.0f, 25.0f );
1905 // Render and notify
1906 application.SendNotification();
1907 application.Render();
1909 // Double tap to select a word.
1910 TestGenerateTap( application, 1.0f, 25.0f );
1912 // Render and notify
1913 application.SendNotification();
1914 application.Render();
1916 Actor stencil = field.GetChildAt( 1u );
1920 int utcDaliTextFieldEvent06(void)
1922 ToolkitTestApplication application;
1923 tet_infoline(" utcDaliTextFieldEvent06");
1925 // Checks Longpress when in edit mode
1927 TextField field = TextField::New();
1928 DALI_TEST_CHECK( field );
1929 Stage::GetCurrent().Add( field );
1930 LoadMarkerImages(application, field);
1931 // Render and notify
1932 application.SendNotification();
1933 application.Render();
1935 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1936 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1937 field.SetSize( 300.f, 50.f );
1938 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1939 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1941 // Avoid a crash when core load gl resources.
1942 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1943 // Render and notify
1944 application.SendNotification();
1945 application.Render();
1947 // Create a tap event to touch the text field.
1948 TestGenerateTap( application, 150.0f, 25.0f );
1949 // Render and notify
1950 application.SendNotification();
1951 application.Render();
1954 // Tap first to get the focus.
1955 TestGenerateTap( application, 1.0f, 25.0f );
1957 // Render and notify
1958 application.SendNotification();
1959 application.Render();
1962 TestGenerateLongPress(application, 1.0f, 25.0f);
1964 // Render and notify
1965 application.SendNotification();
1966 application.Render();
1971 int utcDaliTextFieldEvent07(void)
1973 ToolkitTestApplication application;
1974 tet_infoline(" utcDaliTextFieldEvent07");
1976 // Checks Longpress to start edit mode
1978 TextField field = TextField::New();
1979 DALI_TEST_CHECK( field );
1980 Stage::GetCurrent().Add( field );
1981 LoadMarkerImages(application, field);
1982 // Render and notify
1983 application.SendNotification();
1984 application.Render();
1986 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1987 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1988 field.SetSize( 300.f, 50.f );
1989 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1990 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1991 Property::Map propertyMap;
1992 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
1993 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
1995 // Avoid a crash when core load gl resources.
1996 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1997 // Render and notify
1998 application.SendNotification();
1999 application.Render();
2002 TestGenerateLongPress(application, 1.0f, 25.0f);
2004 // Render and notify
2005 application.SendNotification();
2006 application.Render();
2011 int utcDaliTextFieldEvent08(void)
2013 ToolkitTestApplication application;
2014 tet_infoline(" utcDaliTextFieldEvent08");
2016 Dali::Clipboard clipboard = Clipboard::Get();
2017 clipboard.SetItem("testTextFieldEvent");
2019 // Checks Longpress when only place holder text
2021 TextField field = TextField::New();
2022 DALI_TEST_CHECK( field );
2023 Stage::GetCurrent().Add( field );
2024 LoadMarkerImages(application, field);
2025 // Render and notify
2026 application.SendNotification();
2027 application.Render();
2029 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2030 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2031 field.SetSize( 300.f, 50.f );
2032 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2033 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2035 // Avoid a crash when core load gl resources.
2036 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2037 // Render and notify
2038 application.SendNotification();
2039 application.Render();
2042 TestGenerateLongPress( application, 1.0f, 25.0f, 20 );
2044 // Render and notify
2045 application.SendNotification();
2046 application.Render();
2048 Wait(application, 500);
2050 TestEndLongPress( application, 1.0f, 25.0f, 520 );
2053 TestGenerateLongPress( application, 1.0f, 25.0f, 600 );
2055 // Render and notify
2056 application.Render();
2058 Wait(application, 500);
2060 Stage stage = Stage::GetCurrent();
2061 Layer layer = stage.GetRootLayer();
2062 Actor actor = layer.FindChildByName("optionPaste");
2066 Vector3 worldPosition = actor.GetCurrentWorldPosition();
2067 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2068 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2070 Dali::Integration::TouchEvent event;
2071 event = Dali::Integration::TouchEvent();
2072 event.AddPoint( GetPointDownInside( position ) );
2073 application.ProcessEvent( event );
2075 event = Dali::Integration::TouchEvent();
2076 event.AddPoint( GetPointUpInside( position ) );
2077 application.ProcessEvent( event );
2079 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2084 int utcDaliTextFieldEvent09(void)
2086 ToolkitTestApplication application;
2087 tet_infoline(" utcDaliTextFieldEvent09");
2089 TextField field = TextField::New();
2090 DALI_TEST_CHECK( field );
2091 Stage::GetCurrent().Add( field );
2092 LoadMarkerImages(application, field);
2093 // Render and notify
2094 application.SendNotification();
2095 application.Render();
2097 field.SetProperty( TextField::Property::TEXT, "Hello" );
2098 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2099 field.SetSize( 300.f, 50.f );
2100 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2101 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2103 // Avoid a crash when core load gl resources.
2104 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2106 // Create a tap event to touch the text field.
2107 TestGenerateTap( application, 150.0f, 25.0f );
2108 application.SendNotification();
2109 application.Render();
2112 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2113 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2114 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2115 application.SendNotification();
2116 application.Render();
2118 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2119 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2120 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2121 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2122 application.SendNotification();
2123 application.Render();
2125 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2126 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2127 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2128 for( unsigned int index = 0u; index < 5u; ++index )
2130 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2131 application.SendNotification();
2132 application.Render();
2135 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2136 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2137 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2138 for( unsigned int index = 0u; index < 5u; ++index )
2140 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2141 application.SendNotification();
2142 application.Render();
2145 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2146 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2147 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2148 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2149 application.SendNotification();
2150 application.Render();
2151 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2152 application.SendNotification();
2153 application.Render();
2155 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2156 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2157 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2158 application.SendNotification();
2159 application.Render();
2161 Property::Map mapGet;
2162 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2163 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2164 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2169 int utcDaliTextFieldStyleWhilstSelected(void)
2171 ToolkitTestApplication application;
2172 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2174 // Change font and styles whilst text is selected whilst word selected
2176 TextField field = TextField::New();
2177 DALI_TEST_CHECK( field );
2178 Stage::GetCurrent().Add( field );
2179 LoadMarkerImages(application, field);
2180 // Render and notify
2181 application.SendNotification();
2182 application.Render();
2184 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2185 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2186 field.SetSize( 300.f, 50.f );
2187 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2188 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2190 // Avoid a crash when core load gl resources.
2191 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2192 // Render and notify
2193 application.SendNotification();
2194 application.Render();
2196 // Create a tap event to touch the text field.
2197 TestGenerateTap( application, 150.0f, 25.0f );
2198 // Render and notify
2199 application.SendNotification();
2200 application.Render();
2203 // Tap first to get the focus.
2204 TestGenerateTap( application, 1.0f, 25.0f );
2206 // Render and notify
2207 application.SendNotification();
2208 application.Render();
2210 // Double tap to select a word.
2211 TestGenerateTap( application, 1.0f, 25.0f );
2213 // Render and notify
2214 application.SendNotification();
2215 application.Render();
2217 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2218 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2220 Property::Map fontStyleMapSet;
2221 Property::Map fontStyleMapGet;
2223 fontStyleMapSet.Insert( "weight", "bold" );
2224 fontStyleMapSet.Insert( "slant", "italic" );
2225 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2227 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2228 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2229 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2231 fontStyleMapSet.Clear();
2232 fontStyleMapSet.Insert( "width", "expanded" );
2233 fontStyleMapSet.Insert( "slant", "italic" );
2234 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2236 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2237 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2238 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2240 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2241 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2243 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2244 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2246 fontStyleMapSet.Clear();
2247 fontStyleMapSet.Insert( "weight", "bold" );
2248 fontStyleMapSet.Insert( "slant", "italic" );
2250 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2252 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2253 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2254 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2256 fontStyleMapSet.Clear();
2257 fontStyleMapSet.Insert( "width", "expanded" );
2259 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2261 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2262 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2263 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2265 // Press Escape to increase coverage
2266 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2267 application.SendNotification();
2268 application.Render();
2270 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2275 int utcDaliTextFieldEscKeyLoseFocus(void)
2277 ToolkitTestApplication application;
2278 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2280 // Creates a tap event. After creating a tap event the text field should
2281 // have the focus and add text with key events should be possible.
2283 TextField field = TextField::New();
2284 DALI_TEST_CHECK( field );
2286 Stage::GetCurrent().Add( field );
2288 field.SetSize( 300.f, 50.f );
2289 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2290 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2292 // Avoid a crash when core load gl resources.
2293 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2295 // Render and notify
2296 application.SendNotification();
2297 application.Render();
2299 // Add a key event but as the text field has not the focus it should do nothing.
2300 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2301 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2303 // Render and notify
2304 application.SendNotification();
2305 application.Render();
2307 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2309 // Create a tap event to touch the text field.
2310 TestGenerateTap( application, 150.0f, 25.0f );
2312 // Render and notify
2313 application.SendNotification();
2314 application.Render();
2316 // Now the text field has the focus, so it can handle the key events.
2317 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2318 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2319 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2320 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2322 // Render and notify
2323 application.SendNotification();
2324 application.Render();
2326 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2328 // Generate a Esc key event. The text field should lose the focus.
2329 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2330 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2332 // Render and notify
2333 application.SendNotification();
2334 application.Render();
2336 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2338 // No more text should be introduced
2339 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2340 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2342 // Render and notify
2343 application.SendNotification();
2344 application.Render();
2346 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2351 int utcDaliTextFieldSomeSpecialKeys(void)
2353 ToolkitTestApplication application;
2354 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2356 // Checks some special keys when the text is selected.
2358 TextField field = TextField::New();
2359 DALI_TEST_CHECK( field );
2360 Stage::GetCurrent().Add( field );
2361 LoadMarkerImages(application, field);
2362 // Render and notify
2363 application.SendNotification();
2364 application.Render();
2366 const std::string longText( "This is a long text for the size of the text-field." );
2368 field.SetProperty( TextField::Property::TEXT, longText );
2369 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2370 field.SetSize( 300.f, 50.f );
2371 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2372 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2374 // Avoid a crash when core load gl resources.
2375 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2376 // Render and notify
2377 application.SendNotification();
2378 application.Render();
2380 // Create a tap event to touch the text field.
2381 TestGenerateTap( application, 150.0f, 25.0f );
2383 // Render and notify
2384 application.SendNotification();
2385 application.Render();
2387 // Tap first to get the focus.
2388 TestGenerateTap( application, 1.0f, 25.0f );
2390 // Render and notify
2391 application.SendNotification();
2392 application.Render();
2394 // Double tap to select a word.
2395 TestGenerateTap( application, 1.0f, 25.0f );
2397 // Render and notify
2398 application.SendNotification();
2399 application.Render();
2401 // Generate a Esc key event. The text field should lose the focus.
2402 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2403 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2405 // Render and notify
2406 application.SendNotification();
2407 application.Render();
2409 // Generate a Esc key event. The text field should lose the focus.
2410 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2411 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2413 // Render and notify
2414 application.SendNotification();
2415 application.Render();
2417 // Generate a Esc key event. The text field should lose the focus.
2418 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2419 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2421 // Render and notify
2422 application.SendNotification();
2423 application.Render();
2425 // The text shouldn't be deleted.
2426 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2431 int utcDaliTextFieldSizeUpdate(void)
2433 ToolkitTestApplication application;
2434 tet_infoline("utcDaliTextFieldSizeUpdate");
2436 // Checks some special keys when the text is selected.
2437 TextField field = TextField::New();
2438 DALI_TEST_CHECK( field );
2439 Stage::GetCurrent().Add( field );
2441 float previousHeight = 0.0f;
2442 float currentHeight = 0.0f;
2443 const float fieldWidth = 1920.0f;
2446 // "ㅁ" is bigger then "ኢ"
2447 field.SetSize( Vector2( fieldWidth ,10.0f ) );
2448 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2449 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2451 field.SetProperty( TextField::Property::TEXT, "ኢ");
2452 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2453 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2455 field.SetKeyboardFocusable(true);
2456 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2458 application.SendNotification();
2459 application.Render();
2461 previousHeight = field.GetHeightForWidth( fieldWidth );
2462 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2464 // Add another script characters ( glyph height is defferent )
2465 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2466 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2468 application.SendNotification();
2469 application.Render();
2471 currentHeight = field.GetHeightForWidth( fieldWidth );
2472 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2473 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2478 int utcDaliTextFieldExtremlyLargePointSize(void)
2480 ToolkitTestApplication application;
2481 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2483 TextField field = TextField::New();
2485 field.SetProperty( TextField::Property::TEXT, "Text" );
2486 field.SetSize( 300.f, 50.f );
2487 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2488 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2489 Stage::GetCurrent().Add( field );
2493 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2494 application.SendNotification();
2495 DALI_TEST_CHECK( field );
2499 tet_result(TET_FAIL);
2504 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2506 ToolkitTestApplication application;
2507 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2508 TextField field = TextField::New();
2509 DALI_TEST_CHECK( field );
2510 Stage::GetCurrent().Add( field );
2512 Property::Map fontStyleMapGet;
2514 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2516 Property::Value* weightValue = NULL;
2517 Property::Value* widthValue = NULL;
2518 Property::Value* slantValue = NULL;
2519 weightValue = fontStyleMapGet.Find( "weight" );
2520 widthValue = fontStyleMapGet.Find( "width" );
2521 slantValue = fontStyleMapGet.Find( "slant" );
2522 DALI_TEST_CHECK( !weightValue );
2523 DALI_TEST_CHECK( !widthValue );
2524 DALI_TEST_CHECK( !slantValue );
2529 int UtcDaliTextFieldSettingPlaceholder(void)
2531 ToolkitTestApplication application;
2532 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
2534 TextField field = TextField::New();
2535 DALI_TEST_CHECK( field );
2536 Stage::GetCurrent().Add( field );
2538 // Check the placeholder property with pixel size
2539 Property::Map placeholderPixelSizeMapSet;
2540 Property::Map placeholderPixelSizeMapGet;
2541 Property::Map placeholderFontstyleMap;
2542 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2543 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2544 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
2545 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2546 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
2547 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
2549 placeholderFontstyleMap.Insert( "weight", "bold" );
2550 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2551 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
2553 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2554 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
2555 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
2557 // Check the placeholder property with point size
2558 Property::Map placeholderMapSet;
2559 Property::Map placeholderMapGet;
2560 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2561 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2562 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
2563 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2564 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
2565 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
2567 // Check the placeholder font style property
2568 placeholderFontstyleMap.Clear();
2570 placeholderFontstyleMap.Insert( "weight", "bold" );
2571 placeholderFontstyleMap.Insert( "width", "condensed" );
2572 placeholderFontstyleMap.Insert( "slant", "italic" );
2573 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2574 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2576 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2577 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2578 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2580 // Reset font style.
2581 placeholderFontstyleMap.Clear();
2582 placeholderFontstyleMap.Insert( "weight", "normal" );
2583 placeholderFontstyleMap.Insert( "slant", "oblique" );
2584 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2585 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2587 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2588 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2589 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2591 placeholderFontstyleMap.Clear();
2592 placeholderFontstyleMap.Insert( "slant", "roman" );
2593 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2594 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2596 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2598 placeholderFontstyleMap.Clear();
2599 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2601 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2602 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2603 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2604 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2609 int UtcDaliTextFieldSetPaddingProperty(void)
2611 ToolkitTestApplication application;
2612 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
2614 TextField field = TextField::New();
2615 DALI_TEST_CHECK( field );
2616 field.SetSize( 300.f, 50.f );
2617 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2618 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2619 Stage::GetCurrent().Add( field );
2621 application.SendNotification();
2622 application.Render();
2624 Vector3 originalSize = field.GetNaturalSize();
2626 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2628 application.SendNotification();
2629 application.Render();
2631 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2633 Vector3 paddingAddedSize = field.GetNaturalSize();
2635 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2637 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2642 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
2644 ToolkitTestApplication application;
2645 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
2647 TextField field = TextField::New();
2648 DALI_TEST_CHECK( field );
2649 field.SetSize( 300.0f, 50.0f );
2650 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2651 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2652 Stage::GetCurrent().Add( field );
2654 application.SendNotification();
2655 application.Render();
2657 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2658 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2660 // Check the enable shift selection property
2661 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
2662 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2664 application.SendNotification();
2665 application.Render();
2670 int UtcDaliTextFieldEnableGrabHandleProperty(void)
2672 ToolkitTestApplication application;
2673 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
2675 TextField field = TextField::New();
2676 DALI_TEST_CHECK( field );
2677 field.SetSize( 300.0f, 50.0f );
2678 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2679 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2680 Stage::GetCurrent().Add( field );
2682 application.SendNotification();
2683 application.Render();
2685 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2686 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2688 // Check the enable grab handle property
2689 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
2690 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2692 application.SendNotification();
2693 application.Render();
2698 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
2700 ToolkitTestApplication application;
2701 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
2703 TextField field = TextField::New();
2704 DALI_TEST_CHECK( field );
2705 field.SetSize( 300.0f, 50.0f );
2706 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2707 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2708 Stage::GetCurrent().Add( field );
2710 application.SendNotification();
2711 application.Render();
2713 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2714 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2716 // Check the match system language direction property
2717 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2718 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2720 application.SendNotification();
2721 application.Render();
2726 int utcDaliTextFieldLayoutDirectionCoverage(void)
2728 ToolkitTestApplication application;
2729 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
2731 // Creates a tap event. After creating a tap event the text field should
2732 // have the focus and add text with key events should be possible.
2733 TextField field = TextField::New();
2734 DALI_TEST_CHECK( field );
2736 Stage::GetCurrent().Add( field );
2738 field.SetSize( 300.0f, 50.0f );
2739 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2740 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2742 // Avoid a crash when core load gl resources.
2743 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2745 // Render and notify
2746 application.SendNotification();
2747 application.Render();
2749 // init direction for coverage
2750 // Set horizontal alignment END
2751 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2753 // Create a tap event to touch the text field.
2754 TestGenerateTap( application, 150.0f, 25.0f );
2756 // Render and notify
2757 application.SendNotification();
2758 application.Render();
2760 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
2761 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2762 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
2764 // Set horizontal alignment BEGIN
2765 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
2767 // Create a tap event to touch the text field.
2768 TestGenerateTap( application, 150.0f, 25.0f );
2770 // Render and notify
2771 application.SendNotification();
2772 application.Render();
2774 // Set horizontal alignment CENTER
2775 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
2777 // Create a tap event to touch the text field.
2778 TestGenerateTap( application, 150.0f, 25.0f );
2780 // Render and notify
2781 application.SendNotification();
2782 application.Render();
2784 // Set horizontal alignment END
2785 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2787 // Create a tap event to touch the text field.
2788 TestGenerateTap( application, 150.0f, 25.0f );
2790 // Render and notify
2791 application.SendNotification();
2792 application.Render();
2794 // Generate a Esc key event. The text field should lose the focus.
2795 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2796 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2798 // Render and notify
2799 application.SendNotification();
2800 application.Render();
2802 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2807 int UtcDaliTextFieldGetInputMethodContext(void)
2809 ToolkitTestApplication application;
2810 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
2812 TextField field = TextField::New();
2813 DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );
2818 int UtcDaliTextFieldSelectWholeText(void)
2820 ToolkitTestApplication application;
2821 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
2823 TextField textField = TextField::New();
2825 Stage::GetCurrent().Add( textField );
2827 textField.SetSize( 300.f, 50.f );
2828 textField.SetParentOrigin( ParentOrigin::TOP_LEFT );
2829 textField.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2831 // Avoid a crash when core load gl resources.
2832 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2834 application.SendNotification();
2835 application.Render();
2837 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2839 DevelTextField::SelectWholeText( textField );
2841 application.SendNotification();
2842 application.Render();
2844 // Nothing should have been selected. The number of children is still 1
2845 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2847 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
2849 application.SendNotification();
2850 application.Render();
2852 DevelTextField::SelectWholeText( textField );
2854 application.SendNotification();
2855 application.Render();
2857 // Should be 2 children, the stencil and the layer
2858 DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
2860 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2861 Actor stencil = textField.GetChildAt( 0u );
2863 // The highlight actor is drawn first, so is the first actor in the list
2864 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2865 DALI_TEST_CHECK( highlight );