2 * Copyright (c) 2021 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";
107 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
109 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
110 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
112 const float RENDER_FRAME_INTERVAL = 16.66f;
114 const unsigned int DEFAULT_FONT_SIZE = 1152u;
115 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
117 const int KEY_RETURN_CODE = 36;
118 const int KEY_A_CODE = 38;
119 const int KEY_D_CODE = 40;
121 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
123 static bool gTextChangedCallBackCalled;
124 static bool gMaxCharactersCallBackCalled;
125 static bool gInputStyleChangedCallbackCalled;
126 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
128 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
130 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
131 Integration::ResourcePointer resource(bitmap);
132 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
135 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
139 LoadBitmapResource( app.GetPlatform(), width, height );
141 Property::Map propertyMap;
142 propertyMap["filename"] = "image.png";
143 propertyMap["width"] = width;
144 propertyMap["height"] = height;
145 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
146 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
147 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
148 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
149 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
150 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
151 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
152 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
156 * Simulate time passed by.
158 * @note this will always process at least 1 frame (1/60 sec)
160 * @param application Test application instance
161 * @param duration Time to pass in milliseconds.
162 * @return The actual time passed in milliseconds
164 static int Wait(ToolkitTestApplication& application, int duration = 0)
168 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
170 application.SendNotification();
171 application.Render(RENDER_FRAME_INTERVAL);
172 time += RENDER_FRAME_INTERVAL;
178 Dali::Integration::Point GetPointDownInside( Vector2& pos )
180 Dali::Integration::Point point;
181 point.SetState( PointState::DOWN );
182 point.SetScreenPosition( pos );
186 Dali::Integration::Point GetPointUpInside( Vector2& pos )
188 Dali::Integration::Point point;
189 point.SetState( PointState::UP );
190 point.SetScreenPosition( pos );
194 struct CallbackFunctor
196 CallbackFunctor(bool* callbackFlag)
197 : mCallbackFlag( callbackFlag )
203 *mCallbackFlag = true;
208 static void TestTextChangedCallback( TextField control )
210 tet_infoline(" TestTextChangedCallback");
212 gTextChangedCallBackCalled = true;
215 static void TestMaxLengthReachedCallback( TextField control )
217 tet_infoline(" TestMaxLengthReachedCallback");
219 gMaxCharactersCallBackCalled = true;
222 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
224 tet_infoline(" TestInputStyleChangedCallback");
226 gInputStyleChangedCallbackCalled = true;
227 gInputStyleMask = mask;
230 // Generate a KeyEvent to send to Core.
231 Integration::KeyEvent GenerateKey( const std::string& keyName,
232 const std::string& logicalKey,
233 const std::string& keyString,
236 unsigned long timeStamp,
237 const Integration::KeyEvent::State& keyState,
238 const std::string& compose = "",
239 const std::string& deviceName = DEFAULT_DEVICE_NAME,
240 const Device::Class::Type& deviceClass = Device::Class::NONE,
241 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
243 return Integration::KeyEvent( keyName,
256 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
258 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
260 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
262 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
264 Property::Value* valueSet = NULL;
265 if ( valueGet.first.type == Property::Key::INDEX )
267 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
271 // Get Key is a string so searching Set Map for a string key
272 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
275 if( NULL != valueSet )
277 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
279 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
282 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
284 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
287 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
289 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
292 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
294 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
297 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
299 Vector2 vector2Get = valueGet.second.Get<Vector2>();
300 Vector2 vector2Set = valueSet->Get<Vector2>();
301 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
304 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
306 Vector4 vector4Get = valueGet.second.Get<Vector4>();
307 Vector4 vector4Set = valueSet->Get<Vector4>();
308 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 );
314 if ( valueGet.first.type == Property::Key::INDEX )
316 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
320 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
332 int UtcDaliToolkitTextFieldConstructorP(void)
334 ToolkitTestApplication application;
335 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
337 DALI_TEST_CHECK( !textField );
341 int UtcDaliToolkitTextFieldNewP(void)
343 ToolkitTestApplication application;
344 tet_infoline(" UtcDaliToolkitTextFieldNewP");
345 TextField textField = TextField::New();
346 DALI_TEST_CHECK( textField );
350 int UtcDaliToolkitTextFieldDownCastP(void)
352 ToolkitTestApplication application;
353 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
354 TextField textField1 = TextField::New();
355 BaseHandle object( textField1 );
357 TextField textField2 = TextField::DownCast( object );
358 DALI_TEST_CHECK( textField2 );
360 TextField textField3 = DownCast< TextField >( object );
361 DALI_TEST_CHECK( textField3 );
365 int UtcDaliToolkitTextFieldDownCastN(void)
367 ToolkitTestApplication application;
368 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
369 BaseHandle uninitializedObject;
370 TextField textField1 = TextField::DownCast( uninitializedObject );
371 DALI_TEST_CHECK( !textField1 );
373 TextField textField2 = DownCast< TextField >( uninitializedObject );
374 DALI_TEST_CHECK( !textField2 );
378 int UtcDaliToolkitTextFieldCopyConstructorP(void)
380 ToolkitTestApplication application;
381 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
382 TextField textField = TextField::New();
383 textField.SetProperty( TextField::Property::TEXT, "Test" );
385 TextField copy( textField );
386 DALI_TEST_CHECK( copy );
387 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
391 int UtcDaliTextFieldMoveConstructor(void)
393 ToolkitTestApplication application;
395 TextField textField = TextField::New();
396 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
397 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
399 TextField moved = std::move( textField );
400 DALI_TEST_CHECK( moved );
401 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
402 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
403 DALI_TEST_CHECK( !textField );
408 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
410 ToolkitTestApplication application;
411 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
412 TextField textField = TextField::New();
413 textField.SetProperty( TextField::Property::TEXT, "Test" );
415 TextField copy = textField;
416 DALI_TEST_CHECK( copy );
417 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
421 int UtcDaliTextFieldMoveAssignment(void)
423 ToolkitTestApplication application;
425 TextField textField = TextField::New();
426 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
427 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
430 moved = std::move( textField );
431 DALI_TEST_CHECK( moved );
432 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
433 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
434 DALI_TEST_CHECK( !textField );
439 int UtcDaliTextFieldNewP(void)
441 ToolkitTestApplication application;
442 tet_infoline(" UtcDaliToolkitTextFieldNewP");
443 TextField textField = TextField::New();
444 DALI_TEST_CHECK( textField );
448 // Positive test case for a method
449 int UtcDaliTextFieldGetPropertyP(void)
451 ToolkitTestApplication application;
452 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
453 TextField field = TextField::New();
454 DALI_TEST_CHECK( field );
456 // Check Property Indices are correct
457 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextField::Property::RENDERING_BACKEND );
458 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
459 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
460 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
461 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
462 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
463 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
464 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
465 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
466 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
467 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
468 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
469 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
470 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
471 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
472 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
473 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
474 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
475 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
476 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
477 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
478 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
479 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
480 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
481 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
482 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
483 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
484 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
485 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
486 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
487 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
488 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
489 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
490 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
491 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
492 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
493 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
494 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
495 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
496 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
497 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
498 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
499 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
500 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
501 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
502 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
503 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
504 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
505 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
506 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
507 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextField::Property::FONT_SIZE_SCALE );
508 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
509 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
510 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
511 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP );
512 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextField::Property::BACKGROUND );
517 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
520 Property::Map imageMap;
521 imageMap[mapKey] =mapValue;
523 field.SetProperty( property , imageMap );
524 Property::Value propValue = field.GetProperty( property );
525 Property::Map* resultMap = propValue.GetMap();
527 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
535 // Positive test case for a method
536 int UtcDaliTextFieldSetPropertyP(void)
538 ToolkitTestApplication application;
539 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
540 TextField field = TextField::New();
541 DALI_TEST_CHECK( field );
542 application.GetScene().Add( field );
544 // Note - we can't check the defaults since the stylesheets are platform-specific
546 // Check the render backend property.
547 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
548 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
550 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
551 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION );
553 // Check text property.
554 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
555 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
557 // Check placeholder text properties.
558 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
559 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
561 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
562 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
564 // Check font properties.
565 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
566 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
568 Property::Map fontStyleMapSet;
569 Property::Map fontStyleMapGet;
570 Property::Value* slantValue = NULL;
572 fontStyleMapSet.Insert( "weight", "bold" );
573 fontStyleMapSet.Insert( "width", "condensed" );
574 fontStyleMapSet.Insert( "slant", "italic" );
575 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 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
582 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
584 field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 2.5f );
585 DALI_TEST_EQUALS( field.GetProperty<float>( DevelTextField::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
586 field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 1.0f );
589 fontStyleMapSet.Clear();
590 fontStyleMapSet.Insert( "weight", "normal" );
591 fontStyleMapSet.Insert( "slant", "oblique" );
592 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
594 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
595 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
596 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
598 fontStyleMapSet.Clear();
599 fontStyleMapSet.Insert( "slant", "roman" );
600 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
601 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
603 // Replace 'roman' for 'normal'.
604 slantValue = fontStyleMapGet.Find( "slant" );
605 if( NULL != slantValue )
607 if( "normal" == slantValue->Get<std::string>() )
609 fontStyleMapGet["slant"] = "roman";
612 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
613 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
615 fontStyleMapSet.Clear();
617 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
618 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
619 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
620 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
622 // Check that the MAX_LENGTH property can be correctly set
623 const int maxNumberOfCharacters = 20;
624 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
625 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
627 // Check exceed policy
628 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
629 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
630 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
631 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
633 // Check that the Alignment properties can be correctly set
634 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
635 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
636 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
637 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
639 // Check text's color property
640 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
641 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
643 // Check placeholder text's color property.
644 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
645 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
647 // Check cursor properties
648 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
649 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
650 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
651 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
653 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
654 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
655 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
656 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
657 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
658 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
659 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
660 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
662 // Check scroll properties.
663 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
664 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
665 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
666 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
668 // Check handle images
669 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
670 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
671 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
672 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
673 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
675 // Check handle images
676 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
677 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
678 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
679 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
680 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
681 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
683 // Check the highlight color
684 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
685 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
687 // Decoration bounding box
688 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
689 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
691 // Check the input method setting
692 Property::Map propertyMap;
693 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
694 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
695 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
696 int inputVariation = 1;
697 propertyMap["PANEL_LAYOUT"] = panelLayout;
698 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
699 propertyMap["BUTTON_ACTION"] = buttonAction;
700 propertyMap["VARIATION"] = inputVariation;
701 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
703 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
705 DALI_TEST_CHECK( value.Get( map ) );
708 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
709 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
712 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
713 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
716 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
717 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
720 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
721 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
723 // Check input color property.
724 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
725 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
727 // Check the enable markup property.
728 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
729 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
730 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
732 // Check input font properties.
733 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
734 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
736 fontStyleMapSet.Clear();
737 fontStyleMapSet.Insert( "weight", "bold" );
738 fontStyleMapSet.Insert( "width", "condensed" );
739 fontStyleMapSet.Insert( "slant", "italic" );
741 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
742 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
743 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
744 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
746 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
747 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
749 // Reset input font style.
750 fontStyleMapSet.Clear();
751 fontStyleMapSet.Insert( "weight", "normal" );
752 fontStyleMapSet.Insert( "slant", "oblique" );
754 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
755 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
756 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
757 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
759 fontStyleMapSet.Clear();
760 fontStyleMapSet.Insert( "slant", "roman" );
762 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
763 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
765 // Replace 'roman' for 'normal'.
766 slantValue = fontStyleMapGet.Find( "slant" );
767 if( NULL != slantValue )
769 if( "normal" == slantValue->Get<std::string>() )
771 fontStyleMapGet["slant"] = "roman";
774 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
775 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
777 fontStyleMapSet.Clear();
779 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
780 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
781 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
782 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
784 Property::Map underlineMapSet;
785 Property::Map underlineMapGet;
787 underlineMapSet.Insert( "enable", true );
788 underlineMapSet.Insert( "color", Color::RED );
789 underlineMapSet.Insert( "height", 1 );
791 // Check the underline property
792 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
794 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
795 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
796 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
798 // Check the input underline property
799 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
800 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
802 // Check the shadow property
803 Property::Map shadowMapSet;
804 Property::Map shadowMapGet;
806 shadowMapSet.Insert( "color", Color::GREEN );
807 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
808 shadowMapSet.Insert( "blurRadius", 3.0f );
810 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
812 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
813 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
814 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
816 // Check the input shadow property
817 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
818 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
820 // Check the emboss property
821 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
822 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
824 // Check the input emboss property
825 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
826 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
828 // Check the outline property
830 // Test string type first
831 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
832 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
833 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
835 // Then test the property map type
836 Property::Map outlineMapSet;
837 Property::Map outlineMapGet;
839 outlineMapSet["color"] = Color::RED;
840 outlineMapSet["width"] = 2.0f;
842 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
844 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
845 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
846 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
848 // Check the input outline property
849 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
850 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
852 // Check the hidden input settings property
853 Property::Map hiddenMapSet;
854 Property::Map hiddenMapGet;
855 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
856 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
857 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
858 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
859 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
861 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
862 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
863 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
865 // Check the pixel size of font
866 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
867 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
869 // Check the enable selection property
870 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
871 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
873 // Check the placeholder property with pixel size
874 Property::Map placeholderPixelSizeMapSet;
875 Property::Map placeholderPixelSizeMapGet;
876 Property::Map placeholderFontstyleMap;
877 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
878 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
879 placeholderPixelSizeMapSet["color"] = Color::BLUE;
880 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
881 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
882 placeholderPixelSizeMapSet["ellipsis"] = true;
884 placeholderFontstyleMap.Insert( "weight", "bold" );
885 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
886 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
888 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
889 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
891 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
892 Property::Map placeholderConversionMap;
893 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
894 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
895 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
896 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
897 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
898 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
900 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
902 // Check the placeholder property with point size
903 Property::Map placeholderMapSet;
904 Property::Map placeholderMapGet;
905 placeholderMapSet["text"] = "Setting Placeholder Text";
906 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
907 placeholderMapSet["color"] = Color::RED;
908 placeholderMapSet["fontFamily"] = "Arial";
909 placeholderMapSet["pointSize"] = 12.0f;
910 placeholderMapSet["ellipsis"] = false;
912 // Check the placeholder font style property
913 placeholderFontstyleMap.Clear();
915 placeholderFontstyleMap.Insert( "weight", "bold" );
916 placeholderFontstyleMap.Insert( "width", "condensed" );
917 placeholderFontstyleMap.Insert( "slant", "italic" );
918 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
919 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
921 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
922 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
924 placeholderConversionMap.Clear();
925 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
926 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
927 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
928 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
929 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
930 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
932 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
935 placeholderFontstyleMap.Clear();
936 placeholderFontstyleMap.Insert( "weight", "normal" );
937 placeholderFontstyleMap.Insert( "slant", "oblique" );
938 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
939 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
941 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
942 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
944 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
945 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
947 placeholderFontstyleMap.Clear();
948 placeholderFontstyleMap.Insert( "slant", "roman" );
949 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
950 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
952 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
954 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
956 placeholderFontstyleMap.Clear();
957 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
958 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
960 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
961 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
962 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
964 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
966 // Check the ellipsis property
967 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
968 field.SetProperty( TextField::Property::ELLIPSIS, true );
969 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
971 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
972 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
974 // Test the ENABLE_GRAB_HANDLE_POPUP property
975 DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
976 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false );
977 DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
979 // Check the background property
980 field.SetProperty( DevelTextField::Property::BACKGROUND, Color::RED );
981 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::BACKGROUND ), Color::RED, TEST_LOCATION );
983 application.SendNotification();
984 application.Render();
989 // Positive Atlas Text Renderer test
990 int utcDaliTextFieldAtlasRenderP(void)
992 ToolkitTestApplication application;
993 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
994 StyleManager styleManager = StyleManager::Get();
995 styleManager.ApplyDefaultTheme();
996 TextField field = TextField::New();
997 DALI_TEST_CHECK( field );
999 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1001 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1003 application.GetScene().Add( field );
1007 // Render some text with the shared atlas backend
1008 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1009 application.SendNotification();
1010 application.Render();
1014 tet_result(TET_FAIL);
1019 // Positive test for the textChanged signal.
1020 int utcDaliTextFieldTextChangedP(void)
1022 ToolkitTestApplication application;
1023 tet_infoline(" utcDaliTextFieldTextChangedP");
1024 TextField field = TextField::New();
1025 DALI_TEST_CHECK( field );
1027 application.GetScene().Add( field );
1029 // connect to the text changed signal.
1030 ConnectionTracker* testTracker = new ConnectionTracker();
1031 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1032 bool textChangedSignal = false;
1033 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1035 gTextChangedCallBackCalled = false;
1036 field.SetProperty( TextField::Property::TEXT, "ABC" );
1037 application.SendNotification();
1038 application.Render();
1039 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1040 DALI_TEST_CHECK( textChangedSignal );
1042 field.SetKeyInputFocus();
1044 gTextChangedCallBackCalled = false;
1045 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1046 application.SendNotification();
1047 application.Render();
1048 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1051 field.SetProperty( TextField::Property::TEXT, "" );
1052 application.SendNotification();
1053 application.Render();
1055 // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1056 gTextChangedCallBackCalled = false;
1057 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1058 application.SendNotification();
1059 application.Render();
1060 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1062 // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1063 gTextChangedCallBackCalled = false;
1064 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1065 application.SendNotification();
1066 application.Render();
1067 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1072 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1074 ToolkitTestApplication application;
1075 tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1076 TextField field = TextField::New();
1077 DALI_TEST_CHECK( field );
1080 application.GetScene().Add( field );
1082 // connect to the text changed signal.
1083 ConnectionTracker* testTracker = new ConnectionTracker();
1084 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1085 bool textChangedSignal = false;
1086 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1089 // get InputMethodContext
1091 InputMethodContext::EventData imfEvent;
1092 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext( field );
1094 field.SetKeyInputFocus();
1095 field.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
1098 gTextChangedCallBackCalled = false;
1099 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1100 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1101 application.SendNotification();
1102 application.Render();
1103 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1104 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1106 gTextChangedCallBackCalled = false;
1107 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1108 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1109 application.SendNotification();
1110 application.Render();
1111 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1112 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호"), TEST_LOCATION );
1114 gTextChangedCallBackCalled = false;
1115 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1116 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1117 application.SendNotification();
1118 application.Render();
1119 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1120 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1122 gTextChangedCallBackCalled = false;
1123 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1124 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1125 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1127 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1128 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1129 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1131 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1132 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1133 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1135 application.SendNotification();
1136 application.Render();
1137 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1138 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1144 // Negative test for the textChanged signal.
1145 int utcDaliTextFieldTextChangedN(void)
1147 ToolkitTestApplication application;
1148 tet_infoline(" utcDaliTextFieldTextChangedN");
1149 TextField field = TextField::New();
1150 DALI_TEST_CHECK( field );
1152 application.GetScene().Add( field );
1154 // connect to the text changed signal.
1155 ConnectionTracker* testTracker = new ConnectionTracker();
1156 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1157 bool textChangedSignal = false;
1158 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1160 gTextChangedCallBackCalled = false;
1161 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1162 application.SendNotification();
1163 application.Render();
1164 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1165 DALI_TEST_CHECK( !textChangedSignal );
1170 // Positive test for Max Characters reached signal.
1171 int utcDaliTextFieldMaxCharactersReachedP(void)
1173 ToolkitTestApplication application;
1174 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1175 TextField field = TextField::New();
1176 DALI_TEST_CHECK( field );
1178 application.GetScene().Add( field );
1180 const int maxNumberOfCharacters = 1;
1181 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1183 field.SetKeyInputFocus();
1185 // connect to the text changed signal.
1186 ConnectionTracker* testTracker = new ConnectionTracker();
1187 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1188 bool maxLengthReachedSignal = false;
1189 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1191 gMaxCharactersCallBackCalled = false;
1193 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1194 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1196 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1197 DALI_TEST_CHECK( maxLengthReachedSignal );
1202 // Negative test for Max Characters reached signal.
1203 int utcDaliTextFieldMaxCharactersReachedN(void)
1205 ToolkitTestApplication application;
1206 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1207 TextField field = TextField::New();
1208 DALI_TEST_CHECK( field );
1210 application.GetScene().Add( field );
1212 const int maxNumberOfCharacters = 3;
1213 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1215 field.SetKeyInputFocus();
1217 // connect to the text changed signal.
1218 ConnectionTracker* testTracker = new ConnectionTracker();
1219 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1220 bool maxLengthReachedSignal = false;
1221 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1223 gMaxCharactersCallBackCalled = false;
1225 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1226 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1228 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1229 DALI_TEST_CHECK( !maxLengthReachedSignal );
1231 application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1233 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1234 DALI_TEST_CHECK( !maxLengthReachedSignal );
1239 int utcDaliTextFieldInputStyleChanged01(void)
1241 // The text-field emits signals when the input style changes. These changes of style are
1242 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1243 // can't be emitted during the size negotiation as the callbacks may update the UI.
1244 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1245 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1246 ToolkitTestApplication application;
1247 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1251 char* pathNamePtr = get_current_dir_name();
1252 const std::string pathName( pathNamePtr );
1253 free( pathNamePtr );
1255 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1256 fontClient.SetDpi( 93u, 93u );
1258 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1259 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1261 TextField field = TextField::New();
1262 DALI_TEST_CHECK( field );
1265 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1266 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1267 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1269 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1270 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1272 // connect to the text changed signal.
1273 ConnectionTracker* testTracker = new ConnectionTracker();
1274 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1275 bool inputStyleChangedSignal = false;
1276 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1278 application.GetScene().Add( field );
1280 // Render and notify
1281 application.SendNotification();
1282 application.Render();
1284 // Executes the idle callbacks added by the text control on the change of input style.
1285 application.RunIdles();
1287 gInputStyleChangedCallbackCalled = false;
1288 gInputStyleMask = TextField::InputStyle::NONE;
1289 inputStyleChangedSignal = false;
1291 // Create a tap event to touch the text field.
1292 TestGenerateTap( application, 18.0f, 25.0f );
1294 // Render and notify
1295 application.SendNotification();
1296 application.Render();
1298 // Executes the idle callbacks added by the text control on the change of input style.
1299 application.RunIdles();
1301 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1302 if( gInputStyleChangedCallbackCalled )
1304 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1306 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1307 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1309 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1310 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1312 DALI_TEST_CHECK( inputStyleChangedSignal );
1314 gInputStyleChangedCallbackCalled = false;
1315 gInputStyleMask = TextField::InputStyle::NONE;
1316 inputStyleChangedSignal = false;
1318 // Create a tap event to touch the text field.
1319 TestGenerateTap( application, 30.0f, 25.0f );
1321 // Render and notify
1322 application.SendNotification();
1323 application.Render();
1325 // Executes the idle callbacks added by the text control on the change of input style.
1326 application.RunIdles();
1328 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1329 DALI_TEST_CHECK( !inputStyleChangedSignal );
1331 gInputStyleChangedCallbackCalled = false;
1332 gInputStyleMask = TextField::InputStyle::NONE;
1333 inputStyleChangedSignal = false;
1335 // Create a tap event to touch the text field.
1336 TestGenerateTap( application, 43.0f, 25.0f );
1338 // Render and notify
1339 application.SendNotification();
1340 application.Render();
1342 // Executes the idle callbacks added by the text control on the change of input style.
1343 application.RunIdles();
1345 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1346 if( gInputStyleChangedCallbackCalled )
1348 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1350 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1351 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1353 DALI_TEST_CHECK( inputStyleChangedSignal );
1355 gInputStyleChangedCallbackCalled = false;
1356 gInputStyleMask = TextField::InputStyle::NONE;
1357 inputStyleChangedSignal = false;
1359 // Create a tap event to touch the text field.
1360 TestGenerateTap( application, 88.0f, 25.0f );
1362 // Render and notify
1363 application.SendNotification();
1364 application.Render();
1366 // Executes the idle callbacks added by the text control on the change of input style.
1367 application.RunIdles();
1369 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1370 if( gInputStyleChangedCallbackCalled )
1372 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1374 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1375 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1377 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1379 Property::Map fontStyleMapSet;
1380 fontStyleMapSet.Insert( "weight", "bold" );
1382 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1383 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1385 DALI_TEST_CHECK( inputStyleChangedSignal );
1387 gInputStyleChangedCallbackCalled = false;
1388 gInputStyleMask = TextField::InputStyle::NONE;
1389 inputStyleChangedSignal = false;
1391 // Create a tap event to touch the text field.
1392 TestGenerateTap( application, 115.0f, 25.0f );
1394 // Render and notify
1395 application.SendNotification();
1396 application.Render();
1398 // Executes the idle callbacks added by the text control on the change of input style.
1399 application.RunIdles();
1401 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1402 DALI_TEST_CHECK( !inputStyleChangedSignal );
1404 gInputStyleChangedCallbackCalled = false;
1405 gInputStyleMask = TextField::InputStyle::NONE;
1406 inputStyleChangedSignal = false;
1408 // Create a tap event to touch the text field.
1409 TestGenerateTap( application, 164.0f, 25.0f );
1411 // Render and notify
1412 application.SendNotification();
1413 application.Render();
1415 // Executes the idle callbacks added by the text control on the change of input style.
1416 application.RunIdles();
1418 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1419 if( gInputStyleChangedCallbackCalled )
1421 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1423 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1424 DALI_TEST_CHECK( style.empty() );
1426 DALI_TEST_CHECK( inputStyleChangedSignal );
1428 gInputStyleChangedCallbackCalled = false;
1429 gInputStyleMask = TextField::InputStyle::NONE;
1430 inputStyleChangedSignal = false;
1432 // Create a tap event to touch the text field.
1433 TestGenerateTap( application, 191.0f, 25.0f );
1435 // Render and notify
1436 application.SendNotification();
1437 application.Render();
1439 // Executes the idle callbacks added by the text control on the change of input style.
1440 application.RunIdles();
1442 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1443 DALI_TEST_CHECK( !inputStyleChangedSignal );
1448 int utcDaliTextFieldInputStyleChanged02(void)
1450 // The text-field emits signals when the input style changes. These changes of style are
1451 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1452 // can't be emitted during the size negotiation as the callbacks may update the UI.
1453 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1454 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1455 ToolkitTestApplication application;
1456 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1460 char* pathNamePtr = get_current_dir_name();
1461 const std::string pathName( pathNamePtr );
1462 free( pathNamePtr );
1464 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1465 fontClient.SetDpi( 93u, 93u );
1467 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1468 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1470 TextField field = TextField::New();
1471 DALI_TEST_CHECK( field );
1473 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1474 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1475 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1477 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1478 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>" );
1480 // connect to the text changed signal.
1481 ConnectionTracker* testTracker = new ConnectionTracker();
1482 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1483 bool inputStyleChangedSignal = false;
1484 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1486 application.GetScene().Add( field );
1488 // Render and notify
1489 application.SendNotification();
1490 application.Render();
1492 // Executes the idle callbacks added by the text control on the change of input style.
1493 application.RunIdles();
1495 gInputStyleChangedCallbackCalled = false;
1496 gInputStyleMask = TextField::InputStyle::NONE;
1497 inputStyleChangedSignal = false;
1499 // Create a tap event to touch the text field.
1500 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1501 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1503 // Render and notify
1504 application.SendNotification();
1505 application.Render();
1507 // Executes the idle callbacks added by the text control on the change of input style.
1508 application.RunIdles();
1510 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1511 if( gInputStyleChangedCallbackCalled )
1513 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1514 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1515 TextField::InputStyle::POINT_SIZE |
1516 TextField::InputStyle::COLOR ),
1519 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1520 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1522 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1523 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1525 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1526 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1528 DALI_TEST_CHECK( inputStyleChangedSignal );
1530 gInputStyleChangedCallbackCalled = false;
1531 gInputStyleMask = TextField::InputStyle::NONE;
1532 inputStyleChangedSignal = false;
1534 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1536 // Render and notify
1537 application.SendNotification();
1538 application.Render();
1540 // Executes the idle callbacks added by the text control on the change of input style.
1541 application.RunIdles();
1543 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1544 if( gInputStyleChangedCallbackCalled )
1546 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1547 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1550 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1551 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1553 DALI_TEST_CHECK( inputStyleChangedSignal );
1555 gInputStyleChangedCallbackCalled = false;
1556 gInputStyleMask = TextField::InputStyle::NONE;
1557 inputStyleChangedSignal = false;
1559 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1561 // Render and notify
1562 application.SendNotification();
1563 application.Render();
1565 // Executes the idle callbacks added by the text control on the change of input style.
1566 application.RunIdles();
1568 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1569 DALI_TEST_CHECK( !inputStyleChangedSignal );
1571 gInputStyleChangedCallbackCalled = false;
1572 gInputStyleMask = TextField::InputStyle::NONE;
1573 inputStyleChangedSignal = false;
1575 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1577 // Render and notify
1578 application.SendNotification();
1579 application.Render();
1581 // Executes the idle callbacks added by the text control on the change of input style.
1582 application.RunIdles();
1584 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1585 if( gInputStyleChangedCallbackCalled )
1587 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1588 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1591 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1592 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1594 DALI_TEST_CHECK( inputStyleChangedSignal );
1596 gInputStyleChangedCallbackCalled = false;
1597 gInputStyleMask = TextField::InputStyle::NONE;
1598 inputStyleChangedSignal = false;
1600 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1602 Property::Map fontStyleMapSet;
1603 fontStyleMapSet.Insert( "weight", "thin" );
1604 fontStyleMapSet.Insert( "width", "condensed" );
1605 fontStyleMapSet.Insert( "slant", "italic" );
1607 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1608 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1610 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1611 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1612 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1613 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1615 // Render and notify
1616 application.SendNotification();
1617 application.Render();
1619 // Executes the idle callbacks added by the text control on the change of input style.
1620 application.RunIdles();
1622 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1623 DALI_TEST_CHECK( !inputStyleChangedSignal );
1625 // Create a tap event to touch the text field.
1626 TestGenerateTap( application, 63.0f, 25.0f, 300 );
1628 // Render and notify
1629 application.SendNotification();
1630 application.Render();
1632 // Executes the idle callbacks added by the text control on the change of input style.
1633 application.RunIdles();
1635 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1636 if( gInputStyleChangedCallbackCalled )
1638 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1639 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1640 TextField::InputStyle::POINT_SIZE |
1641 TextField::InputStyle::FONT_STYLE |
1642 TextField::InputStyle::UNDERLINE |
1643 TextField::InputStyle::SHADOW |
1644 TextField::InputStyle::EMBOSS |
1645 TextField::InputStyle::OUTLINE ),
1648 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1649 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1651 DALI_TEST_CHECK( inputStyleChangedSignal );
1656 int utcDaliTextFieldEvent01(void)
1658 ToolkitTestApplication application;
1659 tet_infoline(" utcDaliTextFieldEvent01");
1661 // Creates a tap event. After creating a tap event the text field should
1662 // have the focus and add text with key events should be possible.
1664 TextField field = TextField::New();
1665 DALI_TEST_CHECK( field );
1667 application.GetScene().Add( field );
1669 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1670 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1671 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1673 // Render and notify
1674 application.SendNotification();
1675 application.Render();
1677 // Avoid a crash when core load gl resources.
1678 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1680 // Render and notify
1681 application.SendNotification();
1682 application.Render();
1684 // Add a key event but as the text field has not the focus it should do nothing.
1685 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1687 // Render and notify
1688 application.SendNotification();
1689 application.Render();
1691 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1693 // Create a tap event to touch the text field.
1694 TestGenerateTap( application, 150.0f, 25.0f );
1696 // Render and notify
1697 application.SendNotification();
1698 application.Render();
1700 // Pressing delete key should be fine even if there is no text in TextField.
1701 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 ) );
1702 // Render and notify
1703 application.SendNotification();
1704 application.Render();
1706 // Now the text field has the focus, so it can handle the key events.
1707 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1708 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1710 // Render and notify
1711 application.SendNotification();
1712 application.Render();
1714 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1716 // Create a second text field and send key events to it.
1717 TextField field2 = TextField::New();
1719 field2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1720 field2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1721 field2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1722 field2.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
1724 application.GetScene().Add( field2 );
1726 // Render and notify
1727 application.SendNotification();
1728 application.Render();
1730 // Create a tap event on the second text field.
1731 TestGenerateTap( application, 150.0f, 125.0f );
1733 // Render and notify
1734 application.SendNotification();
1735 application.Render();
1737 // The second text field has the focus. It should handle the key events.
1738 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1739 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1741 // Render and notify
1742 application.SendNotification();
1743 application.Render();
1745 // Check the text has been added to the second text field.
1746 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1751 int utcDaliTextFieldEvent02(void)
1753 ToolkitTestApplication application;
1754 tet_infoline(" utcDaliTextFieldEvent02");
1756 // Checks if the right number of actors are created.
1758 TextField field = TextField::New();
1759 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1760 DALI_TEST_CHECK( field );
1761 LoadMarkerImages(application, field);
1763 application.GetScene().Add( field );
1765 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1766 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1767 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1769 // Avoid a crash when core load gl resources.
1770 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1772 // Render and notify
1773 application.SendNotification();
1774 application.Render();
1776 // Check there are the expected number of children ( stencil ).
1777 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1779 Actor stencil = field.GetChildAt( 0u );
1780 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1782 // Create a tap event to touch the text field.
1783 TestGenerateTap( application, 150.0f, 25.0f, 300 );
1785 // Render and notify
1786 application.SendNotification();
1787 application.Render();
1789 Actor layer = field.GetChildAt( 1u );
1790 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1791 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1793 // Now the text field has the focus, so it can handle the key events.
1794 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1795 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1797 // Render and notify
1798 application.SendNotification();
1799 application.Render();
1801 // Checks the cursor and the renderer have been created.
1802 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1803 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1805 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1806 DALI_TEST_CHECK( cursor );
1808 // The offscreen root actor has a container with all the actors which contain the text renderers.
1809 Actor container = stencil.GetChildAt( 0u );
1810 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1812 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1813 DALI_TEST_CHECK( renderer );
1816 // Move the cursor and check the position changes.
1817 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1818 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1820 // Render and notify
1821 application.SendNotification();
1822 application.Render();
1824 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1825 DALI_TEST_CHECK( position2.x < position1.x );
1827 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1829 // Render and notify
1830 application.SendNotification();
1831 application.Render();
1833 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1834 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1837 // Move the cursor to the first position.
1838 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1839 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1841 // Render and notify
1842 application.SendNotification();
1843 application.Render();
1845 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1847 // Send some taps and check the cursor positions.
1849 // Try to tap at the beginning.
1850 TestGenerateTap( application, 1.0f, 25.0f, 900 );
1852 // Render and notify
1853 application.SendNotification();
1854 application.Render();
1856 // Cursor position should be the same than position1.
1857 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1859 DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
1861 // Tap away from the start position.
1862 TestGenerateTap( application, 16.0f, 25.0f, 1500 );
1864 // Render and notify
1865 application.SendNotification();
1866 application.Render();
1868 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1870 DALI_TEST_CHECK( position6.x > position5.x );
1872 // Remove all the text.
1873 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1874 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1875 field.SetProperty( TextField::Property::TEXT, "" );
1877 // Render and notify
1878 application.SendNotification();
1879 application.Render();
1881 // Cursor position should be the same than position2.
1882 Vector3 position7 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1884 DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
1886 // Should not be a renderer.
1887 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1889 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1890 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1891 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1893 application.SendNotification();
1894 application.Render();
1896 // There are renderer and decorator layer
1897 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1902 int utcDaliTextFieldEvent03(void)
1904 ToolkitTestApplication application;
1905 tet_infoline(" utcDaliTextFieldEvent03");
1907 // Checks if the highlight actor is created.
1909 TextField field = TextField::New();
1910 DALI_TEST_CHECK( field );
1912 application.GetScene().Add( field );
1914 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1915 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1916 field.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1917 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1918 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1920 // Avoid a crash when core load gl resources.
1921 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1922 LoadMarkerImages(application, field);
1924 // Render and notify
1925 application.SendNotification();
1926 application.Render();
1928 // Tap first to get the focus.
1929 TestGenerateTap( application, 3.0f, 25.0f );
1931 // Render and notify
1932 application.SendNotification();
1933 application.Render();
1935 // Double tap to select a word.
1936 TestGenerateTap( application, 3.0f, 25.0f );
1938 // Render and notify
1939 application.SendNotification();
1940 application.Render();
1942 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1943 Actor stencil = field.GetChildAt( 0u );
1945 // The highlight actor is drawn first, so is the first actor in the list
1946 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1947 DALI_TEST_CHECK( highlight );
1949 // The offscreen root actor has a container with all the actors which contain the text renderers.
1950 Actor container = stencil.GetChildAt( 1u );
1951 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1953 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1954 DALI_TEST_CHECK( renderer );
1960 int utcDaliTextFieldEvent04(void)
1962 ToolkitTestApplication application;
1963 tet_infoline(" utcDaliTextFieldEvent04");
1965 // Checks if the highlight actor is created.
1967 TextField field = TextField::New();
1968 DALI_TEST_CHECK( field );
1969 application.GetScene().Add( field );
1970 LoadMarkerImages(application, field);
1971 // Render and notify
1972 application.SendNotification();
1973 application.Render();
1975 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1976 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1977 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1978 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1979 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1981 // Avoid a crash when core load gl resources.
1982 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1983 // Render and notify
1984 application.SendNotification();
1985 application.Render();
1987 // Create a tap event to touch the text field.
1988 TestGenerateTap( application, 150.0f, 25.0f );
1989 // Render and notify
1990 application.SendNotification();
1991 application.Render();
1994 // Tap first to get the focus.
1995 TestGenerateTap( application, 1.0f, 25.0f );
1997 // Render and notify
1998 application.SendNotification();
1999 application.Render();
2001 // Double tap to select a word.
2002 TestGenerateTap( application, 1.0f, 25.0f );
2004 // Render and notify
2005 application.SendNotification();
2006 application.Render();
2009 TestGenerateTap( application, 0.0f, 40.0f );
2013 int utcDaliTextFieldEvent05(void)
2015 ToolkitTestApplication application;
2016 tet_infoline(" utcDaliTextFieldEvent05");
2018 // Checks dragging of cursor/grab handle
2020 TextField field = TextField::New();
2021 DALI_TEST_CHECK( field );
2022 application.GetScene().Add( field );
2023 LoadMarkerImages(application, field);
2024 // Render and notify
2025 application.SendNotification();
2026 application.Render();
2028 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2029 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2030 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2031 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2032 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2034 // Avoid a crash when core load gl resources.
2035 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2036 // Render and notify
2037 application.SendNotification();
2038 application.Render();
2040 // Create a tap event to touch the text field.
2041 TestGenerateTap( application, 150.0f, 25.0f );
2042 // Render and notify
2043 application.SendNotification();
2044 application.Render();
2046 // Tap first to get the focus.
2047 TestGenerateTap( application, 1.0f, 25.0f );
2049 // Render and notify
2050 application.SendNotification();
2051 application.Render();
2053 // Double tap to select a word.
2054 TestGenerateTap( application, 1.0f, 25.0f );
2056 // Render and notify
2057 application.SendNotification();
2058 application.Render();
2060 Actor stencil = field.GetChildAt( 1u );
2064 int utcDaliTextFieldEvent06(void)
2066 ToolkitTestApplication application;
2067 tet_infoline(" utcDaliTextFieldEvent06");
2069 // Checks Longpress when in edit mode
2071 TextField field = TextField::New();
2072 DALI_TEST_CHECK( field );
2073 application.GetScene().Add( field );
2074 LoadMarkerImages(application, field);
2075 // Render and notify
2076 application.SendNotification();
2077 application.Render();
2079 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2080 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2081 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2082 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2083 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2085 // Avoid a crash when core load gl resources.
2086 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2087 // Render and notify
2088 application.SendNotification();
2089 application.Render();
2091 // Create a tap event to touch the text field.
2092 TestGenerateTap( application, 150.0f, 25.0f );
2093 // Render and notify
2094 application.SendNotification();
2095 application.Render();
2098 // Tap first to get the focus.
2099 TestGenerateTap( application, 1.0f, 25.0f );
2101 // Render and notify
2102 application.SendNotification();
2103 application.Render();
2106 TestGenerateLongPress(application, 1.0f, 25.0f);
2108 // Render and notify
2109 application.SendNotification();
2110 application.Render();
2115 int utcDaliTextFieldEvent07(void)
2117 ToolkitTestApplication application;
2118 tet_infoline(" utcDaliTextFieldEvent07");
2120 // Checks Longpress to start edit mode
2122 TextField field = TextField::New();
2123 DALI_TEST_CHECK( field );
2124 application.GetScene().Add( field );
2125 LoadMarkerImages(application, field);
2126 // Render and notify
2127 application.SendNotification();
2128 application.Render();
2130 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2131 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2132 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2133 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2134 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2135 Property::Map propertyMap;
2136 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2137 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2139 // Avoid a crash when core load gl resources.
2140 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2141 // Render and notify
2142 application.SendNotification();
2143 application.Render();
2146 TestGenerateLongPress(application, 1.0f, 25.0f);
2148 // Render and notify
2149 application.SendNotification();
2150 application.Render();
2155 int utcDaliTextFieldEvent08(void)
2157 ToolkitTestApplication application;
2158 tet_infoline(" utcDaliTextFieldEvent08");
2160 Dali::Clipboard clipboard = Clipboard::Get();
2161 clipboard.SetItem("testTextFieldEvent");
2163 // Checks Longpress when only place holder text
2165 TextField field = TextField::New();
2166 DALI_TEST_CHECK( field );
2167 application.GetScene().Add( field );
2168 LoadMarkerImages(application, field);
2169 // Render and notify
2170 application.SendNotification();
2171 application.Render();
2173 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2174 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2175 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2176 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2177 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2179 // Avoid a crash when core load gl resources.
2180 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2181 // Render and notify
2182 application.SendNotification();
2183 application.Render();
2186 TestGenerateLongPress( application, 1.0f, 25.0f, 20 );
2188 // Render and notify
2189 application.SendNotification();
2190 application.Render();
2192 Wait(application, 500);
2194 TestEndLongPress( application, 1.0f, 25.0f, 520 );
2197 TestGenerateLongPress( application, 1.0f, 25.0f, 600 );
2199 // Render and notify
2200 application.Render();
2202 Wait(application, 500);
2204 Integration::Scene stage = application.GetScene();
2205 Layer layer = stage.GetRootLayer();
2206 Actor actor = layer.FindChildByName("optionPaste");
2210 Vector3 worldPosition = actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION );
2211 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2212 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2214 Dali::Integration::TouchEvent event;
2215 event = Dali::Integration::TouchEvent();
2216 event.AddPoint( GetPointDownInside( position ) );
2217 application.ProcessEvent( event );
2219 event = Dali::Integration::TouchEvent();
2220 event.AddPoint( GetPointUpInside( position ) );
2221 application.ProcessEvent( event );
2223 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2228 int utcDaliTextFieldEvent09(void)
2230 ToolkitTestApplication application;
2231 tet_infoline(" utcDaliTextFieldEvent09");
2233 TextField field = TextField::New();
2234 DALI_TEST_CHECK( field );
2235 application.GetScene().Add( field );
2236 LoadMarkerImages(application, field);
2237 // Render and notify
2238 application.SendNotification();
2239 application.Render();
2241 field.SetProperty( TextField::Property::TEXT, "Hello" );
2242 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2243 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2244 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2245 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2247 // Avoid a crash when core load gl resources.
2248 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2250 // Create a tap event to touch the text field.
2251 TestGenerateTap( application, 150.0f, 25.0f );
2252 application.SendNotification();
2253 application.Render();
2256 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2257 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2258 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2259 application.SendNotification();
2260 application.Render();
2262 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2263 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2264 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2265 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2266 application.SendNotification();
2267 application.Render();
2269 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2270 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2271 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2272 for( unsigned int index = 0u; index < 5u; ++index )
2274 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2275 application.SendNotification();
2276 application.Render();
2279 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2280 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2281 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2282 for( unsigned int index = 0u; index < 5u; ++index )
2284 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2285 application.SendNotification();
2286 application.Render();
2289 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2290 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2291 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2292 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2293 application.SendNotification();
2294 application.Render();
2295 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2296 application.SendNotification();
2297 application.Render();
2299 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2300 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2301 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2302 application.SendNotification();
2303 application.Render();
2305 Property::Map mapGet;
2306 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2307 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2308 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2313 int utcDaliTextFieldStyleWhilstSelected(void)
2315 ToolkitTestApplication application;
2316 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2318 // Change font and styles whilst text is selected whilst word selected
2320 TextField field = TextField::New();
2321 DALI_TEST_CHECK( field );
2322 application.GetScene().Add( field );
2323 LoadMarkerImages(application, field);
2324 // Render and notify
2325 application.SendNotification();
2326 application.Render();
2328 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2329 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2330 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2331 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2332 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2334 // Avoid a crash when core load gl resources.
2335 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2336 // Render and notify
2337 application.SendNotification();
2338 application.Render();
2340 // Create a tap event to touch the text field.
2341 TestGenerateTap( application, 150.0f, 25.0f );
2342 // Render and notify
2343 application.SendNotification();
2344 application.Render();
2347 // Tap first to get the focus.
2348 TestGenerateTap( application, 1.0f, 25.0f );
2350 // Render and notify
2351 application.SendNotification();
2352 application.Render();
2354 // Double tap to select a word.
2355 TestGenerateTap( application, 1.0f, 25.0f );
2357 // Render and notify
2358 application.SendNotification();
2359 application.Render();
2361 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2362 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2364 Property::Map fontStyleMapSet;
2365 Property::Map fontStyleMapGet;
2367 fontStyleMapSet.Insert( "weight", "bold" );
2368 fontStyleMapSet.Insert( "slant", "italic" );
2369 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2371 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2372 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2373 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2375 fontStyleMapSet.Clear();
2376 fontStyleMapSet.Insert( "width", "expanded" );
2377 fontStyleMapSet.Insert( "slant", "italic" );
2378 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2380 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2381 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2382 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2384 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2385 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2387 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2388 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2390 fontStyleMapSet.Clear();
2391 fontStyleMapSet.Insert( "weight", "bold" );
2392 fontStyleMapSet.Insert( "slant", "italic" );
2394 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2396 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2397 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2398 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2400 fontStyleMapSet.Clear();
2401 fontStyleMapSet.Insert( "width", "expanded" );
2403 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2405 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2406 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2407 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2409 // Press Escape to increase coverage
2410 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2411 application.SendNotification();
2412 application.Render();
2414 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2419 int utcDaliTextFieldEscKeyLoseFocus(void)
2421 ToolkitTestApplication application;
2422 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2424 // Creates a tap event. After creating a tap event the text field should
2425 // have the focus and add text with key events should be possible.
2427 TextField field = TextField::New();
2428 DALI_TEST_CHECK( field );
2430 application.GetScene().Add( field );
2432 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2433 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2434 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2436 // Avoid a crash when core load gl resources.
2437 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2439 // Render and notify
2440 application.SendNotification();
2441 application.Render();
2443 // Add a key event but as the text field has not the focus it should do nothing.
2444 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2445 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2447 // Render and notify
2448 application.SendNotification();
2449 application.Render();
2451 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2453 // Create a tap event to touch the text field.
2454 TestGenerateTap( application, 150.0f, 25.0f );
2456 // Render and notify
2457 application.SendNotification();
2458 application.Render();
2460 // Now the text field has the focus, so it can handle the key events.
2461 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2462 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2463 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2464 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2466 // Render and notify
2467 application.SendNotification();
2468 application.Render();
2470 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2472 // Generate a Esc key event. The text field should lose the focus.
2473 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2474 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2476 // Render and notify
2477 application.SendNotification();
2478 application.Render();
2480 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2482 // No more text should be introduced
2483 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2484 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2486 // Render and notify
2487 application.SendNotification();
2488 application.Render();
2490 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2495 int utcDaliTextFieldSomeSpecialKeys(void)
2497 ToolkitTestApplication application;
2498 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2500 // Checks some special keys when the text is selected.
2502 TextField field = TextField::New();
2503 DALI_TEST_CHECK( field );
2504 application.GetScene().Add( field );
2505 LoadMarkerImages(application, field);
2506 // Render and notify
2507 application.SendNotification();
2508 application.Render();
2510 const std::string longText( "This is a long text for the size of the text-field." );
2512 field.SetProperty( TextField::Property::TEXT, longText );
2513 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2514 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2515 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2516 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2518 // Avoid a crash when core load gl resources.
2519 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2520 // Render and notify
2521 application.SendNotification();
2522 application.Render();
2524 // Create a tap event to touch the text field.
2525 TestGenerateTap( application, 150.0f, 25.0f );
2527 // Render and notify
2528 application.SendNotification();
2529 application.Render();
2531 // Tap first to get the focus.
2532 TestGenerateTap( application, 1.0f, 25.0f );
2534 // Render and notify
2535 application.SendNotification();
2536 application.Render();
2538 // Double tap to select a word.
2539 TestGenerateTap( application, 1.0f, 25.0f );
2541 // Render and notify
2542 application.SendNotification();
2543 application.Render();
2545 // Generate a Esc key event. The text field should lose the focus.
2546 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2547 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2549 // Render and notify
2550 application.SendNotification();
2551 application.Render();
2553 // Generate a Esc key event. The text field should lose the focus.
2554 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2555 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2557 // Render and notify
2558 application.SendNotification();
2559 application.Render();
2561 // Generate a Esc key event. The text field should lose the focus.
2562 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2563 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2565 // Render and notify
2566 application.SendNotification();
2567 application.Render();
2569 // The text shouldn't be deleted.
2570 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2575 int utcDaliTextFieldSizeUpdate(void)
2577 ToolkitTestApplication application;
2578 tet_infoline("utcDaliTextFieldSizeUpdate");
2580 // Checks some special keys when the text is selected.
2581 TextField field = TextField::New();
2582 DALI_TEST_CHECK( field );
2583 application.GetScene().Add( field );
2585 float previousHeight = 0.0f;
2586 float currentHeight = 0.0f;
2587 const float fieldWidth = 1920.0f;
2590 // "ㅁ" is bigger then "ኢ"
2591 field.SetProperty( Actor::Property::SIZE, Vector2( fieldWidth ,10.0f ) );
2592 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2593 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2595 field.SetProperty( TextField::Property::TEXT, "ኢ");
2596 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2597 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2599 field.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2600 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2602 application.SendNotification();
2603 application.Render();
2605 previousHeight = field.GetHeightForWidth( fieldWidth );
2606 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2608 // Add another script characters ( glyph height is defferent )
2609 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2610 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2612 application.SendNotification();
2613 application.Render();
2615 currentHeight = field.GetHeightForWidth( fieldWidth );
2616 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2617 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2622 int utcDaliTextFieldExtremlyLargePointSize(void)
2624 ToolkitTestApplication application;
2625 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2627 TextField field = TextField::New();
2629 field.SetProperty( TextField::Property::TEXT, "Text" );
2630 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2631 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2632 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2633 application.GetScene().Add( field );
2637 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2638 application.SendNotification();
2639 DALI_TEST_CHECK( field );
2643 tet_result(TET_FAIL);
2648 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2650 ToolkitTestApplication application;
2651 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2652 TextField field = TextField::New();
2653 DALI_TEST_CHECK( field );
2654 application.GetScene().Add( field );
2656 Property::Map fontStyleMapGet;
2658 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2660 Property::Value* weightValue = NULL;
2661 Property::Value* widthValue = NULL;
2662 Property::Value* slantValue = NULL;
2663 weightValue = fontStyleMapGet.Find( "weight" );
2664 widthValue = fontStyleMapGet.Find( "width" );
2665 slantValue = fontStyleMapGet.Find( "slant" );
2666 DALI_TEST_CHECK( !weightValue );
2667 DALI_TEST_CHECK( !widthValue );
2668 DALI_TEST_CHECK( !slantValue );
2673 int UtcDaliTextFieldSettingPlaceholder(void)
2675 ToolkitTestApplication application;
2676 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
2678 TextField field = TextField::New();
2679 DALI_TEST_CHECK( field );
2680 application.GetScene().Add( field );
2682 // Check the placeholder property with pixel size
2683 Property::Map placeholderPixelSizeMapSet;
2684 Property::Map placeholderPixelSizeMapGet;
2685 Property::Map placeholderFontstyleMap;
2686 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2687 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2688 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
2689 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2690 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
2691 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
2693 placeholderFontstyleMap.Insert( "weight", "bold" );
2694 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2695 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
2697 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2698 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
2699 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
2701 // Check the placeholder property with point size
2702 Property::Map placeholderMapSet;
2703 Property::Map placeholderMapGet;
2704 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2705 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2706 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
2707 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2708 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
2709 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
2711 // Check the placeholder font style property
2712 placeholderFontstyleMap.Clear();
2714 placeholderFontstyleMap.Insert( "weight", "bold" );
2715 placeholderFontstyleMap.Insert( "width", "condensed" );
2716 placeholderFontstyleMap.Insert( "slant", "italic" );
2717 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2718 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2720 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2721 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2722 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2724 // Reset font style.
2725 placeholderFontstyleMap.Clear();
2726 placeholderFontstyleMap.Insert( "weight", "normal" );
2727 placeholderFontstyleMap.Insert( "slant", "oblique" );
2728 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2729 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2731 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2732 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2733 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2735 placeholderFontstyleMap.Clear();
2736 placeholderFontstyleMap.Insert( "slant", "roman" );
2737 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2738 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2740 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2742 placeholderFontstyleMap.Clear();
2743 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2745 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2746 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2747 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2748 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2753 int UtcDaliTextFieldSetPaddingProperty(void)
2755 ToolkitTestApplication application;
2756 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
2758 TextField field = TextField::New();
2759 DALI_TEST_CHECK( field );
2760 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2761 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2762 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2763 application.GetScene().Add( field );
2765 application.SendNotification();
2766 application.Render();
2768 Vector3 originalSize = field.GetNaturalSize();
2770 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2772 application.SendNotification();
2773 application.Render();
2775 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2777 Vector3 paddingAddedSize = field.GetNaturalSize();
2779 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2781 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2786 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
2788 ToolkitTestApplication application;
2789 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
2791 TextField field = TextField::New();
2792 DALI_TEST_CHECK( field );
2793 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2794 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2795 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2796 application.GetScene().Add( field );
2798 application.SendNotification();
2799 application.Render();
2801 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2802 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2804 // Check the enable shift selection property
2805 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
2806 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2808 application.SendNotification();
2809 application.Render();
2814 int UtcDaliTextFieldEnableGrabHandleProperty(void)
2816 ToolkitTestApplication application;
2817 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
2819 TextField field = TextField::New();
2820 DALI_TEST_CHECK( field );
2821 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2822 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2823 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2824 application.GetScene().Add( field );
2826 application.SendNotification();
2827 application.Render();
2829 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2830 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2832 // Check the enable grab handle property
2833 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
2834 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2836 application.SendNotification();
2837 application.Render();
2842 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
2844 ToolkitTestApplication application;
2845 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
2847 TextField field = TextField::New();
2848 DALI_TEST_CHECK( field );
2849 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2850 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2851 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2852 application.GetScene().Add( field );
2854 application.SendNotification();
2855 application.Render();
2857 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2858 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2860 // Check the match system language direction property
2861 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2862 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2864 application.SendNotification();
2865 application.Render();
2870 int utcDaliTextFieldLayoutDirectionCoverage(void)
2872 ToolkitTestApplication application;
2873 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
2875 // Creates a tap event. After creating a tap event the text field should
2876 // have the focus and add text with key events should be possible.
2877 TextField field = TextField::New();
2878 DALI_TEST_CHECK( field );
2880 application.GetScene().Add( field );
2882 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2883 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2884 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2886 // Avoid a crash when core load gl resources.
2887 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2889 // Render and notify
2890 application.SendNotification();
2891 application.Render();
2893 // init direction for coverage
2894 // Set horizontal alignment END
2895 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2897 // Create a tap event to touch the text field.
2898 TestGenerateTap( application, 150.0f, 25.0f );
2900 // Render and notify
2901 application.SendNotification();
2902 application.Render();
2904 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
2905 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2906 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
2908 // Set horizontal alignment BEGIN
2909 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
2911 // Create a tap event to touch the text field.
2912 TestGenerateTap( application, 150.0f, 25.0f );
2914 // Render and notify
2915 application.SendNotification();
2916 application.Render();
2918 // Set horizontal alignment CENTER
2919 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
2921 // Create a tap event to touch the text field.
2922 TestGenerateTap( application, 150.0f, 25.0f );
2924 // Render and notify
2925 application.SendNotification();
2926 application.Render();
2928 // Set horizontal alignment END
2929 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2931 // Create a tap event to touch the text field.
2932 TestGenerateTap( application, 150.0f, 25.0f );
2934 // Render and notify
2935 application.SendNotification();
2936 application.Render();
2938 // Generate a Esc key event. The text field should lose the focus.
2939 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2940 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2942 // Render and notify
2943 application.SendNotification();
2944 application.Render();
2946 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2951 int UtcDaliTextFieldGetInputMethodContext(void)
2953 ToolkitTestApplication application;
2954 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
2956 TextField field = TextField::New();
2957 DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );
2962 int UtcDaliTextFieldSelectWholeText(void)
2964 ToolkitTestApplication application;
2965 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
2967 TextField textField = TextField::New();
2969 application.GetScene().Add( textField );
2971 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2972 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2973 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2975 // Avoid a crash when core load gl resources.
2976 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2978 application.SendNotification();
2979 application.Render();
2981 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2983 DevelTextField::SelectWholeText( textField );
2985 application.SendNotification();
2986 application.Render();
2988 // Nothing should have been selected. The number of children is still 1
2989 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2991 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
2993 application.SendNotification();
2994 application.Render();
2996 DevelTextField::SelectWholeText( textField );
2998 application.SendNotification();
2999 application.Render();
3001 // Should be 2 children, the stencil and the layer
3002 DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
3004 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3005 Actor stencil = textField.GetChildAt( 0u );
3007 // The highlight actor is drawn first, so is the first actor in the list
3008 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3009 DALI_TEST_CHECK( highlight );
3014 int UtcDaliTextFieldSelectNone(void)
3016 ToolkitTestApplication application;
3017 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3019 TextField textField = TextField::New();
3021 application.GetScene().Add( textField );
3023 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3024 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3025 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3027 // Avoid a crash when core load gl resources.
3028 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3030 application.SendNotification();
3031 application.Render();
3033 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3035 application.SendNotification();
3036 application.Render();
3038 // Nothing is selected
3039 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3040 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3042 DevelTextField::SelectWholeText( textField );
3044 application.SendNotification();
3045 application.Render();
3047 // whole text is selected
3048 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3049 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3051 DevelTextField::SelectNone( textField );
3053 application.SendNotification();
3054 application.Render();
3056 // Nothing is selected
3057 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3058 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3063 int UtcDaliTextFieldSelectRange(void)
3065 ToolkitTestApplication application;
3066 tet_infoline(" UtcDaliTextFieldSelectRange ");
3068 TextField textField = TextField::New();
3070 application.GetScene().Add( textField );
3072 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3073 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3074 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3076 // Avoid a crash when core load gl resources.
3077 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3079 application.SendNotification();
3080 application.Render();
3082 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3084 application.SendNotification();
3085 application.Render();
3087 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 0);
3088 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 5);
3090 // Hello is selected
3091 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3092 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3094 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3095 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3097 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 6);
3098 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 11);
3100 // world is selected
3101 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3102 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3104 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3105 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3110 int UtcDaliTextFieldEnableEditing(void)
3112 ToolkitTestApplication application;
3113 tet_infoline(" UtcDaliTextFieldEnableEditing ");
3115 TextField textField = TextField::New();
3117 application.GetScene().Add( textField );
3119 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3120 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3121 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3123 // Avoid a crash when core load gl resources.
3124 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3126 application.SendNotification();
3127 application.Render();
3129 textField.SetKeyInputFocus();
3130 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, false );
3131 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3133 // Render and notify
3134 application.SendNotification();
3135 application.Render();
3137 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3138 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3141 textField.SetKeyInputFocus();
3142 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
3143 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3145 // Render and notify
3146 application.SendNotification();
3147 application.Render();
3149 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3150 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3155 int UtcDaliToolkitTextFieldFontSizeScale(void)
3157 ToolkitTestApplication application;
3158 tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
3160 TextField textField = TextField::New();
3161 textField.SetProperty( TextField::Property::POINT_SIZE, 30.f );
3162 textField.SetProperty( TextField::Property::TEXT, "Test" );
3163 Vector3 nonScaledSize = textField.GetNaturalSize();
3165 TextField textFieldScaled = TextField::New();
3166 textFieldScaled.SetProperty( TextField::Property::POINT_SIZE, 15.f );
3167 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3168 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3169 Vector3 scaledSize = textFieldScaled.GetNaturalSize();
3171 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3173 textField.SetProperty( TextField::Property::PIXEL_SIZE, 30.f );
3174 textField.SetProperty( TextField::Property::TEXT, "Test" );
3175 nonScaledSize = textField.GetNaturalSize();
3177 textFieldScaled.SetProperty( TextField::Property::PIXEL_SIZE, 15.f );
3178 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3179 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3180 scaledSize = textFieldScaled.GetNaturalSize();
3182 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3187 int UtcDaliTextFieldPrimaryCursorPosition(void)
3189 ToolkitTestApplication application;
3190 tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
3192 TextField textField = TextField::New();
3194 application.GetScene().Add( textField );
3196 textField.SetProperty( TextField::Property::TEXT, "ABCEF");
3197 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3198 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3199 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3201 // Avoid a crash when core load gl resources.
3202 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3204 textField.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
3205 application.SendNotification();
3206 application.Render();
3208 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3210 // Render and notify
3211 application.SendNotification();
3212 application.Render();
3214 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3215 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );