2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali/public-api/rendering/renderer.h>
23 #include <dali/integration-api/events/key-event-integ.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/devel-api/adaptor-framework/key-devel.h>
27 #include <dali/devel-api/text-abstraction/font-client.h>
28 #include <dali-toolkit-test-suite-utils.h>
29 #include <dali-toolkit/dali-toolkit.h>
30 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
31 #include <dali-toolkit/devel-api/text/rendering-backend.h>
32 #include "toolkit-clipboard.h"
35 using namespace Toolkit;
37 void dali_textfield_startup(void)
39 test_return_value = TET_UNDEF;
42 void dali_textfield_cleanup(void)
44 test_return_value = TET_PASS;
50 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
51 const char* const PROPERTY_NAME_TEXT = "text";
52 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
53 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
54 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
55 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
56 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
57 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
58 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
59 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
60 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
61 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
62 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
63 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
64 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
65 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
66 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
67 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
68 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
69 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
70 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
71 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
72 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
73 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
80 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
81 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
82 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
83 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
84 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
85 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
86 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
88 const char* const PROPERTY_NAME_UNDERLINE = "underline";
89 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
90 const char* const PROPERTY_NAME_SHADOW = "shadow";
91 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
92 const char* const PROPERTY_NAME_EMBOSS = "emboss";
93 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
94 const char* const PROPERTY_NAME_OUTLINE = "outline";
95 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
97 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
98 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
99 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
100 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
101 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
102 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
103 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
104 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
105 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
106 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
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 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1038 DALI_TEST_CHECK( textChangedSignal );
1040 application.SendNotification();
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 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1049 field.SetProperty( TextField::Property::TEXT, "" );
1051 // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1052 gTextChangedCallBackCalled = false;
1053 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1054 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1056 // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1057 gTextChangedCallBackCalled = false;
1058 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1059 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1064 // Negative test for the textChanged signal.
1065 int utcDaliTextFieldTextChangedN(void)
1067 ToolkitTestApplication application;
1068 tet_infoline(" utcDaliTextFieldTextChangedN");
1069 TextField field = TextField::New();
1070 DALI_TEST_CHECK( field );
1072 application.GetScene().Add( field );
1074 // connect to the text changed signal.
1075 ConnectionTracker* testTracker = new ConnectionTracker();
1076 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1077 bool textChangedSignal = false;
1078 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1080 gTextChangedCallBackCalled = false;
1081 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1082 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1083 DALI_TEST_CHECK( !textChangedSignal );
1088 // Positive test for Max Characters reached signal.
1089 int utcDaliTextFieldMaxCharactersReachedP(void)
1091 ToolkitTestApplication application;
1092 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1093 TextField field = TextField::New();
1094 DALI_TEST_CHECK( field );
1096 application.GetScene().Add( field );
1098 const int maxNumberOfCharacters = 1;
1099 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1101 field.SetKeyInputFocus();
1103 // connect to the text changed signal.
1104 ConnectionTracker* testTracker = new ConnectionTracker();
1105 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1106 bool maxLengthReachedSignal = false;
1107 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1109 gMaxCharactersCallBackCalled = false;
1111 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1112 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1114 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1115 DALI_TEST_CHECK( maxLengthReachedSignal );
1120 // Negative test for Max Characters reached signal.
1121 int utcDaliTextFieldMaxCharactersReachedN(void)
1123 ToolkitTestApplication application;
1124 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1125 TextField field = TextField::New();
1126 DALI_TEST_CHECK( field );
1128 application.GetScene().Add( field );
1130 const int maxNumberOfCharacters = 3;
1131 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1133 field.SetKeyInputFocus();
1135 // connect to the text changed signal.
1136 ConnectionTracker* testTracker = new ConnectionTracker();
1137 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1138 bool maxLengthReachedSignal = false;
1139 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1141 gMaxCharactersCallBackCalled = false;
1143 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1144 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1146 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1147 DALI_TEST_CHECK( !maxLengthReachedSignal );
1149 application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1151 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1152 DALI_TEST_CHECK( !maxLengthReachedSignal );
1157 int utcDaliTextFieldInputStyleChanged01(void)
1159 // The text-field emits signals when the input style changes. These changes of style are
1160 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1161 // can't be emitted during the size negotiation as the callbacks may update the UI.
1162 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1163 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1164 ToolkitTestApplication application;
1165 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1169 char* pathNamePtr = get_current_dir_name();
1170 const std::string pathName( pathNamePtr );
1171 free( pathNamePtr );
1173 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1174 fontClient.SetDpi( 93u, 93u );
1176 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1177 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1179 TextField field = TextField::New();
1180 DALI_TEST_CHECK( field );
1183 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1184 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1185 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1187 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1188 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1190 // connect to the text changed signal.
1191 ConnectionTracker* testTracker = new ConnectionTracker();
1192 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1193 bool inputStyleChangedSignal = false;
1194 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1196 application.GetScene().Add( field );
1198 // Render and notify
1199 application.SendNotification();
1200 application.Render();
1202 // Executes the idle callbacks added by the text control on the change of input style.
1203 application.RunIdles();
1205 gInputStyleChangedCallbackCalled = false;
1206 gInputStyleMask = TextField::InputStyle::NONE;
1207 inputStyleChangedSignal = false;
1209 // Create a tap event to touch the text field.
1210 TestGenerateTap( application, 18.0f, 25.0f );
1212 // Render and notify
1213 application.SendNotification();
1214 application.Render();
1216 // Executes the idle callbacks added by the text control on the change of input style.
1217 application.RunIdles();
1219 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1220 if( gInputStyleChangedCallbackCalled )
1222 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1224 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1225 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1227 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1228 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1230 DALI_TEST_CHECK( inputStyleChangedSignal );
1232 gInputStyleChangedCallbackCalled = false;
1233 gInputStyleMask = TextField::InputStyle::NONE;
1234 inputStyleChangedSignal = false;
1236 // Create a tap event to touch the text field.
1237 TestGenerateTap( application, 30.0f, 25.0f );
1239 // Render and notify
1240 application.SendNotification();
1241 application.Render();
1243 // Executes the idle callbacks added by the text control on the change of input style.
1244 application.RunIdles();
1246 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1247 DALI_TEST_CHECK( !inputStyleChangedSignal );
1249 gInputStyleChangedCallbackCalled = false;
1250 gInputStyleMask = TextField::InputStyle::NONE;
1251 inputStyleChangedSignal = false;
1253 // Create a tap event to touch the text field.
1254 TestGenerateTap( application, 43.0f, 25.0f );
1256 // Render and notify
1257 application.SendNotification();
1258 application.Render();
1260 // Executes the idle callbacks added by the text control on the change of input style.
1261 application.RunIdles();
1263 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1264 if( gInputStyleChangedCallbackCalled )
1266 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1268 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1269 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1271 DALI_TEST_CHECK( inputStyleChangedSignal );
1273 gInputStyleChangedCallbackCalled = false;
1274 gInputStyleMask = TextField::InputStyle::NONE;
1275 inputStyleChangedSignal = false;
1277 // Create a tap event to touch the text field.
1278 TestGenerateTap( application, 88.0f, 25.0f );
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 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1288 if( gInputStyleChangedCallbackCalled )
1290 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1292 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1293 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1295 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1297 Property::Map fontStyleMapSet;
1298 fontStyleMapSet.Insert( "weight", "bold" );
1300 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1301 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1303 DALI_TEST_CHECK( inputStyleChangedSignal );
1305 gInputStyleChangedCallbackCalled = false;
1306 gInputStyleMask = TextField::InputStyle::NONE;
1307 inputStyleChangedSignal = false;
1309 // Create a tap event to touch the text field.
1310 TestGenerateTap( application, 115.0f, 25.0f );
1312 // Render and notify
1313 application.SendNotification();
1314 application.Render();
1316 // Executes the idle callbacks added by the text control on the change of input style.
1317 application.RunIdles();
1319 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1320 DALI_TEST_CHECK( !inputStyleChangedSignal );
1322 gInputStyleChangedCallbackCalled = false;
1323 gInputStyleMask = TextField::InputStyle::NONE;
1324 inputStyleChangedSignal = false;
1326 // Create a tap event to touch the text field.
1327 TestGenerateTap( application, 164.0f, 25.0f );
1329 // Render and notify
1330 application.SendNotification();
1331 application.Render();
1333 // Executes the idle callbacks added by the text control on the change of input style.
1334 application.RunIdles();
1336 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1337 if( gInputStyleChangedCallbackCalled )
1339 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1341 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1342 DALI_TEST_CHECK( style.empty() );
1344 DALI_TEST_CHECK( inputStyleChangedSignal );
1346 gInputStyleChangedCallbackCalled = false;
1347 gInputStyleMask = TextField::InputStyle::NONE;
1348 inputStyleChangedSignal = false;
1350 // Create a tap event to touch the text field.
1351 TestGenerateTap( application, 191.0f, 25.0f );
1353 // Render and notify
1354 application.SendNotification();
1355 application.Render();
1357 // Executes the idle callbacks added by the text control on the change of input style.
1358 application.RunIdles();
1360 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1361 DALI_TEST_CHECK( !inputStyleChangedSignal );
1366 int utcDaliTextFieldInputStyleChanged02(void)
1368 // The text-field emits signals when the input style changes. These changes of style are
1369 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1370 // can't be emitted during the size negotiation as the callbacks may update the UI.
1371 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1372 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1373 ToolkitTestApplication application;
1374 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1378 char* pathNamePtr = get_current_dir_name();
1379 const std::string pathName( pathNamePtr );
1380 free( pathNamePtr );
1382 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1383 fontClient.SetDpi( 93u, 93u );
1385 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1386 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1388 TextField field = TextField::New();
1389 DALI_TEST_CHECK( field );
1391 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1392 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1393 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1395 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1396 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>" );
1398 // connect to the text changed signal.
1399 ConnectionTracker* testTracker = new ConnectionTracker();
1400 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1401 bool inputStyleChangedSignal = false;
1402 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1404 application.GetScene().Add( field );
1406 // Render and notify
1407 application.SendNotification();
1408 application.Render();
1410 // Executes the idle callbacks added by the text control on the change of input style.
1411 application.RunIdles();
1413 gInputStyleChangedCallbackCalled = false;
1414 gInputStyleMask = TextField::InputStyle::NONE;
1415 inputStyleChangedSignal = false;
1417 // Create a tap event to touch the text field.
1418 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1419 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1421 // Render and notify
1422 application.SendNotification();
1423 application.Render();
1425 // Executes the idle callbacks added by the text control on the change of input style.
1426 application.RunIdles();
1428 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1429 if( gInputStyleChangedCallbackCalled )
1431 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1432 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1433 TextField::InputStyle::POINT_SIZE |
1434 TextField::InputStyle::COLOR ),
1437 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1438 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1440 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1441 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1443 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1444 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1446 DALI_TEST_CHECK( inputStyleChangedSignal );
1448 gInputStyleChangedCallbackCalled = false;
1449 gInputStyleMask = TextField::InputStyle::NONE;
1450 inputStyleChangedSignal = false;
1452 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1454 // Render and notify
1455 application.SendNotification();
1456 application.Render();
1458 // Executes the idle callbacks added by the text control on the change of input style.
1459 application.RunIdles();
1461 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1462 if( gInputStyleChangedCallbackCalled )
1464 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1465 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1468 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1469 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1471 DALI_TEST_CHECK( inputStyleChangedSignal );
1473 gInputStyleChangedCallbackCalled = false;
1474 gInputStyleMask = TextField::InputStyle::NONE;
1475 inputStyleChangedSignal = false;
1477 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1479 // Render and notify
1480 application.SendNotification();
1481 application.Render();
1483 // Executes the idle callbacks added by the text control on the change of input style.
1484 application.RunIdles();
1486 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1487 DALI_TEST_CHECK( !inputStyleChangedSignal );
1489 gInputStyleChangedCallbackCalled = false;
1490 gInputStyleMask = TextField::InputStyle::NONE;
1491 inputStyleChangedSignal = false;
1493 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1495 // Render and notify
1496 application.SendNotification();
1497 application.Render();
1499 // Executes the idle callbacks added by the text control on the change of input style.
1500 application.RunIdles();
1502 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1503 if( gInputStyleChangedCallbackCalled )
1505 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1506 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1509 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1510 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1512 DALI_TEST_CHECK( inputStyleChangedSignal );
1514 gInputStyleChangedCallbackCalled = false;
1515 gInputStyleMask = TextField::InputStyle::NONE;
1516 inputStyleChangedSignal = false;
1518 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1520 Property::Map fontStyleMapSet;
1521 fontStyleMapSet.Insert( "weight", "thin" );
1522 fontStyleMapSet.Insert( "width", "condensed" );
1523 fontStyleMapSet.Insert( "slant", "italic" );
1525 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1526 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1528 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1529 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1530 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1531 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1533 // Render and notify
1534 application.SendNotification();
1535 application.Render();
1537 // Executes the idle callbacks added by the text control on the change of input style.
1538 application.RunIdles();
1540 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1541 DALI_TEST_CHECK( !inputStyleChangedSignal );
1543 // Create a tap event to touch the text field.
1544 TestGenerateTap( application, 63.0f, 25.0f, 300 );
1546 // Render and notify
1547 application.SendNotification();
1548 application.Render();
1550 // Executes the idle callbacks added by the text control on the change of input style.
1551 application.RunIdles();
1553 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1554 if( gInputStyleChangedCallbackCalled )
1556 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1557 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1558 TextField::InputStyle::POINT_SIZE |
1559 TextField::InputStyle::FONT_STYLE |
1560 TextField::InputStyle::UNDERLINE |
1561 TextField::InputStyle::SHADOW |
1562 TextField::InputStyle::EMBOSS |
1563 TextField::InputStyle::OUTLINE ),
1566 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1567 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1569 DALI_TEST_CHECK( inputStyleChangedSignal );
1574 int utcDaliTextFieldEvent01(void)
1576 ToolkitTestApplication application;
1577 tet_infoline(" utcDaliTextFieldEvent01");
1579 // Creates a tap event. After creating a tap event the text field should
1580 // have the focus and add text with key events should be possible.
1582 TextField field = TextField::New();
1583 DALI_TEST_CHECK( field );
1585 application.GetScene().Add( field );
1587 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1588 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1589 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1591 // Render and notify
1592 application.SendNotification();
1593 application.Render();
1595 // Avoid a crash when core load gl resources.
1596 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1598 // Render and notify
1599 application.SendNotification();
1600 application.Render();
1602 // Add a key event but as the text field has not the focus it should do nothing.
1603 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1605 // Render and notify
1606 application.SendNotification();
1607 application.Render();
1609 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1611 // Create a tap event to touch the text field.
1612 TestGenerateTap( application, 150.0f, 25.0f );
1614 // Render and notify
1615 application.SendNotification();
1616 application.Render();
1618 // Pressing delete key should be fine even if there is no text in TextField.
1619 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 ) );
1620 // Render and notify
1621 application.SendNotification();
1622 application.Render();
1624 // Now the text field has the focus, so it can handle the key events.
1625 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1626 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1628 // Render and notify
1629 application.SendNotification();
1630 application.Render();
1632 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1634 // Create a second text field and send key events to it.
1635 TextField field2 = TextField::New();
1637 field2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1638 field2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1639 field2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1640 field2.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
1642 application.GetScene().Add( field2 );
1644 // Render and notify
1645 application.SendNotification();
1646 application.Render();
1648 // Create a tap event on the second text field.
1649 TestGenerateTap( application, 150.0f, 125.0f );
1651 // Render and notify
1652 application.SendNotification();
1653 application.Render();
1655 // The second text field has the focus. It should handle the key events.
1656 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1657 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1659 // Render and notify
1660 application.SendNotification();
1661 application.Render();
1663 // Check the text has been added to the second text field.
1664 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1669 int utcDaliTextFieldEvent02(void)
1671 ToolkitTestApplication application;
1672 tet_infoline(" utcDaliTextFieldEvent02");
1674 // Checks if the right number of actors are created.
1676 TextField field = TextField::New();
1677 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1678 DALI_TEST_CHECK( field );
1679 LoadMarkerImages(application, field);
1681 application.GetScene().Add( field );
1683 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1684 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1685 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1687 // Avoid a crash when core load gl resources.
1688 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1690 // Render and notify
1691 application.SendNotification();
1692 application.Render();
1694 // Check there are the expected number of children ( stencil ).
1695 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1697 Actor stencil = field.GetChildAt( 0u );
1698 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1700 // Create a tap event to touch the text field.
1701 TestGenerateTap( application, 150.0f, 25.0f, 300 );
1703 // Render and notify
1704 application.SendNotification();
1705 application.Render();
1707 Actor layer = field.GetChildAt( 1u );
1708 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1709 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1711 // Now the text field has the focus, so it can handle the key events.
1712 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1713 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1715 // Render and notify
1716 application.SendNotification();
1717 application.Render();
1719 // Checks the cursor and the renderer have been created.
1720 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1721 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1723 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1724 DALI_TEST_CHECK( cursor );
1726 // The offscreen root actor has a container with all the actors which contain the text renderers.
1727 Actor container = stencil.GetChildAt( 0u );
1728 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1730 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1731 DALI_TEST_CHECK( renderer );
1734 // Move the cursor and check the position changes.
1735 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1736 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1738 // Render and notify
1739 application.SendNotification();
1740 application.Render();
1742 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1743 DALI_TEST_CHECK( position2.x < position1.x );
1745 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1747 // Render and notify
1748 application.SendNotification();
1749 application.Render();
1751 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1752 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1755 // Move the cursor to the first position.
1756 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1757 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1759 // Render and notify
1760 application.SendNotification();
1761 application.Render();
1763 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1765 // Send some taps and check the cursor positions.
1767 // Try to tap at the beginning.
1768 TestGenerateTap( application, 1.0f, 25.0f, 900 );
1770 // Render and notify
1771 application.SendNotification();
1772 application.Render();
1774 // Cursor position should be the same than position1.
1775 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1777 DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
1779 // Tap away from the start position.
1780 TestGenerateTap( application, 16.0f, 25.0f, 1500 );
1782 // Render and notify
1783 application.SendNotification();
1784 application.Render();
1786 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1788 DALI_TEST_CHECK( position6.x > position5.x );
1790 // Remove all the text.
1791 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1792 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1793 field.SetProperty( TextField::Property::TEXT, "" );
1795 // Render and notify
1796 application.SendNotification();
1797 application.Render();
1799 // Cursor position should be the same than position2.
1800 Vector3 position7 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1802 DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
1804 // Should not be a renderer.
1805 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1807 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1808 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1809 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1811 application.SendNotification();
1812 application.Render();
1814 // There are renderer and decorator layer
1815 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1820 int utcDaliTextFieldEvent03(void)
1822 ToolkitTestApplication application;
1823 tet_infoline(" utcDaliTextFieldEvent03");
1825 // Checks if the highlight actor is created.
1827 TextField field = TextField::New();
1828 DALI_TEST_CHECK( field );
1830 application.GetScene().Add( field );
1832 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1833 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1834 field.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1835 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1836 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1838 // Avoid a crash when core load gl resources.
1839 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1840 LoadMarkerImages(application, field);
1842 // Render and notify
1843 application.SendNotification();
1844 application.Render();
1846 // Tap first to get the focus.
1847 TestGenerateTap( application, 3.0f, 25.0f );
1849 // Render and notify
1850 application.SendNotification();
1851 application.Render();
1853 // Double tap to select a word.
1854 TestGenerateTap( application, 3.0f, 25.0f );
1856 // Render and notify
1857 application.SendNotification();
1858 application.Render();
1860 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1861 Actor stencil = field.GetChildAt( 0u );
1863 // The highlight actor is drawn first, so is the first actor in the list
1864 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1865 DALI_TEST_CHECK( highlight );
1867 // The offscreen root actor has a container with all the actors which contain the text renderers.
1868 Actor container = stencil.GetChildAt( 1u );
1869 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1871 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1872 DALI_TEST_CHECK( renderer );
1878 int utcDaliTextFieldEvent04(void)
1880 ToolkitTestApplication application;
1881 tet_infoline(" utcDaliTextFieldEvent04");
1883 // Checks if the highlight actor is created.
1885 TextField field = TextField::New();
1886 DALI_TEST_CHECK( field );
1887 application.GetScene().Add( field );
1888 LoadMarkerImages(application, field);
1889 // Render and notify
1890 application.SendNotification();
1891 application.Render();
1893 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1894 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1895 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1896 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1897 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1899 // Avoid a crash when core load gl resources.
1900 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1901 // Render and notify
1902 application.SendNotification();
1903 application.Render();
1905 // Create a tap event to touch the text field.
1906 TestGenerateTap( application, 150.0f, 25.0f );
1907 // Render and notify
1908 application.SendNotification();
1909 application.Render();
1912 // Tap first to get the focus.
1913 TestGenerateTap( application, 1.0f, 25.0f );
1915 // Render and notify
1916 application.SendNotification();
1917 application.Render();
1919 // Double tap to select a word.
1920 TestGenerateTap( application, 1.0f, 25.0f );
1922 // Render and notify
1923 application.SendNotification();
1924 application.Render();
1927 TestGenerateTap( application, 0.0f, 40.0f );
1931 int utcDaliTextFieldEvent05(void)
1933 ToolkitTestApplication application;
1934 tet_infoline(" utcDaliTextFieldEvent05");
1936 // Checks dragging of cursor/grab handle
1938 TextField field = TextField::New();
1939 DALI_TEST_CHECK( field );
1940 application.GetScene().Add( field );
1941 LoadMarkerImages(application, field);
1942 // Render and notify
1943 application.SendNotification();
1944 application.Render();
1946 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1947 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1948 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1949 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1950 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1952 // Avoid a crash when core load gl resources.
1953 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1954 // Render and notify
1955 application.SendNotification();
1956 application.Render();
1958 // Create a tap event to touch the text field.
1959 TestGenerateTap( application, 150.0f, 25.0f );
1960 // Render and notify
1961 application.SendNotification();
1962 application.Render();
1964 // Tap first to get the focus.
1965 TestGenerateTap( application, 1.0f, 25.0f );
1967 // Render and notify
1968 application.SendNotification();
1969 application.Render();
1971 // Double tap to select a word.
1972 TestGenerateTap( application, 1.0f, 25.0f );
1974 // Render and notify
1975 application.SendNotification();
1976 application.Render();
1978 Actor stencil = field.GetChildAt( 1u );
1982 int utcDaliTextFieldEvent06(void)
1984 ToolkitTestApplication application;
1985 tet_infoline(" utcDaliTextFieldEvent06");
1987 // Checks Longpress when in edit mode
1989 TextField field = TextField::New();
1990 DALI_TEST_CHECK( field );
1991 application.GetScene().Add( field );
1992 LoadMarkerImages(application, field);
1993 // Render and notify
1994 application.SendNotification();
1995 application.Render();
1997 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1998 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1999 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2000 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2001 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2003 // Avoid a crash when core load gl resources.
2004 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2005 // Render and notify
2006 application.SendNotification();
2007 application.Render();
2009 // Create a tap event to touch the text field.
2010 TestGenerateTap( application, 150.0f, 25.0f );
2011 // Render and notify
2012 application.SendNotification();
2013 application.Render();
2016 // Tap first to get the focus.
2017 TestGenerateTap( application, 1.0f, 25.0f );
2019 // Render and notify
2020 application.SendNotification();
2021 application.Render();
2024 TestGenerateLongPress(application, 1.0f, 25.0f);
2026 // Render and notify
2027 application.SendNotification();
2028 application.Render();
2033 int utcDaliTextFieldEvent07(void)
2035 ToolkitTestApplication application;
2036 tet_infoline(" utcDaliTextFieldEvent07");
2038 // Checks Longpress to start edit mode
2040 TextField field = TextField::New();
2041 DALI_TEST_CHECK( field );
2042 application.GetScene().Add( field );
2043 LoadMarkerImages(application, field);
2044 // Render and notify
2045 application.SendNotification();
2046 application.Render();
2048 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2049 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2050 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2051 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2052 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2053 Property::Map propertyMap;
2054 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2055 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2057 // Avoid a crash when core load gl resources.
2058 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2059 // Render and notify
2060 application.SendNotification();
2061 application.Render();
2064 TestGenerateLongPress(application, 1.0f, 25.0f);
2066 // Render and notify
2067 application.SendNotification();
2068 application.Render();
2073 int utcDaliTextFieldEvent08(void)
2075 ToolkitTestApplication application;
2076 tet_infoline(" utcDaliTextFieldEvent08");
2078 Dali::Clipboard clipboard = Clipboard::Get();
2079 clipboard.SetItem("testTextFieldEvent");
2081 // Checks Longpress when only place holder text
2083 TextField field = TextField::New();
2084 DALI_TEST_CHECK( field );
2085 application.GetScene().Add( field );
2086 LoadMarkerImages(application, field);
2087 // Render and notify
2088 application.SendNotification();
2089 application.Render();
2091 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2092 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2093 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2094 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2095 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2097 // Avoid a crash when core load gl resources.
2098 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2099 // Render and notify
2100 application.SendNotification();
2101 application.Render();
2104 TestGenerateLongPress( application, 1.0f, 25.0f, 20 );
2106 // Render and notify
2107 application.SendNotification();
2108 application.Render();
2110 Wait(application, 500);
2112 TestEndLongPress( application, 1.0f, 25.0f, 520 );
2115 TestGenerateLongPress( application, 1.0f, 25.0f, 600 );
2117 // Render and notify
2118 application.Render();
2120 Wait(application, 500);
2122 Integration::Scene stage = application.GetScene();
2123 Layer layer = stage.GetRootLayer();
2124 Actor actor = layer.FindChildByName("optionPaste");
2128 Vector3 worldPosition = actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION );
2129 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2130 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2132 Dali::Integration::TouchEvent event;
2133 event = Dali::Integration::TouchEvent();
2134 event.AddPoint( GetPointDownInside( position ) );
2135 application.ProcessEvent( event );
2137 event = Dali::Integration::TouchEvent();
2138 event.AddPoint( GetPointUpInside( position ) );
2139 application.ProcessEvent( event );
2141 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2146 int utcDaliTextFieldEvent09(void)
2148 ToolkitTestApplication application;
2149 tet_infoline(" utcDaliTextFieldEvent09");
2151 TextField field = TextField::New();
2152 DALI_TEST_CHECK( field );
2153 application.GetScene().Add( field );
2154 LoadMarkerImages(application, field);
2155 // Render and notify
2156 application.SendNotification();
2157 application.Render();
2159 field.SetProperty( TextField::Property::TEXT, "Hello" );
2160 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2161 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2162 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2163 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2165 // Avoid a crash when core load gl resources.
2166 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2168 // Create a tap event to touch the text field.
2169 TestGenerateTap( application, 150.0f, 25.0f );
2170 application.SendNotification();
2171 application.Render();
2174 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2175 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2176 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2177 application.SendNotification();
2178 application.Render();
2180 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2181 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2182 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2183 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2184 application.SendNotification();
2185 application.Render();
2187 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2188 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2189 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2190 for( unsigned int index = 0u; index < 5u; ++index )
2192 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2193 application.SendNotification();
2194 application.Render();
2197 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2198 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2199 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2200 for( unsigned int index = 0u; index < 5u; ++index )
2202 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2203 application.SendNotification();
2204 application.Render();
2207 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2208 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2209 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2210 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2211 application.SendNotification();
2212 application.Render();
2213 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2214 application.SendNotification();
2215 application.Render();
2217 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2218 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2219 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2220 application.SendNotification();
2221 application.Render();
2223 Property::Map mapGet;
2224 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2225 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2226 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2231 int utcDaliTextFieldStyleWhilstSelected(void)
2233 ToolkitTestApplication application;
2234 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2236 // Change font and styles whilst text is selected whilst word selected
2238 TextField field = TextField::New();
2239 DALI_TEST_CHECK( field );
2240 application.GetScene().Add( field );
2241 LoadMarkerImages(application, field);
2242 // Render and notify
2243 application.SendNotification();
2244 application.Render();
2246 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2247 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2248 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2249 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2250 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2252 // Avoid a crash when core load gl resources.
2253 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2254 // Render and notify
2255 application.SendNotification();
2256 application.Render();
2258 // Create a tap event to touch the text field.
2259 TestGenerateTap( application, 150.0f, 25.0f );
2260 // Render and notify
2261 application.SendNotification();
2262 application.Render();
2265 // Tap first to get the focus.
2266 TestGenerateTap( application, 1.0f, 25.0f );
2268 // Render and notify
2269 application.SendNotification();
2270 application.Render();
2272 // Double tap to select a word.
2273 TestGenerateTap( application, 1.0f, 25.0f );
2275 // Render and notify
2276 application.SendNotification();
2277 application.Render();
2279 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2280 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2282 Property::Map fontStyleMapSet;
2283 Property::Map fontStyleMapGet;
2285 fontStyleMapSet.Insert( "weight", "bold" );
2286 fontStyleMapSet.Insert( "slant", "italic" );
2287 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2289 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2290 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2291 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2293 fontStyleMapSet.Clear();
2294 fontStyleMapSet.Insert( "width", "expanded" );
2295 fontStyleMapSet.Insert( "slant", "italic" );
2296 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2298 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2299 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2300 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2302 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2303 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2305 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2306 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2308 fontStyleMapSet.Clear();
2309 fontStyleMapSet.Insert( "weight", "bold" );
2310 fontStyleMapSet.Insert( "slant", "italic" );
2312 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2314 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2315 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2316 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2318 fontStyleMapSet.Clear();
2319 fontStyleMapSet.Insert( "width", "expanded" );
2321 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2323 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2324 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2325 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2327 // Press Escape to increase coverage
2328 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2329 application.SendNotification();
2330 application.Render();
2332 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2337 int utcDaliTextFieldEscKeyLoseFocus(void)
2339 ToolkitTestApplication application;
2340 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2342 // Creates a tap event. After creating a tap event the text field should
2343 // have the focus and add text with key events should be possible.
2345 TextField field = TextField::New();
2346 DALI_TEST_CHECK( field );
2348 application.GetScene().Add( field );
2350 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2351 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2352 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2354 // Avoid a crash when core load gl resources.
2355 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2357 // Render and notify
2358 application.SendNotification();
2359 application.Render();
2361 // Add a key event but as the text field has not the focus it should do nothing.
2362 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2363 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2365 // Render and notify
2366 application.SendNotification();
2367 application.Render();
2369 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2371 // Create a tap event to touch the text field.
2372 TestGenerateTap( application, 150.0f, 25.0f );
2374 // Render and notify
2375 application.SendNotification();
2376 application.Render();
2378 // Now the text field has the focus, so it can handle the key events.
2379 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2380 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2381 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2382 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2384 // Render and notify
2385 application.SendNotification();
2386 application.Render();
2388 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2390 // Generate a Esc key event. The text field should lose the focus.
2391 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2392 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2394 // Render and notify
2395 application.SendNotification();
2396 application.Render();
2398 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2400 // No more text should be introduced
2401 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2402 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2404 // Render and notify
2405 application.SendNotification();
2406 application.Render();
2408 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2413 int utcDaliTextFieldSomeSpecialKeys(void)
2415 ToolkitTestApplication application;
2416 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2418 // Checks some special keys when the text is selected.
2420 TextField field = TextField::New();
2421 DALI_TEST_CHECK( field );
2422 application.GetScene().Add( field );
2423 LoadMarkerImages(application, field);
2424 // Render and notify
2425 application.SendNotification();
2426 application.Render();
2428 const std::string longText( "This is a long text for the size of the text-field." );
2430 field.SetProperty( TextField::Property::TEXT, longText );
2431 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
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 );
2438 // Render and notify
2439 application.SendNotification();
2440 application.Render();
2442 // Create a tap event to touch the text field.
2443 TestGenerateTap( application, 150.0f, 25.0f );
2445 // Render and notify
2446 application.SendNotification();
2447 application.Render();
2449 // Tap first to get the focus.
2450 TestGenerateTap( application, 1.0f, 25.0f );
2452 // Render and notify
2453 application.SendNotification();
2454 application.Render();
2456 // Double tap to select a word.
2457 TestGenerateTap( application, 1.0f, 25.0f );
2459 // Render and notify
2460 application.SendNotification();
2461 application.Render();
2463 // Generate a Esc key event. The text field should lose the focus.
2464 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2465 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2467 // Render and notify
2468 application.SendNotification();
2469 application.Render();
2471 // Generate a Esc key event. The text field should lose the focus.
2472 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2473 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2475 // Render and notify
2476 application.SendNotification();
2477 application.Render();
2479 // Generate a Esc key event. The text field should lose the focus.
2480 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2481 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2483 // Render and notify
2484 application.SendNotification();
2485 application.Render();
2487 // The text shouldn't be deleted.
2488 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2493 int utcDaliTextFieldSizeUpdate(void)
2495 ToolkitTestApplication application;
2496 tet_infoline("utcDaliTextFieldSizeUpdate");
2498 // Checks some special keys when the text is selected.
2499 TextField field = TextField::New();
2500 DALI_TEST_CHECK( field );
2501 application.GetScene().Add( field );
2503 float previousHeight = 0.0f;
2504 float currentHeight = 0.0f;
2505 const float fieldWidth = 1920.0f;
2508 // "ㅁ" is bigger then "ኢ"
2509 field.SetProperty( Actor::Property::SIZE, Vector2( fieldWidth ,10.0f ) );
2510 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2511 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2513 field.SetProperty( TextField::Property::TEXT, "ኢ");
2514 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2515 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2517 field.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2518 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2520 application.SendNotification();
2521 application.Render();
2523 previousHeight = field.GetHeightForWidth( fieldWidth );
2524 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2526 // Add another script characters ( glyph height is defferent )
2527 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2528 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2530 application.SendNotification();
2531 application.Render();
2533 currentHeight = field.GetHeightForWidth( fieldWidth );
2534 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2535 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2540 int utcDaliTextFieldExtremlyLargePointSize(void)
2542 ToolkitTestApplication application;
2543 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2545 TextField field = TextField::New();
2547 field.SetProperty( TextField::Property::TEXT, "Text" );
2548 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2549 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2550 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2551 application.GetScene().Add( field );
2555 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2556 application.SendNotification();
2557 DALI_TEST_CHECK( field );
2561 tet_result(TET_FAIL);
2566 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2568 ToolkitTestApplication application;
2569 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2570 TextField field = TextField::New();
2571 DALI_TEST_CHECK( field );
2572 application.GetScene().Add( field );
2574 Property::Map fontStyleMapGet;
2576 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2578 Property::Value* weightValue = NULL;
2579 Property::Value* widthValue = NULL;
2580 Property::Value* slantValue = NULL;
2581 weightValue = fontStyleMapGet.Find( "weight" );
2582 widthValue = fontStyleMapGet.Find( "width" );
2583 slantValue = fontStyleMapGet.Find( "slant" );
2584 DALI_TEST_CHECK( !weightValue );
2585 DALI_TEST_CHECK( !widthValue );
2586 DALI_TEST_CHECK( !slantValue );
2591 int UtcDaliTextFieldSettingPlaceholder(void)
2593 ToolkitTestApplication application;
2594 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
2596 TextField field = TextField::New();
2597 DALI_TEST_CHECK( field );
2598 application.GetScene().Add( field );
2600 // Check the placeholder property with pixel size
2601 Property::Map placeholderPixelSizeMapSet;
2602 Property::Map placeholderPixelSizeMapGet;
2603 Property::Map placeholderFontstyleMap;
2604 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2605 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2606 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
2607 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2608 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
2609 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
2611 placeholderFontstyleMap.Insert( "weight", "bold" );
2612 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2613 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
2615 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2616 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
2617 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
2619 // Check the placeholder property with point size
2620 Property::Map placeholderMapSet;
2621 Property::Map placeholderMapGet;
2622 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2623 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2624 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
2625 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2626 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
2627 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
2629 // Check the placeholder font style property
2630 placeholderFontstyleMap.Clear();
2632 placeholderFontstyleMap.Insert( "weight", "bold" );
2633 placeholderFontstyleMap.Insert( "width", "condensed" );
2634 placeholderFontstyleMap.Insert( "slant", "italic" );
2635 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2636 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2638 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2639 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2640 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2642 // Reset font style.
2643 placeholderFontstyleMap.Clear();
2644 placeholderFontstyleMap.Insert( "weight", "normal" );
2645 placeholderFontstyleMap.Insert( "slant", "oblique" );
2646 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2647 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2649 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2650 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2651 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2653 placeholderFontstyleMap.Clear();
2654 placeholderFontstyleMap.Insert( "slant", "roman" );
2655 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2656 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2658 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2660 placeholderFontstyleMap.Clear();
2661 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2663 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2664 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2665 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2666 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2671 int UtcDaliTextFieldSetPaddingProperty(void)
2673 ToolkitTestApplication application;
2674 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
2676 TextField field = TextField::New();
2677 DALI_TEST_CHECK( field );
2678 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2679 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2680 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2681 application.GetScene().Add( field );
2683 application.SendNotification();
2684 application.Render();
2686 Vector3 originalSize = field.GetNaturalSize();
2688 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2690 application.SendNotification();
2691 application.Render();
2693 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2695 Vector3 paddingAddedSize = field.GetNaturalSize();
2697 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2699 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2704 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
2706 ToolkitTestApplication application;
2707 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
2709 TextField field = TextField::New();
2710 DALI_TEST_CHECK( field );
2711 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2712 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2713 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2714 application.GetScene().Add( field );
2716 application.SendNotification();
2717 application.Render();
2719 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2720 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2722 // Check the enable shift selection property
2723 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
2724 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2726 application.SendNotification();
2727 application.Render();
2732 int UtcDaliTextFieldEnableGrabHandleProperty(void)
2734 ToolkitTestApplication application;
2735 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
2737 TextField field = TextField::New();
2738 DALI_TEST_CHECK( field );
2739 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2740 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2741 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2742 application.GetScene().Add( field );
2744 application.SendNotification();
2745 application.Render();
2747 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2748 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2750 // Check the enable grab handle property
2751 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
2752 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2754 application.SendNotification();
2755 application.Render();
2760 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
2762 ToolkitTestApplication application;
2763 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
2765 TextField field = TextField::New();
2766 DALI_TEST_CHECK( field );
2767 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2768 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2769 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2770 application.GetScene().Add( field );
2772 application.SendNotification();
2773 application.Render();
2775 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2776 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2778 // Check the match system language direction property
2779 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2780 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2782 application.SendNotification();
2783 application.Render();
2788 int utcDaliTextFieldLayoutDirectionCoverage(void)
2790 ToolkitTestApplication application;
2791 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
2793 // Creates a tap event. After creating a tap event the text field should
2794 // have the focus and add text with key events should be possible.
2795 TextField field = TextField::New();
2796 DALI_TEST_CHECK( field );
2798 application.GetScene().Add( field );
2800 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2801 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2802 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2804 // Avoid a crash when core load gl resources.
2805 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2807 // Render and notify
2808 application.SendNotification();
2809 application.Render();
2811 // init direction for coverage
2812 // Set horizontal alignment END
2813 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2815 // Create a tap event to touch the text field.
2816 TestGenerateTap( application, 150.0f, 25.0f );
2818 // Render and notify
2819 application.SendNotification();
2820 application.Render();
2822 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
2823 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2824 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
2826 // Set horizontal alignment BEGIN
2827 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
2829 // Create a tap event to touch the text field.
2830 TestGenerateTap( application, 150.0f, 25.0f );
2832 // Render and notify
2833 application.SendNotification();
2834 application.Render();
2836 // Set horizontal alignment CENTER
2837 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
2839 // Create a tap event to touch the text field.
2840 TestGenerateTap( application, 150.0f, 25.0f );
2842 // Render and notify
2843 application.SendNotification();
2844 application.Render();
2846 // Set horizontal alignment END
2847 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2849 // Create a tap event to touch the text field.
2850 TestGenerateTap( application, 150.0f, 25.0f );
2852 // Render and notify
2853 application.SendNotification();
2854 application.Render();
2856 // Generate a Esc key event. The text field should lose the focus.
2857 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2858 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2860 // Render and notify
2861 application.SendNotification();
2862 application.Render();
2864 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2869 int UtcDaliTextFieldGetInputMethodContext(void)
2871 ToolkitTestApplication application;
2872 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
2874 TextField field = TextField::New();
2875 DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );
2880 int UtcDaliTextFieldSelectWholeText(void)
2882 ToolkitTestApplication application;
2883 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
2885 TextField textField = TextField::New();
2887 application.GetScene().Add( textField );
2889 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2890 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2891 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2893 // Avoid a crash when core load gl resources.
2894 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2896 application.SendNotification();
2897 application.Render();
2899 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2901 DevelTextField::SelectWholeText( textField );
2903 application.SendNotification();
2904 application.Render();
2906 // Nothing should have been selected. The number of children is still 1
2907 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2909 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
2911 application.SendNotification();
2912 application.Render();
2914 DevelTextField::SelectWholeText( textField );
2916 application.SendNotification();
2917 application.Render();
2919 // Should be 2 children, the stencil and the layer
2920 DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
2922 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2923 Actor stencil = textField.GetChildAt( 0u );
2925 // The highlight actor is drawn first, so is the first actor in the list
2926 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2927 DALI_TEST_CHECK( highlight );
2932 int UtcDaliTextFieldSelectNone(void)
2934 ToolkitTestApplication application;
2935 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
2937 TextField textField = TextField::New();
2939 application.GetScene().Add( textField );
2941 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2942 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2943 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2945 // Avoid a crash when core load gl resources.
2946 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2948 application.SendNotification();
2949 application.Render();
2951 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
2953 application.SendNotification();
2954 application.Render();
2956 // Nothing is selected
2957 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
2958 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
2960 DevelTextField::SelectWholeText( textField );
2962 application.SendNotification();
2963 application.Render();
2965 // whole text is selected
2966 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
2967 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
2969 DevelTextField::SelectNone( textField );
2971 application.SendNotification();
2972 application.Render();
2974 // Nothing is selected
2975 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
2976 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
2981 int UtcDaliTextFieldSelectRange(void)
2983 ToolkitTestApplication application;
2984 tet_infoline(" UtcDaliTextFieldSelectRange ");
2986 TextField textField = TextField::New();
2988 application.GetScene().Add( textField );
2990 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2991 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2992 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2994 // Avoid a crash when core load gl resources.
2995 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2997 application.SendNotification();
2998 application.Render();
3000 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3002 application.SendNotification();
3003 application.Render();
3005 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 0);
3006 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 5);
3008 // Hello is selected
3009 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3010 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3012 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3013 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3015 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 6);
3016 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 11);
3018 // world is selected
3019 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3020 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3022 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3023 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3028 int UtcDaliTextFieldEnableEditing(void)
3030 ToolkitTestApplication application;
3031 tet_infoline(" UtcDaliTextFieldEnableEditing ");
3033 TextField textField = TextField::New();
3035 application.GetScene().Add( textField );
3037 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3038 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3039 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3041 // Avoid a crash when core load gl resources.
3042 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3044 application.SendNotification();
3045 application.Render();
3047 textField.SetKeyInputFocus();
3048 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, false );
3049 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3051 // Render and notify
3052 application.SendNotification();
3053 application.Render();
3055 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3056 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3059 textField.SetKeyInputFocus();
3060 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
3061 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3063 // Render and notify
3064 application.SendNotification();
3065 application.Render();
3067 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3068 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3073 int UtcDaliToolkitTextFieldFontSizeScale(void)
3075 ToolkitTestApplication application;
3076 tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
3078 TextField textField = TextField::New();
3079 textField.SetProperty( TextField::Property::POINT_SIZE, 30.f );
3080 textField.SetProperty( TextField::Property::TEXT, "Test" );
3081 Vector3 nonScaledSize = textField.GetNaturalSize();
3083 TextField textFieldScaled = TextField::New();
3084 textFieldScaled.SetProperty( TextField::Property::POINT_SIZE, 15.f );
3085 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3086 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3087 Vector3 scaledSize = textFieldScaled.GetNaturalSize();
3089 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3091 textField.SetProperty( TextField::Property::PIXEL_SIZE, 30.f );
3092 textField.SetProperty( TextField::Property::TEXT, "Test" );
3093 nonScaledSize = textField.GetNaturalSize();
3095 textFieldScaled.SetProperty( TextField::Property::PIXEL_SIZE, 15.f );
3096 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3097 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3098 scaledSize = textFieldScaled.GetNaturalSize();
3100 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3105 int UtcDaliTextFieldPrimaryCursorPosition(void)
3107 ToolkitTestApplication application;
3108 tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
3110 TextField textField = TextField::New();
3112 application.GetScene().Add( textField );
3114 textField.SetProperty( TextField::Property::TEXT, "ABCEF");
3115 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3116 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3117 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3119 // Avoid a crash when core load gl resources.
3120 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3122 textField.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
3123 application.SendNotification();
3124 application.Render();
3126 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3128 // Render and notify
3129 application.SendNotification();
3130 application.Render();
3132 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3133 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );