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 field.SetProperty( DevelTextField::Property::BACKGROUND, Color::RED );
936 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::BACKGROUND ), Color::RED, TEST_LOCATION );
938 application.SendNotification();
939 application.Render();
944 // Positive Atlas Text Renderer test
945 int utcDaliTextFieldAtlasRenderP(void)
947 ToolkitTestApplication application;
948 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
949 StyleManager styleManager = StyleManager::Get();
950 styleManager.ApplyDefaultTheme();
951 TextField field = TextField::New();
952 DALI_TEST_CHECK( field );
954 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
956 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
958 Stage::GetCurrent().Add( field );
962 // Render some text with the shared atlas backend
963 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
964 application.SendNotification();
965 application.Render();
969 tet_result(TET_FAIL);
974 // Positive test for the textChanged signal.
975 int utcDaliTextFieldTextChangedP(void)
977 ToolkitTestApplication application;
978 tet_infoline(" utcDaliTextFieldTextChangedP");
979 TextField field = TextField::New();
980 DALI_TEST_CHECK( field );
982 Stage::GetCurrent().Add( field );
984 // connect to the text changed signal.
985 ConnectionTracker* testTracker = new ConnectionTracker();
986 field.TextChangedSignal().Connect(&TestTextChangedCallback);
987 bool textChangedSignal = false;
988 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
990 gTextChangedCallBackCalled = false;
991 field.SetProperty( TextField::Property::TEXT, "ABC" );
992 DALI_TEST_CHECK( gTextChangedCallBackCalled );
993 DALI_TEST_CHECK( textChangedSignal );
995 application.SendNotification();
997 field.SetKeyInputFocus();
999 gTextChangedCallBackCalled = false;
1000 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1001 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1006 // Negative test for the textChanged signal.
1007 int utcDaliTextFieldTextChangedN(void)
1009 ToolkitTestApplication application;
1010 tet_infoline(" utcDaliTextFieldTextChangedN");
1011 TextField field = TextField::New();
1012 DALI_TEST_CHECK( field );
1014 Stage::GetCurrent().Add( field );
1016 // connect to the text changed signal.
1017 ConnectionTracker* testTracker = new ConnectionTracker();
1018 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1019 bool textChangedSignal = false;
1020 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1022 gTextChangedCallBackCalled = false;
1023 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1024 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1025 DALI_TEST_CHECK( !textChangedSignal );
1030 // Positive test for Max Characters reached signal.
1031 int utcDaliTextFieldMaxCharactersReachedP(void)
1033 ToolkitTestApplication application;
1034 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1035 TextField field = TextField::New();
1036 DALI_TEST_CHECK( field );
1038 Stage::GetCurrent().Add( field );
1040 const int maxNumberOfCharacters = 1;
1041 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1043 field.SetKeyInputFocus();
1045 // connect to the text changed signal.
1046 ConnectionTracker* testTracker = new ConnectionTracker();
1047 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1048 bool maxLengthReachedSignal = false;
1049 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1051 gMaxCharactersCallBackCalled = false;
1053 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1054 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1056 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1057 DALI_TEST_CHECK( maxLengthReachedSignal );
1062 // Negative test for Max Characters reached signal.
1063 int utcDaliTextFieldMaxCharactersReachedN(void)
1065 ToolkitTestApplication application;
1066 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1067 TextField field = TextField::New();
1068 DALI_TEST_CHECK( field );
1070 Stage::GetCurrent().Add( field );
1072 const int maxNumberOfCharacters = 3;
1073 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1075 field.SetKeyInputFocus();
1077 // connect to the text changed signal.
1078 ConnectionTracker* testTracker = new ConnectionTracker();
1079 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1080 bool maxLengthReachedSignal = false;
1081 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1083 gMaxCharactersCallBackCalled = false;
1085 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1086 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1088 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1089 DALI_TEST_CHECK( !maxLengthReachedSignal );
1091 application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::Down, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1093 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1094 DALI_TEST_CHECK( !maxLengthReachedSignal );
1099 int utcDaliTextFieldInputStyleChanged01(void)
1101 // The text-field emits signals when the input style changes. These changes of style are
1102 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1103 // can't be emitted during the size negotiation as the callbacks may update the UI.
1104 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1105 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1106 ToolkitTestApplication application;
1107 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1111 char* pathNamePtr = get_current_dir_name();
1112 const std::string pathName( pathNamePtr );
1113 free( pathNamePtr );
1115 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1116 fontClient.SetDpi( 93u, 93u );
1118 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1119 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1121 TextField field = TextField::New();
1122 DALI_TEST_CHECK( field );
1125 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1126 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1127 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1129 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1130 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1132 // connect to the text changed signal.
1133 ConnectionTracker* testTracker = new ConnectionTracker();
1134 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1135 bool inputStyleChangedSignal = false;
1136 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1138 Stage::GetCurrent().Add( field );
1140 // Render and notify
1141 application.SendNotification();
1142 application.Render();
1144 // Executes the idle callbacks added by the text control on the change of input style.
1145 application.RunIdles();
1147 gInputStyleChangedCallbackCalled = false;
1148 gInputStyleMask = TextField::InputStyle::NONE;
1149 inputStyleChangedSignal = false;
1151 // Create a tap event to touch the text field.
1152 TestGenerateTap( application, 18.0f, 25.0f );
1154 // Render and notify
1155 application.SendNotification();
1156 application.Render();
1158 // Executes the idle callbacks added by the text control on the change of input style.
1159 application.RunIdles();
1161 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1162 if( gInputStyleChangedCallbackCalled )
1164 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1166 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1167 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1169 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1170 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1172 DALI_TEST_CHECK( inputStyleChangedSignal );
1174 gInputStyleChangedCallbackCalled = false;
1175 gInputStyleMask = TextField::InputStyle::NONE;
1176 inputStyleChangedSignal = false;
1178 // Create a tap event to touch the text field.
1179 TestGenerateTap( application, 30.0f, 25.0f );
1181 // Render and notify
1182 application.SendNotification();
1183 application.Render();
1185 // Executes the idle callbacks added by the text control on the change of input style.
1186 application.RunIdles();
1188 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1189 DALI_TEST_CHECK( !inputStyleChangedSignal );
1191 gInputStyleChangedCallbackCalled = false;
1192 gInputStyleMask = TextField::InputStyle::NONE;
1193 inputStyleChangedSignal = false;
1195 // Create a tap event to touch the text field.
1196 TestGenerateTap( application, 43.0f, 25.0f );
1198 // Render and notify
1199 application.SendNotification();
1200 application.Render();
1202 // Executes the idle callbacks added by the text control on the change of input style.
1203 application.RunIdles();
1205 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1206 if( gInputStyleChangedCallbackCalled )
1208 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1210 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1211 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1213 DALI_TEST_CHECK( inputStyleChangedSignal );
1215 gInputStyleChangedCallbackCalled = false;
1216 gInputStyleMask = TextField::InputStyle::NONE;
1217 inputStyleChangedSignal = false;
1219 // Create a tap event to touch the text field.
1220 TestGenerateTap( application, 88.0f, 25.0f );
1222 // Render and notify
1223 application.SendNotification();
1224 application.Render();
1226 // Executes the idle callbacks added by the text control on the change of input style.
1227 application.RunIdles();
1229 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1230 if( gInputStyleChangedCallbackCalled )
1232 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1234 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1235 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1237 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1239 Property::Map fontStyleMapSet;
1240 fontStyleMapSet.Insert( "weight", "bold" );
1242 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1243 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1245 DALI_TEST_CHECK( inputStyleChangedSignal );
1247 gInputStyleChangedCallbackCalled = false;
1248 gInputStyleMask = TextField::InputStyle::NONE;
1249 inputStyleChangedSignal = false;
1251 // Create a tap event to touch the text field.
1252 TestGenerateTap( application, 115.0f, 25.0f );
1254 // Render and notify
1255 application.SendNotification();
1256 application.Render();
1258 // Executes the idle callbacks added by the text control on the change of input style.
1259 application.RunIdles();
1261 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1262 DALI_TEST_CHECK( !inputStyleChangedSignal );
1264 gInputStyleChangedCallbackCalled = false;
1265 gInputStyleMask = TextField::InputStyle::NONE;
1266 inputStyleChangedSignal = false;
1268 // Create a tap event to touch the text field.
1269 TestGenerateTap( application, 164.0f, 25.0f );
1271 // Render and notify
1272 application.SendNotification();
1273 application.Render();
1275 // Executes the idle callbacks added by the text control on the change of input style.
1276 application.RunIdles();
1278 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1279 if( gInputStyleChangedCallbackCalled )
1281 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1283 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1284 DALI_TEST_CHECK( style.empty() );
1286 DALI_TEST_CHECK( inputStyleChangedSignal );
1288 gInputStyleChangedCallbackCalled = false;
1289 gInputStyleMask = TextField::InputStyle::NONE;
1290 inputStyleChangedSignal = false;
1292 // Create a tap event to touch the text field.
1293 TestGenerateTap( application, 191.0f, 25.0f );
1295 // Render and notify
1296 application.SendNotification();
1297 application.Render();
1299 // Executes the idle callbacks added by the text control on the change of input style.
1300 application.RunIdles();
1302 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1303 DALI_TEST_CHECK( !inputStyleChangedSignal );
1308 int utcDaliTextFieldInputStyleChanged02(void)
1310 // The text-field emits signals when the input style changes. These changes of style are
1311 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1312 // can't be emitted during the size negotiation as the callbacks may update the UI.
1313 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1314 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1315 ToolkitTestApplication application;
1316 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1320 char* pathNamePtr = get_current_dir_name();
1321 const std::string pathName( pathNamePtr );
1322 free( pathNamePtr );
1324 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1325 fontClient.SetDpi( 93u, 93u );
1327 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1328 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1330 TextField field = TextField::New();
1331 DALI_TEST_CHECK( field );
1333 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1334 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1335 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1337 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1338 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>" );
1340 // connect to the text changed signal.
1341 ConnectionTracker* testTracker = new ConnectionTracker();
1342 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1343 bool inputStyleChangedSignal = false;
1344 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1346 Stage::GetCurrent().Add( field );
1348 // Render and notify
1349 application.SendNotification();
1350 application.Render();
1352 // Executes the idle callbacks added by the text control on the change of input style.
1353 application.RunIdles();
1355 gInputStyleChangedCallbackCalled = false;
1356 gInputStyleMask = TextField::InputStyle::NONE;
1357 inputStyleChangedSignal = false;
1359 // Create a tap event to touch the text field.
1360 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1361 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1363 // Render and notify
1364 application.SendNotification();
1365 application.Render();
1367 // Executes the idle callbacks added by the text control on the change of input style.
1368 application.RunIdles();
1370 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1371 if( gInputStyleChangedCallbackCalled )
1373 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1374 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1375 TextField::InputStyle::POINT_SIZE |
1376 TextField::InputStyle::COLOR ),
1379 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1380 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1382 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1383 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1385 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1386 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1388 DALI_TEST_CHECK( inputStyleChangedSignal );
1390 gInputStyleChangedCallbackCalled = false;
1391 gInputStyleMask = TextField::InputStyle::NONE;
1392 inputStyleChangedSignal = false;
1394 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1396 // Render and notify
1397 application.SendNotification();
1398 application.Render();
1400 // Executes the idle callbacks added by the text control on the change of input style.
1401 application.RunIdles();
1403 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1404 if( gInputStyleChangedCallbackCalled )
1406 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1407 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1410 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1411 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1413 DALI_TEST_CHECK( inputStyleChangedSignal );
1415 gInputStyleChangedCallbackCalled = false;
1416 gInputStyleMask = TextField::InputStyle::NONE;
1417 inputStyleChangedSignal = false;
1419 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1421 // Render and notify
1422 application.SendNotification();
1423 application.Render();
1425 // Executes the idle callbacks added by the text control on the change of input style.
1426 application.RunIdles();
1428 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1429 DALI_TEST_CHECK( !inputStyleChangedSignal );
1431 gInputStyleChangedCallbackCalled = false;
1432 gInputStyleMask = TextField::InputStyle::NONE;
1433 inputStyleChangedSignal = false;
1435 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1437 // Render and notify
1438 application.SendNotification();
1439 application.Render();
1441 // Executes the idle callbacks added by the text control on the change of input style.
1442 application.RunIdles();
1444 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1445 if( gInputStyleChangedCallbackCalled )
1447 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1448 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1451 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1452 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1454 DALI_TEST_CHECK( inputStyleChangedSignal );
1456 gInputStyleChangedCallbackCalled = false;
1457 gInputStyleMask = TextField::InputStyle::NONE;
1458 inputStyleChangedSignal = false;
1460 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1462 Property::Map fontStyleMapSet;
1463 fontStyleMapSet.Insert( "weight", "thin" );
1464 fontStyleMapSet.Insert( "width", "condensed" );
1465 fontStyleMapSet.Insert( "slant", "italic" );
1467 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1468 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1470 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1471 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1472 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1473 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1475 // Render and notify
1476 application.SendNotification();
1477 application.Render();
1479 // Executes the idle callbacks added by the text control on the change of input style.
1480 application.RunIdles();
1482 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1483 DALI_TEST_CHECK( !inputStyleChangedSignal );
1485 // Create a tap event to touch the text field.
1486 TestGenerateTap( application, 63.0f, 25.0f, 300 );
1488 // Render and notify
1489 application.SendNotification();
1490 application.Render();
1492 // Executes the idle callbacks added by the text control on the change of input style.
1493 application.RunIdles();
1495 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1496 if( gInputStyleChangedCallbackCalled )
1498 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1499 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1500 TextField::InputStyle::POINT_SIZE |
1501 TextField::InputStyle::FONT_STYLE |
1502 TextField::InputStyle::UNDERLINE |
1503 TextField::InputStyle::SHADOW |
1504 TextField::InputStyle::EMBOSS |
1505 TextField::InputStyle::OUTLINE ),
1508 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1509 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1511 DALI_TEST_CHECK( inputStyleChangedSignal );
1516 int utcDaliTextFieldEvent01(void)
1518 ToolkitTestApplication application;
1519 tet_infoline(" utcDaliTextFieldEvent01");
1521 // Creates a tap event. After creating a tap event the text field should
1522 // have the focus and add text with key events should be possible.
1524 TextField field = TextField::New();
1525 DALI_TEST_CHECK( field );
1527 Stage::GetCurrent().Add( field );
1529 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1530 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1531 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1533 // Render and notify
1534 application.SendNotification();
1535 application.Render();
1537 // Avoid a crash when core load gl resources.
1538 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1540 // Render and notify
1541 application.SendNotification();
1542 application.Render();
1544 // Add a key event but as the text field has not the focus it should do nothing.
1545 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1547 // Render and notify
1548 application.SendNotification();
1549 application.Render();
1551 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1553 // Create a tap event to touch the text field.
1554 TestGenerateTap( application, 150.0f, 25.0f );
1556 // Render and notify
1557 application.SendNotification();
1558 application.Render();
1560 // Pressing delete key should be fine even if there is no text in TextField.
1561 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 ) );
1562 // Render and notify
1563 application.SendNotification();
1564 application.Render();
1566 // Now the text field has the focus, so it can handle the key events.
1567 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1568 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1570 // Render and notify
1571 application.SendNotification();
1572 application.Render();
1574 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1576 // Create a second text field and send key events to it.
1577 TextField field2 = TextField::New();
1579 field2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1580 field2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1581 field2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1582 field2.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
1584 Stage::GetCurrent().Add( field2 );
1586 // Render and notify
1587 application.SendNotification();
1588 application.Render();
1590 // Create a tap event on the second text field.
1591 TestGenerateTap( application, 150.0f, 125.0f );
1593 // Render and notify
1594 application.SendNotification();
1595 application.Render();
1597 // The second text field has the focus. It should handle the key events.
1598 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1599 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1601 // Render and notify
1602 application.SendNotification();
1603 application.Render();
1605 // Check the text has been added to the second text field.
1606 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1611 int utcDaliTextFieldEvent02(void)
1613 ToolkitTestApplication application;
1614 tet_infoline(" utcDaliTextFieldEvent02");
1616 // Checks if the right number of actors are created.
1618 TextField field = TextField::New();
1619 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1620 DALI_TEST_CHECK( field );
1621 LoadMarkerImages(application, field);
1623 Stage::GetCurrent().Add( field );
1625 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1626 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1627 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1629 // Avoid a crash when core load gl resources.
1630 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1632 // Render and notify
1633 application.SendNotification();
1634 application.Render();
1636 // Check there are the expected number of children ( stencil ).
1637 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1639 Actor stencil = field.GetChildAt( 0u );
1640 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1642 // Create a tap event to touch the text field.
1643 TestGenerateTap( application, 150.0f, 25.0f, 300 );
1645 // Render and notify
1646 application.SendNotification();
1647 application.Render();
1649 Actor layer = field.GetChildAt( 1u );
1650 DALI_TEST_CHECK( layer.GetProperty< bool >( Actor::Property::IS_LAYER ) );
1652 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1653 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1655 // Now the text field has the focus, so it can handle the key events.
1656 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1657 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1659 // Render and notify
1660 application.SendNotification();
1661 application.Render();
1663 // Checks the cursor and the renderer have been created.
1664 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1665 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1667 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1668 DALI_TEST_CHECK( cursor );
1670 // The offscreen root actor has a container with all the actors which contain the text renderers.
1671 Actor container = stencil.GetChildAt( 0u );
1672 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1674 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1675 DALI_TEST_CHECK( renderer );
1678 // Move the cursor and check the position changes.
1679 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1680 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1682 // Render and notify
1683 application.SendNotification();
1684 application.Render();
1686 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1687 DALI_TEST_CHECK( position2.x < position1.x );
1689 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1691 // Render and notify
1692 application.SendNotification();
1693 application.Render();
1695 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1696 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1699 // Move the cursor to the first position.
1700 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1701 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1703 // Render and notify
1704 application.SendNotification();
1705 application.Render();
1707 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1709 // Send some taps and check the cursor positions.
1711 // Try to tap at the beginning.
1712 TestGenerateTap( application, 1.0f, 25.0f, 900 );
1714 // Render and notify
1715 application.SendNotification();
1716 application.Render();
1718 // Cursor position should be the same than position1.
1719 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1721 DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
1723 // Tap away from the start position.
1724 TestGenerateTap( application, 16.0f, 25.0f, 1500 );
1726 // Render and notify
1727 application.SendNotification();
1728 application.Render();
1730 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1732 DALI_TEST_CHECK( position6.x > position5.x );
1734 // Remove all the text.
1735 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1736 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1737 field.SetProperty( TextField::Property::TEXT, "" );
1739 // Render and notify
1740 application.SendNotification();
1741 application.Render();
1743 // Cursor position should be the same than position2.
1744 Vector3 position7 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1746 DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
1748 // Should not be a renderer.
1749 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1751 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1752 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1753 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1755 application.SendNotification();
1756 application.Render();
1758 // There are renderer and decorator layer
1759 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1764 int utcDaliTextFieldEvent03(void)
1766 ToolkitTestApplication application;
1767 tet_infoline(" utcDaliTextFieldEvent03");
1769 // Checks if the highlight actor is created.
1771 TextField field = TextField::New();
1772 DALI_TEST_CHECK( field );
1774 Stage::GetCurrent().Add( field );
1776 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1777 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1778 field.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1779 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1780 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1782 // Avoid a crash when core load gl resources.
1783 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1784 LoadMarkerImages(application, field);
1786 // Render and notify
1787 application.SendNotification();
1788 application.Render();
1790 // Tap first to get the focus.
1791 TestGenerateTap( application, 3.0f, 25.0f );
1793 // Render and notify
1794 application.SendNotification();
1795 application.Render();
1797 // Double tap to select a word.
1798 TestGenerateTap( application, 3.0f, 25.0f );
1800 // Render and notify
1801 application.SendNotification();
1802 application.Render();
1804 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1805 Actor stencil = field.GetChildAt( 0u );
1807 // The highlight actor is drawn first, so is the first actor in the list
1808 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1809 DALI_TEST_CHECK( highlight );
1811 // The offscreen root actor has a container with all the actors which contain the text renderers.
1812 Actor container = stencil.GetChildAt( 1u );
1813 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1815 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1816 DALI_TEST_CHECK( renderer );
1822 int utcDaliTextFieldEvent04(void)
1824 ToolkitTestApplication application;
1825 tet_infoline(" utcDaliTextFieldEvent04");
1827 // Checks if the highlight actor is created.
1829 TextField field = TextField::New();
1830 DALI_TEST_CHECK( field );
1831 Stage::GetCurrent().Add( field );
1832 LoadMarkerImages(application, field);
1833 // Render and notify
1834 application.SendNotification();
1835 application.Render();
1837 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1838 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1839 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1840 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1841 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1843 // Avoid a crash when core load gl resources.
1844 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1845 // Render and notify
1846 application.SendNotification();
1847 application.Render();
1849 // Create a tap event to touch the text field.
1850 TestGenerateTap( application, 150.0f, 25.0f );
1851 // Render and notify
1852 application.SendNotification();
1853 application.Render();
1856 // Tap first to get the focus.
1857 TestGenerateTap( application, 1.0f, 25.0f );
1859 // Render and notify
1860 application.SendNotification();
1861 application.Render();
1863 // Double tap to select a word.
1864 TestGenerateTap( application, 1.0f, 25.0f );
1866 // Render and notify
1867 application.SendNotification();
1868 application.Render();
1871 TestGenerateTap( application, 0.0f, 40.0f );
1875 int utcDaliTextFieldEvent05(void)
1877 ToolkitTestApplication application;
1878 tet_infoline(" utcDaliTextFieldEvent05");
1880 // Checks dragging of cursor/grab handle
1882 TextField field = TextField::New();
1883 DALI_TEST_CHECK( field );
1884 Stage::GetCurrent().Add( field );
1885 LoadMarkerImages(application, field);
1886 // Render and notify
1887 application.SendNotification();
1888 application.Render();
1890 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1891 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1892 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1893 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1894 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1896 // Avoid a crash when core load gl resources.
1897 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1898 // Render and notify
1899 application.SendNotification();
1900 application.Render();
1902 // Create a tap event to touch the text field.
1903 TestGenerateTap( application, 150.0f, 25.0f );
1904 // Render and notify
1905 application.SendNotification();
1906 application.Render();
1908 // Tap first to get the focus.
1909 TestGenerateTap( application, 1.0f, 25.0f );
1911 // Render and notify
1912 application.SendNotification();
1913 application.Render();
1915 // Double tap to select a word.
1916 TestGenerateTap( application, 1.0f, 25.0f );
1918 // Render and notify
1919 application.SendNotification();
1920 application.Render();
1922 Actor stencil = field.GetChildAt( 1u );
1926 int utcDaliTextFieldEvent06(void)
1928 ToolkitTestApplication application;
1929 tet_infoline(" utcDaliTextFieldEvent06");
1931 // Checks Longpress when in edit mode
1933 TextField field = TextField::New();
1934 DALI_TEST_CHECK( field );
1935 Stage::GetCurrent().Add( field );
1936 LoadMarkerImages(application, field);
1937 // Render and notify
1938 application.SendNotification();
1939 application.Render();
1941 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1942 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1943 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1944 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1945 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1947 // Avoid a crash when core load gl resources.
1948 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1949 // Render and notify
1950 application.SendNotification();
1951 application.Render();
1953 // Create a tap event to touch the text field.
1954 TestGenerateTap( application, 150.0f, 25.0f );
1955 // Render and notify
1956 application.SendNotification();
1957 application.Render();
1960 // Tap first to get the focus.
1961 TestGenerateTap( application, 1.0f, 25.0f );
1963 // Render and notify
1964 application.SendNotification();
1965 application.Render();
1968 TestGenerateLongPress(application, 1.0f, 25.0f);
1970 // Render and notify
1971 application.SendNotification();
1972 application.Render();
1977 int utcDaliTextFieldEvent07(void)
1979 ToolkitTestApplication application;
1980 tet_infoline(" utcDaliTextFieldEvent07");
1982 // Checks Longpress to start edit mode
1984 TextField field = TextField::New();
1985 DALI_TEST_CHECK( field );
1986 Stage::GetCurrent().Add( field );
1987 LoadMarkerImages(application, field);
1988 // Render and notify
1989 application.SendNotification();
1990 application.Render();
1992 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1993 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1994 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1995 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1996 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1997 Property::Map propertyMap;
1998 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
1999 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2001 // Avoid a crash when core load gl resources.
2002 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2003 // Render and notify
2004 application.SendNotification();
2005 application.Render();
2008 TestGenerateLongPress(application, 1.0f, 25.0f);
2010 // Render and notify
2011 application.SendNotification();
2012 application.Render();
2017 int utcDaliTextFieldEvent08(void)
2019 ToolkitTestApplication application;
2020 tet_infoline(" utcDaliTextFieldEvent08");
2022 Dali::Clipboard clipboard = Clipboard::Get();
2023 clipboard.SetItem("testTextFieldEvent");
2025 // Checks Longpress when only place holder text
2027 TextField field = TextField::New();
2028 DALI_TEST_CHECK( field );
2029 Stage::GetCurrent().Add( field );
2030 LoadMarkerImages(application, field);
2031 // Render and notify
2032 application.SendNotification();
2033 application.Render();
2035 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2036 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2037 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2038 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2039 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2041 // Avoid a crash when core load gl resources.
2042 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2043 // Render and notify
2044 application.SendNotification();
2045 application.Render();
2048 TestGenerateLongPress( application, 1.0f, 25.0f, 20 );
2050 // Render and notify
2051 application.SendNotification();
2052 application.Render();
2054 Wait(application, 500);
2056 TestEndLongPress( application, 1.0f, 25.0f, 520 );
2059 TestGenerateLongPress( application, 1.0f, 25.0f, 600 );
2061 // Render and notify
2062 application.Render();
2064 Wait(application, 500);
2066 Stage stage = Stage::GetCurrent();
2067 Layer layer = stage.GetRootLayer();
2068 Actor actor = layer.FindChildByName("optionPaste");
2072 Vector3 worldPosition = actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION );
2073 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2074 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2076 Dali::Integration::TouchEvent event;
2077 event = Dali::Integration::TouchEvent();
2078 event.AddPoint( GetPointDownInside( position ) );
2079 application.ProcessEvent( event );
2081 event = Dali::Integration::TouchEvent();
2082 event.AddPoint( GetPointUpInside( position ) );
2083 application.ProcessEvent( event );
2085 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2090 int utcDaliTextFieldEvent09(void)
2092 ToolkitTestApplication application;
2093 tet_infoline(" utcDaliTextFieldEvent09");
2095 TextField field = TextField::New();
2096 DALI_TEST_CHECK( field );
2097 Stage::GetCurrent().Add( field );
2098 LoadMarkerImages(application, field);
2099 // Render and notify
2100 application.SendNotification();
2101 application.Render();
2103 field.SetProperty( TextField::Property::TEXT, "Hello" );
2104 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2105 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2106 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2107 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2109 // Avoid a crash when core load gl resources.
2110 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2112 // Create a tap event to touch the text field.
2113 TestGenerateTap( application, 150.0f, 25.0f );
2114 application.SendNotification();
2115 application.Render();
2118 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2119 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2120 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2121 application.SendNotification();
2122 application.Render();
2124 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2125 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2126 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2127 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2128 application.SendNotification();
2129 application.Render();
2131 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2132 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2133 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2134 for( unsigned int index = 0u; index < 5u; ++index )
2136 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2137 application.SendNotification();
2138 application.Render();
2141 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2142 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2143 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2144 for( unsigned int index = 0u; index < 5u; ++index )
2146 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2147 application.SendNotification();
2148 application.Render();
2151 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2152 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2153 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2154 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2155 application.SendNotification();
2156 application.Render();
2157 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2158 application.SendNotification();
2159 application.Render();
2161 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2162 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2163 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2164 application.SendNotification();
2165 application.Render();
2167 Property::Map mapGet;
2168 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2169 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2170 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2175 int utcDaliTextFieldStyleWhilstSelected(void)
2177 ToolkitTestApplication application;
2178 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2180 // Change font and styles whilst text is selected whilst word selected
2182 TextField field = TextField::New();
2183 DALI_TEST_CHECK( field );
2184 Stage::GetCurrent().Add( field );
2185 LoadMarkerImages(application, field);
2186 // Render and notify
2187 application.SendNotification();
2188 application.Render();
2190 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2191 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2192 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2193 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2194 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2196 // Avoid a crash when core load gl resources.
2197 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2198 // Render and notify
2199 application.SendNotification();
2200 application.Render();
2202 // Create a tap event to touch the text field.
2203 TestGenerateTap( application, 150.0f, 25.0f );
2204 // Render and notify
2205 application.SendNotification();
2206 application.Render();
2209 // Tap first to get the focus.
2210 TestGenerateTap( application, 1.0f, 25.0f );
2212 // Render and notify
2213 application.SendNotification();
2214 application.Render();
2216 // Double tap to select a word.
2217 TestGenerateTap( application, 1.0f, 25.0f );
2219 // Render and notify
2220 application.SendNotification();
2221 application.Render();
2223 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2224 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2226 Property::Map fontStyleMapSet;
2227 Property::Map fontStyleMapGet;
2229 fontStyleMapSet.Insert( "weight", "bold" );
2230 fontStyleMapSet.Insert( "slant", "italic" );
2231 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2233 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2234 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2235 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2237 fontStyleMapSet.Clear();
2238 fontStyleMapSet.Insert( "width", "expanded" );
2239 fontStyleMapSet.Insert( "slant", "italic" );
2240 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2242 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2243 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2244 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2246 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2247 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2249 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2250 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2252 fontStyleMapSet.Clear();
2253 fontStyleMapSet.Insert( "weight", "bold" );
2254 fontStyleMapSet.Insert( "slant", "italic" );
2256 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2258 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2259 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2260 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2262 fontStyleMapSet.Clear();
2263 fontStyleMapSet.Insert( "width", "expanded" );
2265 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2267 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2268 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2269 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2271 // Press Escape to increase coverage
2272 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2273 application.SendNotification();
2274 application.Render();
2276 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2281 int utcDaliTextFieldEscKeyLoseFocus(void)
2283 ToolkitTestApplication application;
2284 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2286 // Creates a tap event. After creating a tap event the text field should
2287 // have the focus and add text with key events should be possible.
2289 TextField field = TextField::New();
2290 DALI_TEST_CHECK( field );
2292 Stage::GetCurrent().Add( field );
2294 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2295 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2296 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2298 // Avoid a crash when core load gl resources.
2299 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2301 // Render and notify
2302 application.SendNotification();
2303 application.Render();
2305 // Add a key event but as the text field has not the focus it should do nothing.
2306 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2307 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2309 // Render and notify
2310 application.SendNotification();
2311 application.Render();
2313 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2315 // Create a tap event to touch the text field.
2316 TestGenerateTap( application, 150.0f, 25.0f );
2318 // Render and notify
2319 application.SendNotification();
2320 application.Render();
2322 // Now the text field has the focus, so it can handle the key events.
2323 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2324 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2325 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2326 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2328 // Render and notify
2329 application.SendNotification();
2330 application.Render();
2332 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2334 // Generate a Esc key event. The text field should lose the focus.
2335 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2336 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2338 // Render and notify
2339 application.SendNotification();
2340 application.Render();
2342 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2344 // No more text should be introduced
2345 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2346 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2348 // Render and notify
2349 application.SendNotification();
2350 application.Render();
2352 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2357 int utcDaliTextFieldSomeSpecialKeys(void)
2359 ToolkitTestApplication application;
2360 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2362 // Checks some special keys when the text is selected.
2364 TextField field = TextField::New();
2365 DALI_TEST_CHECK( field );
2366 Stage::GetCurrent().Add( field );
2367 LoadMarkerImages(application, field);
2368 // Render and notify
2369 application.SendNotification();
2370 application.Render();
2372 const std::string longText( "This is a long text for the size of the text-field." );
2374 field.SetProperty( TextField::Property::TEXT, longText );
2375 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2376 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2377 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2378 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2380 // Avoid a crash when core load gl resources.
2381 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2382 // Render and notify
2383 application.SendNotification();
2384 application.Render();
2386 // Create a tap event to touch the text field.
2387 TestGenerateTap( application, 150.0f, 25.0f );
2389 // Render and notify
2390 application.SendNotification();
2391 application.Render();
2393 // Tap first to get the focus.
2394 TestGenerateTap( application, 1.0f, 25.0f );
2396 // Render and notify
2397 application.SendNotification();
2398 application.Render();
2400 // Double tap to select a word.
2401 TestGenerateTap( application, 1.0f, 25.0f );
2403 // Render and notify
2404 application.SendNotification();
2405 application.Render();
2407 // Generate a Esc key event. The text field should lose the focus.
2408 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2409 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
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( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2417 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, "XF86Menu", 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( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2425 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2427 // Render and notify
2428 application.SendNotification();
2429 application.Render();
2431 // The text shouldn't be deleted.
2432 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2437 int utcDaliTextFieldSizeUpdate(void)
2439 ToolkitTestApplication application;
2440 tet_infoline("utcDaliTextFieldSizeUpdate");
2442 // Checks some special keys when the text is selected.
2443 TextField field = TextField::New();
2444 DALI_TEST_CHECK( field );
2445 Stage::GetCurrent().Add( field );
2447 float previousHeight = 0.0f;
2448 float currentHeight = 0.0f;
2449 const float fieldWidth = 1920.0f;
2452 // "ㅁ" is bigger then "ኢ"
2453 field.SetProperty( Actor::Property::SIZE, Vector2( fieldWidth ,10.0f ) );
2454 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2455 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2457 field.SetProperty( TextField::Property::TEXT, "ኢ");
2458 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2459 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2461 field.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2462 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2464 application.SendNotification();
2465 application.Render();
2467 previousHeight = field.GetHeightForWidth( fieldWidth );
2468 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2470 // Add another script characters ( glyph height is defferent )
2471 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2472 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2474 application.SendNotification();
2475 application.Render();
2477 currentHeight = field.GetHeightForWidth( fieldWidth );
2478 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2479 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2484 int utcDaliTextFieldExtremlyLargePointSize(void)
2486 ToolkitTestApplication application;
2487 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2489 TextField field = TextField::New();
2491 field.SetProperty( TextField::Property::TEXT, "Text" );
2492 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2493 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2494 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2495 Stage::GetCurrent().Add( field );
2499 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2500 application.SendNotification();
2501 DALI_TEST_CHECK( field );
2505 tet_result(TET_FAIL);
2510 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2512 ToolkitTestApplication application;
2513 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2514 TextField field = TextField::New();
2515 DALI_TEST_CHECK( field );
2516 Stage::GetCurrent().Add( field );
2518 Property::Map fontStyleMapGet;
2520 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2522 Property::Value* weightValue = NULL;
2523 Property::Value* widthValue = NULL;
2524 Property::Value* slantValue = NULL;
2525 weightValue = fontStyleMapGet.Find( "weight" );
2526 widthValue = fontStyleMapGet.Find( "width" );
2527 slantValue = fontStyleMapGet.Find( "slant" );
2528 DALI_TEST_CHECK( !weightValue );
2529 DALI_TEST_CHECK( !widthValue );
2530 DALI_TEST_CHECK( !slantValue );
2535 int UtcDaliTextFieldSettingPlaceholder(void)
2537 ToolkitTestApplication application;
2538 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
2540 TextField field = TextField::New();
2541 DALI_TEST_CHECK( field );
2542 Stage::GetCurrent().Add( field );
2544 // Check the placeholder property with pixel size
2545 Property::Map placeholderPixelSizeMapSet;
2546 Property::Map placeholderPixelSizeMapGet;
2547 Property::Map placeholderFontstyleMap;
2548 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2549 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2550 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
2551 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2552 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
2553 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
2555 placeholderFontstyleMap.Insert( "weight", "bold" );
2556 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2557 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
2559 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2560 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
2561 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
2563 // Check the placeholder property with point size
2564 Property::Map placeholderMapSet;
2565 Property::Map placeholderMapGet;
2566 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2567 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2568 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
2569 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2570 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
2571 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
2573 // Check the placeholder font style property
2574 placeholderFontstyleMap.Clear();
2576 placeholderFontstyleMap.Insert( "weight", "bold" );
2577 placeholderFontstyleMap.Insert( "width", "condensed" );
2578 placeholderFontstyleMap.Insert( "slant", "italic" );
2579 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2580 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2582 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2583 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2584 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2586 // Reset font style.
2587 placeholderFontstyleMap.Clear();
2588 placeholderFontstyleMap.Insert( "weight", "normal" );
2589 placeholderFontstyleMap.Insert( "slant", "oblique" );
2590 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2591 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2593 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2594 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2595 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2597 placeholderFontstyleMap.Clear();
2598 placeholderFontstyleMap.Insert( "slant", "roman" );
2599 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2600 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2602 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2604 placeholderFontstyleMap.Clear();
2605 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2607 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2608 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2609 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2610 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2615 int UtcDaliTextFieldSetPaddingProperty(void)
2617 ToolkitTestApplication application;
2618 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
2620 TextField field = TextField::New();
2621 DALI_TEST_CHECK( field );
2622 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2623 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2624 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2625 Stage::GetCurrent().Add( field );
2627 application.SendNotification();
2628 application.Render();
2630 Vector3 originalSize = field.GetNaturalSize();
2632 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2634 application.SendNotification();
2635 application.Render();
2637 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2639 Vector3 paddingAddedSize = field.GetNaturalSize();
2641 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2643 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2648 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
2650 ToolkitTestApplication application;
2651 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
2653 TextField field = TextField::New();
2654 DALI_TEST_CHECK( field );
2655 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2656 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2657 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2658 Stage::GetCurrent().Add( field );
2660 application.SendNotification();
2661 application.Render();
2663 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2664 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2666 // Check the enable shift selection property
2667 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
2668 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2670 application.SendNotification();
2671 application.Render();
2676 int UtcDaliTextFieldEnableGrabHandleProperty(void)
2678 ToolkitTestApplication application;
2679 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
2681 TextField field = TextField::New();
2682 DALI_TEST_CHECK( field );
2683 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2684 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2685 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2686 Stage::GetCurrent().Add( field );
2688 application.SendNotification();
2689 application.Render();
2691 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2692 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2694 // Check the enable grab handle property
2695 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
2696 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2698 application.SendNotification();
2699 application.Render();
2704 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
2706 ToolkitTestApplication application;
2707 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
2709 TextField field = TextField::New();
2710 DALI_TEST_CHECK( field );
2711 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2712 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2713 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2714 Stage::GetCurrent().Add( field );
2716 application.SendNotification();
2717 application.Render();
2719 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2720 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2722 // Check the match system language direction property
2723 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2724 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2726 application.SendNotification();
2727 application.Render();
2732 int utcDaliTextFieldLayoutDirectionCoverage(void)
2734 ToolkitTestApplication application;
2735 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
2737 // Creates a tap event. After creating a tap event the text field should
2738 // have the focus and add text with key events should be possible.
2739 TextField field = TextField::New();
2740 DALI_TEST_CHECK( field );
2742 Stage::GetCurrent().Add( field );
2744 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2745 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2746 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2748 // Avoid a crash when core load gl resources.
2749 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2751 // Render and notify
2752 application.SendNotification();
2753 application.Render();
2755 // init direction for coverage
2756 // Set horizontal alignment END
2757 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2759 // Create a tap event to touch the text field.
2760 TestGenerateTap( application, 150.0f, 25.0f );
2762 // Render and notify
2763 application.SendNotification();
2764 application.Render();
2766 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
2767 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2768 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
2770 // Set horizontal alignment BEGIN
2771 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
2773 // Create a tap event to touch the text field.
2774 TestGenerateTap( application, 150.0f, 25.0f );
2776 // Render and notify
2777 application.SendNotification();
2778 application.Render();
2780 // Set horizontal alignment CENTER
2781 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
2783 // Create a tap event to touch the text field.
2784 TestGenerateTap( application, 150.0f, 25.0f );
2786 // Render and notify
2787 application.SendNotification();
2788 application.Render();
2790 // Set horizontal alignment END
2791 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2793 // Create a tap event to touch the text field.
2794 TestGenerateTap( application, 150.0f, 25.0f );
2796 // Render and notify
2797 application.SendNotification();
2798 application.Render();
2800 // Generate a Esc key event. The text field should lose the focus.
2801 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2802 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2804 // Render and notify
2805 application.SendNotification();
2806 application.Render();
2808 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2813 int UtcDaliTextFieldGetInputMethodContext(void)
2815 ToolkitTestApplication application;
2816 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
2818 TextField field = TextField::New();
2819 DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );
2824 int UtcDaliTextFieldSelectWholeText(void)
2826 ToolkitTestApplication application;
2827 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
2829 TextField textField = TextField::New();
2831 Stage::GetCurrent().Add( textField );
2833 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2834 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2835 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2837 // Avoid a crash when core load gl resources.
2838 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2840 application.SendNotification();
2841 application.Render();
2843 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2845 DevelTextField::SelectWholeText( textField );
2847 application.SendNotification();
2848 application.Render();
2850 // Nothing should have been selected. The number of children is still 1
2851 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2853 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
2855 application.SendNotification();
2856 application.Render();
2858 DevelTextField::SelectWholeText( textField );
2860 application.SendNotification();
2861 application.Render();
2863 // Should be 2 children, the stencil and the layer
2864 DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
2866 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2867 Actor stencil = textField.GetChildAt( 0u );
2869 // The highlight actor is drawn first, so is the first actor in the list
2870 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2871 DALI_TEST_CHECK( highlight );
2876 int UtcDaliTextFieldSelectNone(void)
2878 ToolkitTestApplication application;
2879 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
2881 TextField textField = TextField::New();
2883 Stage::GetCurrent().Add( textField );
2885 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2886 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2887 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2889 // Avoid a crash when core load gl resources.
2890 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2892 application.SendNotification();
2893 application.Render();
2895 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
2897 application.SendNotification();
2898 application.Render();
2900 // Nothing is selected
2901 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
2902 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
2904 DevelTextField::SelectWholeText( textField );
2906 application.SendNotification();
2907 application.Render();
2909 // whole text is selected
2910 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
2911 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
2913 DevelTextField::SelectNone( textField );
2915 application.SendNotification();
2916 application.Render();
2918 // Nothing is selected
2919 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
2920 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );