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 );
1051 // Negative test for the textChanged signal.
1052 int utcDaliTextFieldTextChangedN(void)
1054 ToolkitTestApplication application;
1055 tet_infoline(" utcDaliTextFieldTextChangedN");
1056 TextField field = TextField::New();
1057 DALI_TEST_CHECK( field );
1059 application.GetScene().Add( field );
1061 // connect to the text changed signal.
1062 ConnectionTracker* testTracker = new ConnectionTracker();
1063 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1064 bool textChangedSignal = false;
1065 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1067 gTextChangedCallBackCalled = false;
1068 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1069 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1070 DALI_TEST_CHECK( !textChangedSignal );
1075 // Positive test for Max Characters reached signal.
1076 int utcDaliTextFieldMaxCharactersReachedP(void)
1078 ToolkitTestApplication application;
1079 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1080 TextField field = TextField::New();
1081 DALI_TEST_CHECK( field );
1083 application.GetScene().Add( field );
1085 const int maxNumberOfCharacters = 1;
1086 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1088 field.SetKeyInputFocus();
1090 // connect to the text changed signal.
1091 ConnectionTracker* testTracker = new ConnectionTracker();
1092 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1093 bool maxLengthReachedSignal = false;
1094 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1096 gMaxCharactersCallBackCalled = false;
1098 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1099 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1101 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1102 DALI_TEST_CHECK( maxLengthReachedSignal );
1107 // Negative test for Max Characters reached signal.
1108 int utcDaliTextFieldMaxCharactersReachedN(void)
1110 ToolkitTestApplication application;
1111 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1112 TextField field = TextField::New();
1113 DALI_TEST_CHECK( field );
1115 application.GetScene().Add( field );
1117 const int maxNumberOfCharacters = 3;
1118 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1120 field.SetKeyInputFocus();
1122 // connect to the text changed signal.
1123 ConnectionTracker* testTracker = new ConnectionTracker();
1124 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1125 bool maxLengthReachedSignal = false;
1126 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1128 gMaxCharactersCallBackCalled = false;
1130 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1131 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1133 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1134 DALI_TEST_CHECK( !maxLengthReachedSignal );
1136 application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1138 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1139 DALI_TEST_CHECK( !maxLengthReachedSignal );
1144 int utcDaliTextFieldInputStyleChanged01(void)
1146 // The text-field emits signals when the input style changes. These changes of style are
1147 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1148 // can't be emitted during the size negotiation as the callbacks may update the UI.
1149 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1150 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1151 ToolkitTestApplication application;
1152 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1156 char* pathNamePtr = get_current_dir_name();
1157 const std::string pathName( pathNamePtr );
1158 free( pathNamePtr );
1160 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1161 fontClient.SetDpi( 93u, 93u );
1163 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1164 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1166 TextField field = TextField::New();
1167 DALI_TEST_CHECK( field );
1170 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1171 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1172 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1174 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1175 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1177 // connect to the text changed signal.
1178 ConnectionTracker* testTracker = new ConnectionTracker();
1179 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1180 bool inputStyleChangedSignal = false;
1181 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1183 application.GetScene().Add( field );
1185 // Render and notify
1186 application.SendNotification();
1187 application.Render();
1189 // Executes the idle callbacks added by the text control on the change of input style.
1190 application.RunIdles();
1192 gInputStyleChangedCallbackCalled = false;
1193 gInputStyleMask = TextField::InputStyle::NONE;
1194 inputStyleChangedSignal = false;
1196 // Create a tap event to touch the text field.
1197 TestGenerateTap( application, 18.0f, 25.0f );
1199 // Render and notify
1200 application.SendNotification();
1201 application.Render();
1203 // Executes the idle callbacks added by the text control on the change of input style.
1204 application.RunIdles();
1206 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1207 if( gInputStyleChangedCallbackCalled )
1209 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1211 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1212 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1214 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1215 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1217 DALI_TEST_CHECK( inputStyleChangedSignal );
1219 gInputStyleChangedCallbackCalled = false;
1220 gInputStyleMask = TextField::InputStyle::NONE;
1221 inputStyleChangedSignal = false;
1223 // Create a tap event to touch the text field.
1224 TestGenerateTap( application, 30.0f, 25.0f );
1226 // Render and notify
1227 application.SendNotification();
1228 application.Render();
1230 // Executes the idle callbacks added by the text control on the change of input style.
1231 application.RunIdles();
1233 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1234 DALI_TEST_CHECK( !inputStyleChangedSignal );
1236 gInputStyleChangedCallbackCalled = false;
1237 gInputStyleMask = TextField::InputStyle::NONE;
1238 inputStyleChangedSignal = false;
1240 // Create a tap event to touch the text field.
1241 TestGenerateTap( application, 43.0f, 25.0f );
1243 // Render and notify
1244 application.SendNotification();
1245 application.Render();
1247 // Executes the idle callbacks added by the text control on the change of input style.
1248 application.RunIdles();
1250 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1251 if( gInputStyleChangedCallbackCalled )
1253 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1255 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1256 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1258 DALI_TEST_CHECK( inputStyleChangedSignal );
1260 gInputStyleChangedCallbackCalled = false;
1261 gInputStyleMask = TextField::InputStyle::NONE;
1262 inputStyleChangedSignal = false;
1264 // Create a tap event to touch the text field.
1265 TestGenerateTap( application, 88.0f, 25.0f );
1267 // Render and notify
1268 application.SendNotification();
1269 application.Render();
1271 // Executes the idle callbacks added by the text control on the change of input style.
1272 application.RunIdles();
1274 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1275 if( gInputStyleChangedCallbackCalled )
1277 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1279 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1280 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1282 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1284 Property::Map fontStyleMapSet;
1285 fontStyleMapSet.Insert( "weight", "bold" );
1287 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1288 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1290 DALI_TEST_CHECK( inputStyleChangedSignal );
1292 gInputStyleChangedCallbackCalled = false;
1293 gInputStyleMask = TextField::InputStyle::NONE;
1294 inputStyleChangedSignal = false;
1296 // Create a tap event to touch the text field.
1297 TestGenerateTap( application, 115.0f, 25.0f );
1299 // Render and notify
1300 application.SendNotification();
1301 application.Render();
1303 // Executes the idle callbacks added by the text control on the change of input style.
1304 application.RunIdles();
1306 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1307 DALI_TEST_CHECK( !inputStyleChangedSignal );
1309 gInputStyleChangedCallbackCalled = false;
1310 gInputStyleMask = TextField::InputStyle::NONE;
1311 inputStyleChangedSignal = false;
1313 // Create a tap event to touch the text field.
1314 TestGenerateTap( application, 164.0f, 25.0f );
1316 // Render and notify
1317 application.SendNotification();
1318 application.Render();
1320 // Executes the idle callbacks added by the text control on the change of input style.
1321 application.RunIdles();
1323 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1324 if( gInputStyleChangedCallbackCalled )
1326 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1328 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1329 DALI_TEST_CHECK( style.empty() );
1331 DALI_TEST_CHECK( inputStyleChangedSignal );
1333 gInputStyleChangedCallbackCalled = false;
1334 gInputStyleMask = TextField::InputStyle::NONE;
1335 inputStyleChangedSignal = false;
1337 // Create a tap event to touch the text field.
1338 TestGenerateTap( application, 191.0f, 25.0f );
1340 // Render and notify
1341 application.SendNotification();
1342 application.Render();
1344 // Executes the idle callbacks added by the text control on the change of input style.
1345 application.RunIdles();
1347 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1348 DALI_TEST_CHECK( !inputStyleChangedSignal );
1353 int utcDaliTextFieldInputStyleChanged02(void)
1355 // The text-field emits signals when the input style changes. These changes of style are
1356 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1357 // can't be emitted during the size negotiation as the callbacks may update the UI.
1358 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1359 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1360 ToolkitTestApplication application;
1361 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1365 char* pathNamePtr = get_current_dir_name();
1366 const std::string pathName( pathNamePtr );
1367 free( pathNamePtr );
1369 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1370 fontClient.SetDpi( 93u, 93u );
1372 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1373 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1375 TextField field = TextField::New();
1376 DALI_TEST_CHECK( field );
1378 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1379 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1380 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1382 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1383 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>" );
1385 // connect to the text changed signal.
1386 ConnectionTracker* testTracker = new ConnectionTracker();
1387 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1388 bool inputStyleChangedSignal = false;
1389 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1391 application.GetScene().Add( field );
1393 // Render and notify
1394 application.SendNotification();
1395 application.Render();
1397 // Executes the idle callbacks added by the text control on the change of input style.
1398 application.RunIdles();
1400 gInputStyleChangedCallbackCalled = false;
1401 gInputStyleMask = TextField::InputStyle::NONE;
1402 inputStyleChangedSignal = false;
1404 // Create a tap event to touch the text field.
1405 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1406 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1408 // Render and notify
1409 application.SendNotification();
1410 application.Render();
1412 // Executes the idle callbacks added by the text control on the change of input style.
1413 application.RunIdles();
1415 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1416 if( gInputStyleChangedCallbackCalled )
1418 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1419 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1420 TextField::InputStyle::POINT_SIZE |
1421 TextField::InputStyle::COLOR ),
1424 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1425 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1427 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1428 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1430 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1431 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1433 DALI_TEST_CHECK( inputStyleChangedSignal );
1435 gInputStyleChangedCallbackCalled = false;
1436 gInputStyleMask = TextField::InputStyle::NONE;
1437 inputStyleChangedSignal = false;
1439 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1441 // Render and notify
1442 application.SendNotification();
1443 application.Render();
1445 // Executes the idle callbacks added by the text control on the change of input style.
1446 application.RunIdles();
1448 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1449 if( gInputStyleChangedCallbackCalled )
1451 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1452 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1455 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1456 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1458 DALI_TEST_CHECK( inputStyleChangedSignal );
1460 gInputStyleChangedCallbackCalled = false;
1461 gInputStyleMask = TextField::InputStyle::NONE;
1462 inputStyleChangedSignal = false;
1464 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1466 // Render and notify
1467 application.SendNotification();
1468 application.Render();
1470 // Executes the idle callbacks added by the text control on the change of input style.
1471 application.RunIdles();
1473 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1474 DALI_TEST_CHECK( !inputStyleChangedSignal );
1476 gInputStyleChangedCallbackCalled = false;
1477 gInputStyleMask = TextField::InputStyle::NONE;
1478 inputStyleChangedSignal = false;
1480 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1482 // Render and notify
1483 application.SendNotification();
1484 application.Render();
1486 // Executes the idle callbacks added by the text control on the change of input style.
1487 application.RunIdles();
1489 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1490 if( gInputStyleChangedCallbackCalled )
1492 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1493 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1496 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1497 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1499 DALI_TEST_CHECK( inputStyleChangedSignal );
1501 gInputStyleChangedCallbackCalled = false;
1502 gInputStyleMask = TextField::InputStyle::NONE;
1503 inputStyleChangedSignal = false;
1505 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1507 Property::Map fontStyleMapSet;
1508 fontStyleMapSet.Insert( "weight", "thin" );
1509 fontStyleMapSet.Insert( "width", "condensed" );
1510 fontStyleMapSet.Insert( "slant", "italic" );
1512 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1513 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1515 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1516 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1517 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1518 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1520 // Render and notify
1521 application.SendNotification();
1522 application.Render();
1524 // Executes the idle callbacks added by the text control on the change of input style.
1525 application.RunIdles();
1527 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1528 DALI_TEST_CHECK( !inputStyleChangedSignal );
1530 // Create a tap event to touch the text field.
1531 TestGenerateTap( application, 63.0f, 25.0f, 300 );
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 if( gInputStyleChangedCallbackCalled )
1543 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1544 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1545 TextField::InputStyle::POINT_SIZE |
1546 TextField::InputStyle::FONT_STYLE |
1547 TextField::InputStyle::UNDERLINE |
1548 TextField::InputStyle::SHADOW |
1549 TextField::InputStyle::EMBOSS |
1550 TextField::InputStyle::OUTLINE ),
1553 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1554 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1556 DALI_TEST_CHECK( inputStyleChangedSignal );
1561 int utcDaliTextFieldEvent01(void)
1563 ToolkitTestApplication application;
1564 tet_infoline(" utcDaliTextFieldEvent01");
1566 // Creates a tap event. After creating a tap event the text field should
1567 // have the focus and add text with key events should be possible.
1569 TextField field = TextField::New();
1570 DALI_TEST_CHECK( field );
1572 application.GetScene().Add( field );
1574 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1575 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1576 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1578 // Render and notify
1579 application.SendNotification();
1580 application.Render();
1582 // Avoid a crash when core load gl resources.
1583 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1585 // Render and notify
1586 application.SendNotification();
1587 application.Render();
1589 // Add a key event but as the text field has not the focus it should do nothing.
1590 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1592 // Render and notify
1593 application.SendNotification();
1594 application.Render();
1596 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1598 // Create a tap event to touch the text field.
1599 TestGenerateTap( application, 150.0f, 25.0f );
1601 // Render and notify
1602 application.SendNotification();
1603 application.Render();
1605 // Pressing delete key should be fine even if there is no text in TextField.
1606 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 ) );
1607 // Render and notify
1608 application.SendNotification();
1609 application.Render();
1611 // Now the text field has the focus, so it can handle the key events.
1612 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1613 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1615 // Render and notify
1616 application.SendNotification();
1617 application.Render();
1619 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1621 // Create a second text field and send key events to it.
1622 TextField field2 = TextField::New();
1624 field2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1625 field2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1626 field2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1627 field2.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
1629 application.GetScene().Add( field2 );
1631 // Render and notify
1632 application.SendNotification();
1633 application.Render();
1635 // Create a tap event on the second text field.
1636 TestGenerateTap( application, 150.0f, 125.0f );
1638 // Render and notify
1639 application.SendNotification();
1640 application.Render();
1642 // The second text field has the focus. It should handle the key events.
1643 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1644 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1646 // Render and notify
1647 application.SendNotification();
1648 application.Render();
1650 // Check the text has been added to the second text field.
1651 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1656 int utcDaliTextFieldEvent02(void)
1658 ToolkitTestApplication application;
1659 tet_infoline(" utcDaliTextFieldEvent02");
1661 // Checks if the right number of actors are created.
1663 TextField field = TextField::New();
1664 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1665 DALI_TEST_CHECK( field );
1666 LoadMarkerImages(application, field);
1668 application.GetScene().Add( field );
1670 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1671 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1672 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1674 // Avoid a crash when core load gl resources.
1675 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1677 // Render and notify
1678 application.SendNotification();
1679 application.Render();
1681 // Check there are the expected number of children ( stencil ).
1682 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1684 Actor stencil = field.GetChildAt( 0u );
1685 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1687 // Create a tap event to touch the text field.
1688 TestGenerateTap( application, 150.0f, 25.0f, 300 );
1690 // Render and notify
1691 application.SendNotification();
1692 application.Render();
1694 Actor layer = field.GetChildAt( 1u );
1695 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1696 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1698 // Now the text field has the focus, so it can handle the key events.
1699 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1700 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1702 // Render and notify
1703 application.SendNotification();
1704 application.Render();
1706 // Checks the cursor and the renderer have been created.
1707 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1708 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1710 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1711 DALI_TEST_CHECK( cursor );
1713 // The offscreen root actor has a container with all the actors which contain the text renderers.
1714 Actor container = stencil.GetChildAt( 0u );
1715 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1717 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1718 DALI_TEST_CHECK( renderer );
1721 // Move the cursor and check the position changes.
1722 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1723 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1725 // Render and notify
1726 application.SendNotification();
1727 application.Render();
1729 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1730 DALI_TEST_CHECK( position2.x < position1.x );
1732 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1734 // Render and notify
1735 application.SendNotification();
1736 application.Render();
1738 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1739 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1742 // Move the cursor to the first position.
1743 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1744 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1746 // Render and notify
1747 application.SendNotification();
1748 application.Render();
1750 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1752 // Send some taps and check the cursor positions.
1754 // Try to tap at the beginning.
1755 TestGenerateTap( application, 1.0f, 25.0f, 900 );
1757 // Render and notify
1758 application.SendNotification();
1759 application.Render();
1761 // Cursor position should be the same than position1.
1762 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1764 DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
1766 // Tap away from the start position.
1767 TestGenerateTap( application, 16.0f, 25.0f, 1500 );
1769 // Render and notify
1770 application.SendNotification();
1771 application.Render();
1773 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1775 DALI_TEST_CHECK( position6.x > position5.x );
1777 // Remove all the text.
1778 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1779 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1780 field.SetProperty( TextField::Property::TEXT, "" );
1782 // Render and notify
1783 application.SendNotification();
1784 application.Render();
1786 // Cursor position should be the same than position2.
1787 Vector3 position7 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1789 DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
1791 // Should not be a renderer.
1792 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1794 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1795 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1796 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1798 application.SendNotification();
1799 application.Render();
1801 // There are renderer and decorator layer
1802 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1807 int utcDaliTextFieldEvent03(void)
1809 ToolkitTestApplication application;
1810 tet_infoline(" utcDaliTextFieldEvent03");
1812 // Checks if the highlight actor is created.
1814 TextField field = TextField::New();
1815 DALI_TEST_CHECK( field );
1817 application.GetScene().Add( field );
1819 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1820 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1821 field.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1822 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1823 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1825 // Avoid a crash when core load gl resources.
1826 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1827 LoadMarkerImages(application, field);
1829 // Render and notify
1830 application.SendNotification();
1831 application.Render();
1833 // Tap first to get the focus.
1834 TestGenerateTap( application, 3.0f, 25.0f );
1836 // Render and notify
1837 application.SendNotification();
1838 application.Render();
1840 // Double tap to select a word.
1841 TestGenerateTap( application, 3.0f, 25.0f );
1843 // Render and notify
1844 application.SendNotification();
1845 application.Render();
1847 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1848 Actor stencil = field.GetChildAt( 0u );
1850 // The highlight actor is drawn first, so is the first actor in the list
1851 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1852 DALI_TEST_CHECK( highlight );
1854 // The offscreen root actor has a container with all the actors which contain the text renderers.
1855 Actor container = stencil.GetChildAt( 1u );
1856 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1858 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1859 DALI_TEST_CHECK( renderer );
1865 int utcDaliTextFieldEvent04(void)
1867 ToolkitTestApplication application;
1868 tet_infoline(" utcDaliTextFieldEvent04");
1870 // Checks if the highlight actor is created.
1872 TextField field = TextField::New();
1873 DALI_TEST_CHECK( field );
1874 application.GetScene().Add( field );
1875 LoadMarkerImages(application, field);
1876 // Render and notify
1877 application.SendNotification();
1878 application.Render();
1880 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1881 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1882 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1883 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1884 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1886 // Avoid a crash when core load gl resources.
1887 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1888 // Render and notify
1889 application.SendNotification();
1890 application.Render();
1892 // Create a tap event to touch the text field.
1893 TestGenerateTap( application, 150.0f, 25.0f );
1894 // Render and notify
1895 application.SendNotification();
1896 application.Render();
1899 // Tap first to get the focus.
1900 TestGenerateTap( application, 1.0f, 25.0f );
1902 // Render and notify
1903 application.SendNotification();
1904 application.Render();
1906 // Double tap to select a word.
1907 TestGenerateTap( application, 1.0f, 25.0f );
1909 // Render and notify
1910 application.SendNotification();
1911 application.Render();
1914 TestGenerateTap( application, 0.0f, 40.0f );
1918 int utcDaliTextFieldEvent05(void)
1920 ToolkitTestApplication application;
1921 tet_infoline(" utcDaliTextFieldEvent05");
1923 // Checks dragging of cursor/grab handle
1925 TextField field = TextField::New();
1926 DALI_TEST_CHECK( field );
1927 application.GetScene().Add( field );
1928 LoadMarkerImages(application, field);
1929 // Render and notify
1930 application.SendNotification();
1931 application.Render();
1933 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1934 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1935 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1936 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1937 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1939 // Avoid a crash when core load gl resources.
1940 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1941 // Render and notify
1942 application.SendNotification();
1943 application.Render();
1945 // Create a tap event to touch the text field.
1946 TestGenerateTap( application, 150.0f, 25.0f );
1947 // Render and notify
1948 application.SendNotification();
1949 application.Render();
1951 // Tap first to get the focus.
1952 TestGenerateTap( application, 1.0f, 25.0f );
1954 // Render and notify
1955 application.SendNotification();
1956 application.Render();
1958 // Double tap to select a word.
1959 TestGenerateTap( application, 1.0f, 25.0f );
1961 // Render and notify
1962 application.SendNotification();
1963 application.Render();
1965 Actor stencil = field.GetChildAt( 1u );
1969 int utcDaliTextFieldEvent06(void)
1971 ToolkitTestApplication application;
1972 tet_infoline(" utcDaliTextFieldEvent06");
1974 // Checks Longpress when in edit mode
1976 TextField field = TextField::New();
1977 DALI_TEST_CHECK( field );
1978 application.GetScene().Add( field );
1979 LoadMarkerImages(application, field);
1980 // Render and notify
1981 application.SendNotification();
1982 application.Render();
1984 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1985 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1986 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1987 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1988 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1990 // Avoid a crash when core load gl resources.
1991 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1992 // Render and notify
1993 application.SendNotification();
1994 application.Render();
1996 // Create a tap event to touch the text field.
1997 TestGenerateTap( application, 150.0f, 25.0f );
1998 // Render and notify
1999 application.SendNotification();
2000 application.Render();
2003 // Tap first to get the focus.
2004 TestGenerateTap( application, 1.0f, 25.0f );
2006 // Render and notify
2007 application.SendNotification();
2008 application.Render();
2011 TestGenerateLongPress(application, 1.0f, 25.0f);
2013 // Render and notify
2014 application.SendNotification();
2015 application.Render();
2020 int utcDaliTextFieldEvent07(void)
2022 ToolkitTestApplication application;
2023 tet_infoline(" utcDaliTextFieldEvent07");
2025 // Checks Longpress to start edit mode
2027 TextField field = TextField::New();
2028 DALI_TEST_CHECK( field );
2029 application.GetScene().Add( field );
2030 LoadMarkerImages(application, field);
2031 // Render and notify
2032 application.SendNotification();
2033 application.Render();
2035 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2036 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2037 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2038 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2039 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2040 Property::Map propertyMap;
2041 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2042 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2044 // Avoid a crash when core load gl resources.
2045 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2046 // Render and notify
2047 application.SendNotification();
2048 application.Render();
2051 TestGenerateLongPress(application, 1.0f, 25.0f);
2053 // Render and notify
2054 application.SendNotification();
2055 application.Render();
2060 int utcDaliTextFieldEvent08(void)
2062 ToolkitTestApplication application;
2063 tet_infoline(" utcDaliTextFieldEvent08");
2065 Dali::Clipboard clipboard = Clipboard::Get();
2066 clipboard.SetItem("testTextFieldEvent");
2068 // Checks Longpress when only place holder text
2070 TextField field = TextField::New();
2071 DALI_TEST_CHECK( field );
2072 application.GetScene().Add( field );
2073 LoadMarkerImages(application, field);
2074 // Render and notify
2075 application.SendNotification();
2076 application.Render();
2078 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2079 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2080 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2081 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2082 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2084 // Avoid a crash when core load gl resources.
2085 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2086 // Render and notify
2087 application.SendNotification();
2088 application.Render();
2091 TestGenerateLongPress( application, 1.0f, 25.0f, 20 );
2093 // Render and notify
2094 application.SendNotification();
2095 application.Render();
2097 Wait(application, 500);
2099 TestEndLongPress( application, 1.0f, 25.0f, 520 );
2102 TestGenerateLongPress( application, 1.0f, 25.0f, 600 );
2104 // Render and notify
2105 application.Render();
2107 Wait(application, 500);
2109 Integration::Scene stage = application.GetScene();
2110 Layer layer = stage.GetRootLayer();
2111 Actor actor = layer.FindChildByName("optionPaste");
2115 Vector3 worldPosition = actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION );
2116 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2117 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2119 Dali::Integration::TouchEvent event;
2120 event = Dali::Integration::TouchEvent();
2121 event.AddPoint( GetPointDownInside( position ) );
2122 application.ProcessEvent( event );
2124 event = Dali::Integration::TouchEvent();
2125 event.AddPoint( GetPointUpInside( position ) );
2126 application.ProcessEvent( event );
2128 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2133 int utcDaliTextFieldEvent09(void)
2135 ToolkitTestApplication application;
2136 tet_infoline(" utcDaliTextFieldEvent09");
2138 TextField field = TextField::New();
2139 DALI_TEST_CHECK( field );
2140 application.GetScene().Add( field );
2141 LoadMarkerImages(application, field);
2142 // Render and notify
2143 application.SendNotification();
2144 application.Render();
2146 field.SetProperty( TextField::Property::TEXT, "Hello" );
2147 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2148 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2149 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2150 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2152 // Avoid a crash when core load gl resources.
2153 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2155 // Create a tap event to touch the text field.
2156 TestGenerateTap( application, 150.0f, 25.0f );
2157 application.SendNotification();
2158 application.Render();
2161 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2162 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2163 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2164 application.SendNotification();
2165 application.Render();
2167 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2168 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2169 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2170 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2171 application.SendNotification();
2172 application.Render();
2174 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2175 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2176 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2177 for( unsigned int index = 0u; index < 5u; ++index )
2179 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2180 application.SendNotification();
2181 application.Render();
2184 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2185 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2186 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2187 for( unsigned int index = 0u; index < 5u; ++index )
2189 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2190 application.SendNotification();
2191 application.Render();
2194 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2195 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2196 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2197 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2198 application.SendNotification();
2199 application.Render();
2200 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2201 application.SendNotification();
2202 application.Render();
2204 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2205 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2206 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2207 application.SendNotification();
2208 application.Render();
2210 Property::Map mapGet;
2211 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2212 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2213 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2218 int utcDaliTextFieldStyleWhilstSelected(void)
2220 ToolkitTestApplication application;
2221 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2223 // Change font and styles whilst text is selected whilst word selected
2225 TextField field = TextField::New();
2226 DALI_TEST_CHECK( field );
2227 application.GetScene().Add( field );
2228 LoadMarkerImages(application, field);
2229 // Render and notify
2230 application.SendNotification();
2231 application.Render();
2233 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2234 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2235 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2236 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2237 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2239 // Avoid a crash when core load gl resources.
2240 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2241 // Render and notify
2242 application.SendNotification();
2243 application.Render();
2245 // Create a tap event to touch the text field.
2246 TestGenerateTap( application, 150.0f, 25.0f );
2247 // Render and notify
2248 application.SendNotification();
2249 application.Render();
2252 // Tap first to get the focus.
2253 TestGenerateTap( application, 1.0f, 25.0f );
2255 // Render and notify
2256 application.SendNotification();
2257 application.Render();
2259 // Double tap to select a word.
2260 TestGenerateTap( application, 1.0f, 25.0f );
2262 // Render and notify
2263 application.SendNotification();
2264 application.Render();
2266 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2267 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2269 Property::Map fontStyleMapSet;
2270 Property::Map fontStyleMapGet;
2272 fontStyleMapSet.Insert( "weight", "bold" );
2273 fontStyleMapSet.Insert( "slant", "italic" );
2274 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2276 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2277 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2278 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2280 fontStyleMapSet.Clear();
2281 fontStyleMapSet.Insert( "width", "expanded" );
2282 fontStyleMapSet.Insert( "slant", "italic" );
2283 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2285 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2286 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2287 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2289 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2290 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2292 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2293 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2295 fontStyleMapSet.Clear();
2296 fontStyleMapSet.Insert( "weight", "bold" );
2297 fontStyleMapSet.Insert( "slant", "italic" );
2299 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2301 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2302 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2303 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2305 fontStyleMapSet.Clear();
2306 fontStyleMapSet.Insert( "width", "expanded" );
2308 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2310 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2311 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2312 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2314 // Press Escape to increase coverage
2315 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2316 application.SendNotification();
2317 application.Render();
2319 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2324 int utcDaliTextFieldEscKeyLoseFocus(void)
2326 ToolkitTestApplication application;
2327 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2329 // Creates a tap event. After creating a tap event the text field should
2330 // have the focus and add text with key events should be possible.
2332 TextField field = TextField::New();
2333 DALI_TEST_CHECK( field );
2335 application.GetScene().Add( field );
2337 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2338 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2339 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2341 // Avoid a crash when core load gl resources.
2342 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2344 // Render and notify
2345 application.SendNotification();
2346 application.Render();
2348 // Add a key event but as the text field has not the focus it should do nothing.
2349 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2350 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2352 // Render and notify
2353 application.SendNotification();
2354 application.Render();
2356 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2358 // Create a tap event to touch the text field.
2359 TestGenerateTap( application, 150.0f, 25.0f );
2361 // Render and notify
2362 application.SendNotification();
2363 application.Render();
2365 // Now the text field has the focus, so it can handle the key events.
2366 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2367 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2368 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2369 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2371 // Render and notify
2372 application.SendNotification();
2373 application.Render();
2375 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2377 // Generate a Esc key event. The text field should lose the focus.
2378 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2379 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2381 // Render and notify
2382 application.SendNotification();
2383 application.Render();
2385 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2387 // No more text should be introduced
2388 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2389 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2391 // Render and notify
2392 application.SendNotification();
2393 application.Render();
2395 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2400 int utcDaliTextFieldSomeSpecialKeys(void)
2402 ToolkitTestApplication application;
2403 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2405 // Checks some special keys when the text is selected.
2407 TextField field = TextField::New();
2408 DALI_TEST_CHECK( field );
2409 application.GetScene().Add( field );
2410 LoadMarkerImages(application, field);
2411 // Render and notify
2412 application.SendNotification();
2413 application.Render();
2415 const std::string longText( "This is a long text for the size of the text-field." );
2417 field.SetProperty( TextField::Property::TEXT, longText );
2418 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2419 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2420 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2421 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2423 // Avoid a crash when core load gl resources.
2424 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2425 // Render and notify
2426 application.SendNotification();
2427 application.Render();
2429 // Create a tap event to touch the text field.
2430 TestGenerateTap( application, 150.0f, 25.0f );
2432 // Render and notify
2433 application.SendNotification();
2434 application.Render();
2436 // Tap first to get the focus.
2437 TestGenerateTap( application, 1.0f, 25.0f );
2439 // Render and notify
2440 application.SendNotification();
2441 application.Render();
2443 // Double tap to select a word.
2444 TestGenerateTap( application, 1.0f, 25.0f );
2446 // Render and notify
2447 application.SendNotification();
2448 application.Render();
2450 // Generate a Esc key event. The text field should lose the focus.
2451 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2452 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2454 // Render and notify
2455 application.SendNotification();
2456 application.Render();
2458 // Generate a Esc key event. The text field should lose the focus.
2459 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2460 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2462 // Render and notify
2463 application.SendNotification();
2464 application.Render();
2466 // Generate a Esc key event. The text field should lose the focus.
2467 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2468 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2470 // Render and notify
2471 application.SendNotification();
2472 application.Render();
2474 // The text shouldn't be deleted.
2475 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2480 int utcDaliTextFieldSizeUpdate(void)
2482 ToolkitTestApplication application;
2483 tet_infoline("utcDaliTextFieldSizeUpdate");
2485 // Checks some special keys when the text is selected.
2486 TextField field = TextField::New();
2487 DALI_TEST_CHECK( field );
2488 application.GetScene().Add( field );
2490 float previousHeight = 0.0f;
2491 float currentHeight = 0.0f;
2492 const float fieldWidth = 1920.0f;
2495 // "ㅁ" is bigger then "ኢ"
2496 field.SetProperty( Actor::Property::SIZE, Vector2( fieldWidth ,10.0f ) );
2497 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2498 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2500 field.SetProperty( TextField::Property::TEXT, "ኢ");
2501 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2502 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2504 field.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2505 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2507 application.SendNotification();
2508 application.Render();
2510 previousHeight = field.GetHeightForWidth( fieldWidth );
2511 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2513 // Add another script characters ( glyph height is defferent )
2514 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2515 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2517 application.SendNotification();
2518 application.Render();
2520 currentHeight = field.GetHeightForWidth( fieldWidth );
2521 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2522 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2527 int utcDaliTextFieldExtremlyLargePointSize(void)
2529 ToolkitTestApplication application;
2530 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2532 TextField field = TextField::New();
2534 field.SetProperty( TextField::Property::TEXT, "Text" );
2535 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2536 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2537 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2538 application.GetScene().Add( field );
2542 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2543 application.SendNotification();
2544 DALI_TEST_CHECK( field );
2548 tet_result(TET_FAIL);
2553 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2555 ToolkitTestApplication application;
2556 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2557 TextField field = TextField::New();
2558 DALI_TEST_CHECK( field );
2559 application.GetScene().Add( field );
2561 Property::Map fontStyleMapGet;
2563 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2565 Property::Value* weightValue = NULL;
2566 Property::Value* widthValue = NULL;
2567 Property::Value* slantValue = NULL;
2568 weightValue = fontStyleMapGet.Find( "weight" );
2569 widthValue = fontStyleMapGet.Find( "width" );
2570 slantValue = fontStyleMapGet.Find( "slant" );
2571 DALI_TEST_CHECK( !weightValue );
2572 DALI_TEST_CHECK( !widthValue );
2573 DALI_TEST_CHECK( !slantValue );
2578 int UtcDaliTextFieldSettingPlaceholder(void)
2580 ToolkitTestApplication application;
2581 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
2583 TextField field = TextField::New();
2584 DALI_TEST_CHECK( field );
2585 application.GetScene().Add( field );
2587 // Check the placeholder property with pixel size
2588 Property::Map placeholderPixelSizeMapSet;
2589 Property::Map placeholderPixelSizeMapGet;
2590 Property::Map placeholderFontstyleMap;
2591 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2592 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2593 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
2594 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2595 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
2596 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
2598 placeholderFontstyleMap.Insert( "weight", "bold" );
2599 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2600 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
2602 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2603 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
2604 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
2606 // Check the placeholder property with point size
2607 Property::Map placeholderMapSet;
2608 Property::Map placeholderMapGet;
2609 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2610 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2611 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
2612 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2613 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
2614 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
2616 // Check the placeholder font style property
2617 placeholderFontstyleMap.Clear();
2619 placeholderFontstyleMap.Insert( "weight", "bold" );
2620 placeholderFontstyleMap.Insert( "width", "condensed" );
2621 placeholderFontstyleMap.Insert( "slant", "italic" );
2622 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2623 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2625 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2626 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2627 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2629 // Reset font style.
2630 placeholderFontstyleMap.Clear();
2631 placeholderFontstyleMap.Insert( "weight", "normal" );
2632 placeholderFontstyleMap.Insert( "slant", "oblique" );
2633 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2634 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2636 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2637 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2638 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2640 placeholderFontstyleMap.Clear();
2641 placeholderFontstyleMap.Insert( "slant", "roman" );
2642 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2643 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2645 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2647 placeholderFontstyleMap.Clear();
2648 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2650 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2651 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2652 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2653 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2658 int UtcDaliTextFieldSetPaddingProperty(void)
2660 ToolkitTestApplication application;
2661 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
2663 TextField field = TextField::New();
2664 DALI_TEST_CHECK( field );
2665 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2666 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2667 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2668 application.GetScene().Add( field );
2670 application.SendNotification();
2671 application.Render();
2673 Vector3 originalSize = field.GetNaturalSize();
2675 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2677 application.SendNotification();
2678 application.Render();
2680 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2682 Vector3 paddingAddedSize = field.GetNaturalSize();
2684 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2686 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2691 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
2693 ToolkitTestApplication application;
2694 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
2696 TextField field = TextField::New();
2697 DALI_TEST_CHECK( field );
2698 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2699 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2700 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2701 application.GetScene().Add( field );
2703 application.SendNotification();
2704 application.Render();
2706 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2707 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2709 // Check the enable shift selection property
2710 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
2711 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2713 application.SendNotification();
2714 application.Render();
2719 int UtcDaliTextFieldEnableGrabHandleProperty(void)
2721 ToolkitTestApplication application;
2722 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
2724 TextField field = TextField::New();
2725 DALI_TEST_CHECK( field );
2726 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2727 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2728 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2729 application.GetScene().Add( field );
2731 application.SendNotification();
2732 application.Render();
2734 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2735 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2737 // Check the enable grab handle property
2738 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
2739 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2741 application.SendNotification();
2742 application.Render();
2747 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
2749 ToolkitTestApplication application;
2750 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
2752 TextField field = TextField::New();
2753 DALI_TEST_CHECK( field );
2754 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2755 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2756 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2757 application.GetScene().Add( field );
2759 application.SendNotification();
2760 application.Render();
2762 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2763 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2765 // Check the match system language direction property
2766 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2767 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2769 application.SendNotification();
2770 application.Render();
2775 int utcDaliTextFieldLayoutDirectionCoverage(void)
2777 ToolkitTestApplication application;
2778 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
2780 // Creates a tap event. After creating a tap event the text field should
2781 // have the focus and add text with key events should be possible.
2782 TextField field = TextField::New();
2783 DALI_TEST_CHECK( field );
2785 application.GetScene().Add( field );
2787 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2788 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2789 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2791 // Avoid a crash when core load gl resources.
2792 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2794 // Render and notify
2795 application.SendNotification();
2796 application.Render();
2798 // init direction for coverage
2799 // Set horizontal alignment END
2800 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2802 // Create a tap event to touch the text field.
2803 TestGenerateTap( application, 150.0f, 25.0f );
2805 // Render and notify
2806 application.SendNotification();
2807 application.Render();
2809 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
2810 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2811 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
2813 // Set horizontal alignment BEGIN
2814 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
2816 // Create a tap event to touch the text field.
2817 TestGenerateTap( application, 150.0f, 25.0f );
2819 // Render and notify
2820 application.SendNotification();
2821 application.Render();
2823 // Set horizontal alignment CENTER
2824 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
2826 // Create a tap event to touch the text field.
2827 TestGenerateTap( application, 150.0f, 25.0f );
2829 // Render and notify
2830 application.SendNotification();
2831 application.Render();
2833 // Set horizontal alignment END
2834 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2836 // Create a tap event to touch the text field.
2837 TestGenerateTap( application, 150.0f, 25.0f );
2839 // Render and notify
2840 application.SendNotification();
2841 application.Render();
2843 // Generate a Esc key event. The text field should lose the focus.
2844 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2845 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2847 // Render and notify
2848 application.SendNotification();
2849 application.Render();
2851 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2856 int UtcDaliTextFieldGetInputMethodContext(void)
2858 ToolkitTestApplication application;
2859 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
2861 TextField field = TextField::New();
2862 DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );
2867 int UtcDaliTextFieldSelectWholeText(void)
2869 ToolkitTestApplication application;
2870 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
2872 TextField textField = TextField::New();
2874 application.GetScene().Add( textField );
2876 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2877 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2878 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2880 // Avoid a crash when core load gl resources.
2881 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2883 application.SendNotification();
2884 application.Render();
2886 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2888 DevelTextField::SelectWholeText( textField );
2890 application.SendNotification();
2891 application.Render();
2893 // Nothing should have been selected. The number of children is still 1
2894 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2896 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
2898 application.SendNotification();
2899 application.Render();
2901 DevelTextField::SelectWholeText( textField );
2903 application.SendNotification();
2904 application.Render();
2906 // Should be 2 children, the stencil and the layer
2907 DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
2909 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2910 Actor stencil = textField.GetChildAt( 0u );
2912 // The highlight actor is drawn first, so is the first actor in the list
2913 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2914 DALI_TEST_CHECK( highlight );
2919 int UtcDaliTextFieldSelectNone(void)
2921 ToolkitTestApplication application;
2922 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
2924 TextField textField = TextField::New();
2926 application.GetScene().Add( textField );
2928 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2929 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2930 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2932 // Avoid a crash when core load gl resources.
2933 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2935 application.SendNotification();
2936 application.Render();
2938 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
2940 application.SendNotification();
2941 application.Render();
2943 // Nothing is selected
2944 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
2945 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
2947 DevelTextField::SelectWholeText( textField );
2949 application.SendNotification();
2950 application.Render();
2952 // whole text is selected
2953 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
2954 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
2956 DevelTextField::SelectNone( textField );
2958 application.SendNotification();
2959 application.Render();
2961 // Nothing is selected
2962 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
2963 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
2968 int UtcDaliTextFieldSelectRange(void)
2970 ToolkitTestApplication application;
2971 tet_infoline(" UtcDaliTextFieldSelectRange ");
2973 TextField textField = TextField::New();
2975 application.GetScene().Add( textField );
2977 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2978 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2979 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2981 // Avoid a crash when core load gl resources.
2982 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2984 application.SendNotification();
2985 application.Render();
2987 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
2989 application.SendNotification();
2990 application.Render();
2992 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 0);
2993 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 5);
2995 // Hello is selected
2996 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
2997 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
2999 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3000 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3002 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 6);
3003 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 11);
3005 // world is selected
3006 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3007 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3009 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3010 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3015 int UtcDaliTextFieldEnableEditing(void)
3017 ToolkitTestApplication application;
3018 tet_infoline(" UtcDaliTextFieldEnableEditing ");
3020 TextField textField = TextField::New();
3022 application.GetScene().Add( textField );
3024 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3025 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3026 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3028 // Avoid a crash when core load gl resources.
3029 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3031 application.SendNotification();
3032 application.Render();
3034 textField.SetKeyInputFocus();
3035 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, false );
3036 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3038 // Render and notify
3039 application.SendNotification();
3040 application.Render();
3042 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3043 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3046 textField.SetKeyInputFocus();
3047 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
3048 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3050 // Render and notify
3051 application.SendNotification();
3052 application.Render();
3054 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3055 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3060 int UtcDaliToolkitTextFieldFontSizeScale(void)
3062 ToolkitTestApplication application;
3063 tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
3065 TextField textField = TextField::New();
3066 textField.SetProperty( TextField::Property::POINT_SIZE, 30.f );
3067 textField.SetProperty( TextField::Property::TEXT, "Test" );
3068 Vector3 nonScaledSize = textField.GetNaturalSize();
3070 TextField textFieldScaled = TextField::New();
3071 textFieldScaled.SetProperty( TextField::Property::POINT_SIZE, 15.f );
3072 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3073 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3074 Vector3 scaledSize = textFieldScaled.GetNaturalSize();
3076 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3078 textField.SetProperty( TextField::Property::PIXEL_SIZE, 30.f );
3079 textField.SetProperty( TextField::Property::TEXT, "Test" );
3080 nonScaledSize = textField.GetNaturalSize();
3082 textFieldScaled.SetProperty( TextField::Property::PIXEL_SIZE, 15.f );
3083 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3084 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3085 scaledSize = textFieldScaled.GetNaturalSize();
3087 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3092 int UtcDaliTextFieldPrimaryCursorPosition(void)
3094 ToolkitTestApplication application;
3095 tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
3097 TextField textField = TextField::New();
3099 application.GetScene().Add( textField );
3101 textField.SetProperty( TextField::Property::TEXT, "ABCEF");
3102 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3103 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3104 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3106 // Avoid a crash when core load gl resources.
3107 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3109 textField.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
3110 application.SendNotification();
3111 application.Render();
3113 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3115 // Render and notify
3116 application.SendNotification();
3117 application.Render();
3119 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3120 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );