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-toolkit-test-suite-utils.h>
28 #include <dali-toolkit/dali-toolkit.h>
29 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
30 #include "toolkit-clipboard.h"
33 using namespace Toolkit;
35 void dali_textfield_startup(void)
37 test_return_value = TET_UNDEF;
40 void dali_textfield_cleanup(void)
42 test_return_value = TET_PASS;
48 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
49 const char* const PROPERTY_NAME_TEXT = "text";
50 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
51 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
52 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
53 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
54 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
55 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
56 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
57 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
58 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
59 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
60 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
61 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
62 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
63 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
64 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
65 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
66 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
67 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
68 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
69 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
70 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
71 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
72 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
73 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
77 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
78 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
79 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
80 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
81 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
82 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
83 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
84 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
86 const char* const PROPERTY_NAME_UNDERLINE = "underline";
87 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
88 const char* const PROPERTY_NAME_SHADOW = "shadow";
89 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
90 const char* const PROPERTY_NAME_EMBOSS = "emboss";
91 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
92 const char* const PROPERTY_NAME_OUTLINE = "outline";
93 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
95 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
96 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
97 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
98 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
99 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
100 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
101 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
102 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
103 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
105 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
106 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
108 const float RENDER_FRAME_INTERVAL = 16.66f;
110 const unsigned int DEFAULT_FONT_SIZE = 1152u;
111 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
113 const int KEY_RETURN_CODE = 36;
114 const int KEY_A_CODE = 38;
115 const int KEY_D_CODE = 40;
117 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
119 static bool gTextChangedCallBackCalled;
120 static bool gMaxCharactersCallBackCalled;
121 static bool gInputStyleChangedCallbackCalled;
122 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
124 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
126 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
127 Integration::ResourcePointer resource(bitmap);
128 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
131 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
135 LoadBitmapResource( app.GetPlatform(), width, height );
137 Property::Map propertyMap;
138 propertyMap["filename"] = "image.png";
139 propertyMap["width"] = width;
140 propertyMap["height"] = height;
141 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
142 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
143 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
144 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
145 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
146 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
147 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
148 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
152 * Simulate time passed by.
154 * @note this will always process at least 1 frame (1/60 sec)
156 * @param application Test application instance
157 * @param duration Time to pass in milliseconds.
158 * @return The actual time passed in milliseconds
160 static int Wait(ToolkitTestApplication& application, int duration = 0)
164 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
166 application.SendNotification();
167 application.Render(RENDER_FRAME_INTERVAL);
168 time += RENDER_FRAME_INTERVAL;
174 Dali::Integration::Point GetPointDownInside( Vector2& pos )
176 Dali::Integration::Point point;
177 point.SetState( PointState::DOWN );
178 point.SetScreenPosition( pos );
182 Dali::Integration::Point GetPointUpInside( Vector2& pos )
184 Dali::Integration::Point point;
185 point.SetState( PointState::UP );
186 point.SetScreenPosition( pos );
190 struct CallbackFunctor
192 CallbackFunctor(bool* callbackFlag)
193 : mCallbackFlag( callbackFlag )
199 *mCallbackFlag = true;
204 static void TestTextChangedCallback( TextField control )
206 tet_infoline(" TestTextChangedCallback");
208 gTextChangedCallBackCalled = true;
211 static void TestMaxLengthReachedCallback( TextField control )
213 tet_infoline(" TestMaxLengthReachedCallback");
215 gMaxCharactersCallBackCalled = true;
218 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
220 tet_infoline(" TestInputStyleChangedCallback");
222 gInputStyleChangedCallbackCalled = true;
223 gInputStyleMask = mask;
226 // Generate a KeyEvent to send to Core.
227 Integration::KeyEvent GenerateKey( const std::string& keyName,
228 const std::string& logicalKey,
229 const std::string& keyString,
232 unsigned long timeStamp,
233 const Integration::KeyEvent::State& keyState,
234 const std::string& compose = "",
235 const std::string& deviceName = DEFAULT_DEVICE_NAME,
236 const Device::Class::Type& deviceClass = Device::Class::NONE,
237 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
239 return Integration::KeyEvent( keyName,
252 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
254 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
256 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
258 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
260 Property::Value* valueSet = NULL;
261 if ( valueGet.first.type == Property::Key::INDEX )
263 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
267 // Get Key is a string so searching Set Map for a string key
268 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
271 if( NULL != valueSet )
273 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
275 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
278 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
280 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
283 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
285 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
288 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
290 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
293 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
295 Vector2 vector2Get = valueGet.second.Get<Vector2>();
296 Vector2 vector2Set = valueSet->Get<Vector2>();
297 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
300 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
302 Vector4 vector4Get = valueGet.second.Get<Vector4>();
303 Vector4 vector4Set = valueSet->Get<Vector4>();
304 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 );
310 if ( valueGet.first.type == Property::Key::INDEX )
312 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
316 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
328 int UtcDaliToolkitTextFieldConstructorP(void)
330 ToolkitTestApplication application;
331 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
333 DALI_TEST_CHECK( !textField );
337 int UtcDaliToolkitTextFieldNewP(void)
339 ToolkitTestApplication application;
340 tet_infoline(" UtcDaliToolkitTextFieldNewP");
341 TextField textField = TextField::New();
342 DALI_TEST_CHECK( textField );
346 int UtcDaliToolkitTextFieldDownCastP(void)
348 ToolkitTestApplication application;
349 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
350 TextField textField1 = TextField::New();
351 BaseHandle object( textField1 );
353 TextField textField2 = TextField::DownCast( object );
354 DALI_TEST_CHECK( textField2 );
356 TextField textField3 = DownCast< TextField >( object );
357 DALI_TEST_CHECK( textField3 );
361 int UtcDaliToolkitTextFieldDownCastN(void)
363 ToolkitTestApplication application;
364 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
365 BaseHandle uninitializedObject;
366 TextField textField1 = TextField::DownCast( uninitializedObject );
367 DALI_TEST_CHECK( !textField1 );
369 TextField textField2 = DownCast< TextField >( uninitializedObject );
370 DALI_TEST_CHECK( !textField2 );
374 int UtcDaliToolkitTextFieldCopyConstructorP(void)
376 ToolkitTestApplication application;
377 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
378 TextField textField = TextField::New();
379 textField.SetProperty( TextField::Property::TEXT, "Test" );
381 TextField copy( textField );
382 DALI_TEST_CHECK( copy );
383 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
387 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
389 ToolkitTestApplication application;
390 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
391 TextField textField = TextField::New();
392 textField.SetProperty( TextField::Property::TEXT, "Test" );
394 TextField copy = textField;
395 DALI_TEST_CHECK( copy );
396 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
400 int UtcDaliTextFieldNewP(void)
402 ToolkitTestApplication application;
403 tet_infoline(" UtcDaliToolkitTextFieldNewP");
404 TextField textField = TextField::New();
405 DALI_TEST_CHECK( textField );
409 // Positive test case for a method
410 int UtcDaliTextFieldGetPropertyP(void)
412 ToolkitTestApplication application;
413 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
414 TextField field = TextField::New();
415 DALI_TEST_CHECK( field );
417 // Check Property Indices are correct
418 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
419 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
420 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
421 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
422 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
423 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
424 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
425 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
426 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
427 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
428 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
429 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
430 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
431 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
432 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
433 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
434 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
435 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
436 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
437 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
438 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
439 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
440 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
441 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
442 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
443 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
444 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
445 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
446 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
447 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
448 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
449 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
450 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
451 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
452 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
453 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
454 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
455 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
456 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
457 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
458 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
459 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
460 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
461 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
462 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
463 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
464 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
465 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
466 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
467 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
468 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
469 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
470 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
471 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP );
476 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
479 Property::Map imageMap;
480 imageMap[mapKey] =mapValue;
482 field.SetProperty( property , imageMap );
483 Property::Value propValue = field.GetProperty( property );
484 Property::Map* resultMap = propValue.GetMap();
486 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
494 // Positive test case for a method
495 int UtcDaliTextFieldSetPropertyP(void)
497 ToolkitTestApplication application;
498 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
499 TextField field = TextField::New();
500 DALI_TEST_CHECK( field );
501 Stage::GetCurrent().Add( field );
503 // Note - we can't check the defaults since the stylesheets are platform-specific
505 // Check the render backend property.
506 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
507 DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
509 // Check text property.
510 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
511 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
513 // Check placeholder text properties.
514 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
515 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
517 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
518 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
520 // Check font properties.
521 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
522 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
524 Property::Map fontStyleMapSet;
525 Property::Map fontStyleMapGet;
526 Property::Value* slantValue = NULL;
528 fontStyleMapSet.Insert( "weight", "bold" );
529 fontStyleMapSet.Insert( "width", "condensed" );
530 fontStyleMapSet.Insert( "slant", "italic" );
531 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
533 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
534 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
535 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
537 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
538 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
541 fontStyleMapSet.Clear();
542 fontStyleMapSet.Insert( "weight", "normal" );
543 fontStyleMapSet.Insert( "slant", "oblique" );
544 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
546 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
547 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
548 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
550 fontStyleMapSet.Clear();
551 fontStyleMapSet.Insert( "slant", "roman" );
552 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
553 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
555 // Replace 'roman' for 'normal'.
556 slantValue = fontStyleMapGet.Find( "slant" );
557 if( NULL != slantValue )
559 if( "normal" == slantValue->Get<std::string>() )
561 fontStyleMapGet["slant"] = "roman";
564 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
565 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
567 fontStyleMapSet.Clear();
569 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
570 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
571 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
572 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
574 // Check that the MAX_LENGTH property can be correctly set
575 const int maxNumberOfCharacters = 20;
576 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
577 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
579 // Check exceed policy
580 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
581 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
582 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
583 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
585 // Check that the Alignment properties can be correctly set
586 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
587 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
588 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
589 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
591 // Check text's color property
592 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
593 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
595 // Check placeholder text's color property.
596 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
597 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
599 // Check cursor properties
600 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
601 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
602 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
603 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
605 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
606 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
607 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
608 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
609 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
610 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
611 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
612 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
614 // Check scroll properties.
615 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
616 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
617 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
618 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
620 // Check handle images
621 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
622 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
623 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
624 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
625 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
627 // Check handle images
628 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
629 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
630 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
631 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
632 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
633 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
635 // Check the highlight color
636 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
637 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
639 // Decoration bounding box
640 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
641 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
643 // Check the input method setting
644 Property::Map propertyMap;
645 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
646 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
647 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
648 int inputVariation = 1;
649 propertyMap["PANEL_LAYOUT"] = panelLayout;
650 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
651 propertyMap["BUTTON_ACTION"] = buttonAction;
652 propertyMap["VARIATION"] = inputVariation;
653 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
655 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
657 DALI_TEST_CHECK( value.Get( map ) );
660 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
661 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
664 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
665 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
668 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
669 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
672 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
673 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
675 // Check input color property.
676 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
677 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
679 // Check the enable markup property.
680 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
681 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
682 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
684 // Check input font properties.
685 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
686 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
688 fontStyleMapSet.Clear();
689 fontStyleMapSet.Insert( "weight", "bold" );
690 fontStyleMapSet.Insert( "width", "condensed" );
691 fontStyleMapSet.Insert( "slant", "italic" );
693 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
694 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
695 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
696 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
698 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
699 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
701 // Reset input font style.
702 fontStyleMapSet.Clear();
703 fontStyleMapSet.Insert( "weight", "normal" );
704 fontStyleMapSet.Insert( "slant", "oblique" );
706 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
707 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
708 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
709 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
711 fontStyleMapSet.Clear();
712 fontStyleMapSet.Insert( "slant", "roman" );
714 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
715 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
717 // Replace 'roman' for 'normal'.
718 slantValue = fontStyleMapGet.Find( "slant" );
719 if( NULL != slantValue )
721 if( "normal" == slantValue->Get<std::string>() )
723 fontStyleMapGet["slant"] = "roman";
726 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
727 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
729 fontStyleMapSet.Clear();
731 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
732 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
733 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
734 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
736 Property::Map underlineMapSet;
737 Property::Map underlineMapGet;
739 underlineMapSet.Insert( "enable", true );
740 underlineMapSet.Insert( "color", Color::RED );
741 underlineMapSet.Insert( "height", 1 );
743 // Check the underline property
744 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
746 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
747 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
748 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
750 // Check the input underline property
751 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
752 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
754 // Check the shadow property
755 Property::Map shadowMapSet;
756 Property::Map shadowMapGet;
758 shadowMapSet.Insert( "color", Color::GREEN );
759 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
760 shadowMapSet.Insert( "blurRadius", 3.0f );
762 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
764 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
765 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
766 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
768 // Check the input shadow property
769 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
770 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
772 // Check the emboss property
773 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
774 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
776 // Check the input emboss property
777 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
778 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
780 // Check the outline property
782 // Test string type first
783 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
784 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
785 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
787 // Then test the property map type
788 Property::Map outlineMapSet;
789 Property::Map outlineMapGet;
791 outlineMapSet["color"] = Color::RED;
792 outlineMapSet["width"] = 2.0f;
794 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
796 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
797 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
798 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
800 // Check the input outline property
801 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
802 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
804 // Check the hidden input settings property
805 Property::Map hiddenMapSet;
806 Property::Map hiddenMapGet;
807 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
808 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
809 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
810 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
811 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
813 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
814 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
815 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
817 // Check the pixel size of font
818 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
819 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
821 // Check the enable selection property
822 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
823 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
825 // Check the placeholder property with pixel size
826 Property::Map placeholderPixelSizeMapSet;
827 Property::Map placeholderPixelSizeMapGet;
828 Property::Map placeholderFontstyleMap;
829 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
830 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
831 placeholderPixelSizeMapSet["color"] = Color::BLUE;
832 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
833 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
834 placeholderPixelSizeMapSet["ellipsis"] = true;
836 placeholderFontstyleMap.Insert( "weight", "bold" );
837 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
838 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
840 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
841 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
843 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
844 Property::Map placeholderConversionMap;
845 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
846 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
847 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
848 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
849 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
850 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
852 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
854 // Check the placeholder property with point size
855 Property::Map placeholderMapSet;
856 Property::Map placeholderMapGet;
857 placeholderMapSet["text"] = "Setting Placeholder Text";
858 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
859 placeholderMapSet["color"] = Color::RED;
860 placeholderMapSet["fontFamily"] = "Arial";
861 placeholderMapSet["pointSize"] = 12.0f;
862 placeholderMapSet["ellipsis"] = false;
864 // Check the placeholder font style property
865 placeholderFontstyleMap.Clear();
867 placeholderFontstyleMap.Insert( "weight", "bold" );
868 placeholderFontstyleMap.Insert( "width", "condensed" );
869 placeholderFontstyleMap.Insert( "slant", "italic" );
870 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
871 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
873 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
874 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
876 placeholderConversionMap.Clear();
877 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
878 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
879 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
880 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
881 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
882 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
884 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
887 placeholderFontstyleMap.Clear();
888 placeholderFontstyleMap.Insert( "weight", "normal" );
889 placeholderFontstyleMap.Insert( "slant", "oblique" );
890 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
891 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
893 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
894 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
896 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
897 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
899 placeholderFontstyleMap.Clear();
900 placeholderFontstyleMap.Insert( "slant", "roman" );
901 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
902 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
904 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
906 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
908 placeholderFontstyleMap.Clear();
909 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
910 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
912 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
913 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
914 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
916 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
918 // Check the ellipsis property
919 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
920 field.SetProperty( TextField::Property::ELLIPSIS, true );
921 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
923 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
924 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
926 // Test the ENABLE_GRAB_HANDLE_POPUP property
927 DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
928 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false );
929 DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
931 application.SendNotification();
932 application.Render();
937 // Positive Atlas Text Renderer test
938 int utcDaliTextFieldAtlasRenderP(void)
940 ToolkitTestApplication application;
941 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
942 StyleManager styleManager = StyleManager::Get();
943 styleManager.ApplyDefaultTheme();
944 TextField field = TextField::New();
945 DALI_TEST_CHECK( field );
947 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
949 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
951 Stage::GetCurrent().Add( field );
955 // Render some text with the shared atlas backend
956 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
957 application.SendNotification();
958 application.Render();
962 tet_result(TET_FAIL);
967 // Positive test for the textChanged signal.
968 int utcDaliTextFieldTextChangedP(void)
970 ToolkitTestApplication application;
971 tet_infoline(" utcDaliTextFieldTextChangedP");
972 TextField field = TextField::New();
973 DALI_TEST_CHECK( field );
975 Stage::GetCurrent().Add( field );
977 // connect to the text changed signal.
978 ConnectionTracker* testTracker = new ConnectionTracker();
979 field.TextChangedSignal().Connect(&TestTextChangedCallback);
980 bool textChangedSignal = false;
981 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
983 gTextChangedCallBackCalled = false;
984 field.SetProperty( TextField::Property::TEXT, "ABC" );
985 DALI_TEST_CHECK( gTextChangedCallBackCalled );
986 DALI_TEST_CHECK( textChangedSignal );
988 application.SendNotification();
990 field.SetKeyInputFocus();
992 gTextChangedCallBackCalled = false;
993 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
994 DALI_TEST_CHECK( gTextChangedCallBackCalled );
999 // Negative test for the textChanged signal.
1000 int utcDaliTextFieldTextChangedN(void)
1002 ToolkitTestApplication application;
1003 tet_infoline(" utcDaliTextFieldTextChangedN");
1004 TextField field = TextField::New();
1005 DALI_TEST_CHECK( field );
1007 Stage::GetCurrent().Add( field );
1009 // connect to the text changed signal.
1010 ConnectionTracker* testTracker = new ConnectionTracker();
1011 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1012 bool textChangedSignal = false;
1013 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1015 gTextChangedCallBackCalled = false;
1016 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1017 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1018 DALI_TEST_CHECK( !textChangedSignal );
1023 // Positive test for Max Characters reached signal.
1024 int utcDaliTextFieldMaxCharactersReachedP(void)
1026 ToolkitTestApplication application;
1027 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1028 TextField field = TextField::New();
1029 DALI_TEST_CHECK( field );
1031 Stage::GetCurrent().Add( field );
1033 const int maxNumberOfCharacters = 1;
1034 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1036 field.SetKeyInputFocus();
1038 // connect to the text changed signal.
1039 ConnectionTracker* testTracker = new ConnectionTracker();
1040 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1041 bool maxLengthReachedSignal = false;
1042 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1044 gMaxCharactersCallBackCalled = false;
1046 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1047 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1049 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1050 DALI_TEST_CHECK( maxLengthReachedSignal );
1055 // Negative test for Max Characters reached signal.
1056 int utcDaliTextFieldMaxCharactersReachedN(void)
1058 ToolkitTestApplication application;
1059 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1060 TextField field = TextField::New();
1061 DALI_TEST_CHECK( field );
1063 Stage::GetCurrent().Add( field );
1065 const int maxNumberOfCharacters = 3;
1066 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1068 field.SetKeyInputFocus();
1070 // connect to the text changed signal.
1071 ConnectionTracker* testTracker = new ConnectionTracker();
1072 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1073 bool maxLengthReachedSignal = false;
1074 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1076 gMaxCharactersCallBackCalled = false;
1078 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1079 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1081 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1082 DALI_TEST_CHECK( !maxLengthReachedSignal );
1084 application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::Down, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1086 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1087 DALI_TEST_CHECK( !maxLengthReachedSignal );
1092 int utcDaliTextFieldInputStyleChanged01(void)
1094 ToolkitTestApplication application;
1095 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1097 // The text-field emits signals when the input style changes. These changes of style are
1098 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1099 // can't be emitted during the size negotiation as the callbacks may update the UI.
1100 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1101 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1102 application.CreateAdaptor();
1106 char* pathNamePtr = get_current_dir_name();
1107 const std::string pathName( pathNamePtr );
1108 free( pathNamePtr );
1110 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1111 fontClient.SetDpi( 93u, 93u );
1113 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1114 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1116 TextField field = TextField::New();
1117 DALI_TEST_CHECK( field );
1120 field.SetSize( 300.f, 50.f );
1121 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1122 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1124 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1125 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1127 // connect to the text changed signal.
1128 ConnectionTracker* testTracker = new ConnectionTracker();
1129 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1130 bool inputStyleChangedSignal = false;
1131 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1133 Stage::GetCurrent().Add( field );
1135 // Render and notify
1136 application.SendNotification();
1137 application.Render();
1139 // Executes the idle callbacks added by the text control on the change of input style.
1140 application.RunIdles();
1142 gInputStyleChangedCallbackCalled = false;
1143 gInputStyleMask = TextField::InputStyle::NONE;
1144 inputStyleChangedSignal = false;
1146 // Create a tap event to touch the text field.
1147 TestGenerateTap( application, 18.0f, 25.0f );
1149 // Render and notify
1150 application.SendNotification();
1151 application.Render();
1153 // Executes the idle callbacks added by the text control on the change of input style.
1154 application.RunIdles();
1156 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1157 if( gInputStyleChangedCallbackCalled )
1159 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1161 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1162 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1164 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1165 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1167 DALI_TEST_CHECK( inputStyleChangedSignal );
1169 gInputStyleChangedCallbackCalled = false;
1170 gInputStyleMask = TextField::InputStyle::NONE;
1171 inputStyleChangedSignal = false;
1173 // Create a tap event to touch the text field.
1174 TestGenerateTap( application, 30.0f, 25.0f );
1176 // Render and notify
1177 application.SendNotification();
1178 application.Render();
1180 // Executes the idle callbacks added by the text control on the change of input style.
1181 application.RunIdles();
1183 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1184 DALI_TEST_CHECK( !inputStyleChangedSignal );
1186 gInputStyleChangedCallbackCalled = false;
1187 gInputStyleMask = TextField::InputStyle::NONE;
1188 inputStyleChangedSignal = false;
1190 // Create a tap event to touch the text field.
1191 TestGenerateTap( application, 43.0f, 25.0f );
1193 // Render and notify
1194 application.SendNotification();
1195 application.Render();
1197 // Executes the idle callbacks added by the text control on the change of input style.
1198 application.RunIdles();
1200 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1201 if( gInputStyleChangedCallbackCalled )
1203 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1205 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1206 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1208 DALI_TEST_CHECK( inputStyleChangedSignal );
1210 gInputStyleChangedCallbackCalled = false;
1211 gInputStyleMask = TextField::InputStyle::NONE;
1212 inputStyleChangedSignal = false;
1214 // Create a tap event to touch the text field.
1215 TestGenerateTap( application, 88.0f, 25.0f );
1217 // Render and notify
1218 application.SendNotification();
1219 application.Render();
1221 // Executes the idle callbacks added by the text control on the change of input style.
1222 application.RunIdles();
1224 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1225 if( gInputStyleChangedCallbackCalled )
1227 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1229 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1230 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1232 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1234 Property::Map fontStyleMapSet;
1235 fontStyleMapSet.Insert( "weight", "bold" );
1237 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1238 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1240 DALI_TEST_CHECK( inputStyleChangedSignal );
1242 gInputStyleChangedCallbackCalled = false;
1243 gInputStyleMask = TextField::InputStyle::NONE;
1244 inputStyleChangedSignal = false;
1246 // Create a tap event to touch the text field.
1247 TestGenerateTap( application, 115.0f, 25.0f );
1249 // Render and notify
1250 application.SendNotification();
1251 application.Render();
1253 // Executes the idle callbacks added by the text control on the change of input style.
1254 application.RunIdles();
1256 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1257 DALI_TEST_CHECK( !inputStyleChangedSignal );
1259 gInputStyleChangedCallbackCalled = false;
1260 gInputStyleMask = TextField::InputStyle::NONE;
1261 inputStyleChangedSignal = false;
1263 // Create a tap event to touch the text field.
1264 TestGenerateTap( application, 164.0f, 25.0f );
1266 // Render and notify
1267 application.SendNotification();
1268 application.Render();
1270 // Executes the idle callbacks added by the text control on the change of input style.
1271 application.RunIdles();
1273 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1274 if( gInputStyleChangedCallbackCalled )
1276 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1278 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1279 DALI_TEST_CHECK( style.empty() );
1281 DALI_TEST_CHECK( inputStyleChangedSignal );
1283 gInputStyleChangedCallbackCalled = false;
1284 gInputStyleMask = TextField::InputStyle::NONE;
1285 inputStyleChangedSignal = false;
1287 // Create a tap event to touch the text field.
1288 TestGenerateTap( application, 191.0f, 25.0f );
1290 // Render and notify
1291 application.SendNotification();
1292 application.Render();
1294 // Executes the idle callbacks added by the text control on the change of input style.
1295 application.RunIdles();
1297 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1298 DALI_TEST_CHECK( !inputStyleChangedSignal );
1303 int utcDaliTextFieldInputStyleChanged02(void)
1305 ToolkitTestApplication application;
1306 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1308 // The text-field emits signals when the input style changes. These changes of style are
1309 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1310 // can't be emitted during the size negotiation as the callbacks may update the UI.
1311 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1312 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1313 application.CreateAdaptor();
1317 char* pathNamePtr = get_current_dir_name();
1318 const std::string pathName( pathNamePtr );
1319 free( pathNamePtr );
1321 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1322 fontClient.SetDpi( 93u, 93u );
1324 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1325 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1327 TextField field = TextField::New();
1328 DALI_TEST_CHECK( field );
1330 field.SetSize( 300.f, 50.f );
1331 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1332 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1334 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1335 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>" );
1337 // connect to the text changed signal.
1338 ConnectionTracker* testTracker = new ConnectionTracker();
1339 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1340 bool inputStyleChangedSignal = false;
1341 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1343 Stage::GetCurrent().Add( field );
1345 // Render and notify
1346 application.SendNotification();
1347 application.Render();
1349 // Executes the idle callbacks added by the text control on the change of input style.
1350 application.RunIdles();
1352 gInputStyleChangedCallbackCalled = false;
1353 gInputStyleMask = TextField::InputStyle::NONE;
1354 inputStyleChangedSignal = false;
1356 // Create a tap event to touch the text field.
1357 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1358 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1360 // Render and notify
1361 application.SendNotification();
1362 application.Render();
1364 // Executes the idle callbacks added by the text control on the change of input style.
1365 application.RunIdles();
1367 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1368 if( gInputStyleChangedCallbackCalled )
1370 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1371 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1372 TextField::InputStyle::POINT_SIZE |
1373 TextField::InputStyle::COLOR ),
1376 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1377 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1379 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1380 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1382 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1383 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1385 DALI_TEST_CHECK( inputStyleChangedSignal );
1387 gInputStyleChangedCallbackCalled = false;
1388 gInputStyleMask = TextField::InputStyle::NONE;
1389 inputStyleChangedSignal = false;
1391 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1393 // Render and notify
1394 application.SendNotification();
1395 application.Render();
1397 // Executes the idle callbacks added by the text control on the change of input style.
1398 application.RunIdles();
1400 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1401 if( gInputStyleChangedCallbackCalled )
1403 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1404 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1407 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1408 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1410 DALI_TEST_CHECK( inputStyleChangedSignal );
1412 gInputStyleChangedCallbackCalled = false;
1413 gInputStyleMask = TextField::InputStyle::NONE;
1414 inputStyleChangedSignal = false;
1416 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1418 // Render and notify
1419 application.SendNotification();
1420 application.Render();
1422 // Executes the idle callbacks added by the text control on the change of input style.
1423 application.RunIdles();
1425 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1426 DALI_TEST_CHECK( !inputStyleChangedSignal );
1428 gInputStyleChangedCallbackCalled = false;
1429 gInputStyleMask = TextField::InputStyle::NONE;
1430 inputStyleChangedSignal = false;
1432 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1434 // Render and notify
1435 application.SendNotification();
1436 application.Render();
1438 // Executes the idle callbacks added by the text control on the change of input style.
1439 application.RunIdles();
1441 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1442 if( gInputStyleChangedCallbackCalled )
1444 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1445 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1448 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1449 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1451 DALI_TEST_CHECK( inputStyleChangedSignal );
1453 gInputStyleChangedCallbackCalled = false;
1454 gInputStyleMask = TextField::InputStyle::NONE;
1455 inputStyleChangedSignal = false;
1457 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1459 Property::Map fontStyleMapSet;
1460 fontStyleMapSet.Insert( "weight", "thin" );
1461 fontStyleMapSet.Insert( "width", "condensed" );
1462 fontStyleMapSet.Insert( "slant", "italic" );
1464 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1465 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1467 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1468 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1469 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1470 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1472 // Render and notify
1473 application.SendNotification();
1474 application.Render();
1476 // Executes the idle callbacks added by the text control on the change of input style.
1477 application.RunIdles();
1479 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1480 DALI_TEST_CHECK( !inputStyleChangedSignal );
1482 // Create a tap event to touch the text field.
1483 TestGenerateTap( application, 63.0f, 25.0f, 300 );
1485 // Render and notify
1486 application.SendNotification();
1487 application.Render();
1489 // Executes the idle callbacks added by the text control on the change of input style.
1490 application.RunIdles();
1492 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1493 if( gInputStyleChangedCallbackCalled )
1495 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1496 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1497 TextField::InputStyle::POINT_SIZE |
1498 TextField::InputStyle::FONT_STYLE |
1499 TextField::InputStyle::UNDERLINE |
1500 TextField::InputStyle::SHADOW |
1501 TextField::InputStyle::EMBOSS |
1502 TextField::InputStyle::OUTLINE ),
1505 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1506 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1508 DALI_TEST_CHECK( inputStyleChangedSignal );
1513 int utcDaliTextFieldEvent01(void)
1515 ToolkitTestApplication application;
1516 tet_infoline(" utcDaliTextFieldEvent01");
1518 // Creates a tap event. After creating a tap event the text field should
1519 // have the focus and add text with key events should be possible.
1521 TextField field = TextField::New();
1522 DALI_TEST_CHECK( field );
1524 Stage::GetCurrent().Add( field );
1526 field.SetSize( 300.f, 50.f );
1527 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1528 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1530 // Render and notify
1531 application.SendNotification();
1532 application.Render();
1534 // Avoid a crash when core load gl resources.
1535 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1537 // Render and notify
1538 application.SendNotification();
1539 application.Render();
1541 // Add a key event but as the text field has not the focus it should do nothing.
1542 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1544 // Render and notify
1545 application.SendNotification();
1546 application.Render();
1548 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1550 // Create a tap event to touch the text field.
1551 TestGenerateTap( application, 150.0f, 25.0f );
1553 // Render and notify
1554 application.SendNotification();
1555 application.Render();
1557 // Pressing delete key should be fine even if there is no text in TextField.
1558 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 ) );
1559 // Render and notify
1560 application.SendNotification();
1561 application.Render();
1563 // Now the text field has the focus, so it can handle the key events.
1564 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1565 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1567 // Render and notify
1568 application.SendNotification();
1569 application.Render();
1571 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1573 // Create a second text field and send key events to it.
1574 TextField field2 = TextField::New();
1576 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1577 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1578 field2.SetSize( 100.f, 100.0f );
1579 field2.SetPosition( 100.0f, 100.0f );
1581 Stage::GetCurrent().Add( field2 );
1583 // Render and notify
1584 application.SendNotification();
1585 application.Render();
1587 // Create a tap event on the second text field.
1588 TestGenerateTap( application, 150.0f, 125.0f );
1590 // Render and notify
1591 application.SendNotification();
1592 application.Render();
1594 // The second text field has the focus. It should handle the key events.
1595 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1596 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1598 // Render and notify
1599 application.SendNotification();
1600 application.Render();
1602 // Check the text has been added to the second text field.
1603 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1608 int utcDaliTextFieldEvent02(void)
1610 ToolkitTestApplication application;
1611 tet_infoline(" utcDaliTextFieldEvent02");
1613 // Checks if the right number of actors are created.
1615 TextField field = TextField::New();
1616 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1617 DALI_TEST_CHECK( field );
1618 LoadMarkerImages(application, field);
1620 Stage::GetCurrent().Add( field );
1622 field.SetSize( 300.0f, 50.0f );
1623 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1624 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1626 // Avoid a crash when core load gl resources.
1627 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1629 // Render and notify
1630 application.SendNotification();
1631 application.Render();
1633 // Check there are the expected number of children ( stencil ).
1634 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1636 Actor stencil = field.GetChildAt( 0u );
1637 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1639 // Create a tap event to touch the text field.
1640 TestGenerateTap( application, 150.0f, 25.0f, 300 );
1642 // Render and notify
1643 application.SendNotification();
1644 application.Render();
1646 Actor layer = field.GetChildAt( 1u );
1647 DALI_TEST_CHECK( layer.IsLayer() );
1649 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1650 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1652 // Now the text field has the focus, so it can handle the key events.
1653 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1654 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1656 // Render and notify
1657 application.SendNotification();
1658 application.Render();
1660 // Checks the cursor and the renderer have been created.
1661 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1662 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1664 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1665 DALI_TEST_CHECK( cursor );
1667 // The offscreen root actor has a container with all the actors which contain the text renderers.
1668 Actor container = stencil.GetChildAt( 0u );
1669 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1671 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1672 DALI_TEST_CHECK( renderer );
1675 // Move the cursor and check the position changes.
1676 Vector3 position1 = cursor.GetCurrentPosition();
1677 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1679 // Render and notify
1680 application.SendNotification();
1681 application.Render();
1683 Vector3 position2 = cursor.GetCurrentPosition();
1684 DALI_TEST_CHECK( position2.x < position1.x );
1686 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1688 // Render and notify
1689 application.SendNotification();
1690 application.Render();
1692 Vector3 position3 = cursor.GetCurrentPosition();
1693 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1696 // Move the cursor to the first position.
1697 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1698 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1700 // Render and notify
1701 application.SendNotification();
1702 application.Render();
1704 Vector3 position4 = cursor.GetCurrentPosition();
1706 // Send some taps and check the cursor positions.
1708 // Try to tap at the beginning.
1709 TestGenerateTap( application, 1.0f, 25.0f, 900 );
1711 // Render and notify
1712 application.SendNotification();
1713 application.Render();
1715 // Cursor position should be the same than position1.
1716 Vector3 position5 = cursor.GetCurrentPosition();
1718 DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
1720 // Tap away from the start position.
1721 TestGenerateTap( application, 16.0f, 25.0f, 1500 );
1723 // Render and notify
1724 application.SendNotification();
1725 application.Render();
1727 Vector3 position6 = cursor.GetCurrentPosition();
1729 DALI_TEST_CHECK( position6.x > position5.x );
1731 // Remove all the text.
1732 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1733 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1734 field.SetProperty( TextField::Property::TEXT, "" );
1736 // Render and notify
1737 application.SendNotification();
1738 application.Render();
1740 // Cursor position should be the same than position2.
1741 Vector3 position7 = cursor.GetCurrentPosition();
1743 DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
1745 // Should not be a renderer.
1746 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1748 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1749 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1750 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1752 application.SendNotification();
1753 application.Render();
1755 // There are renderer and decorator layer
1756 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1761 int utcDaliTextFieldEvent03(void)
1763 ToolkitTestApplication application;
1764 tet_infoline(" utcDaliTextFieldEvent03");
1766 // Checks if the highlight actor is created.
1768 TextField field = TextField::New();
1769 DALI_TEST_CHECK( field );
1771 Stage::GetCurrent().Add( field );
1773 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1774 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1775 field.SetSize( 30.f, 50.f );
1776 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1777 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1779 // Avoid a crash when core load gl resources.
1780 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1781 LoadMarkerImages(application, field);
1783 // Render and notify
1784 application.SendNotification();
1785 application.Render();
1787 // Tap first to get the focus.
1788 TestGenerateTap( application, 3.0f, 25.0f );
1790 // Render and notify
1791 application.SendNotification();
1792 application.Render();
1794 // Double tap to select a word.
1795 TestGenerateTap( application, 3.0f, 25.0f );
1797 // Render and notify
1798 application.SendNotification();
1799 application.Render();
1801 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1802 Actor stencil = field.GetChildAt( 0u );
1804 // The highlight actor is drawn first, so is the first actor in the list
1805 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1806 DALI_TEST_CHECK( highlight );
1808 // The offscreen root actor has a container with all the actors which contain the text renderers.
1809 Actor container = stencil.GetChildAt( 1u );
1810 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1812 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1813 DALI_TEST_CHECK( renderer );
1819 int utcDaliTextFieldEvent04(void)
1821 ToolkitTestApplication application;
1822 tet_infoline(" utcDaliTextFieldEvent04");
1824 // Checks if the highlight actor is created.
1826 TextField field = TextField::New();
1827 DALI_TEST_CHECK( field );
1828 Stage::GetCurrent().Add( field );
1829 LoadMarkerImages(application, field);
1830 // Render and notify
1831 application.SendNotification();
1832 application.Render();
1834 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1835 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1836 field.SetSize( 300.f, 50.f );
1837 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1838 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1840 // Avoid a crash when core load gl resources.
1841 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1842 // Render and notify
1843 application.SendNotification();
1844 application.Render();
1846 // Create a tap event to touch the text field.
1847 TestGenerateTap( application, 150.0f, 25.0f );
1848 // Render and notify
1849 application.SendNotification();
1850 application.Render();
1853 // Tap first to get the focus.
1854 TestGenerateTap( application, 1.0f, 25.0f );
1856 // Render and notify
1857 application.SendNotification();
1858 application.Render();
1860 // Double tap to select a word.
1861 TestGenerateTap( application, 1.0f, 25.0f );
1863 // Render and notify
1864 application.SendNotification();
1865 application.Render();
1868 TestGenerateTap( application, 0.0f, 40.0f );
1872 int utcDaliTextFieldEvent05(void)
1874 ToolkitTestApplication application;
1875 tet_infoline(" utcDaliTextFieldEvent05");
1877 // Checks dragging of cursor/grab handle
1879 TextField field = TextField::New();
1880 DALI_TEST_CHECK( field );
1881 Stage::GetCurrent().Add( field );
1882 LoadMarkerImages(application, field);
1883 // Render and notify
1884 application.SendNotification();
1885 application.Render();
1887 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1888 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1889 field.SetSize( 300.f, 50.f );
1890 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1891 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1893 // Avoid a crash when core load gl resources.
1894 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1895 // Render and notify
1896 application.SendNotification();
1897 application.Render();
1899 // Create a tap event to touch the text field.
1900 TestGenerateTap( application, 150.0f, 25.0f );
1901 // Render and notify
1902 application.SendNotification();
1903 application.Render();
1905 // Tap first to get the focus.
1906 TestGenerateTap( application, 1.0f, 25.0f );
1908 // Render and notify
1909 application.SendNotification();
1910 application.Render();
1912 // Double tap to select a word.
1913 TestGenerateTap( application, 1.0f, 25.0f );
1915 // Render and notify
1916 application.SendNotification();
1917 application.Render();
1919 Actor stencil = field.GetChildAt( 1u );
1923 int utcDaliTextFieldEvent06(void)
1925 ToolkitTestApplication application;
1926 tet_infoline(" utcDaliTextFieldEvent06");
1928 // Checks Longpress when in edit mode
1930 TextField field = TextField::New();
1931 DALI_TEST_CHECK( field );
1932 Stage::GetCurrent().Add( field );
1933 LoadMarkerImages(application, field);
1934 // Render and notify
1935 application.SendNotification();
1936 application.Render();
1938 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1939 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1940 field.SetSize( 300.f, 50.f );
1941 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1942 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1944 // Avoid a crash when core load gl resources.
1945 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1946 // Render and notify
1947 application.SendNotification();
1948 application.Render();
1950 // Create a tap event to touch the text field.
1951 TestGenerateTap( application, 150.0f, 25.0f );
1952 // Render and notify
1953 application.SendNotification();
1954 application.Render();
1957 // Tap first to get the focus.
1958 TestGenerateTap( application, 1.0f, 25.0f );
1960 // Render and notify
1961 application.SendNotification();
1962 application.Render();
1965 TestGenerateLongPress(application, 1.0f, 25.0f);
1967 // Render and notify
1968 application.SendNotification();
1969 application.Render();
1974 int utcDaliTextFieldEvent07(void)
1976 ToolkitTestApplication application;
1977 tet_infoline(" utcDaliTextFieldEvent07");
1979 // Checks Longpress to start edit mode
1981 TextField field = TextField::New();
1982 DALI_TEST_CHECK( field );
1983 Stage::GetCurrent().Add( field );
1984 LoadMarkerImages(application, field);
1985 // Render and notify
1986 application.SendNotification();
1987 application.Render();
1989 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1990 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1991 field.SetSize( 300.f, 50.f );
1992 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1993 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1994 Property::Map propertyMap;
1995 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
1996 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
1998 // Avoid a crash when core load gl resources.
1999 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2000 // Render and notify
2001 application.SendNotification();
2002 application.Render();
2005 TestGenerateLongPress(application, 1.0f, 25.0f);
2007 // Render and notify
2008 application.SendNotification();
2009 application.Render();
2014 int utcDaliTextFieldEvent08(void)
2016 ToolkitTestApplication application;
2017 tet_infoline(" utcDaliTextFieldEvent08");
2019 Dali::Clipboard clipboard = Clipboard::Get();
2020 clipboard.SetItem("testTextFieldEvent");
2022 // Checks Longpress when only place holder text
2024 TextField field = TextField::New();
2025 DALI_TEST_CHECK( field );
2026 Stage::GetCurrent().Add( field );
2027 LoadMarkerImages(application, field);
2028 // Render and notify
2029 application.SendNotification();
2030 application.Render();
2032 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2033 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2034 field.SetSize( 300.f, 50.f );
2035 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2036 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2038 // Avoid a crash when core load gl resources.
2039 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2040 // Render and notify
2041 application.SendNotification();
2042 application.Render();
2045 TestGenerateLongPress( application, 1.0f, 25.0f, 20 );
2047 // Render and notify
2048 application.SendNotification();
2049 application.Render();
2051 Wait(application, 500);
2053 TestEndLongPress( application, 1.0f, 25.0f, 520 );
2056 TestGenerateLongPress( application, 1.0f, 25.0f, 600 );
2058 // Render and notify
2059 application.Render();
2061 Wait(application, 500);
2063 Stage stage = Stage::GetCurrent();
2064 Layer layer = stage.GetRootLayer();
2065 Actor actor = layer.FindChildByName("optionPaste");
2069 Vector3 worldPosition = actor.GetCurrentWorldPosition();
2070 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2071 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2073 Dali::Integration::TouchEvent event;
2074 event = Dali::Integration::TouchEvent();
2075 event.AddPoint( GetPointDownInside( position ) );
2076 application.ProcessEvent( event );
2078 event = Dali::Integration::TouchEvent();
2079 event.AddPoint( GetPointUpInside( position ) );
2080 application.ProcessEvent( event );
2082 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2087 int utcDaliTextFieldEvent09(void)
2089 ToolkitTestApplication application;
2090 tet_infoline(" utcDaliTextFieldEvent09");
2092 TextField field = TextField::New();
2093 DALI_TEST_CHECK( field );
2094 Stage::GetCurrent().Add( field );
2095 LoadMarkerImages(application, field);
2096 // Render and notify
2097 application.SendNotification();
2098 application.Render();
2100 field.SetProperty( TextField::Property::TEXT, "Hello" );
2101 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2102 field.SetSize( 300.f, 50.f );
2103 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2104 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2106 // Avoid a crash when core load gl resources.
2107 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2109 // Create a tap event to touch the text field.
2110 TestGenerateTap( application, 150.0f, 25.0f );
2111 application.SendNotification();
2112 application.Render();
2115 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2116 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2117 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2118 application.SendNotification();
2119 application.Render();
2121 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2122 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2123 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2124 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2125 application.SendNotification();
2126 application.Render();
2128 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2129 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2130 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2131 for( unsigned int index = 0u; index < 5u; ++index )
2133 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2134 application.SendNotification();
2135 application.Render();
2138 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2139 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2140 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2141 for( unsigned int index = 0u; index < 5u; ++index )
2143 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2144 application.SendNotification();
2145 application.Render();
2148 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2149 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2150 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2151 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2152 application.SendNotification();
2153 application.Render();
2154 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2155 application.SendNotification();
2156 application.Render();
2158 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2159 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2160 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2161 application.SendNotification();
2162 application.Render();
2164 Property::Map mapGet;
2165 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2166 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2167 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2172 int utcDaliTextFieldStyleWhilstSelected(void)
2174 ToolkitTestApplication application;
2175 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2177 // Change font and styles whilst text is selected whilst word selected
2179 TextField field = TextField::New();
2180 DALI_TEST_CHECK( field );
2181 Stage::GetCurrent().Add( field );
2182 LoadMarkerImages(application, field);
2183 // Render and notify
2184 application.SendNotification();
2185 application.Render();
2187 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2188 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2189 field.SetSize( 300.f, 50.f );
2190 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2191 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2193 // Avoid a crash when core load gl resources.
2194 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2195 // Render and notify
2196 application.SendNotification();
2197 application.Render();
2199 // Create a tap event to touch the text field.
2200 TestGenerateTap( application, 150.0f, 25.0f );
2201 // Render and notify
2202 application.SendNotification();
2203 application.Render();
2206 // Tap first to get the focus.
2207 TestGenerateTap( application, 1.0f, 25.0f );
2209 // Render and notify
2210 application.SendNotification();
2211 application.Render();
2213 // Double tap to select a word.
2214 TestGenerateTap( application, 1.0f, 25.0f );
2216 // Render and notify
2217 application.SendNotification();
2218 application.Render();
2220 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2221 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2223 Property::Map fontStyleMapSet;
2224 Property::Map fontStyleMapGet;
2226 fontStyleMapSet.Insert( "weight", "bold" );
2227 fontStyleMapSet.Insert( "slant", "italic" );
2228 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2230 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2231 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2232 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2234 fontStyleMapSet.Clear();
2235 fontStyleMapSet.Insert( "width", "expanded" );
2236 fontStyleMapSet.Insert( "slant", "italic" );
2237 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2239 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2240 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2241 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2243 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2244 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2246 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2247 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2249 fontStyleMapSet.Clear();
2250 fontStyleMapSet.Insert( "weight", "bold" );
2251 fontStyleMapSet.Insert( "slant", "italic" );
2253 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2255 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2256 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2257 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2259 fontStyleMapSet.Clear();
2260 fontStyleMapSet.Insert( "width", "expanded" );
2262 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2264 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2265 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2266 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2268 // Press Escape to increase coverage
2269 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2270 application.SendNotification();
2271 application.Render();
2273 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2278 int utcDaliTextFieldEscKeyLoseFocus(void)
2280 ToolkitTestApplication application;
2281 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2283 // Creates a tap event. After creating a tap event the text field should
2284 // have the focus and add text with key events should be possible.
2286 TextField field = TextField::New();
2287 DALI_TEST_CHECK( field );
2289 Stage::GetCurrent().Add( field );
2291 field.SetSize( 300.f, 50.f );
2292 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2293 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2295 // Avoid a crash when core load gl resources.
2296 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2298 // Render and notify
2299 application.SendNotification();
2300 application.Render();
2302 // Add a key event but as the text field has not the focus it should do nothing.
2303 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2304 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2306 // Render and notify
2307 application.SendNotification();
2308 application.Render();
2310 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2312 // Create a tap event to touch the text field.
2313 TestGenerateTap( application, 150.0f, 25.0f );
2315 // Render and notify
2316 application.SendNotification();
2317 application.Render();
2319 // Now the text field has the focus, so it can handle the key events.
2320 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2321 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2322 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2323 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2325 // Render and notify
2326 application.SendNotification();
2327 application.Render();
2329 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2331 // Generate a Esc key event. The text field should lose the focus.
2332 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2333 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2335 // Render and notify
2336 application.SendNotification();
2337 application.Render();
2339 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2341 // No more text should be introduced
2342 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2343 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2345 // Render and notify
2346 application.SendNotification();
2347 application.Render();
2349 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2354 int utcDaliTextFieldSomeSpecialKeys(void)
2356 ToolkitTestApplication application;
2357 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2359 // Checks some special keys when the text is selected.
2361 TextField field = TextField::New();
2362 DALI_TEST_CHECK( field );
2363 Stage::GetCurrent().Add( field );
2364 LoadMarkerImages(application, field);
2365 // Render and notify
2366 application.SendNotification();
2367 application.Render();
2369 const std::string longText( "This is a long text for the size of the text-field." );
2371 field.SetProperty( TextField::Property::TEXT, longText );
2372 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2373 field.SetSize( 300.f, 50.f );
2374 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2375 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2377 // Avoid a crash when core load gl resources.
2378 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2379 // Render and notify
2380 application.SendNotification();
2381 application.Render();
2383 // Create a tap event to touch the text field.
2384 TestGenerateTap( application, 150.0f, 25.0f );
2386 // Render and notify
2387 application.SendNotification();
2388 application.Render();
2390 // Tap first to get the focus.
2391 TestGenerateTap( application, 1.0f, 25.0f );
2393 // Render and notify
2394 application.SendNotification();
2395 application.Render();
2397 // Double tap to select a word.
2398 TestGenerateTap( application, 1.0f, 25.0f );
2400 // Render and notify
2401 application.SendNotification();
2402 application.Render();
2404 // Generate a Esc key event. The text field should lose the focus.
2405 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2406 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2408 // Render and notify
2409 application.SendNotification();
2410 application.Render();
2412 // Generate a Esc key event. The text field should lose the focus.
2413 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2414 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2416 // Render and notify
2417 application.SendNotification();
2418 application.Render();
2420 // Generate a Esc key event. The text field should lose the focus.
2421 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2422 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2424 // Render and notify
2425 application.SendNotification();
2426 application.Render();
2428 // The text shouldn't be deleted.
2429 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2434 int utcDaliTextFieldSizeUpdate(void)
2436 ToolkitTestApplication application;
2437 tet_infoline("utcDaliTextFieldSizeUpdate");
2439 // Checks some special keys when the text is selected.
2440 TextField field = TextField::New();
2441 DALI_TEST_CHECK( field );
2442 Stage::GetCurrent().Add( field );
2444 float previousHeight = 0.0f;
2445 float currentHeight = 0.0f;
2446 const float fieldWidth = 1920.0f;
2449 // "ㅁ" is bigger then "ኢ"
2450 field.SetSize( Vector2( fieldWidth ,10.0f ) );
2451 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2452 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2454 field.SetProperty( TextField::Property::TEXT, "ኢ");
2455 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2456 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2458 field.SetKeyboardFocusable(true);
2459 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2461 application.SendNotification();
2462 application.Render();
2464 previousHeight = field.GetHeightForWidth( fieldWidth );
2465 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2467 // Add another script characters ( glyph height is defferent )
2468 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2469 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2471 application.SendNotification();
2472 application.Render();
2474 currentHeight = field.GetHeightForWidth( fieldWidth );
2475 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2476 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2481 int utcDaliTextFieldExtremlyLargePointSize(void)
2483 ToolkitTestApplication application;
2484 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2486 TextField field = TextField::New();
2488 field.SetProperty( TextField::Property::TEXT, "Text" );
2489 field.SetSize( 300.f, 50.f );
2490 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2491 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2492 Stage::GetCurrent().Add( field );
2496 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2497 application.SendNotification();
2498 DALI_TEST_CHECK( field );
2502 tet_result(TET_FAIL);
2507 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2509 ToolkitTestApplication application;
2510 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2511 TextField field = TextField::New();
2512 DALI_TEST_CHECK( field );
2513 Stage::GetCurrent().Add( field );
2515 Property::Map fontStyleMapGet;
2517 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2519 Property::Value* weightValue = NULL;
2520 Property::Value* widthValue = NULL;
2521 Property::Value* slantValue = NULL;
2522 weightValue = fontStyleMapGet.Find( "weight" );
2523 widthValue = fontStyleMapGet.Find( "width" );
2524 slantValue = fontStyleMapGet.Find( "slant" );
2525 DALI_TEST_CHECK( !weightValue );
2526 DALI_TEST_CHECK( !widthValue );
2527 DALI_TEST_CHECK( !slantValue );
2532 int UtcDaliTextFieldSettingPlaceholder(void)
2534 ToolkitTestApplication application;
2535 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
2537 TextField field = TextField::New();
2538 DALI_TEST_CHECK( field );
2539 Stage::GetCurrent().Add( field );
2541 // Check the placeholder property with pixel size
2542 Property::Map placeholderPixelSizeMapSet;
2543 Property::Map placeholderPixelSizeMapGet;
2544 Property::Map placeholderFontstyleMap;
2545 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2546 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2547 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
2548 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2549 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
2550 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
2552 placeholderFontstyleMap.Insert( "weight", "bold" );
2553 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2554 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
2556 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2557 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
2558 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
2560 // Check the placeholder property with point size
2561 Property::Map placeholderMapSet;
2562 Property::Map placeholderMapGet;
2563 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2564 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2565 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
2566 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2567 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
2568 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
2570 // Check the placeholder font style property
2571 placeholderFontstyleMap.Clear();
2573 placeholderFontstyleMap.Insert( "weight", "bold" );
2574 placeholderFontstyleMap.Insert( "width", "condensed" );
2575 placeholderFontstyleMap.Insert( "slant", "italic" );
2576 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2577 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2579 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2580 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2581 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2583 // Reset font style.
2584 placeholderFontstyleMap.Clear();
2585 placeholderFontstyleMap.Insert( "weight", "normal" );
2586 placeholderFontstyleMap.Insert( "slant", "oblique" );
2587 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2588 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2590 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2591 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2592 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2594 placeholderFontstyleMap.Clear();
2595 placeholderFontstyleMap.Insert( "slant", "roman" );
2596 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2597 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2599 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2601 placeholderFontstyleMap.Clear();
2602 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2604 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2605 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2606 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2607 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2612 int UtcDaliTextFieldSetPaddingProperty(void)
2614 ToolkitTestApplication application;
2615 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
2617 TextField field = TextField::New();
2618 DALI_TEST_CHECK( field );
2619 field.SetSize( 300.f, 50.f );
2620 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2621 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2622 Stage::GetCurrent().Add( field );
2624 application.SendNotification();
2625 application.Render();
2627 Vector3 originalSize = field.GetNaturalSize();
2629 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2631 application.SendNotification();
2632 application.Render();
2634 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2636 Vector3 paddingAddedSize = field.GetNaturalSize();
2638 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2640 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2645 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
2647 ToolkitTestApplication application;
2648 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
2650 TextField field = TextField::New();
2651 DALI_TEST_CHECK( field );
2652 field.SetSize( 300.0f, 50.0f );
2653 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2654 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2655 Stage::GetCurrent().Add( field );
2657 application.SendNotification();
2658 application.Render();
2660 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2661 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2663 // Check the enable shift selection property
2664 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
2665 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2667 application.SendNotification();
2668 application.Render();
2673 int UtcDaliTextFieldEnableGrabHandleProperty(void)
2675 ToolkitTestApplication application;
2676 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
2678 TextField field = TextField::New();
2679 DALI_TEST_CHECK( field );
2680 field.SetSize( 300.0f, 50.0f );
2681 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2682 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2683 Stage::GetCurrent().Add( field );
2685 application.SendNotification();
2686 application.Render();
2688 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2689 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2691 // Check the enable grab handle property
2692 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
2693 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2695 application.SendNotification();
2696 application.Render();
2701 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
2703 ToolkitTestApplication application;
2704 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
2706 TextField field = TextField::New();
2707 DALI_TEST_CHECK( field );
2708 field.SetSize( 300.0f, 50.0f );
2709 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2710 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2711 Stage::GetCurrent().Add( field );
2713 application.SendNotification();
2714 application.Render();
2716 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2717 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2719 // Check the match system language direction property
2720 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2721 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2723 application.SendNotification();
2724 application.Render();
2729 int utcDaliTextFieldLayoutDirectionCoverage(void)
2731 ToolkitTestApplication application;
2732 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
2734 // Creates a tap event. After creating a tap event the text field should
2735 // have the focus and add text with key events should be possible.
2736 TextField field = TextField::New();
2737 DALI_TEST_CHECK( field );
2739 Stage::GetCurrent().Add( field );
2741 field.SetSize( 300.0f, 50.0f );
2742 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2743 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2745 // Avoid a crash when core load gl resources.
2746 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2748 // Render and notify
2749 application.SendNotification();
2750 application.Render();
2752 // init direction for coverage
2753 // Set horizontal alignment END
2754 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2756 // Create a tap event to touch the text field.
2757 TestGenerateTap( application, 150.0f, 25.0f );
2759 // Render and notify
2760 application.SendNotification();
2761 application.Render();
2763 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
2764 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2765 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
2767 // Set horizontal alignment BEGIN
2768 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
2770 // Create a tap event to touch the text field.
2771 TestGenerateTap( application, 150.0f, 25.0f );
2773 // Render and notify
2774 application.SendNotification();
2775 application.Render();
2777 // Set horizontal alignment CENTER
2778 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
2780 // Create a tap event to touch the text field.
2781 TestGenerateTap( application, 150.0f, 25.0f );
2783 // Render and notify
2784 application.SendNotification();
2785 application.Render();
2787 // Set horizontal alignment END
2788 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2790 // Create a tap event to touch the text field.
2791 TestGenerateTap( application, 150.0f, 25.0f );
2793 // Render and notify
2794 application.SendNotification();
2795 application.Render();
2797 // Generate a Esc key event. The text field should lose the focus.
2798 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2799 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2801 // Render and notify
2802 application.SendNotification();
2803 application.Render();
2805 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2810 int UtcDaliTextFieldGetInputMethodContext(void)
2812 ToolkitTestApplication application;
2813 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
2815 TextField field = TextField::New();
2816 DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );
2821 int UtcDaliTextFieldSelectWholeText(void)
2823 ToolkitTestApplication application;
2824 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
2826 TextField textField = TextField::New();
2828 Stage::GetCurrent().Add( textField );
2830 textField.SetSize( 300.f, 50.f );
2831 textField.SetParentOrigin( ParentOrigin::TOP_LEFT );
2832 textField.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2834 // Avoid a crash when core load gl resources.
2835 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2837 application.SendNotification();
2838 application.Render();
2840 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2842 DevelTextField::SelectWholeText( textField );
2844 application.SendNotification();
2845 application.Render();
2847 // Nothing should have been selected. The number of children is still 1
2848 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2850 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
2852 application.SendNotification();
2853 application.Render();
2855 DevelTextField::SelectWholeText( textField );
2857 application.SendNotification();
2858 application.Render();
2860 // Should be 2 children, the stencil and the layer
2861 DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
2863 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2864 Actor stencil = textField.GetChildAt( 0u );
2866 // The highlight actor is drawn first, so is the first actor in the list
2867 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2868 DALI_TEST_CHECK( highlight );