2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali/public-api/rendering/renderer.h>
23 #include <dali/integration-api/events/key-event-integ.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/devel-api/adaptor-framework/key-devel.h>
27 #include <dali/devel-api/text-abstraction/font-client.h>
28 #include <dali-toolkit-test-suite-utils.h>
29 #include <dali-toolkit/dali-toolkit.h>
30 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
31 #include "toolkit-clipboard.h"
34 using namespace Toolkit;
36 void dali_textfield_startup(void)
38 test_return_value = TET_UNDEF;
41 void dali_textfield_cleanup(void)
43 test_return_value = TET_PASS;
49 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
50 const char* const PROPERTY_NAME_TEXT = "text";
51 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
52 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
53 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
54 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
55 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
56 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
57 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
58 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
59 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
60 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
61 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
62 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
63 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
64 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
65 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
66 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
67 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
68 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
69 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
70 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
71 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
72 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
73 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
78 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
79 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
80 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
81 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
82 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
83 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
84 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
85 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
87 const char* const PROPERTY_NAME_UNDERLINE = "underline";
88 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
89 const char* const PROPERTY_NAME_SHADOW = "shadow";
90 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
91 const char* const PROPERTY_NAME_EMBOSS = "emboss";
92 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
93 const char* const PROPERTY_NAME_OUTLINE = "outline";
94 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
96 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
97 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
98 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
99 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
100 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
101 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
102 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
103 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
104 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
105 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
107 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
108 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
110 const float RENDER_FRAME_INTERVAL = 16.66f;
112 const unsigned int DEFAULT_FONT_SIZE = 1152u;
113 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
115 const int KEY_RETURN_CODE = 36;
116 const int KEY_A_CODE = 38;
117 const int KEY_D_CODE = 40;
119 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
121 static bool gTextChangedCallBackCalled;
122 static bool gMaxCharactersCallBackCalled;
123 static bool gInputStyleChangedCallbackCalled;
124 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
126 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
128 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
129 Integration::ResourcePointer resource(bitmap);
130 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
133 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
137 LoadBitmapResource( app.GetPlatform(), width, height );
139 Property::Map propertyMap;
140 propertyMap["filename"] = "image.png";
141 propertyMap["width"] = width;
142 propertyMap["height"] = height;
143 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
144 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
145 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
146 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
147 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
148 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
149 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
150 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
154 * Simulate time passed by.
156 * @note this will always process at least 1 frame (1/60 sec)
158 * @param application Test application instance
159 * @param duration Time to pass in milliseconds.
160 * @return The actual time passed in milliseconds
162 static int Wait(ToolkitTestApplication& application, int duration = 0)
166 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
168 application.SendNotification();
169 application.Render(RENDER_FRAME_INTERVAL);
170 time += RENDER_FRAME_INTERVAL;
176 Dali::Integration::Point GetPointDownInside( Vector2& pos )
178 Dali::Integration::Point point;
179 point.SetState( PointState::DOWN );
180 point.SetScreenPosition( pos );
184 Dali::Integration::Point GetPointUpInside( Vector2& pos )
186 Dali::Integration::Point point;
187 point.SetState( PointState::UP );
188 point.SetScreenPosition( pos );
192 struct CallbackFunctor
194 CallbackFunctor(bool* callbackFlag)
195 : mCallbackFlag( callbackFlag )
201 *mCallbackFlag = true;
206 static void TestTextChangedCallback( TextField control )
208 tet_infoline(" TestTextChangedCallback");
210 gTextChangedCallBackCalled = true;
213 static void TestMaxLengthReachedCallback( TextField control )
215 tet_infoline(" TestMaxLengthReachedCallback");
217 gMaxCharactersCallBackCalled = true;
220 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
222 tet_infoline(" TestInputStyleChangedCallback");
224 gInputStyleChangedCallbackCalled = true;
225 gInputStyleMask = mask;
228 // Generate a KeyEvent to send to Core.
229 Integration::KeyEvent GenerateKey( const std::string& keyName,
230 const std::string& logicalKey,
231 const std::string& keyString,
234 unsigned long timeStamp,
235 const Integration::KeyEvent::State& keyState,
236 const std::string& compose = "",
237 const std::string& deviceName = DEFAULT_DEVICE_NAME,
238 const Device::Class::Type& deviceClass = Device::Class::NONE,
239 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
241 return Integration::KeyEvent( keyName,
254 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
256 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
258 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
260 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
262 Property::Value* valueSet = NULL;
263 if ( valueGet.first.type == Property::Key::INDEX )
265 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
269 // Get Key is a string so searching Set Map for a string key
270 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
273 if( NULL != valueSet )
275 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
277 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
280 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
282 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
285 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
287 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
290 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
292 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
295 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
297 Vector2 vector2Get = valueGet.second.Get<Vector2>();
298 Vector2 vector2Set = valueSet->Get<Vector2>();
299 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
302 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
304 Vector4 vector4Get = valueGet.second.Get<Vector4>();
305 Vector4 vector4Set = valueSet->Get<Vector4>();
306 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 );
312 if ( valueGet.first.type == Property::Key::INDEX )
314 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
318 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
330 int UtcDaliToolkitTextFieldConstructorP(void)
332 ToolkitTestApplication application;
333 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
335 DALI_TEST_CHECK( !textField );
339 int UtcDaliToolkitTextFieldNewP(void)
341 ToolkitTestApplication application;
342 tet_infoline(" UtcDaliToolkitTextFieldNewP");
343 TextField textField = TextField::New();
344 DALI_TEST_CHECK( textField );
348 int UtcDaliToolkitTextFieldDownCastP(void)
350 ToolkitTestApplication application;
351 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
352 TextField textField1 = TextField::New();
353 BaseHandle object( textField1 );
355 TextField textField2 = TextField::DownCast( object );
356 DALI_TEST_CHECK( textField2 );
358 TextField textField3 = DownCast< TextField >( object );
359 DALI_TEST_CHECK( textField3 );
363 int UtcDaliToolkitTextFieldDownCastN(void)
365 ToolkitTestApplication application;
366 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
367 BaseHandle uninitializedObject;
368 TextField textField1 = TextField::DownCast( uninitializedObject );
369 DALI_TEST_CHECK( !textField1 );
371 TextField textField2 = DownCast< TextField >( uninitializedObject );
372 DALI_TEST_CHECK( !textField2 );
376 int UtcDaliToolkitTextFieldCopyConstructorP(void)
378 ToolkitTestApplication application;
379 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
380 TextField textField = TextField::New();
381 textField.SetProperty( TextField::Property::TEXT, "Test" );
383 TextField copy( textField );
384 DALI_TEST_CHECK( copy );
385 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
389 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
391 ToolkitTestApplication application;
392 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
393 TextField textField = TextField::New();
394 textField.SetProperty( TextField::Property::TEXT, "Test" );
396 TextField copy = textField;
397 DALI_TEST_CHECK( copy );
398 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
402 int UtcDaliTextFieldNewP(void)
404 ToolkitTestApplication application;
405 tet_infoline(" UtcDaliToolkitTextFieldNewP");
406 TextField textField = TextField::New();
407 DALI_TEST_CHECK( textField );
411 // Positive test case for a method
412 int UtcDaliTextFieldGetPropertyP(void)
414 ToolkitTestApplication application;
415 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
416 TextField field = TextField::New();
417 DALI_TEST_CHECK( field );
419 // Check Property Indices are correct
420 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
421 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
422 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
423 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
424 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
425 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
426 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
427 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
428 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
429 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
430 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
431 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
432 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
433 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
434 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
435 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
436 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
437 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
438 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
439 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
440 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
441 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
442 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
443 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
444 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
445 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
446 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
447 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
448 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
449 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
450 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
451 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
452 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
453 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
454 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
455 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
456 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
457 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
458 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
459 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
460 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
461 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
462 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
463 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
464 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
465 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
466 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
467 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
468 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
469 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
470 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
471 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
472 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
473 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP );
474 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextField::Property::BACKGROUND );
479 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
482 Property::Map imageMap;
483 imageMap[mapKey] =mapValue;
485 field.SetProperty( property , imageMap );
486 Property::Value propValue = field.GetProperty( property );
487 Property::Map* resultMap = propValue.GetMap();
489 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
497 // Positive test case for a method
498 int UtcDaliTextFieldSetPropertyP(void)
500 ToolkitTestApplication application;
501 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
502 TextField field = TextField::New();
503 DALI_TEST_CHECK( field );
504 Stage::GetCurrent().Add( field );
506 // Note - we can't check the defaults since the stylesheets are platform-specific
508 // Check the render backend property.
509 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
510 DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
512 // Check text property.
513 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
514 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
516 // Check placeholder text properties.
517 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
518 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
520 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
521 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
523 // Check font properties.
524 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
525 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
527 Property::Map fontStyleMapSet;
528 Property::Map fontStyleMapGet;
529 Property::Value* slantValue = NULL;
531 fontStyleMapSet.Insert( "weight", "bold" );
532 fontStyleMapSet.Insert( "width", "condensed" );
533 fontStyleMapSet.Insert( "slant", "italic" );
534 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
536 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
537 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
538 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
540 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
541 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
544 fontStyleMapSet.Clear();
545 fontStyleMapSet.Insert( "weight", "normal" );
546 fontStyleMapSet.Insert( "slant", "oblique" );
547 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
549 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
550 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
551 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
553 fontStyleMapSet.Clear();
554 fontStyleMapSet.Insert( "slant", "roman" );
555 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
556 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
558 // Replace 'roman' for 'normal'.
559 slantValue = fontStyleMapGet.Find( "slant" );
560 if( NULL != slantValue )
562 if( "normal" == slantValue->Get<std::string>() )
564 fontStyleMapGet["slant"] = "roman";
567 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
568 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
570 fontStyleMapSet.Clear();
572 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
573 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
574 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
575 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
577 // Check that the MAX_LENGTH property can be correctly set
578 const int maxNumberOfCharacters = 20;
579 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
580 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
582 // Check exceed policy
583 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
584 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
585 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
586 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
588 // Check that the Alignment properties can be correctly set
589 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
590 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
591 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
592 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
594 // Check text's color property
595 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
596 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
598 // Check placeholder text's color property.
599 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
600 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
602 // Check cursor properties
603 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
604 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
605 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
606 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
608 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
609 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
610 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
611 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
612 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
613 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
614 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
615 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
617 // Check scroll properties.
618 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
619 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
620 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
621 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
623 // Check handle images
624 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
625 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
626 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
627 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
628 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
630 // Check handle images
631 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
632 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
633 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
634 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
635 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
636 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
638 // Check the highlight color
639 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
640 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
642 // Decoration bounding box
643 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
644 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
646 // Check the input method setting
647 Property::Map propertyMap;
648 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
649 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
650 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
651 int inputVariation = 1;
652 propertyMap["PANEL_LAYOUT"] = panelLayout;
653 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
654 propertyMap["BUTTON_ACTION"] = buttonAction;
655 propertyMap["VARIATION"] = inputVariation;
656 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
658 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
660 DALI_TEST_CHECK( value.Get( map ) );
663 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
664 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
667 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
668 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
671 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
672 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
675 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
676 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
678 // Check input color property.
679 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
680 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
682 // Check the enable markup property.
683 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
684 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
685 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
687 // Check input font properties.
688 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
689 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
691 fontStyleMapSet.Clear();
692 fontStyleMapSet.Insert( "weight", "bold" );
693 fontStyleMapSet.Insert( "width", "condensed" );
694 fontStyleMapSet.Insert( "slant", "italic" );
696 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
697 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
698 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
699 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
701 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
702 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
704 // Reset input font style.
705 fontStyleMapSet.Clear();
706 fontStyleMapSet.Insert( "weight", "normal" );
707 fontStyleMapSet.Insert( "slant", "oblique" );
709 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
710 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
711 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
712 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
714 fontStyleMapSet.Clear();
715 fontStyleMapSet.Insert( "slant", "roman" );
717 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
718 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
720 // Replace 'roman' for 'normal'.
721 slantValue = fontStyleMapGet.Find( "slant" );
722 if( NULL != slantValue )
724 if( "normal" == slantValue->Get<std::string>() )
726 fontStyleMapGet["slant"] = "roman";
729 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
730 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
732 fontStyleMapSet.Clear();
734 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
735 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
736 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
737 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
739 Property::Map underlineMapSet;
740 Property::Map underlineMapGet;
742 underlineMapSet.Insert( "enable", true );
743 underlineMapSet.Insert( "color", Color::RED );
744 underlineMapSet.Insert( "height", 1 );
746 // Check the underline property
747 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
749 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
750 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
751 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
753 // Check the input underline property
754 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
755 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
757 // Check the shadow property
758 Property::Map shadowMapSet;
759 Property::Map shadowMapGet;
761 shadowMapSet.Insert( "color", Color::GREEN );
762 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
763 shadowMapSet.Insert( "blurRadius", 3.0f );
765 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
767 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
768 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
769 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
771 // Check the input shadow property
772 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
773 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
775 // Check the emboss property
776 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
777 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
779 // Check the input emboss property
780 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
781 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
783 // Check the outline property
785 // Test string type first
786 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
787 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
788 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
790 // Then test the property map type
791 Property::Map outlineMapSet;
792 Property::Map outlineMapGet;
794 outlineMapSet["color"] = Color::RED;
795 outlineMapSet["width"] = 2.0f;
797 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
799 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
800 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
801 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
803 // Check the input outline property
804 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
805 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
807 // Check the hidden input settings property
808 Property::Map hiddenMapSet;
809 Property::Map hiddenMapGet;
810 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
811 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
812 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
813 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
814 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
816 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
817 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
818 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
820 // Check the pixel size of font
821 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
822 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
824 // Check the enable selection property
825 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
826 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
828 // Check the placeholder property with pixel size
829 Property::Map placeholderPixelSizeMapSet;
830 Property::Map placeholderPixelSizeMapGet;
831 Property::Map placeholderFontstyleMap;
832 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
833 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
834 placeholderPixelSizeMapSet["color"] = Color::BLUE;
835 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
836 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
837 placeholderPixelSizeMapSet["ellipsis"] = true;
839 placeholderFontstyleMap.Insert( "weight", "bold" );
840 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
841 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
843 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
844 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
846 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
847 Property::Map placeholderConversionMap;
848 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
849 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
850 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
851 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
852 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
853 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
855 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
857 // Check the placeholder property with point size
858 Property::Map placeholderMapSet;
859 Property::Map placeholderMapGet;
860 placeholderMapSet["text"] = "Setting Placeholder Text";
861 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
862 placeholderMapSet["color"] = Color::RED;
863 placeholderMapSet["fontFamily"] = "Arial";
864 placeholderMapSet["pointSize"] = 12.0f;
865 placeholderMapSet["ellipsis"] = false;
867 // Check the placeholder font style property
868 placeholderFontstyleMap.Clear();
870 placeholderFontstyleMap.Insert( "weight", "bold" );
871 placeholderFontstyleMap.Insert( "width", "condensed" );
872 placeholderFontstyleMap.Insert( "slant", "italic" );
873 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
874 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
876 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
877 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
879 placeholderConversionMap.Clear();
880 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
881 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
882 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
883 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
884 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
885 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
887 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
890 placeholderFontstyleMap.Clear();
891 placeholderFontstyleMap.Insert( "weight", "normal" );
892 placeholderFontstyleMap.Insert( "slant", "oblique" );
893 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
894 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
896 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
897 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
899 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
900 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
902 placeholderFontstyleMap.Clear();
903 placeholderFontstyleMap.Insert( "slant", "roman" );
904 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
905 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
907 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
909 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
911 placeholderFontstyleMap.Clear();
912 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
913 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
915 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
916 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
917 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
919 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
921 // Check the ellipsis property
922 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
923 field.SetProperty( TextField::Property::ELLIPSIS, true );
924 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
926 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
927 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
929 // Test the ENABLE_GRAB_HANDLE_POPUP property
930 DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
931 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false );
932 DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
934 // Check the background property
935 Property::Map backgroundMapSet;
936 Property::Map backgroundMapGet;
938 backgroundMapSet["enable"] = true;
939 backgroundMapSet["color"] = Color::RED;
940 field.SetProperty( DevelTextField::Property::BACKGROUND, backgroundMapSet );
942 backgroundMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::BACKGROUND );
943 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
944 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet ), true, TEST_LOCATION );
946 application.SendNotification();
947 application.Render();
952 // Positive Atlas Text Renderer test
953 int utcDaliTextFieldAtlasRenderP(void)
955 ToolkitTestApplication application;
956 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
957 StyleManager styleManager = StyleManager::Get();
958 styleManager.ApplyDefaultTheme();
959 TextField field = TextField::New();
960 DALI_TEST_CHECK( field );
962 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
964 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
966 Stage::GetCurrent().Add( field );
970 // Render some text with the shared atlas backend
971 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
972 application.SendNotification();
973 application.Render();
977 tet_result(TET_FAIL);
982 // Positive test for the textChanged signal.
983 int utcDaliTextFieldTextChangedP(void)
985 ToolkitTestApplication application;
986 tet_infoline(" utcDaliTextFieldTextChangedP");
987 TextField field = TextField::New();
988 DALI_TEST_CHECK( field );
990 Stage::GetCurrent().Add( field );
992 // connect to the text changed signal.
993 ConnectionTracker* testTracker = new ConnectionTracker();
994 field.TextChangedSignal().Connect(&TestTextChangedCallback);
995 bool textChangedSignal = false;
996 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
998 gTextChangedCallBackCalled = false;
999 field.SetProperty( TextField::Property::TEXT, "ABC" );
1000 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1001 DALI_TEST_CHECK( textChangedSignal );
1003 application.SendNotification();
1005 field.SetKeyInputFocus();
1007 gTextChangedCallBackCalled = false;
1008 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1009 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1014 // Negative test for the textChanged signal.
1015 int utcDaliTextFieldTextChangedN(void)
1017 ToolkitTestApplication application;
1018 tet_infoline(" utcDaliTextFieldTextChangedN");
1019 TextField field = TextField::New();
1020 DALI_TEST_CHECK( field );
1022 Stage::GetCurrent().Add( field );
1024 // connect to the text changed signal.
1025 ConnectionTracker* testTracker = new ConnectionTracker();
1026 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1027 bool textChangedSignal = false;
1028 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1030 gTextChangedCallBackCalled = false;
1031 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1032 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1033 DALI_TEST_CHECK( !textChangedSignal );
1038 // Positive test for Max Characters reached signal.
1039 int utcDaliTextFieldMaxCharactersReachedP(void)
1041 ToolkitTestApplication application;
1042 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1043 TextField field = TextField::New();
1044 DALI_TEST_CHECK( field );
1046 Stage::GetCurrent().Add( field );
1048 const int maxNumberOfCharacters = 1;
1049 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1051 field.SetKeyInputFocus();
1053 // connect to the text changed signal.
1054 ConnectionTracker* testTracker = new ConnectionTracker();
1055 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1056 bool maxLengthReachedSignal = false;
1057 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1059 gMaxCharactersCallBackCalled = false;
1061 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1062 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1064 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1065 DALI_TEST_CHECK( maxLengthReachedSignal );
1070 // Negative test for Max Characters reached signal.
1071 int utcDaliTextFieldMaxCharactersReachedN(void)
1073 ToolkitTestApplication application;
1074 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1075 TextField field = TextField::New();
1076 DALI_TEST_CHECK( field );
1078 Stage::GetCurrent().Add( field );
1080 const int maxNumberOfCharacters = 3;
1081 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1083 field.SetKeyInputFocus();
1085 // connect to the text changed signal.
1086 ConnectionTracker* testTracker = new ConnectionTracker();
1087 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1088 bool maxLengthReachedSignal = false;
1089 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1091 gMaxCharactersCallBackCalled = false;
1093 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1094 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1096 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1097 DALI_TEST_CHECK( !maxLengthReachedSignal );
1099 application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::Down, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1101 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1102 DALI_TEST_CHECK( !maxLengthReachedSignal );
1107 int utcDaliTextFieldInputStyleChanged01(void)
1109 // The text-field emits signals when the input style changes. These changes of style are
1110 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1111 // can't be emitted during the size negotiation as the callbacks may update the UI.
1112 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1113 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1114 ToolkitTestApplication application;
1115 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1119 char* pathNamePtr = get_current_dir_name();
1120 const std::string pathName( pathNamePtr );
1121 free( pathNamePtr );
1123 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1124 fontClient.SetDpi( 93u, 93u );
1126 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1127 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1129 TextField field = TextField::New();
1130 DALI_TEST_CHECK( field );
1133 field.SetSize( 300.f, 50.f );
1134 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1135 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1137 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1138 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1140 // connect to the text changed signal.
1141 ConnectionTracker* testTracker = new ConnectionTracker();
1142 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1143 bool inputStyleChangedSignal = false;
1144 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1146 Stage::GetCurrent().Add( field );
1148 // Render and notify
1149 application.SendNotification();
1150 application.Render();
1152 // Executes the idle callbacks added by the text control on the change of input style.
1153 application.RunIdles();
1155 gInputStyleChangedCallbackCalled = false;
1156 gInputStyleMask = TextField::InputStyle::NONE;
1157 inputStyleChangedSignal = false;
1159 // Create a tap event to touch the text field.
1160 TestGenerateTap( application, 18.0f, 25.0f );
1162 // Render and notify
1163 application.SendNotification();
1164 application.Render();
1166 // Executes the idle callbacks added by the text control on the change of input style.
1167 application.RunIdles();
1169 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1170 if( gInputStyleChangedCallbackCalled )
1172 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1174 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1175 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1177 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1178 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1180 DALI_TEST_CHECK( inputStyleChangedSignal );
1182 gInputStyleChangedCallbackCalled = false;
1183 gInputStyleMask = TextField::InputStyle::NONE;
1184 inputStyleChangedSignal = false;
1186 // Create a tap event to touch the text field.
1187 TestGenerateTap( application, 30.0f, 25.0f );
1189 // Render and notify
1190 application.SendNotification();
1191 application.Render();
1193 // Executes the idle callbacks added by the text control on the change of input style.
1194 application.RunIdles();
1196 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1197 DALI_TEST_CHECK( !inputStyleChangedSignal );
1199 gInputStyleChangedCallbackCalled = false;
1200 gInputStyleMask = TextField::InputStyle::NONE;
1201 inputStyleChangedSignal = false;
1203 // Create a tap event to touch the text field.
1204 TestGenerateTap( application, 43.0f, 25.0f );
1206 // Render and notify
1207 application.SendNotification();
1208 application.Render();
1210 // Executes the idle callbacks added by the text control on the change of input style.
1211 application.RunIdles();
1213 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1214 if( gInputStyleChangedCallbackCalled )
1216 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1218 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1219 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1221 DALI_TEST_CHECK( inputStyleChangedSignal );
1223 gInputStyleChangedCallbackCalled = false;
1224 gInputStyleMask = TextField::InputStyle::NONE;
1225 inputStyleChangedSignal = false;
1227 // Create a tap event to touch the text field.
1228 TestGenerateTap( application, 88.0f, 25.0f );
1230 // Render and notify
1231 application.SendNotification();
1232 application.Render();
1234 // Executes the idle callbacks added by the text control on the change of input style.
1235 application.RunIdles();
1237 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1238 if( gInputStyleChangedCallbackCalled )
1240 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1242 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1243 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1245 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1247 Property::Map fontStyleMapSet;
1248 fontStyleMapSet.Insert( "weight", "bold" );
1250 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1251 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1253 DALI_TEST_CHECK( inputStyleChangedSignal );
1255 gInputStyleChangedCallbackCalled = false;
1256 gInputStyleMask = TextField::InputStyle::NONE;
1257 inputStyleChangedSignal = false;
1259 // Create a tap event to touch the text field.
1260 TestGenerateTap( application, 115.0f, 25.0f );
1262 // Render and notify
1263 application.SendNotification();
1264 application.Render();
1266 // Executes the idle callbacks added by the text control on the change of input style.
1267 application.RunIdles();
1269 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1270 DALI_TEST_CHECK( !inputStyleChangedSignal );
1272 gInputStyleChangedCallbackCalled = false;
1273 gInputStyleMask = TextField::InputStyle::NONE;
1274 inputStyleChangedSignal = false;
1276 // Create a tap event to touch the text field.
1277 TestGenerateTap( application, 164.0f, 25.0f );
1279 // Render and notify
1280 application.SendNotification();
1281 application.Render();
1283 // Executes the idle callbacks added by the text control on the change of input style.
1284 application.RunIdles();
1286 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1287 if( gInputStyleChangedCallbackCalled )
1289 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1291 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1292 DALI_TEST_CHECK( style.empty() );
1294 DALI_TEST_CHECK( inputStyleChangedSignal );
1296 gInputStyleChangedCallbackCalled = false;
1297 gInputStyleMask = TextField::InputStyle::NONE;
1298 inputStyleChangedSignal = false;
1300 // Create a tap event to touch the text field.
1301 TestGenerateTap( application, 191.0f, 25.0f );
1303 // Render and notify
1304 application.SendNotification();
1305 application.Render();
1307 // Executes the idle callbacks added by the text control on the change of input style.
1308 application.RunIdles();
1310 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1311 DALI_TEST_CHECK( !inputStyleChangedSignal );
1316 int utcDaliTextFieldInputStyleChanged02(void)
1318 // The text-field emits signals when the input style changes. These changes of style are
1319 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1320 // can't be emitted during the size negotiation as the callbacks may update the UI.
1321 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1322 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1323 ToolkitTestApplication application;
1324 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1328 char* pathNamePtr = get_current_dir_name();
1329 const std::string pathName( pathNamePtr );
1330 free( pathNamePtr );
1332 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1333 fontClient.SetDpi( 93u, 93u );
1335 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1336 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1338 TextField field = TextField::New();
1339 DALI_TEST_CHECK( field );
1341 field.SetSize( 300.f, 50.f );
1342 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1343 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1345 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1346 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>" );
1348 // connect to the text changed signal.
1349 ConnectionTracker* testTracker = new ConnectionTracker();
1350 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1351 bool inputStyleChangedSignal = false;
1352 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1354 Stage::GetCurrent().Add( field );
1356 // Render and notify
1357 application.SendNotification();
1358 application.Render();
1360 // Executes the idle callbacks added by the text control on the change of input style.
1361 application.RunIdles();
1363 gInputStyleChangedCallbackCalled = false;
1364 gInputStyleMask = TextField::InputStyle::NONE;
1365 inputStyleChangedSignal = false;
1367 // Create a tap event to touch the text field.
1368 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1369 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1371 // Render and notify
1372 application.SendNotification();
1373 application.Render();
1375 // Executes the idle callbacks added by the text control on the change of input style.
1376 application.RunIdles();
1378 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1379 if( gInputStyleChangedCallbackCalled )
1381 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1382 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1383 TextField::InputStyle::POINT_SIZE |
1384 TextField::InputStyle::COLOR ),
1387 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1388 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1390 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1391 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1393 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1394 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1396 DALI_TEST_CHECK( inputStyleChangedSignal );
1398 gInputStyleChangedCallbackCalled = false;
1399 gInputStyleMask = TextField::InputStyle::NONE;
1400 inputStyleChangedSignal = false;
1402 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1404 // Render and notify
1405 application.SendNotification();
1406 application.Render();
1408 // Executes the idle callbacks added by the text control on the change of input style.
1409 application.RunIdles();
1411 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1412 if( gInputStyleChangedCallbackCalled )
1414 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1415 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1418 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1419 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1421 DALI_TEST_CHECK( inputStyleChangedSignal );
1423 gInputStyleChangedCallbackCalled = false;
1424 gInputStyleMask = TextField::InputStyle::NONE;
1425 inputStyleChangedSignal = false;
1427 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1429 // Render and notify
1430 application.SendNotification();
1431 application.Render();
1433 // Executes the idle callbacks added by the text control on the change of input style.
1434 application.RunIdles();
1436 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1437 DALI_TEST_CHECK( !inputStyleChangedSignal );
1439 gInputStyleChangedCallbackCalled = false;
1440 gInputStyleMask = TextField::InputStyle::NONE;
1441 inputStyleChangedSignal = false;
1443 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1445 // Render and notify
1446 application.SendNotification();
1447 application.Render();
1449 // Executes the idle callbacks added by the text control on the change of input style.
1450 application.RunIdles();
1452 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1453 if( gInputStyleChangedCallbackCalled )
1455 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1456 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1459 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1460 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1462 DALI_TEST_CHECK( inputStyleChangedSignal );
1464 gInputStyleChangedCallbackCalled = false;
1465 gInputStyleMask = TextField::InputStyle::NONE;
1466 inputStyleChangedSignal = false;
1468 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1470 Property::Map fontStyleMapSet;
1471 fontStyleMapSet.Insert( "weight", "thin" );
1472 fontStyleMapSet.Insert( "width", "condensed" );
1473 fontStyleMapSet.Insert( "slant", "italic" );
1475 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1476 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1478 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1479 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1480 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1481 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1483 // Render and notify
1484 application.SendNotification();
1485 application.Render();
1487 // Executes the idle callbacks added by the text control on the change of input style.
1488 application.RunIdles();
1490 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1491 DALI_TEST_CHECK( !inputStyleChangedSignal );
1493 // Create a tap event to touch the text field.
1494 TestGenerateTap( application, 63.0f, 25.0f, 300 );
1496 // Render and notify
1497 application.SendNotification();
1498 application.Render();
1500 // Executes the idle callbacks added by the text control on the change of input style.
1501 application.RunIdles();
1503 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1504 if( gInputStyleChangedCallbackCalled )
1506 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1507 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1508 TextField::InputStyle::POINT_SIZE |
1509 TextField::InputStyle::FONT_STYLE |
1510 TextField::InputStyle::UNDERLINE |
1511 TextField::InputStyle::SHADOW |
1512 TextField::InputStyle::EMBOSS |
1513 TextField::InputStyle::OUTLINE ),
1516 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1517 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1519 DALI_TEST_CHECK( inputStyleChangedSignal );
1524 int utcDaliTextFieldEvent01(void)
1526 ToolkitTestApplication application;
1527 tet_infoline(" utcDaliTextFieldEvent01");
1529 // Creates a tap event. After creating a tap event the text field should
1530 // have the focus and add text with key events should be possible.
1532 TextField field = TextField::New();
1533 DALI_TEST_CHECK( field );
1535 Stage::GetCurrent().Add( field );
1537 field.SetSize( 300.f, 50.f );
1538 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1539 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1541 // Render and notify
1542 application.SendNotification();
1543 application.Render();
1545 // Avoid a crash when core load gl resources.
1546 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1548 // Render and notify
1549 application.SendNotification();
1550 application.Render();
1552 // Add a key event but as the text field has not the focus it should do nothing.
1553 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1555 // Render and notify
1556 application.SendNotification();
1557 application.Render();
1559 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1561 // Create a tap event to touch the text field.
1562 TestGenerateTap( application, 150.0f, 25.0f );
1564 // Render and notify
1565 application.SendNotification();
1566 application.Render();
1568 // Pressing delete key should be fine even if there is no text in TextField.
1569 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 ) );
1570 // Render and notify
1571 application.SendNotification();
1572 application.Render();
1574 // Now the text field has the focus, so it can handle the key events.
1575 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1576 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1578 // Render and notify
1579 application.SendNotification();
1580 application.Render();
1582 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1584 // Create a second text field and send key events to it.
1585 TextField field2 = TextField::New();
1587 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1588 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1589 field2.SetSize( 100.f, 100.0f );
1590 field2.SetPosition( 100.0f, 100.0f );
1592 Stage::GetCurrent().Add( field2 );
1594 // Render and notify
1595 application.SendNotification();
1596 application.Render();
1598 // Create a tap event on the second text field.
1599 TestGenerateTap( application, 150.0f, 125.0f );
1601 // Render and notify
1602 application.SendNotification();
1603 application.Render();
1605 // The second text field has the focus. It should handle the key events.
1606 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1607 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1609 // Render and notify
1610 application.SendNotification();
1611 application.Render();
1613 // Check the text has been added to the second text field.
1614 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1619 int utcDaliTextFieldEvent02(void)
1621 ToolkitTestApplication application;
1622 tet_infoline(" utcDaliTextFieldEvent02");
1624 // Checks if the right number of actors are created.
1626 TextField field = TextField::New();
1627 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1628 DALI_TEST_CHECK( field );
1629 LoadMarkerImages(application, field);
1631 Stage::GetCurrent().Add( field );
1633 field.SetSize( 300.0f, 50.0f );
1634 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1635 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1637 // Avoid a crash when core load gl resources.
1638 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1640 // Render and notify
1641 application.SendNotification();
1642 application.Render();
1644 // Check there are the expected number of children ( stencil ).
1645 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1647 Actor stencil = field.GetChildAt( 0u );
1648 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1650 // Create a tap event to touch the text field.
1651 TestGenerateTap( application, 150.0f, 25.0f, 300 );
1653 // Render and notify
1654 application.SendNotification();
1655 application.Render();
1657 Actor layer = field.GetChildAt( 1u );
1658 DALI_TEST_CHECK( layer.IsLayer() );
1660 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1661 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1663 // Now the text field has the focus, so it can handle the key events.
1664 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1665 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1667 // Render and notify
1668 application.SendNotification();
1669 application.Render();
1671 // Checks the cursor and the renderer have been created.
1672 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1673 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1675 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1676 DALI_TEST_CHECK( cursor );
1678 // The offscreen root actor has a container with all the actors which contain the text renderers.
1679 Actor container = stencil.GetChildAt( 0u );
1680 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1682 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1683 DALI_TEST_CHECK( renderer );
1686 // Move the cursor and check the position changes.
1687 Vector3 position1 = cursor.GetCurrentPosition();
1688 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1690 // Render and notify
1691 application.SendNotification();
1692 application.Render();
1694 Vector3 position2 = cursor.GetCurrentPosition();
1695 DALI_TEST_CHECK( position2.x < position1.x );
1697 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1699 // Render and notify
1700 application.SendNotification();
1701 application.Render();
1703 Vector3 position3 = cursor.GetCurrentPosition();
1704 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1707 // Move the cursor to the first position.
1708 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1709 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1711 // Render and notify
1712 application.SendNotification();
1713 application.Render();
1715 Vector3 position4 = cursor.GetCurrentPosition();
1717 // Send some taps and check the cursor positions.
1719 // Try to tap at the beginning.
1720 TestGenerateTap( application, 1.0f, 25.0f, 900 );
1722 // Render and notify
1723 application.SendNotification();
1724 application.Render();
1726 // Cursor position should be the same than position1.
1727 Vector3 position5 = cursor.GetCurrentPosition();
1729 DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
1731 // Tap away from the start position.
1732 TestGenerateTap( application, 16.0f, 25.0f, 1500 );
1734 // Render and notify
1735 application.SendNotification();
1736 application.Render();
1738 Vector3 position6 = cursor.GetCurrentPosition();
1740 DALI_TEST_CHECK( position6.x > position5.x );
1742 // Remove all the text.
1743 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1744 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1745 field.SetProperty( TextField::Property::TEXT, "" );
1747 // Render and notify
1748 application.SendNotification();
1749 application.Render();
1751 // Cursor position should be the same than position2.
1752 Vector3 position7 = cursor.GetCurrentPosition();
1754 DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
1756 // Should not be a renderer.
1757 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1759 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1760 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1761 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1763 application.SendNotification();
1764 application.Render();
1766 // There are renderer and decorator layer
1767 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1772 int utcDaliTextFieldEvent03(void)
1774 ToolkitTestApplication application;
1775 tet_infoline(" utcDaliTextFieldEvent03");
1777 // Checks if the highlight actor is created.
1779 TextField field = TextField::New();
1780 DALI_TEST_CHECK( field );
1782 Stage::GetCurrent().Add( field );
1784 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1785 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1786 field.SetSize( 30.f, 50.f );
1787 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1788 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1790 // Avoid a crash when core load gl resources.
1791 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1792 LoadMarkerImages(application, field);
1794 // Render and notify
1795 application.SendNotification();
1796 application.Render();
1798 // Tap first to get the focus.
1799 TestGenerateTap( application, 3.0f, 25.0f );
1801 // Render and notify
1802 application.SendNotification();
1803 application.Render();
1805 // Double tap to select a word.
1806 TestGenerateTap( application, 3.0f, 25.0f );
1808 // Render and notify
1809 application.SendNotification();
1810 application.Render();
1812 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1813 Actor stencil = field.GetChildAt( 0u );
1815 // The highlight actor is drawn first, so is the first actor in the list
1816 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1817 DALI_TEST_CHECK( highlight );
1819 // The offscreen root actor has a container with all the actors which contain the text renderers.
1820 Actor container = stencil.GetChildAt( 1u );
1821 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1823 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1824 DALI_TEST_CHECK( renderer );
1830 int utcDaliTextFieldEvent04(void)
1832 ToolkitTestApplication application;
1833 tet_infoline(" utcDaliTextFieldEvent04");
1835 // Checks if the highlight actor is created.
1837 TextField field = TextField::New();
1838 DALI_TEST_CHECK( field );
1839 Stage::GetCurrent().Add( field );
1840 LoadMarkerImages(application, field);
1841 // Render and notify
1842 application.SendNotification();
1843 application.Render();
1845 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1846 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1847 field.SetSize( 300.f, 50.f );
1848 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1849 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1851 // Avoid a crash when core load gl resources.
1852 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1853 // Render and notify
1854 application.SendNotification();
1855 application.Render();
1857 // Create a tap event to touch the text field.
1858 TestGenerateTap( application, 150.0f, 25.0f );
1859 // Render and notify
1860 application.SendNotification();
1861 application.Render();
1864 // Tap first to get the focus.
1865 TestGenerateTap( application, 1.0f, 25.0f );
1867 // Render and notify
1868 application.SendNotification();
1869 application.Render();
1871 // Double tap to select a word.
1872 TestGenerateTap( application, 1.0f, 25.0f );
1874 // Render and notify
1875 application.SendNotification();
1876 application.Render();
1879 TestGenerateTap( application, 0.0f, 40.0f );
1883 int utcDaliTextFieldEvent05(void)
1885 ToolkitTestApplication application;
1886 tet_infoline(" utcDaliTextFieldEvent05");
1888 // Checks dragging of cursor/grab handle
1890 TextField field = TextField::New();
1891 DALI_TEST_CHECK( field );
1892 Stage::GetCurrent().Add( field );
1893 LoadMarkerImages(application, field);
1894 // Render and notify
1895 application.SendNotification();
1896 application.Render();
1898 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1899 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1900 field.SetSize( 300.f, 50.f );
1901 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1902 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1904 // Avoid a crash when core load gl resources.
1905 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1906 // Render and notify
1907 application.SendNotification();
1908 application.Render();
1910 // Create a tap event to touch the text field.
1911 TestGenerateTap( application, 150.0f, 25.0f );
1912 // Render and notify
1913 application.SendNotification();
1914 application.Render();
1916 // Tap first to get the focus.
1917 TestGenerateTap( application, 1.0f, 25.0f );
1919 // Render and notify
1920 application.SendNotification();
1921 application.Render();
1923 // Double tap to select a word.
1924 TestGenerateTap( application, 1.0f, 25.0f );
1926 // Render and notify
1927 application.SendNotification();
1928 application.Render();
1930 Actor stencil = field.GetChildAt( 1u );
1934 int utcDaliTextFieldEvent06(void)
1936 ToolkitTestApplication application;
1937 tet_infoline(" utcDaliTextFieldEvent06");
1939 // Checks Longpress when in edit mode
1941 TextField field = TextField::New();
1942 DALI_TEST_CHECK( field );
1943 Stage::GetCurrent().Add( field );
1944 LoadMarkerImages(application, field);
1945 // Render and notify
1946 application.SendNotification();
1947 application.Render();
1949 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1950 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1951 field.SetSize( 300.f, 50.f );
1952 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1953 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1955 // Avoid a crash when core load gl resources.
1956 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1957 // Render and notify
1958 application.SendNotification();
1959 application.Render();
1961 // Create a tap event to touch the text field.
1962 TestGenerateTap( application, 150.0f, 25.0f );
1963 // Render and notify
1964 application.SendNotification();
1965 application.Render();
1968 // Tap first to get the focus.
1969 TestGenerateTap( application, 1.0f, 25.0f );
1971 // Render and notify
1972 application.SendNotification();
1973 application.Render();
1976 TestGenerateLongPress(application, 1.0f, 25.0f);
1978 // Render and notify
1979 application.SendNotification();
1980 application.Render();
1985 int utcDaliTextFieldEvent07(void)
1987 ToolkitTestApplication application;
1988 tet_infoline(" utcDaliTextFieldEvent07");
1990 // Checks Longpress to start edit mode
1992 TextField field = TextField::New();
1993 DALI_TEST_CHECK( field );
1994 Stage::GetCurrent().Add( field );
1995 LoadMarkerImages(application, field);
1996 // Render and notify
1997 application.SendNotification();
1998 application.Render();
2000 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2001 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2002 field.SetSize( 300.f, 50.f );
2003 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2004 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2005 Property::Map propertyMap;
2006 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2007 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2009 // Avoid a crash when core load gl resources.
2010 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2011 // Render and notify
2012 application.SendNotification();
2013 application.Render();
2016 TestGenerateLongPress(application, 1.0f, 25.0f);
2018 // Render and notify
2019 application.SendNotification();
2020 application.Render();
2025 int utcDaliTextFieldEvent08(void)
2027 ToolkitTestApplication application;
2028 tet_infoline(" utcDaliTextFieldEvent08");
2030 Dali::Clipboard clipboard = Clipboard::Get();
2031 clipboard.SetItem("testTextFieldEvent");
2033 // Checks Longpress when only place holder text
2035 TextField field = TextField::New();
2036 DALI_TEST_CHECK( field );
2037 Stage::GetCurrent().Add( field );
2038 LoadMarkerImages(application, field);
2039 // Render and notify
2040 application.SendNotification();
2041 application.Render();
2043 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2044 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2045 field.SetSize( 300.f, 50.f );
2046 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2047 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2049 // Avoid a crash when core load gl resources.
2050 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2051 // Render and notify
2052 application.SendNotification();
2053 application.Render();
2056 TestGenerateLongPress( application, 1.0f, 25.0f, 20 );
2058 // Render and notify
2059 application.SendNotification();
2060 application.Render();
2062 Wait(application, 500);
2064 TestEndLongPress( application, 1.0f, 25.0f, 520 );
2067 TestGenerateLongPress( application, 1.0f, 25.0f, 600 );
2069 // Render and notify
2070 application.Render();
2072 Wait(application, 500);
2074 Stage stage = Stage::GetCurrent();
2075 Layer layer = stage.GetRootLayer();
2076 Actor actor = layer.FindChildByName("optionPaste");
2080 Vector3 worldPosition = actor.GetCurrentWorldPosition();
2081 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2082 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2084 Dali::Integration::TouchEvent event;
2085 event = Dali::Integration::TouchEvent();
2086 event.AddPoint( GetPointDownInside( position ) );
2087 application.ProcessEvent( event );
2089 event = Dali::Integration::TouchEvent();
2090 event.AddPoint( GetPointUpInside( position ) );
2091 application.ProcessEvent( event );
2093 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2098 int utcDaliTextFieldEvent09(void)
2100 ToolkitTestApplication application;
2101 tet_infoline(" utcDaliTextFieldEvent09");
2103 TextField field = TextField::New();
2104 DALI_TEST_CHECK( field );
2105 Stage::GetCurrent().Add( field );
2106 LoadMarkerImages(application, field);
2107 // Render and notify
2108 application.SendNotification();
2109 application.Render();
2111 field.SetProperty( TextField::Property::TEXT, "Hello" );
2112 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2113 field.SetSize( 300.f, 50.f );
2114 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2115 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2117 // Avoid a crash when core load gl resources.
2118 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2120 // Create a tap event to touch the text field.
2121 TestGenerateTap( application, 150.0f, 25.0f );
2122 application.SendNotification();
2123 application.Render();
2126 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2127 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2128 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2129 application.SendNotification();
2130 application.Render();
2132 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2133 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2134 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2135 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2136 application.SendNotification();
2137 application.Render();
2139 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2140 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2141 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2142 for( unsigned int index = 0u; index < 5u; ++index )
2144 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2145 application.SendNotification();
2146 application.Render();
2149 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2150 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2151 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2152 for( unsigned int index = 0u; index < 5u; ++index )
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();
2159 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2160 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2161 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2162 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2163 application.SendNotification();
2164 application.Render();
2165 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2166 application.SendNotification();
2167 application.Render();
2169 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2170 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2171 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2172 application.SendNotification();
2173 application.Render();
2175 Property::Map mapGet;
2176 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2177 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2178 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2183 int utcDaliTextFieldStyleWhilstSelected(void)
2185 ToolkitTestApplication application;
2186 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2188 // Change font and styles whilst text is selected whilst word selected
2190 TextField field = TextField::New();
2191 DALI_TEST_CHECK( field );
2192 Stage::GetCurrent().Add( field );
2193 LoadMarkerImages(application, field);
2194 // Render and notify
2195 application.SendNotification();
2196 application.Render();
2198 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2199 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2200 field.SetSize( 300.f, 50.f );
2201 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2202 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2204 // Avoid a crash when core load gl resources.
2205 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2206 // Render and notify
2207 application.SendNotification();
2208 application.Render();
2210 // Create a tap event to touch the text field.
2211 TestGenerateTap( application, 150.0f, 25.0f );
2212 // Render and notify
2213 application.SendNotification();
2214 application.Render();
2217 // Tap first to get the focus.
2218 TestGenerateTap( application, 1.0f, 25.0f );
2220 // Render and notify
2221 application.SendNotification();
2222 application.Render();
2224 // Double tap to select a word.
2225 TestGenerateTap( application, 1.0f, 25.0f );
2227 // Render and notify
2228 application.SendNotification();
2229 application.Render();
2231 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2232 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2234 Property::Map fontStyleMapSet;
2235 Property::Map fontStyleMapGet;
2237 fontStyleMapSet.Insert( "weight", "bold" );
2238 fontStyleMapSet.Insert( "slant", "italic" );
2239 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2241 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2242 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2243 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2245 fontStyleMapSet.Clear();
2246 fontStyleMapSet.Insert( "width", "expanded" );
2247 fontStyleMapSet.Insert( "slant", "italic" );
2248 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2250 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2251 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2252 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2254 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2255 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2257 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2258 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2260 fontStyleMapSet.Clear();
2261 fontStyleMapSet.Insert( "weight", "bold" );
2262 fontStyleMapSet.Insert( "slant", "italic" );
2264 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2266 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2267 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2268 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2270 fontStyleMapSet.Clear();
2271 fontStyleMapSet.Insert( "width", "expanded" );
2273 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2275 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2276 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2277 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2279 // Press Escape to increase coverage
2280 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2281 application.SendNotification();
2282 application.Render();
2284 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2289 int utcDaliTextFieldEscKeyLoseFocus(void)
2291 ToolkitTestApplication application;
2292 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2294 // Creates a tap event. After creating a tap event the text field should
2295 // have the focus and add text with key events should be possible.
2297 TextField field = TextField::New();
2298 DALI_TEST_CHECK( field );
2300 Stage::GetCurrent().Add( field );
2302 field.SetSize( 300.f, 50.f );
2303 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2304 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2306 // Avoid a crash when core load gl resources.
2307 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2309 // Render and notify
2310 application.SendNotification();
2311 application.Render();
2313 // Add a key event but as the text field has not the focus it should do nothing.
2314 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2315 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2317 // Render and notify
2318 application.SendNotification();
2319 application.Render();
2321 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2323 // Create a tap event to touch the text field.
2324 TestGenerateTap( application, 150.0f, 25.0f );
2326 // Render and notify
2327 application.SendNotification();
2328 application.Render();
2330 // Now the text field has the focus, so it can handle the key events.
2331 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2332 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2333 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2334 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2336 // Render and notify
2337 application.SendNotification();
2338 application.Render();
2340 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2342 // Generate a Esc key event. The text field should lose the focus.
2343 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2344 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2346 // Render and notify
2347 application.SendNotification();
2348 application.Render();
2350 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2352 // No more text should be introduced
2353 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2354 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2356 // Render and notify
2357 application.SendNotification();
2358 application.Render();
2360 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2365 int utcDaliTextFieldSomeSpecialKeys(void)
2367 ToolkitTestApplication application;
2368 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2370 // Checks some special keys when the text is selected.
2372 TextField field = TextField::New();
2373 DALI_TEST_CHECK( field );
2374 Stage::GetCurrent().Add( field );
2375 LoadMarkerImages(application, field);
2376 // Render and notify
2377 application.SendNotification();
2378 application.Render();
2380 const std::string longText( "This is a long text for the size of the text-field." );
2382 field.SetProperty( TextField::Property::TEXT, longText );
2383 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2384 field.SetSize( 300.f, 50.f );
2385 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2386 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2388 // Avoid a crash when core load gl resources.
2389 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2390 // Render and notify
2391 application.SendNotification();
2392 application.Render();
2394 // Create a tap event to touch the text field.
2395 TestGenerateTap( application, 150.0f, 25.0f );
2397 // Render and notify
2398 application.SendNotification();
2399 application.Render();
2401 // Tap first to get the focus.
2402 TestGenerateTap( application, 1.0f, 25.0f );
2404 // Render and notify
2405 application.SendNotification();
2406 application.Render();
2408 // Double tap to select a word.
2409 TestGenerateTap( application, 1.0f, 25.0f );
2411 // Render and notify
2412 application.SendNotification();
2413 application.Render();
2415 // Generate a Esc key event. The text field should lose the focus.
2416 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2417 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2419 // Render and notify
2420 application.SendNotification();
2421 application.Render();
2423 // Generate a Esc key event. The text field should lose the focus.
2424 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2425 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2427 // Render and notify
2428 application.SendNotification();
2429 application.Render();
2431 // Generate a Esc key event. The text field should lose the focus.
2432 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2433 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2435 // Render and notify
2436 application.SendNotification();
2437 application.Render();
2439 // The text shouldn't be deleted.
2440 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2445 int utcDaliTextFieldSizeUpdate(void)
2447 ToolkitTestApplication application;
2448 tet_infoline("utcDaliTextFieldSizeUpdate");
2450 // Checks some special keys when the text is selected.
2451 TextField field = TextField::New();
2452 DALI_TEST_CHECK( field );
2453 Stage::GetCurrent().Add( field );
2455 float previousHeight = 0.0f;
2456 float currentHeight = 0.0f;
2457 const float fieldWidth = 1920.0f;
2460 // "ㅁ" is bigger then "ኢ"
2461 field.SetSize( Vector2( fieldWidth ,10.0f ) );
2462 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2463 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2465 field.SetProperty( TextField::Property::TEXT, "ኢ");
2466 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2467 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2469 field.SetKeyboardFocusable(true);
2470 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2472 application.SendNotification();
2473 application.Render();
2475 previousHeight = field.GetHeightForWidth( fieldWidth );
2476 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2478 // Add another script characters ( glyph height is defferent )
2479 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2480 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2482 application.SendNotification();
2483 application.Render();
2485 currentHeight = field.GetHeightForWidth( fieldWidth );
2486 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2487 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2492 int utcDaliTextFieldExtremlyLargePointSize(void)
2494 ToolkitTestApplication application;
2495 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2497 TextField field = TextField::New();
2499 field.SetProperty( TextField::Property::TEXT, "Text" );
2500 field.SetSize( 300.f, 50.f );
2501 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2502 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2503 Stage::GetCurrent().Add( field );
2507 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2508 application.SendNotification();
2509 DALI_TEST_CHECK( field );
2513 tet_result(TET_FAIL);
2518 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2520 ToolkitTestApplication application;
2521 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2522 TextField field = TextField::New();
2523 DALI_TEST_CHECK( field );
2524 Stage::GetCurrent().Add( field );
2526 Property::Map fontStyleMapGet;
2528 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2530 Property::Value* weightValue = NULL;
2531 Property::Value* widthValue = NULL;
2532 Property::Value* slantValue = NULL;
2533 weightValue = fontStyleMapGet.Find( "weight" );
2534 widthValue = fontStyleMapGet.Find( "width" );
2535 slantValue = fontStyleMapGet.Find( "slant" );
2536 DALI_TEST_CHECK( !weightValue );
2537 DALI_TEST_CHECK( !widthValue );
2538 DALI_TEST_CHECK( !slantValue );
2543 int UtcDaliTextFieldSettingPlaceholder(void)
2545 ToolkitTestApplication application;
2546 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
2548 TextField field = TextField::New();
2549 DALI_TEST_CHECK( field );
2550 Stage::GetCurrent().Add( field );
2552 // Check the placeholder property with pixel size
2553 Property::Map placeholderPixelSizeMapSet;
2554 Property::Map placeholderPixelSizeMapGet;
2555 Property::Map placeholderFontstyleMap;
2556 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2557 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2558 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
2559 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2560 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
2561 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
2563 placeholderFontstyleMap.Insert( "weight", "bold" );
2564 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2565 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
2567 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2568 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
2569 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
2571 // Check the placeholder property with point size
2572 Property::Map placeholderMapSet;
2573 Property::Map placeholderMapGet;
2574 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2575 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2576 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
2577 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2578 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
2579 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
2581 // Check the placeholder font style property
2582 placeholderFontstyleMap.Clear();
2584 placeholderFontstyleMap.Insert( "weight", "bold" );
2585 placeholderFontstyleMap.Insert( "width", "condensed" );
2586 placeholderFontstyleMap.Insert( "slant", "italic" );
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 // Reset font style.
2595 placeholderFontstyleMap.Clear();
2596 placeholderFontstyleMap.Insert( "weight", "normal" );
2597 placeholderFontstyleMap.Insert( "slant", "oblique" );
2598 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2599 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2601 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2602 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2603 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2605 placeholderFontstyleMap.Clear();
2606 placeholderFontstyleMap.Insert( "slant", "roman" );
2607 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2608 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2610 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2612 placeholderFontstyleMap.Clear();
2613 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2615 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2616 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2617 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2618 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2623 int UtcDaliTextFieldSetPaddingProperty(void)
2625 ToolkitTestApplication application;
2626 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
2628 TextField field = TextField::New();
2629 DALI_TEST_CHECK( field );
2630 field.SetSize( 300.f, 50.f );
2631 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2632 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2633 Stage::GetCurrent().Add( field );
2635 application.SendNotification();
2636 application.Render();
2638 Vector3 originalSize = field.GetNaturalSize();
2640 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2642 application.SendNotification();
2643 application.Render();
2645 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2647 Vector3 paddingAddedSize = field.GetNaturalSize();
2649 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2651 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2656 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
2658 ToolkitTestApplication application;
2659 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
2661 TextField field = TextField::New();
2662 DALI_TEST_CHECK( field );
2663 field.SetSize( 300.0f, 50.0f );
2664 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2665 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2666 Stage::GetCurrent().Add( field );
2668 application.SendNotification();
2669 application.Render();
2671 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2672 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2674 // Check the enable shift selection property
2675 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
2676 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2678 application.SendNotification();
2679 application.Render();
2684 int UtcDaliTextFieldEnableGrabHandleProperty(void)
2686 ToolkitTestApplication application;
2687 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
2689 TextField field = TextField::New();
2690 DALI_TEST_CHECK( field );
2691 field.SetSize( 300.0f, 50.0f );
2692 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2693 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2694 Stage::GetCurrent().Add( field );
2696 application.SendNotification();
2697 application.Render();
2699 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2700 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2702 // Check the enable grab handle property
2703 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
2704 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2706 application.SendNotification();
2707 application.Render();
2712 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
2714 ToolkitTestApplication application;
2715 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
2717 TextField field = TextField::New();
2718 DALI_TEST_CHECK( field );
2719 field.SetSize( 300.0f, 50.0f );
2720 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2721 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2722 Stage::GetCurrent().Add( field );
2724 application.SendNotification();
2725 application.Render();
2727 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2728 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2730 // Check the match system language direction property
2731 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2732 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2734 application.SendNotification();
2735 application.Render();
2740 int utcDaliTextFieldLayoutDirectionCoverage(void)
2742 ToolkitTestApplication application;
2743 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
2745 // Creates a tap event. After creating a tap event the text field should
2746 // have the focus and add text with key events should be possible.
2747 TextField field = TextField::New();
2748 DALI_TEST_CHECK( field );
2750 Stage::GetCurrent().Add( field );
2752 field.SetSize( 300.0f, 50.0f );
2753 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2754 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2756 // Avoid a crash when core load gl resources.
2757 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2759 // Render and notify
2760 application.SendNotification();
2761 application.Render();
2763 // init direction for coverage
2764 // Set horizontal alignment END
2765 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2767 // Create a tap event to touch the text field.
2768 TestGenerateTap( application, 150.0f, 25.0f );
2770 // Render and notify
2771 application.SendNotification();
2772 application.Render();
2774 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
2775 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2776 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
2778 // Set horizontal alignment BEGIN
2779 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
2781 // Create a tap event to touch the text field.
2782 TestGenerateTap( application, 150.0f, 25.0f );
2784 // Render and notify
2785 application.SendNotification();
2786 application.Render();
2788 // Set horizontal alignment CENTER
2789 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
2791 // Create a tap event to touch the text field.
2792 TestGenerateTap( application, 150.0f, 25.0f );
2794 // Render and notify
2795 application.SendNotification();
2796 application.Render();
2798 // Set horizontal alignment END
2799 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2801 // Create a tap event to touch the text field.
2802 TestGenerateTap( application, 150.0f, 25.0f );
2804 // Render and notify
2805 application.SendNotification();
2806 application.Render();
2808 // Generate a Esc key event. The text field should lose the focus.
2809 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2810 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2812 // Render and notify
2813 application.SendNotification();
2814 application.Render();
2816 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2821 int UtcDaliTextFieldGetInputMethodContext(void)
2823 ToolkitTestApplication application;
2824 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
2826 TextField field = TextField::New();
2827 DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );
2832 int UtcDaliTextFieldSelectWholeText(void)
2834 ToolkitTestApplication application;
2835 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
2837 TextField textField = TextField::New();
2839 Stage::GetCurrent().Add( textField );
2841 textField.SetSize( 300.f, 50.f );
2842 textField.SetParentOrigin( ParentOrigin::TOP_LEFT );
2843 textField.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2845 // Avoid a crash when core load gl resources.
2846 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2848 application.SendNotification();
2849 application.Render();
2851 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2853 DevelTextField::SelectWholeText( textField );
2855 application.SendNotification();
2856 application.Render();
2858 // Nothing should have been selected. The number of children is still 1
2859 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2861 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
2863 application.SendNotification();
2864 application.Render();
2866 DevelTextField::SelectWholeText( textField );
2868 application.SendNotification();
2869 application.Render();
2871 // Should be 2 children, the stencil and the layer
2872 DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
2874 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2875 Actor stencil = textField.GetChildAt( 0u );
2877 // The highlight actor is drawn first, so is the first actor in the list
2878 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2879 DALI_TEST_CHECK( highlight );