2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali/public-api/rendering/renderer.h>
23 #include <dali/integration-api/events/key-event-integ.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/devel-api/adaptor-framework/key-devel.h>
27 #include <dali/devel-api/text-abstraction/font-client.h>
28 #include <dali-toolkit-test-suite-utils.h>
29 #include <dali-toolkit/dali-toolkit.h>
30 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
31 #include <dali-toolkit/devel-api/text/rendering-backend.h>
32 #include "toolkit-clipboard.h"
35 using namespace Toolkit;
37 void dali_textfield_startup(void)
39 test_return_value = TET_UNDEF;
42 void dali_textfield_cleanup(void)
44 test_return_value = TET_PASS;
50 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
51 const char* const PROPERTY_NAME_TEXT = "text";
52 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
53 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
54 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
55 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
56 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
57 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
58 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
59 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
60 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
61 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
62 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
63 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
64 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
65 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
66 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
67 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
68 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
69 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
70 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
71 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
72 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
73 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
80 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
81 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
82 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
83 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
84 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
85 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
86 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
88 const char* const PROPERTY_NAME_UNDERLINE = "underline";
89 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
90 const char* const PROPERTY_NAME_SHADOW = "shadow";
91 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
92 const char* const PROPERTY_NAME_EMBOSS = "emboss";
93 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
94 const char* const PROPERTY_NAME_OUTLINE = "outline";
95 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
97 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
98 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
99 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
100 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
101 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
102 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
103 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
104 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
105 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
106 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
108 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
109 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
111 const float RENDER_FRAME_INTERVAL = 16.66f;
113 const unsigned int DEFAULT_FONT_SIZE = 1152u;
114 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
116 const int KEY_RETURN_CODE = 36;
117 const int KEY_A_CODE = 38;
118 const int KEY_D_CODE = 40;
120 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
122 static bool gTextChangedCallBackCalled;
123 static bool gMaxCharactersCallBackCalled;
124 static bool gInputStyleChangedCallbackCalled;
125 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
127 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
129 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
130 Integration::ResourcePointer resource(bitmap);
131 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
134 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
138 LoadBitmapResource( app.GetPlatform(), width, height );
140 Property::Map propertyMap;
141 propertyMap["filename"] = "image.png";
142 propertyMap["width"] = width;
143 propertyMap["height"] = height;
144 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
145 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
146 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
147 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
148 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
149 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
150 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
151 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
155 * Simulate time passed by.
157 * @note this will always process at least 1 frame (1/60 sec)
159 * @param application Test application instance
160 * @param duration Time to pass in milliseconds.
161 * @return The actual time passed in milliseconds
163 static int Wait(ToolkitTestApplication& application, int duration = 0)
167 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
169 application.SendNotification();
170 application.Render(RENDER_FRAME_INTERVAL);
171 time += RENDER_FRAME_INTERVAL;
177 Dali::Integration::Point GetPointDownInside( Vector2& pos )
179 Dali::Integration::Point point;
180 point.SetState( PointState::DOWN );
181 point.SetScreenPosition( pos );
185 Dali::Integration::Point GetPointUpInside( Vector2& pos )
187 Dali::Integration::Point point;
188 point.SetState( PointState::UP );
189 point.SetScreenPosition( pos );
193 struct CallbackFunctor
195 CallbackFunctor(bool* callbackFlag)
196 : mCallbackFlag( callbackFlag )
202 *mCallbackFlag = true;
207 static void TestTextChangedCallback( TextField control )
209 tet_infoline(" TestTextChangedCallback");
211 gTextChangedCallBackCalled = true;
214 static void TestMaxLengthReachedCallback( TextField control )
216 tet_infoline(" TestMaxLengthReachedCallback");
218 gMaxCharactersCallBackCalled = true;
221 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
223 tet_infoline(" TestInputStyleChangedCallback");
225 gInputStyleChangedCallbackCalled = true;
226 gInputStyleMask = mask;
229 // Generate a KeyEvent to send to Core.
230 Integration::KeyEvent GenerateKey( const std::string& keyName,
231 const std::string& logicalKey,
232 const std::string& keyString,
235 unsigned long timeStamp,
236 const Integration::KeyEvent::State& keyState,
237 const std::string& compose = "",
238 const std::string& deviceName = DEFAULT_DEVICE_NAME,
239 const Device::Class::Type& deviceClass = Device::Class::NONE,
240 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
242 return Integration::KeyEvent( keyName,
255 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
257 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
259 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
261 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
263 Property::Value* valueSet = NULL;
264 if ( valueGet.first.type == Property::Key::INDEX )
266 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
270 // Get Key is a string so searching Set Map for a string key
271 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
274 if( NULL != valueSet )
276 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
278 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
281 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
283 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
286 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
288 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
291 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
293 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
296 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
298 Vector2 vector2Get = valueGet.second.Get<Vector2>();
299 Vector2 vector2Set = valueSet->Get<Vector2>();
300 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
303 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
305 Vector4 vector4Get = valueGet.second.Get<Vector4>();
306 Vector4 vector4Set = valueSet->Get<Vector4>();
307 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 );
313 if ( valueGet.first.type == Property::Key::INDEX )
315 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
319 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
331 int UtcDaliToolkitTextFieldConstructorP(void)
333 ToolkitTestApplication application;
334 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
336 DALI_TEST_CHECK( !textField );
340 int UtcDaliToolkitTextFieldNewP(void)
342 ToolkitTestApplication application;
343 tet_infoline(" UtcDaliToolkitTextFieldNewP");
344 TextField textField = TextField::New();
345 DALI_TEST_CHECK( textField );
349 int UtcDaliToolkitTextFieldDownCastP(void)
351 ToolkitTestApplication application;
352 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
353 TextField textField1 = TextField::New();
354 BaseHandle object( textField1 );
356 TextField textField2 = TextField::DownCast( object );
357 DALI_TEST_CHECK( textField2 );
359 TextField textField3 = DownCast< TextField >( object );
360 DALI_TEST_CHECK( textField3 );
364 int UtcDaliToolkitTextFieldDownCastN(void)
366 ToolkitTestApplication application;
367 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
368 BaseHandle uninitializedObject;
369 TextField textField1 = TextField::DownCast( uninitializedObject );
370 DALI_TEST_CHECK( !textField1 );
372 TextField textField2 = DownCast< TextField >( uninitializedObject );
373 DALI_TEST_CHECK( !textField2 );
377 int UtcDaliToolkitTextFieldCopyConstructorP(void)
379 ToolkitTestApplication application;
380 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
381 TextField textField = TextField::New();
382 textField.SetProperty( TextField::Property::TEXT, "Test" );
384 TextField copy( textField );
385 DALI_TEST_CHECK( copy );
386 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
390 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
392 ToolkitTestApplication application;
393 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
394 TextField textField = TextField::New();
395 textField.SetProperty( TextField::Property::TEXT, "Test" );
397 TextField copy = textField;
398 DALI_TEST_CHECK( copy );
399 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
403 int UtcDaliTextFieldNewP(void)
405 ToolkitTestApplication application;
406 tet_infoline(" UtcDaliToolkitTextFieldNewP");
407 TextField textField = TextField::New();
408 DALI_TEST_CHECK( textField );
412 // Positive test case for a method
413 int UtcDaliTextFieldGetPropertyP(void)
415 ToolkitTestApplication application;
416 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
417 TextField field = TextField::New();
418 DALI_TEST_CHECK( field );
420 // Check Property Indices are correct
421 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextField::Property::RENDERING_BACKEND );
422 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
423 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
424 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
425 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
426 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
427 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
428 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
429 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
430 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
431 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
432 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
433 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
434 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
435 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
436 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
437 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
438 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
439 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
440 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
441 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
442 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
443 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
444 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
445 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
446 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
447 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
448 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
449 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
450 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
451 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
452 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
453 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
454 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
455 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
456 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
457 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
458 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
459 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
460 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
461 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
462 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
463 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
464 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
465 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
466 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
467 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
468 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
469 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
470 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
471 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
472 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
473 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
474 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP );
475 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextField::Property::BACKGROUND );
480 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
483 Property::Map imageMap;
484 imageMap[mapKey] =mapValue;
486 field.SetProperty( property , imageMap );
487 Property::Value propValue = field.GetProperty( property );
488 Property::Map* resultMap = propValue.GetMap();
490 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
498 // Positive test case for a method
499 int UtcDaliTextFieldSetPropertyP(void)
501 ToolkitTestApplication application;
502 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
503 TextField field = TextField::New();
504 DALI_TEST_CHECK( field );
505 application.GetScene().Add( field );
507 // Note - we can't check the defaults since the stylesheets are platform-specific
509 // Check the render backend property.
510 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
511 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
513 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
514 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION );
516 // Check text property.
517 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
518 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
520 // Check placeholder text properties.
521 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
522 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
524 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
525 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
527 // Check font properties.
528 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
529 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
531 Property::Map fontStyleMapSet;
532 Property::Map fontStyleMapGet;
533 Property::Value* slantValue = NULL;
535 fontStyleMapSet.Insert( "weight", "bold" );
536 fontStyleMapSet.Insert( "width", "condensed" );
537 fontStyleMapSet.Insert( "slant", "italic" );
538 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
540 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
541 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
542 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
544 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
545 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
548 fontStyleMapSet.Clear();
549 fontStyleMapSet.Insert( "weight", "normal" );
550 fontStyleMapSet.Insert( "slant", "oblique" );
551 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
553 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
554 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
555 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
557 fontStyleMapSet.Clear();
558 fontStyleMapSet.Insert( "slant", "roman" );
559 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
560 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
562 // Replace 'roman' for 'normal'.
563 slantValue = fontStyleMapGet.Find( "slant" );
564 if( NULL != slantValue )
566 if( "normal" == slantValue->Get<std::string>() )
568 fontStyleMapGet["slant"] = "roman";
571 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
572 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
574 fontStyleMapSet.Clear();
576 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
577 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
578 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
579 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
581 // Check that the MAX_LENGTH property can be correctly set
582 const int maxNumberOfCharacters = 20;
583 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
584 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
586 // Check exceed policy
587 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
588 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
589 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
590 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
592 // Check that the Alignment properties can be correctly set
593 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
594 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
595 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
596 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
598 // Check text's color property
599 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
600 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
602 // Check placeholder text's color property.
603 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
604 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
606 // Check cursor properties
607 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
608 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
609 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
610 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
612 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
613 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
614 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
615 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
616 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
617 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
618 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
619 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
621 // Check scroll properties.
622 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
623 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
624 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
625 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
627 // Check handle images
628 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
629 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
630 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
631 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
632 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
634 // Check handle images
635 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
636 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
637 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
638 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
639 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
640 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
642 // Check the highlight color
643 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
644 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
646 // Decoration bounding box
647 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
648 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
650 // Check the input method setting
651 Property::Map propertyMap;
652 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
653 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
654 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
655 int inputVariation = 1;
656 propertyMap["PANEL_LAYOUT"] = panelLayout;
657 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
658 propertyMap["BUTTON_ACTION"] = buttonAction;
659 propertyMap["VARIATION"] = inputVariation;
660 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
662 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
664 DALI_TEST_CHECK( value.Get( map ) );
667 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
668 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
671 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
672 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
675 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
676 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
679 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
680 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
682 // Check input color property.
683 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
684 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
686 // Check the enable markup property.
687 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
688 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
689 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
691 // Check input font properties.
692 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
693 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
695 fontStyleMapSet.Clear();
696 fontStyleMapSet.Insert( "weight", "bold" );
697 fontStyleMapSet.Insert( "width", "condensed" );
698 fontStyleMapSet.Insert( "slant", "italic" );
700 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
701 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
702 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
703 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
705 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
706 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
708 // Reset input font style.
709 fontStyleMapSet.Clear();
710 fontStyleMapSet.Insert( "weight", "normal" );
711 fontStyleMapSet.Insert( "slant", "oblique" );
713 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
714 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
715 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
716 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
718 fontStyleMapSet.Clear();
719 fontStyleMapSet.Insert( "slant", "roman" );
721 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
722 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
724 // Replace 'roman' for 'normal'.
725 slantValue = fontStyleMapGet.Find( "slant" );
726 if( NULL != slantValue )
728 if( "normal" == slantValue->Get<std::string>() )
730 fontStyleMapGet["slant"] = "roman";
733 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
734 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
736 fontStyleMapSet.Clear();
738 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
739 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
740 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
741 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
743 Property::Map underlineMapSet;
744 Property::Map underlineMapGet;
746 underlineMapSet.Insert( "enable", true );
747 underlineMapSet.Insert( "color", Color::RED );
748 underlineMapSet.Insert( "height", 1 );
750 // Check the underline property
751 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
753 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
754 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
755 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
757 // Check the input underline property
758 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
759 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
761 // Check the shadow property
762 Property::Map shadowMapSet;
763 Property::Map shadowMapGet;
765 shadowMapSet.Insert( "color", Color::GREEN );
766 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
767 shadowMapSet.Insert( "blurRadius", 3.0f );
769 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
771 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
772 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
773 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
775 // Check the input shadow property
776 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
777 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
779 // Check the emboss property
780 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
781 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
783 // Check the input emboss property
784 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
785 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
787 // Check the outline property
789 // Test string type first
790 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
791 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
792 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
794 // Then test the property map type
795 Property::Map outlineMapSet;
796 Property::Map outlineMapGet;
798 outlineMapSet["color"] = Color::RED;
799 outlineMapSet["width"] = 2.0f;
801 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
803 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
804 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
805 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
807 // Check the input outline property
808 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
809 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
811 // Check the hidden input settings property
812 Property::Map hiddenMapSet;
813 Property::Map hiddenMapGet;
814 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
815 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
816 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
817 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
818 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
820 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
821 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
822 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
824 // Check the pixel size of font
825 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
826 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
828 // Check the enable selection property
829 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
830 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
832 // Check the placeholder property with pixel size
833 Property::Map placeholderPixelSizeMapSet;
834 Property::Map placeholderPixelSizeMapGet;
835 Property::Map placeholderFontstyleMap;
836 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
837 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
838 placeholderPixelSizeMapSet["color"] = Color::BLUE;
839 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
840 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
841 placeholderPixelSizeMapSet["ellipsis"] = true;
843 placeholderFontstyleMap.Insert( "weight", "bold" );
844 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
845 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
847 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
848 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
850 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
851 Property::Map placeholderConversionMap;
852 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
853 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
854 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
855 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
856 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
857 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
859 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
861 // Check the placeholder property with point size
862 Property::Map placeholderMapSet;
863 Property::Map placeholderMapGet;
864 placeholderMapSet["text"] = "Setting Placeholder Text";
865 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
866 placeholderMapSet["color"] = Color::RED;
867 placeholderMapSet["fontFamily"] = "Arial";
868 placeholderMapSet["pointSize"] = 12.0f;
869 placeholderMapSet["ellipsis"] = false;
871 // Check the placeholder font style property
872 placeholderFontstyleMap.Clear();
874 placeholderFontstyleMap.Insert( "weight", "bold" );
875 placeholderFontstyleMap.Insert( "width", "condensed" );
876 placeholderFontstyleMap.Insert( "slant", "italic" );
877 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
878 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
880 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
881 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
883 placeholderConversionMap.Clear();
884 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
885 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
886 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
887 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
888 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
889 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
891 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
894 placeholderFontstyleMap.Clear();
895 placeholderFontstyleMap.Insert( "weight", "normal" );
896 placeholderFontstyleMap.Insert( "slant", "oblique" );
897 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
898 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
900 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
901 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
903 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
904 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
906 placeholderFontstyleMap.Clear();
907 placeholderFontstyleMap.Insert( "slant", "roman" );
908 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
909 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
911 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
913 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
915 placeholderFontstyleMap.Clear();
916 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
917 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
919 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
920 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
921 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
923 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
925 // Check the ellipsis property
926 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
927 field.SetProperty( TextField::Property::ELLIPSIS, true );
928 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
930 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
931 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
933 // Test the ENABLE_GRAB_HANDLE_POPUP property
934 DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
935 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false );
936 DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
938 // Check the background property
939 field.SetProperty( DevelTextField::Property::BACKGROUND, Color::RED );
940 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::BACKGROUND ), Color::RED, TEST_LOCATION );
942 application.SendNotification();
943 application.Render();
948 // Positive Atlas Text Renderer test
949 int utcDaliTextFieldAtlasRenderP(void)
951 ToolkitTestApplication application;
952 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
953 StyleManager styleManager = StyleManager::Get();
954 styleManager.ApplyDefaultTheme();
955 TextField field = TextField::New();
956 DALI_TEST_CHECK( field );
958 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
960 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
962 application.GetScene().Add( field );
966 // Render some text with the shared atlas backend
967 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
968 application.SendNotification();
969 application.Render();
973 tet_result(TET_FAIL);
978 // Positive test for the textChanged signal.
979 int utcDaliTextFieldTextChangedP(void)
981 ToolkitTestApplication application;
982 tet_infoline(" utcDaliTextFieldTextChangedP");
983 TextField field = TextField::New();
984 DALI_TEST_CHECK( field );
986 application.GetScene().Add( field );
988 // connect to the text changed signal.
989 ConnectionTracker* testTracker = new ConnectionTracker();
990 field.TextChangedSignal().Connect(&TestTextChangedCallback);
991 bool textChangedSignal = false;
992 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
994 gTextChangedCallBackCalled = false;
995 field.SetProperty( TextField::Property::TEXT, "ABC" );
996 DALI_TEST_CHECK( gTextChangedCallBackCalled );
997 DALI_TEST_CHECK( textChangedSignal );
999 application.SendNotification();
1001 field.SetKeyInputFocus();
1003 gTextChangedCallBackCalled = false;
1004 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1005 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1010 // Negative test for the textChanged signal.
1011 int utcDaliTextFieldTextChangedN(void)
1013 ToolkitTestApplication application;
1014 tet_infoline(" utcDaliTextFieldTextChangedN");
1015 TextField field = TextField::New();
1016 DALI_TEST_CHECK( field );
1018 application.GetScene().Add( field );
1020 // connect to the text changed signal.
1021 ConnectionTracker* testTracker = new ConnectionTracker();
1022 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1023 bool textChangedSignal = false;
1024 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1026 gTextChangedCallBackCalled = false;
1027 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1028 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1029 DALI_TEST_CHECK( !textChangedSignal );
1034 // Positive test for Max Characters reached signal.
1035 int utcDaliTextFieldMaxCharactersReachedP(void)
1037 ToolkitTestApplication application;
1038 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1039 TextField field = TextField::New();
1040 DALI_TEST_CHECK( field );
1042 application.GetScene().Add( field );
1044 const int maxNumberOfCharacters = 1;
1045 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1047 field.SetKeyInputFocus();
1049 // connect to the text changed signal.
1050 ConnectionTracker* testTracker = new ConnectionTracker();
1051 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1052 bool maxLengthReachedSignal = false;
1053 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1055 gMaxCharactersCallBackCalled = false;
1057 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1058 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1060 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1061 DALI_TEST_CHECK( maxLengthReachedSignal );
1066 // Negative test for Max Characters reached signal.
1067 int utcDaliTextFieldMaxCharactersReachedN(void)
1069 ToolkitTestApplication application;
1070 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1071 TextField field = TextField::New();
1072 DALI_TEST_CHECK( field );
1074 application.GetScene().Add( field );
1076 const int maxNumberOfCharacters = 3;
1077 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1079 field.SetKeyInputFocus();
1081 // connect to the text changed signal.
1082 ConnectionTracker* testTracker = new ConnectionTracker();
1083 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1084 bool maxLengthReachedSignal = false;
1085 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1087 gMaxCharactersCallBackCalled = false;
1089 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1090 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1092 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1093 DALI_TEST_CHECK( !maxLengthReachedSignal );
1095 application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::Down, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1097 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1098 DALI_TEST_CHECK( !maxLengthReachedSignal );
1103 int utcDaliTextFieldInputStyleChanged01(void)
1105 // The text-field emits signals when the input style changes. These changes of style are
1106 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1107 // can't be emitted during the size negotiation as the callbacks may update the UI.
1108 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1109 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1110 ToolkitTestApplication application;
1111 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1115 char* pathNamePtr = get_current_dir_name();
1116 const std::string pathName( pathNamePtr );
1117 free( pathNamePtr );
1119 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1120 fontClient.SetDpi( 93u, 93u );
1122 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1123 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1125 TextField field = TextField::New();
1126 DALI_TEST_CHECK( field );
1129 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1130 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1131 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1133 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1134 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1136 // connect to the text changed signal.
1137 ConnectionTracker* testTracker = new ConnectionTracker();
1138 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1139 bool inputStyleChangedSignal = false;
1140 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1142 application.GetScene().Add( field );
1144 // Render and notify
1145 application.SendNotification();
1146 application.Render();
1148 // Executes the idle callbacks added by the text control on the change of input style.
1149 application.RunIdles();
1151 gInputStyleChangedCallbackCalled = false;
1152 gInputStyleMask = TextField::InputStyle::NONE;
1153 inputStyleChangedSignal = false;
1155 // Create a tap event to touch the text field.
1156 TestGenerateTap( application, 18.0f, 25.0f );
1158 // Render and notify
1159 application.SendNotification();
1160 application.Render();
1162 // Executes the idle callbacks added by the text control on the change of input style.
1163 application.RunIdles();
1165 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1166 if( gInputStyleChangedCallbackCalled )
1168 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1170 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1171 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1173 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1174 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1176 DALI_TEST_CHECK( inputStyleChangedSignal );
1178 gInputStyleChangedCallbackCalled = false;
1179 gInputStyleMask = TextField::InputStyle::NONE;
1180 inputStyleChangedSignal = false;
1182 // Create a tap event to touch the text field.
1183 TestGenerateTap( application, 30.0f, 25.0f );
1185 // Render and notify
1186 application.SendNotification();
1187 application.Render();
1189 // Executes the idle callbacks added by the text control on the change of input style.
1190 application.RunIdles();
1192 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1193 DALI_TEST_CHECK( !inputStyleChangedSignal );
1195 gInputStyleChangedCallbackCalled = false;
1196 gInputStyleMask = TextField::InputStyle::NONE;
1197 inputStyleChangedSignal = false;
1199 // Create a tap event to touch the text field.
1200 TestGenerateTap( application, 43.0f, 25.0f );
1202 // Render and notify
1203 application.SendNotification();
1204 application.Render();
1206 // Executes the idle callbacks added by the text control on the change of input style.
1207 application.RunIdles();
1209 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1210 if( gInputStyleChangedCallbackCalled )
1212 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1214 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1215 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1217 DALI_TEST_CHECK( inputStyleChangedSignal );
1219 gInputStyleChangedCallbackCalled = false;
1220 gInputStyleMask = TextField::InputStyle::NONE;
1221 inputStyleChangedSignal = false;
1223 // Create a tap event to touch the text field.
1224 TestGenerateTap( application, 88.0f, 25.0f );
1226 // Render and notify
1227 application.SendNotification();
1228 application.Render();
1230 // Executes the idle callbacks added by the text control on the change of input style.
1231 application.RunIdles();
1233 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1234 if( gInputStyleChangedCallbackCalled )
1236 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1238 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1239 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1241 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1243 Property::Map fontStyleMapSet;
1244 fontStyleMapSet.Insert( "weight", "bold" );
1246 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1247 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1249 DALI_TEST_CHECK( inputStyleChangedSignal );
1251 gInputStyleChangedCallbackCalled = false;
1252 gInputStyleMask = TextField::InputStyle::NONE;
1253 inputStyleChangedSignal = false;
1255 // Create a tap event to touch the text field.
1256 TestGenerateTap( application, 115.0f, 25.0f );
1258 // Render and notify
1259 application.SendNotification();
1260 application.Render();
1262 // Executes the idle callbacks added by the text control on the change of input style.
1263 application.RunIdles();
1265 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1266 DALI_TEST_CHECK( !inputStyleChangedSignal );
1268 gInputStyleChangedCallbackCalled = false;
1269 gInputStyleMask = TextField::InputStyle::NONE;
1270 inputStyleChangedSignal = false;
1272 // Create a tap event to touch the text field.
1273 TestGenerateTap( application, 164.0f, 25.0f );
1275 // Render and notify
1276 application.SendNotification();
1277 application.Render();
1279 // Executes the idle callbacks added by the text control on the change of input style.
1280 application.RunIdles();
1282 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1283 if( gInputStyleChangedCallbackCalled )
1285 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1287 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1288 DALI_TEST_CHECK( style.empty() );
1290 DALI_TEST_CHECK( inputStyleChangedSignal );
1292 gInputStyleChangedCallbackCalled = false;
1293 gInputStyleMask = TextField::InputStyle::NONE;
1294 inputStyleChangedSignal = false;
1296 // Create a tap event to touch the text field.
1297 TestGenerateTap( application, 191.0f, 25.0f );
1299 // Render and notify
1300 application.SendNotification();
1301 application.Render();
1303 // Executes the idle callbacks added by the text control on the change of input style.
1304 application.RunIdles();
1306 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1307 DALI_TEST_CHECK( !inputStyleChangedSignal );
1312 int utcDaliTextFieldInputStyleChanged02(void)
1314 // The text-field emits signals when the input style changes. These changes of style are
1315 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1316 // can't be emitted during the size negotiation as the callbacks may update the UI.
1317 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1318 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1319 ToolkitTestApplication application;
1320 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1324 char* pathNamePtr = get_current_dir_name();
1325 const std::string pathName( pathNamePtr );
1326 free( pathNamePtr );
1328 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1329 fontClient.SetDpi( 93u, 93u );
1331 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1332 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1334 TextField field = TextField::New();
1335 DALI_TEST_CHECK( field );
1337 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1338 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1339 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1341 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1342 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>" );
1344 // connect to the text changed signal.
1345 ConnectionTracker* testTracker = new ConnectionTracker();
1346 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1347 bool inputStyleChangedSignal = false;
1348 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1350 application.GetScene().Add( field );
1352 // Render and notify
1353 application.SendNotification();
1354 application.Render();
1356 // Executes the idle callbacks added by the text control on the change of input style.
1357 application.RunIdles();
1359 gInputStyleChangedCallbackCalled = false;
1360 gInputStyleMask = TextField::InputStyle::NONE;
1361 inputStyleChangedSignal = false;
1363 // Create a tap event to touch the text field.
1364 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1365 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1367 // Render and notify
1368 application.SendNotification();
1369 application.Render();
1371 // Executes the idle callbacks added by the text control on the change of input style.
1372 application.RunIdles();
1374 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1375 if( gInputStyleChangedCallbackCalled )
1377 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1378 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1379 TextField::InputStyle::POINT_SIZE |
1380 TextField::InputStyle::COLOR ),
1383 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1384 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1386 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1387 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1389 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1390 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1392 DALI_TEST_CHECK( inputStyleChangedSignal );
1394 gInputStyleChangedCallbackCalled = false;
1395 gInputStyleMask = TextField::InputStyle::NONE;
1396 inputStyleChangedSignal = false;
1398 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1400 // Render and notify
1401 application.SendNotification();
1402 application.Render();
1404 // Executes the idle callbacks added by the text control on the change of input style.
1405 application.RunIdles();
1407 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1408 if( gInputStyleChangedCallbackCalled )
1410 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1411 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1414 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1415 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1417 DALI_TEST_CHECK( inputStyleChangedSignal );
1419 gInputStyleChangedCallbackCalled = false;
1420 gInputStyleMask = TextField::InputStyle::NONE;
1421 inputStyleChangedSignal = false;
1423 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1425 // Render and notify
1426 application.SendNotification();
1427 application.Render();
1429 // Executes the idle callbacks added by the text control on the change of input style.
1430 application.RunIdles();
1432 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1433 DALI_TEST_CHECK( !inputStyleChangedSignal );
1435 gInputStyleChangedCallbackCalled = false;
1436 gInputStyleMask = TextField::InputStyle::NONE;
1437 inputStyleChangedSignal = false;
1439 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1441 // Render and notify
1442 application.SendNotification();
1443 application.Render();
1445 // Executes the idle callbacks added by the text control on the change of input style.
1446 application.RunIdles();
1448 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1449 if( gInputStyleChangedCallbackCalled )
1451 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1452 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1455 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1456 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1458 DALI_TEST_CHECK( inputStyleChangedSignal );
1460 gInputStyleChangedCallbackCalled = false;
1461 gInputStyleMask = TextField::InputStyle::NONE;
1462 inputStyleChangedSignal = false;
1464 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1466 Property::Map fontStyleMapSet;
1467 fontStyleMapSet.Insert( "weight", "thin" );
1468 fontStyleMapSet.Insert( "width", "condensed" );
1469 fontStyleMapSet.Insert( "slant", "italic" );
1471 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1472 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1474 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1475 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1476 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1477 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1479 // Render and notify
1480 application.SendNotification();
1481 application.Render();
1483 // Executes the idle callbacks added by the text control on the change of input style.
1484 application.RunIdles();
1486 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1487 DALI_TEST_CHECK( !inputStyleChangedSignal );
1489 // Create a tap event to touch the text field.
1490 TestGenerateTap( application, 63.0f, 25.0f, 300 );
1492 // Render and notify
1493 application.SendNotification();
1494 application.Render();
1496 // Executes the idle callbacks added by the text control on the change of input style.
1497 application.RunIdles();
1499 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1500 if( gInputStyleChangedCallbackCalled )
1502 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1503 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1504 TextField::InputStyle::POINT_SIZE |
1505 TextField::InputStyle::FONT_STYLE |
1506 TextField::InputStyle::UNDERLINE |
1507 TextField::InputStyle::SHADOW |
1508 TextField::InputStyle::EMBOSS |
1509 TextField::InputStyle::OUTLINE ),
1512 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1513 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1515 DALI_TEST_CHECK( inputStyleChangedSignal );
1520 int utcDaliTextFieldEvent01(void)
1522 ToolkitTestApplication application;
1523 tet_infoline(" utcDaliTextFieldEvent01");
1525 // Creates a tap event. After creating a tap event the text field should
1526 // have the focus and add text with key events should be possible.
1528 TextField field = TextField::New();
1529 DALI_TEST_CHECK( field );
1531 application.GetScene().Add( field );
1533 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1534 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1535 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1537 // Render and notify
1538 application.SendNotification();
1539 application.Render();
1541 // Avoid a crash when core load gl resources.
1542 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1544 // Render and notify
1545 application.SendNotification();
1546 application.Render();
1548 // Add a key event but as the text field has not the focus it should do nothing.
1549 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1551 // Render and notify
1552 application.SendNotification();
1553 application.Render();
1555 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1557 // Create a tap event to touch the text field.
1558 TestGenerateTap( application, 150.0f, 25.0f );
1560 // Render and notify
1561 application.SendNotification();
1562 application.Render();
1564 // Pressing delete key should be fine even if there is no text in TextField.
1565 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 ) );
1566 // Render and notify
1567 application.SendNotification();
1568 application.Render();
1570 // Now the text field has the focus, so it can handle the key events.
1571 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1572 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1574 // Render and notify
1575 application.SendNotification();
1576 application.Render();
1578 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1580 // Create a second text field and send key events to it.
1581 TextField field2 = TextField::New();
1583 field2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1584 field2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1585 field2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1586 field2.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
1588 application.GetScene().Add( field2 );
1590 // Render and notify
1591 application.SendNotification();
1592 application.Render();
1594 // Create a tap event on the second text field.
1595 TestGenerateTap( application, 150.0f, 125.0f );
1597 // Render and notify
1598 application.SendNotification();
1599 application.Render();
1601 // The second text field has the focus. It should handle the key events.
1602 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1603 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1605 // Render and notify
1606 application.SendNotification();
1607 application.Render();
1609 // Check the text has been added to the second text field.
1610 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1615 int utcDaliTextFieldEvent02(void)
1617 ToolkitTestApplication application;
1618 tet_infoline(" utcDaliTextFieldEvent02");
1620 // Checks if the right number of actors are created.
1622 TextField field = TextField::New();
1623 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1624 DALI_TEST_CHECK( field );
1625 LoadMarkerImages(application, field);
1627 application.GetScene().Add( field );
1629 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1630 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1631 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1633 // Avoid a crash when core load gl resources.
1634 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1636 // Render and notify
1637 application.SendNotification();
1638 application.Render();
1640 // Check there are the expected number of children ( stencil ).
1641 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1643 Actor stencil = field.GetChildAt( 0u );
1644 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1646 // Create a tap event to touch the text field.
1647 TestGenerateTap( application, 150.0f, 25.0f, 300 );
1649 // Render and notify
1650 application.SendNotification();
1651 application.Render();
1653 Actor layer = field.GetChildAt( 1u );
1654 DALI_TEST_CHECK( layer.GetProperty< bool >( Actor::Property::IS_LAYER ) );
1656 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1657 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1659 // Now the text field has the focus, so it can handle the key events.
1660 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1661 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1663 // Render and notify
1664 application.SendNotification();
1665 application.Render();
1667 // Checks the cursor and the renderer have been created.
1668 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1669 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1671 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1672 DALI_TEST_CHECK( cursor );
1674 // The offscreen root actor has a container with all the actors which contain the text renderers.
1675 Actor container = stencil.GetChildAt( 0u );
1676 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1678 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1679 DALI_TEST_CHECK( renderer );
1682 // Move the cursor and check the position changes.
1683 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1684 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1686 // Render and notify
1687 application.SendNotification();
1688 application.Render();
1690 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1691 DALI_TEST_CHECK( position2.x < position1.x );
1693 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1695 // Render and notify
1696 application.SendNotification();
1697 application.Render();
1699 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1700 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1703 // Move the cursor to the first position.
1704 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1705 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1707 // Render and notify
1708 application.SendNotification();
1709 application.Render();
1711 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1713 // Send some taps and check the cursor positions.
1715 // Try to tap at the beginning.
1716 TestGenerateTap( application, 1.0f, 25.0f, 900 );
1718 // Render and notify
1719 application.SendNotification();
1720 application.Render();
1722 // Cursor position should be the same than position1.
1723 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1725 DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
1727 // Tap away from the start position.
1728 TestGenerateTap( application, 16.0f, 25.0f, 1500 );
1730 // Render and notify
1731 application.SendNotification();
1732 application.Render();
1734 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1736 DALI_TEST_CHECK( position6.x > position5.x );
1738 // Remove all the text.
1739 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1740 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1741 field.SetProperty( TextField::Property::TEXT, "" );
1743 // Render and notify
1744 application.SendNotification();
1745 application.Render();
1747 // Cursor position should be the same than position2.
1748 Vector3 position7 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1750 DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
1752 // Should not be a renderer.
1753 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1755 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1756 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1757 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1759 application.SendNotification();
1760 application.Render();
1762 // There are renderer and decorator layer
1763 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1768 int utcDaliTextFieldEvent03(void)
1770 ToolkitTestApplication application;
1771 tet_infoline(" utcDaliTextFieldEvent03");
1773 // Checks if the highlight actor is created.
1775 TextField field = TextField::New();
1776 DALI_TEST_CHECK( field );
1778 application.GetScene().Add( field );
1780 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1781 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1782 field.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1783 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1784 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1786 // Avoid a crash when core load gl resources.
1787 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1788 LoadMarkerImages(application, field);
1790 // Render and notify
1791 application.SendNotification();
1792 application.Render();
1794 // Tap first to get the focus.
1795 TestGenerateTap( application, 3.0f, 25.0f );
1797 // Render and notify
1798 application.SendNotification();
1799 application.Render();
1801 // Double tap to select a word.
1802 TestGenerateTap( application, 3.0f, 25.0f );
1804 // Render and notify
1805 application.SendNotification();
1806 application.Render();
1808 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1809 Actor stencil = field.GetChildAt( 0u );
1811 // The highlight actor is drawn first, so is the first actor in the list
1812 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1813 DALI_TEST_CHECK( highlight );
1815 // The offscreen root actor has a container with all the actors which contain the text renderers.
1816 Actor container = stencil.GetChildAt( 1u );
1817 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1819 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1820 DALI_TEST_CHECK( renderer );
1826 int utcDaliTextFieldEvent04(void)
1828 ToolkitTestApplication application;
1829 tet_infoline(" utcDaliTextFieldEvent04");
1831 // Checks if the highlight actor is created.
1833 TextField field = TextField::New();
1834 DALI_TEST_CHECK( field );
1835 application.GetScene().Add( field );
1836 LoadMarkerImages(application, field);
1837 // Render and notify
1838 application.SendNotification();
1839 application.Render();
1841 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1842 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1843 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1844 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1845 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1847 // Avoid a crash when core load gl resources.
1848 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1849 // Render and notify
1850 application.SendNotification();
1851 application.Render();
1853 // Create a tap event to touch the text field.
1854 TestGenerateTap( application, 150.0f, 25.0f );
1855 // Render and notify
1856 application.SendNotification();
1857 application.Render();
1860 // Tap first to get the focus.
1861 TestGenerateTap( application, 1.0f, 25.0f );
1863 // Render and notify
1864 application.SendNotification();
1865 application.Render();
1867 // Double tap to select a word.
1868 TestGenerateTap( application, 1.0f, 25.0f );
1870 // Render and notify
1871 application.SendNotification();
1872 application.Render();
1875 TestGenerateTap( application, 0.0f, 40.0f );
1879 int utcDaliTextFieldEvent05(void)
1881 ToolkitTestApplication application;
1882 tet_infoline(" utcDaliTextFieldEvent05");
1884 // Checks dragging of cursor/grab handle
1886 TextField field = TextField::New();
1887 DALI_TEST_CHECK( field );
1888 application.GetScene().Add( field );
1889 LoadMarkerImages(application, field);
1890 // Render and notify
1891 application.SendNotification();
1892 application.Render();
1894 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1895 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1896 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1897 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1898 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1900 // Avoid a crash when core load gl resources.
1901 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1902 // Render and notify
1903 application.SendNotification();
1904 application.Render();
1906 // Create a tap event to touch the text field.
1907 TestGenerateTap( application, 150.0f, 25.0f );
1908 // Render and notify
1909 application.SendNotification();
1910 application.Render();
1912 // Tap first to get the focus.
1913 TestGenerateTap( application, 1.0f, 25.0f );
1915 // Render and notify
1916 application.SendNotification();
1917 application.Render();
1919 // Double tap to select a word.
1920 TestGenerateTap( application, 1.0f, 25.0f );
1922 // Render and notify
1923 application.SendNotification();
1924 application.Render();
1926 Actor stencil = field.GetChildAt( 1u );
1930 int utcDaliTextFieldEvent06(void)
1932 ToolkitTestApplication application;
1933 tet_infoline(" utcDaliTextFieldEvent06");
1935 // Checks Longpress when in edit mode
1937 TextField field = TextField::New();
1938 DALI_TEST_CHECK( field );
1939 application.GetScene().Add( field );
1940 LoadMarkerImages(application, field);
1941 // Render and notify
1942 application.SendNotification();
1943 application.Render();
1945 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1946 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1947 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1948 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1949 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1951 // Avoid a crash when core load gl resources.
1952 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1953 // Render and notify
1954 application.SendNotification();
1955 application.Render();
1957 // Create a tap event to touch the text field.
1958 TestGenerateTap( application, 150.0f, 25.0f );
1959 // Render and notify
1960 application.SendNotification();
1961 application.Render();
1964 // Tap first to get the focus.
1965 TestGenerateTap( application, 1.0f, 25.0f );
1967 // Render and notify
1968 application.SendNotification();
1969 application.Render();
1972 TestGenerateLongPress(application, 1.0f, 25.0f);
1974 // Render and notify
1975 application.SendNotification();
1976 application.Render();
1981 int utcDaliTextFieldEvent07(void)
1983 ToolkitTestApplication application;
1984 tet_infoline(" utcDaliTextFieldEvent07");
1986 // Checks Longpress to start edit mode
1988 TextField field = TextField::New();
1989 DALI_TEST_CHECK( field );
1990 application.GetScene().Add( field );
1991 LoadMarkerImages(application, field);
1992 // Render and notify
1993 application.SendNotification();
1994 application.Render();
1996 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1997 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1998 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1999 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2000 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2001 Property::Map propertyMap;
2002 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2003 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2005 // Avoid a crash when core load gl resources.
2006 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2007 // Render and notify
2008 application.SendNotification();
2009 application.Render();
2012 TestGenerateLongPress(application, 1.0f, 25.0f);
2014 // Render and notify
2015 application.SendNotification();
2016 application.Render();
2021 int utcDaliTextFieldEvent08(void)
2023 ToolkitTestApplication application;
2024 tet_infoline(" utcDaliTextFieldEvent08");
2026 Dali::Clipboard clipboard = Clipboard::Get();
2027 clipboard.SetItem("testTextFieldEvent");
2029 // Checks Longpress when only place holder text
2031 TextField field = TextField::New();
2032 DALI_TEST_CHECK( field );
2033 application.GetScene().Add( field );
2034 LoadMarkerImages(application, field);
2035 // Render and notify
2036 application.SendNotification();
2037 application.Render();
2039 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2040 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2041 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2042 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2043 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2045 // Avoid a crash when core load gl resources.
2046 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2047 // Render and notify
2048 application.SendNotification();
2049 application.Render();
2052 TestGenerateLongPress( application, 1.0f, 25.0f, 20 );
2054 // Render and notify
2055 application.SendNotification();
2056 application.Render();
2058 Wait(application, 500);
2060 TestEndLongPress( application, 1.0f, 25.0f, 520 );
2063 TestGenerateLongPress( application, 1.0f, 25.0f, 600 );
2065 // Render and notify
2066 application.Render();
2068 Wait(application, 500);
2070 Integration::Scene stage = application.GetScene();
2071 Layer layer = stage.GetRootLayer();
2072 Actor actor = layer.FindChildByName("optionPaste");
2076 Vector3 worldPosition = actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION );
2077 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2078 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2080 Dali::Integration::TouchEvent event;
2081 event = Dali::Integration::TouchEvent();
2082 event.AddPoint( GetPointDownInside( position ) );
2083 application.ProcessEvent( event );
2085 event = Dali::Integration::TouchEvent();
2086 event.AddPoint( GetPointUpInside( position ) );
2087 application.ProcessEvent( event );
2089 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2094 int utcDaliTextFieldEvent09(void)
2096 ToolkitTestApplication application;
2097 tet_infoline(" utcDaliTextFieldEvent09");
2099 TextField field = TextField::New();
2100 DALI_TEST_CHECK( field );
2101 application.GetScene().Add( field );
2102 LoadMarkerImages(application, field);
2103 // Render and notify
2104 application.SendNotification();
2105 application.Render();
2107 field.SetProperty( TextField::Property::TEXT, "Hello" );
2108 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2109 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2110 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2111 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2113 // Avoid a crash when core load gl resources.
2114 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2116 // Create a tap event to touch the text field.
2117 TestGenerateTap( application, 150.0f, 25.0f );
2118 application.SendNotification();
2119 application.Render();
2122 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2123 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2124 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2125 application.SendNotification();
2126 application.Render();
2128 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2129 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2130 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2131 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2132 application.SendNotification();
2133 application.Render();
2135 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2136 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2137 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2138 for( unsigned int index = 0u; index < 5u; ++index )
2140 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2141 application.SendNotification();
2142 application.Render();
2145 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2146 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2147 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2148 for( unsigned int index = 0u; index < 5u; ++index )
2150 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2151 application.SendNotification();
2152 application.Render();
2155 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2156 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2157 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2158 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2159 application.SendNotification();
2160 application.Render();
2161 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2162 application.SendNotification();
2163 application.Render();
2165 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2166 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2167 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2168 application.SendNotification();
2169 application.Render();
2171 Property::Map mapGet;
2172 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2173 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2174 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2179 int utcDaliTextFieldStyleWhilstSelected(void)
2181 ToolkitTestApplication application;
2182 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2184 // Change font and styles whilst text is selected whilst word selected
2186 TextField field = TextField::New();
2187 DALI_TEST_CHECK( field );
2188 application.GetScene().Add( field );
2189 LoadMarkerImages(application, field);
2190 // Render and notify
2191 application.SendNotification();
2192 application.Render();
2194 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2195 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2196 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2197 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2198 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2200 // Avoid a crash when core load gl resources.
2201 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2202 // Render and notify
2203 application.SendNotification();
2204 application.Render();
2206 // Create a tap event to touch the text field.
2207 TestGenerateTap( application, 150.0f, 25.0f );
2208 // Render and notify
2209 application.SendNotification();
2210 application.Render();
2213 // Tap first to get the focus.
2214 TestGenerateTap( application, 1.0f, 25.0f );
2216 // Render and notify
2217 application.SendNotification();
2218 application.Render();
2220 // Double tap to select a word.
2221 TestGenerateTap( application, 1.0f, 25.0f );
2223 // Render and notify
2224 application.SendNotification();
2225 application.Render();
2227 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2228 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2230 Property::Map fontStyleMapSet;
2231 Property::Map fontStyleMapGet;
2233 fontStyleMapSet.Insert( "weight", "bold" );
2234 fontStyleMapSet.Insert( "slant", "italic" );
2235 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2237 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2238 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2239 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2241 fontStyleMapSet.Clear();
2242 fontStyleMapSet.Insert( "width", "expanded" );
2243 fontStyleMapSet.Insert( "slant", "italic" );
2244 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2246 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2247 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2248 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2250 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2251 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2253 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2254 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2256 fontStyleMapSet.Clear();
2257 fontStyleMapSet.Insert( "weight", "bold" );
2258 fontStyleMapSet.Insert( "slant", "italic" );
2260 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2262 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2263 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2264 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2266 fontStyleMapSet.Clear();
2267 fontStyleMapSet.Insert( "width", "expanded" );
2269 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2271 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2272 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2273 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2275 // Press Escape to increase coverage
2276 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2277 application.SendNotification();
2278 application.Render();
2280 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2285 int utcDaliTextFieldEscKeyLoseFocus(void)
2287 ToolkitTestApplication application;
2288 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2290 // Creates a tap event. After creating a tap event the text field should
2291 // have the focus and add text with key events should be possible.
2293 TextField field = TextField::New();
2294 DALI_TEST_CHECK( field );
2296 application.GetScene().Add( field );
2298 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2299 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2300 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2302 // Avoid a crash when core load gl resources.
2303 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2305 // Render and notify
2306 application.SendNotification();
2307 application.Render();
2309 // Add a key event but as the text field has not the focus it should do nothing.
2310 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2311 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2313 // Render and notify
2314 application.SendNotification();
2315 application.Render();
2317 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2319 // Create a tap event to touch the text field.
2320 TestGenerateTap( application, 150.0f, 25.0f );
2322 // Render and notify
2323 application.SendNotification();
2324 application.Render();
2326 // Now the text field has the focus, so it can handle the key events.
2327 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2328 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2329 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2330 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2332 // Render and notify
2333 application.SendNotification();
2334 application.Render();
2336 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2338 // Generate a Esc key event. The text field should lose the focus.
2339 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2340 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2342 // Render and notify
2343 application.SendNotification();
2344 application.Render();
2346 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2348 // No more text should be introduced
2349 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2350 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2352 // Render and notify
2353 application.SendNotification();
2354 application.Render();
2356 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2361 int utcDaliTextFieldSomeSpecialKeys(void)
2363 ToolkitTestApplication application;
2364 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2366 // Checks some special keys when the text is selected.
2368 TextField field = TextField::New();
2369 DALI_TEST_CHECK( field );
2370 application.GetScene().Add( field );
2371 LoadMarkerImages(application, field);
2372 // Render and notify
2373 application.SendNotification();
2374 application.Render();
2376 const std::string longText( "This is a long text for the size of the text-field." );
2378 field.SetProperty( TextField::Property::TEXT, longText );
2379 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2380 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2381 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2382 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2384 // Avoid a crash when core load gl resources.
2385 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2386 // Render and notify
2387 application.SendNotification();
2388 application.Render();
2390 // Create a tap event to touch the text field.
2391 TestGenerateTap( application, 150.0f, 25.0f );
2393 // Render and notify
2394 application.SendNotification();
2395 application.Render();
2397 // Tap first to get the focus.
2398 TestGenerateTap( application, 1.0f, 25.0f );
2400 // Render and notify
2401 application.SendNotification();
2402 application.Render();
2404 // Double tap to select a word.
2405 TestGenerateTap( application, 1.0f, 25.0f );
2407 // Render and notify
2408 application.SendNotification();
2409 application.Render();
2411 // Generate a Esc key event. The text field should lose the focus.
2412 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2413 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2415 // Render and notify
2416 application.SendNotification();
2417 application.Render();
2419 // Generate a Esc key event. The text field should lose the focus.
2420 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2421 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2423 // Render and notify
2424 application.SendNotification();
2425 application.Render();
2427 // Generate a Esc key event. The text field should lose the focus.
2428 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2429 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2431 // Render and notify
2432 application.SendNotification();
2433 application.Render();
2435 // The text shouldn't be deleted.
2436 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2441 int utcDaliTextFieldSizeUpdate(void)
2443 ToolkitTestApplication application;
2444 tet_infoline("utcDaliTextFieldSizeUpdate");
2446 // Checks some special keys when the text is selected.
2447 TextField field = TextField::New();
2448 DALI_TEST_CHECK( field );
2449 application.GetScene().Add( field );
2451 float previousHeight = 0.0f;
2452 float currentHeight = 0.0f;
2453 const float fieldWidth = 1920.0f;
2456 // "ㅁ" is bigger then "ኢ"
2457 field.SetProperty( Actor::Property::SIZE, Vector2( fieldWidth ,10.0f ) );
2458 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2459 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2461 field.SetProperty( TextField::Property::TEXT, "ኢ");
2462 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2463 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2465 field.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2466 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2468 application.SendNotification();
2469 application.Render();
2471 previousHeight = field.GetHeightForWidth( fieldWidth );
2472 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2474 // Add another script characters ( glyph height is defferent )
2475 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2476 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2478 application.SendNotification();
2479 application.Render();
2481 currentHeight = field.GetHeightForWidth( fieldWidth );
2482 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2483 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2488 int utcDaliTextFieldExtremlyLargePointSize(void)
2490 ToolkitTestApplication application;
2491 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2493 TextField field = TextField::New();
2495 field.SetProperty( TextField::Property::TEXT, "Text" );
2496 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2497 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2498 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2499 application.GetScene().Add( field );
2503 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2504 application.SendNotification();
2505 DALI_TEST_CHECK( field );
2509 tet_result(TET_FAIL);
2514 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2516 ToolkitTestApplication application;
2517 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2518 TextField field = TextField::New();
2519 DALI_TEST_CHECK( field );
2520 application.GetScene().Add( field );
2522 Property::Map fontStyleMapGet;
2524 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2526 Property::Value* weightValue = NULL;
2527 Property::Value* widthValue = NULL;
2528 Property::Value* slantValue = NULL;
2529 weightValue = fontStyleMapGet.Find( "weight" );
2530 widthValue = fontStyleMapGet.Find( "width" );
2531 slantValue = fontStyleMapGet.Find( "slant" );
2532 DALI_TEST_CHECK( !weightValue );
2533 DALI_TEST_CHECK( !widthValue );
2534 DALI_TEST_CHECK( !slantValue );
2539 int UtcDaliTextFieldSettingPlaceholder(void)
2541 ToolkitTestApplication application;
2542 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
2544 TextField field = TextField::New();
2545 DALI_TEST_CHECK( field );
2546 application.GetScene().Add( field );
2548 // Check the placeholder property with pixel size
2549 Property::Map placeholderPixelSizeMapSet;
2550 Property::Map placeholderPixelSizeMapGet;
2551 Property::Map placeholderFontstyleMap;
2552 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2553 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2554 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
2555 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2556 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
2557 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
2559 placeholderFontstyleMap.Insert( "weight", "bold" );
2560 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2561 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
2563 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2564 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
2565 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
2567 // Check the placeholder property with point size
2568 Property::Map placeholderMapSet;
2569 Property::Map placeholderMapGet;
2570 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2571 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2572 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
2573 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2574 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
2575 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
2577 // Check the placeholder font style property
2578 placeholderFontstyleMap.Clear();
2580 placeholderFontstyleMap.Insert( "weight", "bold" );
2581 placeholderFontstyleMap.Insert( "width", "condensed" );
2582 placeholderFontstyleMap.Insert( "slant", "italic" );
2583 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2584 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2586 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2587 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2588 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2590 // Reset font style.
2591 placeholderFontstyleMap.Clear();
2592 placeholderFontstyleMap.Insert( "weight", "normal" );
2593 placeholderFontstyleMap.Insert( "slant", "oblique" );
2594 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2595 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2597 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2598 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2599 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2601 placeholderFontstyleMap.Clear();
2602 placeholderFontstyleMap.Insert( "slant", "roman" );
2603 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2604 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2606 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2608 placeholderFontstyleMap.Clear();
2609 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2611 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2612 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2613 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2614 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2619 int UtcDaliTextFieldSetPaddingProperty(void)
2621 ToolkitTestApplication application;
2622 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
2624 TextField field = TextField::New();
2625 DALI_TEST_CHECK( field );
2626 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2627 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2628 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2629 application.GetScene().Add( field );
2631 application.SendNotification();
2632 application.Render();
2634 Vector3 originalSize = field.GetNaturalSize();
2636 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2638 application.SendNotification();
2639 application.Render();
2641 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2643 Vector3 paddingAddedSize = field.GetNaturalSize();
2645 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2647 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2652 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
2654 ToolkitTestApplication application;
2655 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
2657 TextField field = TextField::New();
2658 DALI_TEST_CHECK( field );
2659 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2660 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2661 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2662 application.GetScene().Add( field );
2664 application.SendNotification();
2665 application.Render();
2667 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2668 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2670 // Check the enable shift selection property
2671 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
2672 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2674 application.SendNotification();
2675 application.Render();
2680 int UtcDaliTextFieldEnableGrabHandleProperty(void)
2682 ToolkitTestApplication application;
2683 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
2685 TextField field = TextField::New();
2686 DALI_TEST_CHECK( field );
2687 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2688 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2689 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2690 application.GetScene().Add( field );
2692 application.SendNotification();
2693 application.Render();
2695 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2696 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2698 // Check the enable grab handle property
2699 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
2700 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2702 application.SendNotification();
2703 application.Render();
2708 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
2710 ToolkitTestApplication application;
2711 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
2713 TextField field = TextField::New();
2714 DALI_TEST_CHECK( field );
2715 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2716 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2717 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2718 application.GetScene().Add( field );
2720 application.SendNotification();
2721 application.Render();
2723 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2724 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2726 // Check the match system language direction property
2727 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2728 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2730 application.SendNotification();
2731 application.Render();
2736 int utcDaliTextFieldLayoutDirectionCoverage(void)
2738 ToolkitTestApplication application;
2739 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
2741 // Creates a tap event. After creating a tap event the text field should
2742 // have the focus and add text with key events should be possible.
2743 TextField field = TextField::New();
2744 DALI_TEST_CHECK( field );
2746 application.GetScene().Add( field );
2748 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2749 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2750 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2752 // Avoid a crash when core load gl resources.
2753 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2755 // Render and notify
2756 application.SendNotification();
2757 application.Render();
2759 // init direction for coverage
2760 // Set horizontal alignment END
2761 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2763 // Create a tap event to touch the text field.
2764 TestGenerateTap( application, 150.0f, 25.0f );
2766 // Render and notify
2767 application.SendNotification();
2768 application.Render();
2770 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
2771 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2772 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
2774 // Set horizontal alignment BEGIN
2775 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
2777 // Create a tap event to touch the text field.
2778 TestGenerateTap( application, 150.0f, 25.0f );
2780 // Render and notify
2781 application.SendNotification();
2782 application.Render();
2784 // Set horizontal alignment CENTER
2785 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
2787 // Create a tap event to touch the text field.
2788 TestGenerateTap( application, 150.0f, 25.0f );
2790 // Render and notify
2791 application.SendNotification();
2792 application.Render();
2794 // Set horizontal alignment END
2795 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2797 // Create a tap event to touch the text field.
2798 TestGenerateTap( application, 150.0f, 25.0f );
2800 // Render and notify
2801 application.SendNotification();
2802 application.Render();
2804 // Generate a Esc key event. The text field should lose the focus.
2805 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2806 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2808 // Render and notify
2809 application.SendNotification();
2810 application.Render();
2812 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2817 int UtcDaliTextFieldGetInputMethodContext(void)
2819 ToolkitTestApplication application;
2820 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
2822 TextField field = TextField::New();
2823 DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );
2828 int UtcDaliTextFieldSelectWholeText(void)
2830 ToolkitTestApplication application;
2831 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
2833 TextField textField = TextField::New();
2835 application.GetScene().Add( textField );
2837 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2838 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2839 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2841 // Avoid a crash when core load gl resources.
2842 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2844 application.SendNotification();
2845 application.Render();
2847 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2849 DevelTextField::SelectWholeText( textField );
2851 application.SendNotification();
2852 application.Render();
2854 // Nothing should have been selected. The number of children is still 1
2855 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2857 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
2859 application.SendNotification();
2860 application.Render();
2862 DevelTextField::SelectWholeText( textField );
2864 application.SendNotification();
2865 application.Render();
2867 // Should be 2 children, the stencil and the layer
2868 DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
2870 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2871 Actor stencil = textField.GetChildAt( 0u );
2873 // The highlight actor is drawn first, so is the first actor in the list
2874 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2875 DALI_TEST_CHECK( highlight );
2880 int UtcDaliTextFieldSelectNone(void)
2882 ToolkitTestApplication application;
2883 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
2885 TextField textField = TextField::New();
2887 application.GetScene().Add( textField );
2889 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2890 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2891 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2893 // Avoid a crash when core load gl resources.
2894 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2896 application.SendNotification();
2897 application.Render();
2899 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
2901 application.SendNotification();
2902 application.Render();
2904 // Nothing is selected
2905 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
2906 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
2908 DevelTextField::SelectWholeText( textField );
2910 application.SendNotification();
2911 application.Render();
2913 // whole text is selected
2914 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
2915 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
2917 DevelTextField::SelectNone( textField );
2919 application.SendNotification();
2920 application.Render();
2922 // Nothing is selected
2923 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
2924 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );