2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali/public-api/rendering/renderer.h>
23 #include <dali/integration-api/events/key-event-integ.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/devel-api/adaptor-framework/key-devel.h>
27 #include <dali/devel-api/text-abstraction/font-client.h>
28 #include <dali-toolkit-test-suite-utils.h>
29 #include <dali-toolkit/dali-toolkit.h>
30 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
31 #include <dali-toolkit/devel-api/text/rendering-backend.h>
32 #include "toolkit-clipboard.h"
35 using namespace Toolkit;
37 void dali_textfield_startup(void)
39 test_return_value = TET_UNDEF;
42 void dali_textfield_cleanup(void)
44 test_return_value = TET_PASS;
50 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
51 const char* const PROPERTY_NAME_TEXT = "text";
52 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
53 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
54 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
55 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
56 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
57 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
58 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
59 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
60 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
61 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
62 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
63 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
64 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
65 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
66 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
67 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
68 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
69 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
70 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
71 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
72 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
73 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
80 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
81 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
82 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
83 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
84 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
85 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
86 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
88 const char* const PROPERTY_NAME_UNDERLINE = "underline";
89 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
90 const char* const PROPERTY_NAME_SHADOW = "shadow";
91 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
92 const char* const PROPERTY_NAME_EMBOSS = "emboss";
93 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
94 const char* const PROPERTY_NAME_OUTLINE = "outline";
95 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
97 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
98 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
99 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
100 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
101 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
102 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
103 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
104 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
105 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
106 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
107 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
108 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
110 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
111 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
113 const float RENDER_FRAME_INTERVAL = 16.66f;
115 const unsigned int DEFAULT_FONT_SIZE = 1152u;
116 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
118 const int KEY_RETURN_CODE = 36;
119 const int KEY_A_CODE = 38;
120 const int KEY_D_CODE = 40;
122 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
124 static bool gTextChangedCallBackCalled;
125 static bool gMaxCharactersCallBackCalled;
126 static bool gInputStyleChangedCallbackCalled;
127 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
129 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
131 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
132 Integration::ResourcePointer resource(bitmap);
133 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
136 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
140 LoadBitmapResource( app.GetPlatform(), width, height );
142 Property::Map propertyMap;
143 propertyMap["filename"] = "image.png";
144 propertyMap["width"] = width;
145 propertyMap["height"] = height;
146 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
147 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
148 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
149 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
150 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
151 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
152 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
153 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
157 * Simulate time passed by.
159 * @note this will always process at least 1 frame (1/60 sec)
161 * @param application Test application instance
162 * @param duration Time to pass in milliseconds.
163 * @return The actual time passed in milliseconds
165 static int Wait(ToolkitTestApplication& application, int duration = 0)
169 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
171 application.SendNotification();
172 application.Render(RENDER_FRAME_INTERVAL);
173 time += RENDER_FRAME_INTERVAL;
179 Dali::Integration::Point GetPointDownInside( Vector2& pos )
181 Dali::Integration::Point point;
182 point.SetState( PointState::DOWN );
183 point.SetScreenPosition( pos );
187 Dali::Integration::Point GetPointUpInside( Vector2& pos )
189 Dali::Integration::Point point;
190 point.SetState( PointState::UP );
191 point.SetScreenPosition( pos );
195 struct CallbackFunctor
197 CallbackFunctor(bool* callbackFlag)
198 : mCallbackFlag( callbackFlag )
204 *mCallbackFlag = true;
209 static void TestTextChangedCallback( TextField control )
211 tet_infoline(" TestTextChangedCallback");
213 gTextChangedCallBackCalled = true;
216 static void TestMaxLengthReachedCallback( TextField control )
218 tet_infoline(" TestMaxLengthReachedCallback");
220 gMaxCharactersCallBackCalled = true;
223 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
225 tet_infoline(" TestInputStyleChangedCallback");
227 gInputStyleChangedCallbackCalled = true;
228 gInputStyleMask = mask;
231 // Generate a KeyEvent to send to Core.
232 Integration::KeyEvent GenerateKey( const std::string& keyName,
233 const std::string& logicalKey,
234 const std::string& keyString,
237 unsigned long timeStamp,
238 const Integration::KeyEvent::State& keyState,
239 const std::string& compose = "",
240 const std::string& deviceName = DEFAULT_DEVICE_NAME,
241 const Device::Class::Type& deviceClass = Device::Class::NONE,
242 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
244 return Integration::KeyEvent( keyName,
257 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
259 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
261 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
263 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
265 Property::Value* valueSet = NULL;
266 if ( valueGet.first.type == Property::Key::INDEX )
268 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
272 // Get Key is a string so searching Set Map for a string key
273 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
276 if( NULL != valueSet )
278 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
280 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
283 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
285 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
288 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
290 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
293 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
295 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
298 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
300 Vector2 vector2Get = valueGet.second.Get<Vector2>();
301 Vector2 vector2Set = valueSet->Get<Vector2>();
302 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
305 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
307 Vector4 vector4Get = valueGet.second.Get<Vector4>();
308 Vector4 vector4Set = valueSet->Get<Vector4>();
309 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 );
315 if ( valueGet.first.type == Property::Key::INDEX )
317 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
321 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
333 int UtcDaliToolkitTextFieldConstructorP(void)
335 ToolkitTestApplication application;
336 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
338 DALI_TEST_CHECK( !textField );
342 int UtcDaliToolkitTextFieldNewP(void)
344 ToolkitTestApplication application;
345 tet_infoline(" UtcDaliToolkitTextFieldNewP");
346 TextField textField = TextField::New();
347 DALI_TEST_CHECK( textField );
351 int UtcDaliToolkitTextFieldDownCastP(void)
353 ToolkitTestApplication application;
354 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
355 TextField textField1 = TextField::New();
356 BaseHandle object( textField1 );
358 TextField textField2 = TextField::DownCast( object );
359 DALI_TEST_CHECK( textField2 );
361 TextField textField3 = DownCast< TextField >( object );
362 DALI_TEST_CHECK( textField3 );
366 int UtcDaliToolkitTextFieldDownCastN(void)
368 ToolkitTestApplication application;
369 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
370 BaseHandle uninitializedObject;
371 TextField textField1 = TextField::DownCast( uninitializedObject );
372 DALI_TEST_CHECK( !textField1 );
374 TextField textField2 = DownCast< TextField >( uninitializedObject );
375 DALI_TEST_CHECK( !textField2 );
379 int UtcDaliToolkitTextFieldCopyConstructorP(void)
381 ToolkitTestApplication application;
382 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
383 TextField textField = TextField::New();
384 textField.SetProperty( TextField::Property::TEXT, "Test" );
386 TextField copy( textField );
387 DALI_TEST_CHECK( copy );
388 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
392 int UtcDaliTextFieldMoveConstructor(void)
394 ToolkitTestApplication application;
396 TextField textField = TextField::New();
397 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
398 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
400 TextField moved = std::move( textField );
401 DALI_TEST_CHECK( moved );
402 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
403 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
404 DALI_TEST_CHECK( !textField );
409 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
411 ToolkitTestApplication application;
412 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
413 TextField textField = TextField::New();
414 textField.SetProperty( TextField::Property::TEXT, "Test" );
416 TextField copy = textField;
417 DALI_TEST_CHECK( copy );
418 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
422 int UtcDaliTextFieldMoveAssignment(void)
424 ToolkitTestApplication application;
426 TextField textField = TextField::New();
427 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
428 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
431 moved = std::move( textField );
432 DALI_TEST_CHECK( moved );
433 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
434 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
435 DALI_TEST_CHECK( !textField );
440 int UtcDaliTextFieldNewP(void)
442 ToolkitTestApplication application;
443 tet_infoline(" UtcDaliToolkitTextFieldNewP");
444 TextField textField = TextField::New();
445 DALI_TEST_CHECK( textField );
449 // Positive test case for a method
450 int UtcDaliTextFieldGetPropertyP(void)
452 ToolkitTestApplication application;
453 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
454 TextField field = TextField::New();
455 DALI_TEST_CHECK( field );
457 // Check Property Indices are correct
458 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextField::Property::RENDERING_BACKEND );
459 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
460 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
461 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
462 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
463 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
464 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
465 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
466 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
467 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
468 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
469 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
470 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
471 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
472 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
473 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
474 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
475 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
476 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
477 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
478 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
479 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
480 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
481 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
482 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
483 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
484 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
485 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
486 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
487 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
488 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
489 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
490 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
491 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
492 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
493 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
494 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
495 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
496 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
497 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
498 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
499 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
500 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
501 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
502 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
503 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
504 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
505 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
506 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
507 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
508 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextField::Property::FONT_SIZE_SCALE );
509 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
510 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
511 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
512 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP );
513 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextField::Property::BACKGROUND );
514 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextField::Property::GRAB_HANDLE_COLOR );
519 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
522 Property::Map imageMap;
523 imageMap[mapKey] =mapValue;
525 field.SetProperty( property , imageMap );
526 Property::Value propValue = field.GetProperty( property );
527 Property::Map* resultMap = propValue.GetMap();
529 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
537 // Positive test case for a method
538 int UtcDaliTextFieldSetPropertyP(void)
540 ToolkitTestApplication application;
541 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
542 TextField field = TextField::New();
543 DALI_TEST_CHECK( field );
544 application.GetScene().Add( field );
546 // Note - we can't check the defaults since the stylesheets are platform-specific
548 // Check the render backend property.
549 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
550 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
552 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
553 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION );
555 // Check text property.
556 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
557 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
559 // Check placeholder text properties.
560 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
561 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
563 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
564 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
566 // Check font properties.
567 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
568 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
570 Property::Map fontStyleMapSet;
571 Property::Map fontStyleMapGet;
572 Property::Value* slantValue = NULL;
574 fontStyleMapSet.Insert( "weight", "bold" );
575 fontStyleMapSet.Insert( "width", "condensed" );
576 fontStyleMapSet.Insert( "slant", "italic" );
577 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
579 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
580 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
581 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
583 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
584 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
586 field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 2.5f );
587 DALI_TEST_EQUALS( field.GetProperty<float>( DevelTextField::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
588 field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 1.0f );
591 fontStyleMapSet.Clear();
592 fontStyleMapSet.Insert( "weight", "normal" );
593 fontStyleMapSet.Insert( "slant", "oblique" );
594 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
596 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
597 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
598 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
600 fontStyleMapSet.Clear();
601 fontStyleMapSet.Insert( "slant", "roman" );
602 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
603 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
605 // Replace 'roman' for 'normal'.
606 slantValue = fontStyleMapGet.Find( "slant" );
607 if( NULL != slantValue )
609 if( "normal" == slantValue->Get<std::string>() )
611 fontStyleMapGet["slant"] = "roman";
614 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
615 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
617 fontStyleMapSet.Clear();
619 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
620 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
621 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
622 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
624 // Check that the MAX_LENGTH property can be correctly set
625 const int maxNumberOfCharacters = 20;
626 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
627 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
629 // Check exceed policy
630 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
631 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
632 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
633 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
635 // Check that the Alignment properties can be correctly set
636 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
637 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
638 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
639 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
641 // Check text's color property
642 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
643 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
645 // Check placeholder text's color property.
646 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
647 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
649 // Check cursor properties
650 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
651 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
652 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
653 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
655 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
656 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
657 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
658 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
659 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
660 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
661 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
662 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
664 // Check scroll properties.
665 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
666 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
667 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
668 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
670 // Check handle images
671 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
672 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
673 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
674 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
675 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
677 // Check handle images
678 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
679 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
680 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
681 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
682 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
683 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
685 // Check the highlight color
686 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
687 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
689 // Decoration bounding box
690 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
691 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
693 // Check the input method setting
694 Property::Map propertyMap;
695 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
696 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
697 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
698 int inputVariation = 1;
699 propertyMap["PANEL_LAYOUT"] = panelLayout;
700 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
701 propertyMap["BUTTON_ACTION"] = buttonAction;
702 propertyMap["VARIATION"] = inputVariation;
703 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
705 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
707 DALI_TEST_CHECK( value.Get( map ) );
710 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
711 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
714 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
715 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
718 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
719 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
722 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
723 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
725 // Check input color property.
726 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
727 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
729 // Check the enable markup property.
730 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
731 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
732 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
734 // Check input font properties.
735 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
736 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
738 fontStyleMapSet.Clear();
739 fontStyleMapSet.Insert( "weight", "bold" );
740 fontStyleMapSet.Insert( "width", "condensed" );
741 fontStyleMapSet.Insert( "slant", "italic" );
743 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
744 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
745 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
746 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
748 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
749 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
751 // Reset input font style.
752 fontStyleMapSet.Clear();
753 fontStyleMapSet.Insert( "weight", "normal" );
754 fontStyleMapSet.Insert( "slant", "oblique" );
756 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
757 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
758 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
759 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
761 fontStyleMapSet.Clear();
762 fontStyleMapSet.Insert( "slant", "roman" );
764 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
765 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
767 // Replace 'roman' for 'normal'.
768 slantValue = fontStyleMapGet.Find( "slant" );
769 if( NULL != slantValue )
771 if( "normal" == slantValue->Get<std::string>() )
773 fontStyleMapGet["slant"] = "roman";
776 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
777 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
779 fontStyleMapSet.Clear();
781 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
782 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
783 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
784 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
786 Property::Map underlineMapSet;
787 Property::Map underlineMapGet;
789 underlineMapSet.Insert( "enable", true );
790 underlineMapSet.Insert( "color", Color::RED );
791 underlineMapSet.Insert( "height", 1 );
793 // Check the underline property
794 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
796 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
797 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
798 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
800 // Check the input underline property
801 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
802 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
804 // Check the shadow property
805 Property::Map shadowMapSet;
806 Property::Map shadowMapGet;
808 shadowMapSet.Insert( "color", Color::GREEN );
809 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
810 shadowMapSet.Insert( "blurRadius", 3.0f );
812 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
814 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
815 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
816 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
818 // Check the input shadow property
819 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
820 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
822 // Check the emboss property
823 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
824 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
826 // Check the input emboss property
827 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
828 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
830 // Check the outline property
832 // Test string type first
833 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
834 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
835 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
837 // Then test the property map type
838 Property::Map outlineMapSet;
839 Property::Map outlineMapGet;
841 outlineMapSet["color"] = Color::RED;
842 outlineMapSet["width"] = 2.0f;
844 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
846 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
847 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
848 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
850 // Check the input outline property
851 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
852 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
854 // Check the hidden input settings property
855 Property::Map hiddenMapSet;
856 Property::Map hiddenMapGet;
857 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
858 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
859 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
860 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
861 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
863 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
864 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
865 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
867 // Check the pixel size of font
868 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
869 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
871 // Check the enable selection property
872 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
873 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
875 // Check the placeholder property with pixel size
876 Property::Map placeholderPixelSizeMapSet;
877 Property::Map placeholderPixelSizeMapGet;
878 Property::Map placeholderFontstyleMap;
879 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
880 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
881 placeholderPixelSizeMapSet["color"] = Color::BLUE;
882 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
883 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
884 placeholderPixelSizeMapSet["ellipsis"] = true;
886 placeholderFontstyleMap.Insert( "weight", "bold" );
887 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
888 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
890 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
891 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
893 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
894 Property::Map placeholderConversionMap;
895 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
896 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
897 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
898 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
899 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
900 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
902 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
904 // Check the placeholder property with point size
905 Property::Map placeholderMapSet;
906 Property::Map placeholderMapGet;
907 placeholderMapSet["text"] = "Setting Placeholder Text";
908 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
909 placeholderMapSet["color"] = Color::RED;
910 placeholderMapSet["fontFamily"] = "Arial";
911 placeholderMapSet["pointSize"] = 12.0f;
912 placeholderMapSet["ellipsis"] = false;
914 // Check the placeholder font style property
915 placeholderFontstyleMap.Clear();
917 placeholderFontstyleMap.Insert( "weight", "bold" );
918 placeholderFontstyleMap.Insert( "width", "condensed" );
919 placeholderFontstyleMap.Insert( "slant", "italic" );
920 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
921 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
923 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
924 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
926 placeholderConversionMap.Clear();
927 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
928 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
929 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
930 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
931 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
932 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
934 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
937 placeholderFontstyleMap.Clear();
938 placeholderFontstyleMap.Insert( "weight", "normal" );
939 placeholderFontstyleMap.Insert( "slant", "oblique" );
940 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
941 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
943 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
944 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
946 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
947 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
949 placeholderFontstyleMap.Clear();
950 placeholderFontstyleMap.Insert( "slant", "roman" );
951 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
952 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
954 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
956 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
958 placeholderFontstyleMap.Clear();
959 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
960 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
962 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
963 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
964 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
966 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
968 // Check the ellipsis property
969 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
970 field.SetProperty( TextField::Property::ELLIPSIS, true );
971 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
973 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
974 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
976 // Test the ENABLE_GRAB_HANDLE_POPUP property
977 DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
978 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false );
979 DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
981 // Check the background property
982 field.SetProperty( DevelTextField::Property::BACKGROUND, Color::RED );
983 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::BACKGROUND ), Color::RED, TEST_LOCATION );
986 field.SetProperty( DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN );
987 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
989 application.SendNotification();
990 application.Render();
995 // Positive Atlas Text Renderer test
996 int utcDaliTextFieldAtlasRenderP(void)
998 ToolkitTestApplication application;
999 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1000 StyleManager styleManager = StyleManager::Get();
1001 styleManager.ApplyDefaultTheme();
1002 TextField field = TextField::New();
1003 DALI_TEST_CHECK( field );
1005 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1007 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1009 application.GetScene().Add( field );
1013 // Render some text with the shared atlas backend
1014 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1015 application.SendNotification();
1016 application.Render();
1020 tet_result(TET_FAIL);
1025 // Positive test for the textChanged signal.
1026 int utcDaliTextFieldTextChangedP(void)
1028 ToolkitTestApplication application;
1029 tet_infoline(" utcDaliTextFieldTextChangedP");
1030 TextField field = TextField::New();
1031 DALI_TEST_CHECK( field );
1033 application.GetScene().Add( field );
1035 // connect to the text changed signal.
1036 ConnectionTracker* testTracker = new ConnectionTracker();
1037 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1038 bool textChangedSignal = false;
1039 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1041 gTextChangedCallBackCalled = false;
1042 field.SetProperty( TextField::Property::TEXT, "ABC" );
1043 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1044 DALI_TEST_CHECK( textChangedSignal );
1046 application.SendNotification();
1047 field.SetKeyInputFocus();
1049 gTextChangedCallBackCalled = false;
1050 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1051 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1054 field.SetProperty( TextField::Property::TEXT, "" );
1056 // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1057 gTextChangedCallBackCalled = false;
1058 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1059 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1061 // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1062 gTextChangedCallBackCalled = false;
1063 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1064 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1069 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1071 ToolkitTestApplication application;
1072 tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1073 TextField field = TextField::New();
1074 DALI_TEST_CHECK( field );
1077 application.GetScene().Add( field );
1079 // connect to the text changed signal.
1080 ConnectionTracker* testTracker = new ConnectionTracker();
1081 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1082 bool textChangedSignal = false;
1083 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1086 // get InputMethodContext
1088 InputMethodContext::EventData imfEvent;
1089 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext( field );
1091 field.SetKeyInputFocus();
1092 field.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
1095 gTextChangedCallBackCalled = false;
1096 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1097 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1098 application.SendNotification();
1099 application.Render();
1100 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1101 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1103 gTextChangedCallBackCalled = false;
1104 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1105 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1106 application.SendNotification();
1107 application.Render();
1108 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1109 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호"), TEST_LOCATION );
1111 gTextChangedCallBackCalled = false;
1112 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1113 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1114 application.SendNotification();
1115 application.Render();
1116 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1117 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1119 gTextChangedCallBackCalled = false;
1120 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1121 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1122 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1124 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1125 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1126 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1128 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1129 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1130 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1132 application.SendNotification();
1133 application.Render();
1134 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1135 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1141 // Negative test for the textChanged signal.
1142 int utcDaliTextFieldTextChangedN(void)
1144 ToolkitTestApplication application;
1145 tet_infoline(" utcDaliTextFieldTextChangedN");
1146 TextField field = TextField::New();
1147 DALI_TEST_CHECK( field );
1149 application.GetScene().Add( field );
1151 // connect to the text changed signal.
1152 ConnectionTracker* testTracker = new ConnectionTracker();
1153 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1154 bool textChangedSignal = false;
1155 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1157 gTextChangedCallBackCalled = false;
1158 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1159 application.SendNotification();
1160 application.Render();
1161 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1162 DALI_TEST_CHECK( !textChangedSignal );
1167 // Positive test for Max Characters reached signal.
1168 int utcDaliTextFieldMaxCharactersReachedP(void)
1170 ToolkitTestApplication application;
1171 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1172 TextField field = TextField::New();
1173 DALI_TEST_CHECK( field );
1175 application.GetScene().Add( field );
1177 const int maxNumberOfCharacters = 1;
1178 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1180 field.SetKeyInputFocus();
1182 // connect to the text changed signal.
1183 ConnectionTracker* testTracker = new ConnectionTracker();
1184 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1185 bool maxLengthReachedSignal = false;
1186 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1188 gMaxCharactersCallBackCalled = false;
1190 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1191 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1193 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1194 DALI_TEST_CHECK( maxLengthReachedSignal );
1199 // Negative test for Max Characters reached signal.
1200 int utcDaliTextFieldMaxCharactersReachedN(void)
1202 ToolkitTestApplication application;
1203 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1204 TextField field = TextField::New();
1205 DALI_TEST_CHECK( field );
1207 application.GetScene().Add( field );
1209 const int maxNumberOfCharacters = 3;
1210 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1212 field.SetKeyInputFocus();
1214 // connect to the text changed signal.
1215 ConnectionTracker* testTracker = new ConnectionTracker();
1216 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1217 bool maxLengthReachedSignal = false;
1218 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1220 gMaxCharactersCallBackCalled = false;
1222 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1223 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1225 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1226 DALI_TEST_CHECK( !maxLengthReachedSignal );
1228 application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1230 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1231 DALI_TEST_CHECK( !maxLengthReachedSignal );
1236 int utcDaliTextFieldInputStyleChanged01(void)
1238 // The text-field emits signals when the input style changes. These changes of style are
1239 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1240 // can't be emitted during the size negotiation as the callbacks may update the UI.
1241 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1242 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1243 ToolkitTestApplication application;
1244 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1248 char* pathNamePtr = get_current_dir_name();
1249 const std::string pathName( pathNamePtr );
1250 free( pathNamePtr );
1252 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1253 fontClient.SetDpi( 93u, 93u );
1255 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1256 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1258 TextField field = TextField::New();
1259 DALI_TEST_CHECK( field );
1262 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1263 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1264 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1266 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1267 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1269 // connect to the text changed signal.
1270 ConnectionTracker* testTracker = new ConnectionTracker();
1271 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1272 bool inputStyleChangedSignal = false;
1273 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1275 application.GetScene().Add( field );
1277 // Render and notify
1278 application.SendNotification();
1279 application.Render();
1281 // Executes the idle callbacks added by the text control on the change of input style.
1282 application.RunIdles();
1284 gInputStyleChangedCallbackCalled = false;
1285 gInputStyleMask = TextField::InputStyle::NONE;
1286 inputStyleChangedSignal = false;
1288 // Create a tap event to touch the text field.
1289 TestGenerateTap( application, 18.0f, 25.0f );
1291 // Render and notify
1292 application.SendNotification();
1293 application.Render();
1295 // Executes the idle callbacks added by the text control on the change of input style.
1296 application.RunIdles();
1298 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1299 if( gInputStyleChangedCallbackCalled )
1301 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1303 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1304 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1306 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1307 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1309 DALI_TEST_CHECK( inputStyleChangedSignal );
1311 gInputStyleChangedCallbackCalled = false;
1312 gInputStyleMask = TextField::InputStyle::NONE;
1313 inputStyleChangedSignal = false;
1315 // Create a tap event to touch the text field.
1316 TestGenerateTap( application, 30.0f, 25.0f );
1318 // Render and notify
1319 application.SendNotification();
1320 application.Render();
1322 // Executes the idle callbacks added by the text control on the change of input style.
1323 application.RunIdles();
1325 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1326 DALI_TEST_CHECK( !inputStyleChangedSignal );
1328 gInputStyleChangedCallbackCalled = false;
1329 gInputStyleMask = TextField::InputStyle::NONE;
1330 inputStyleChangedSignal = false;
1332 // Create a tap event to touch the text field.
1333 TestGenerateTap( application, 43.0f, 25.0f );
1335 // Render and notify
1336 application.SendNotification();
1337 application.Render();
1339 // Executes the idle callbacks added by the text control on the change of input style.
1340 application.RunIdles();
1342 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1343 if( gInputStyleChangedCallbackCalled )
1345 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1347 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1348 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1350 DALI_TEST_CHECK( inputStyleChangedSignal );
1352 gInputStyleChangedCallbackCalled = false;
1353 gInputStyleMask = TextField::InputStyle::NONE;
1354 inputStyleChangedSignal = false;
1356 // Create a tap event to touch the text field.
1357 TestGenerateTap( application, 88.0f, 25.0f );
1359 // Render and notify
1360 application.SendNotification();
1361 application.Render();
1363 // Executes the idle callbacks added by the text control on the change of input style.
1364 application.RunIdles();
1366 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1367 if( gInputStyleChangedCallbackCalled )
1369 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1371 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1372 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1374 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1376 Property::Map fontStyleMapSet;
1377 fontStyleMapSet.Insert( "weight", "bold" );
1379 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1380 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1382 DALI_TEST_CHECK( inputStyleChangedSignal );
1384 gInputStyleChangedCallbackCalled = false;
1385 gInputStyleMask = TextField::InputStyle::NONE;
1386 inputStyleChangedSignal = false;
1388 // Create a tap event to touch the text field.
1389 TestGenerateTap( application, 115.0f, 25.0f );
1391 // Render and notify
1392 application.SendNotification();
1393 application.Render();
1395 // Executes the idle callbacks added by the text control on the change of input style.
1396 application.RunIdles();
1398 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1399 DALI_TEST_CHECK( !inputStyleChangedSignal );
1401 gInputStyleChangedCallbackCalled = false;
1402 gInputStyleMask = TextField::InputStyle::NONE;
1403 inputStyleChangedSignal = false;
1405 // Create a tap event to touch the text field.
1406 TestGenerateTap( application, 164.0f, 25.0f );
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 ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1420 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1421 DALI_TEST_CHECK( style.empty() );
1423 DALI_TEST_CHECK( inputStyleChangedSignal );
1425 gInputStyleChangedCallbackCalled = false;
1426 gInputStyleMask = TextField::InputStyle::NONE;
1427 inputStyleChangedSignal = false;
1429 // Create a tap event to touch the text field.
1430 TestGenerateTap( application, 191.0f, 25.0f );
1432 // Render and notify
1433 application.SendNotification();
1434 application.Render();
1436 // Executes the idle callbacks added by the text control on the change of input style.
1437 application.RunIdles();
1439 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1440 DALI_TEST_CHECK( !inputStyleChangedSignal );
1445 int utcDaliTextFieldInputStyleChanged02(void)
1447 // The text-field emits signals when the input style changes. These changes of style are
1448 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1449 // can't be emitted during the size negotiation as the callbacks may update the UI.
1450 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1451 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1452 ToolkitTestApplication application;
1453 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1457 char* pathNamePtr = get_current_dir_name();
1458 const std::string pathName( pathNamePtr );
1459 free( pathNamePtr );
1461 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1462 fontClient.SetDpi( 93u, 93u );
1464 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1465 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1467 TextField field = TextField::New();
1468 DALI_TEST_CHECK( field );
1470 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1471 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1472 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1474 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1475 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>" );
1477 // connect to the text changed signal.
1478 ConnectionTracker* testTracker = new ConnectionTracker();
1479 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1480 bool inputStyleChangedSignal = false;
1481 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1483 application.GetScene().Add( field );
1485 // Render and notify
1486 application.SendNotification();
1487 application.Render();
1489 // Executes the idle callbacks added by the text control on the change of input style.
1490 application.RunIdles();
1492 gInputStyleChangedCallbackCalled = false;
1493 gInputStyleMask = TextField::InputStyle::NONE;
1494 inputStyleChangedSignal = false;
1496 // Create a tap event to touch the text field.
1497 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1498 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1500 // Render and notify
1501 application.SendNotification();
1502 application.Render();
1504 // Executes the idle callbacks added by the text control on the change of input style.
1505 application.RunIdles();
1507 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1508 if( gInputStyleChangedCallbackCalled )
1510 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1511 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1512 TextField::InputStyle::POINT_SIZE |
1513 TextField::InputStyle::COLOR ),
1516 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1517 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1519 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1520 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1522 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1523 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1525 DALI_TEST_CHECK( inputStyleChangedSignal );
1527 gInputStyleChangedCallbackCalled = false;
1528 gInputStyleMask = TextField::InputStyle::NONE;
1529 inputStyleChangedSignal = false;
1531 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
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 ),
1547 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1548 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1550 DALI_TEST_CHECK( inputStyleChangedSignal );
1552 gInputStyleChangedCallbackCalled = false;
1553 gInputStyleMask = TextField::InputStyle::NONE;
1554 inputStyleChangedSignal = false;
1556 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1558 // Render and notify
1559 application.SendNotification();
1560 application.Render();
1562 // Executes the idle callbacks added by the text control on the change of input style.
1563 application.RunIdles();
1565 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1566 DALI_TEST_CHECK( !inputStyleChangedSignal );
1568 gInputStyleChangedCallbackCalled = false;
1569 gInputStyleMask = TextField::InputStyle::NONE;
1570 inputStyleChangedSignal = false;
1572 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1574 // Render and notify
1575 application.SendNotification();
1576 application.Render();
1578 // Executes the idle callbacks added by the text control on the change of input style.
1579 application.RunIdles();
1581 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1582 if( gInputStyleChangedCallbackCalled )
1584 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1585 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1588 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1589 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1591 DALI_TEST_CHECK( inputStyleChangedSignal );
1593 gInputStyleChangedCallbackCalled = false;
1594 gInputStyleMask = TextField::InputStyle::NONE;
1595 inputStyleChangedSignal = false;
1597 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1599 Property::Map fontStyleMapSet;
1600 fontStyleMapSet.Insert( "weight", "thin" );
1601 fontStyleMapSet.Insert( "width", "condensed" );
1602 fontStyleMapSet.Insert( "slant", "italic" );
1604 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1605 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1607 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1608 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1609 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1610 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1612 // Render and notify
1613 application.SendNotification();
1614 application.Render();
1616 // Executes the idle callbacks added by the text control on the change of input style.
1617 application.RunIdles();
1619 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1620 DALI_TEST_CHECK( !inputStyleChangedSignal );
1622 // Create a tap event to touch the text field.
1623 TestGenerateTap( application, 63.0f, 25.0f, 300 );
1625 // Render and notify
1626 application.SendNotification();
1627 application.Render();
1629 // Executes the idle callbacks added by the text control on the change of input style.
1630 application.RunIdles();
1632 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1633 if( gInputStyleChangedCallbackCalled )
1635 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1636 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1637 TextField::InputStyle::POINT_SIZE |
1638 TextField::InputStyle::FONT_STYLE |
1639 TextField::InputStyle::UNDERLINE |
1640 TextField::InputStyle::SHADOW |
1641 TextField::InputStyle::EMBOSS |
1642 TextField::InputStyle::OUTLINE ),
1645 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1646 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1648 DALI_TEST_CHECK( inputStyleChangedSignal );
1653 int utcDaliTextFieldEvent01(void)
1655 ToolkitTestApplication application;
1656 tet_infoline(" utcDaliTextFieldEvent01");
1658 // Creates a tap event. After creating a tap event the text field should
1659 // have the focus and add text with key events should be possible.
1661 TextField field = TextField::New();
1662 DALI_TEST_CHECK( field );
1664 application.GetScene().Add( field );
1666 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1667 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1668 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1670 // Render and notify
1671 application.SendNotification();
1672 application.Render();
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 // Add a key event but as the text field has not the focus it should do nothing.
1682 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1684 // Render and notify
1685 application.SendNotification();
1686 application.Render();
1688 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1690 // Create a tap event to touch the text field.
1691 TestGenerateTap( application, 150.0f, 25.0f );
1693 // Render and notify
1694 application.SendNotification();
1695 application.Render();
1697 // Pressing delete key should be fine even if there is no text in TextField.
1698 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 ) );
1699 // Render and notify
1700 application.SendNotification();
1701 application.Render();
1703 // Now the text field has the focus, so it can handle the key events.
1704 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1705 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1707 // Render and notify
1708 application.SendNotification();
1709 application.Render();
1711 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1713 // Create a second text field and send key events to it.
1714 TextField field2 = TextField::New();
1716 field2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1717 field2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1718 field2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1719 field2.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
1721 application.GetScene().Add( field2 );
1723 // Render and notify
1724 application.SendNotification();
1725 application.Render();
1727 // Create a tap event on the second text field.
1728 TestGenerateTap( application, 150.0f, 125.0f );
1730 // Render and notify
1731 application.SendNotification();
1732 application.Render();
1734 // The second text field has the focus. It should handle the key events.
1735 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1736 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1738 // Render and notify
1739 application.SendNotification();
1740 application.Render();
1742 // Check the text has been added to the second text field.
1743 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1748 int utcDaliTextFieldEvent02(void)
1750 ToolkitTestApplication application;
1751 tet_infoline(" utcDaliTextFieldEvent02");
1753 // Checks if the right number of actors are created.
1755 TextField field = TextField::New();
1756 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1757 DALI_TEST_CHECK( field );
1758 LoadMarkerImages(application, field);
1760 application.GetScene().Add( field );
1762 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1763 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1764 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1766 // Avoid a crash when core load gl resources.
1767 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1769 // Render and notify
1770 application.SendNotification();
1771 application.Render();
1773 // Check there are the expected number of children ( stencil ).
1774 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1776 Actor stencil = field.GetChildAt( 0u );
1777 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1779 // Create a tap event to touch the text field.
1780 TestGenerateTap( application, 150.0f, 25.0f, 300 );
1782 // Render and notify
1783 application.SendNotification();
1784 application.Render();
1786 Actor layer = field.GetChildAt( 1u );
1787 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1788 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1790 // Now the text field has the focus, so it can handle the key events.
1791 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1792 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1794 // Render and notify
1795 application.SendNotification();
1796 application.Render();
1798 // Checks the cursor and the renderer have been created.
1799 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1800 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1802 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1803 DALI_TEST_CHECK( cursor );
1805 // The offscreen root actor has a container with all the actors which contain the text renderers.
1806 Actor container = stencil.GetChildAt( 0u );
1807 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1809 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1810 DALI_TEST_CHECK( renderer );
1813 // Move the cursor and check the position changes.
1814 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1815 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1817 // Render and notify
1818 application.SendNotification();
1819 application.Render();
1821 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1822 DALI_TEST_CHECK( position2.x < position1.x );
1824 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1826 // Render and notify
1827 application.SendNotification();
1828 application.Render();
1830 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1831 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1834 // Move the cursor to the first position.
1835 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1836 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1838 // Render and notify
1839 application.SendNotification();
1840 application.Render();
1842 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1844 // Send some taps and check the cursor positions.
1846 // Try to tap at the beginning.
1847 TestGenerateTap( application, 1.0f, 25.0f, 900 );
1849 // Render and notify
1850 application.SendNotification();
1851 application.Render();
1853 // Cursor position should be the same than position1.
1854 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1856 DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
1858 // Tap away from the start position.
1859 TestGenerateTap( application, 16.0f, 25.0f, 1500 );
1861 // Render and notify
1862 application.SendNotification();
1863 application.Render();
1865 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1867 DALI_TEST_CHECK( position6.x > position5.x );
1869 // Remove all the text.
1870 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1871 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1872 field.SetProperty( TextField::Property::TEXT, "" );
1874 // Render and notify
1875 application.SendNotification();
1876 application.Render();
1878 // Cursor position should be the same than position2.
1879 Vector3 position7 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1881 DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
1883 // Should not be a renderer.
1884 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1886 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1887 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1888 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1890 application.SendNotification();
1891 application.Render();
1893 // There are renderer and decorator layer
1894 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1899 int utcDaliTextFieldEvent03(void)
1901 ToolkitTestApplication application;
1902 tet_infoline(" utcDaliTextFieldEvent03");
1904 // Checks if the highlight actor is created.
1906 TextField field = TextField::New();
1907 DALI_TEST_CHECK( field );
1909 application.GetScene().Add( field );
1911 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1912 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1913 field.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1914 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1915 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1917 // Avoid a crash when core load gl resources.
1918 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1919 LoadMarkerImages(application, field);
1921 // Render and notify
1922 application.SendNotification();
1923 application.Render();
1925 // Tap first to get the focus.
1926 TestGenerateTap( application, 3.0f, 25.0f );
1928 // Render and notify
1929 application.SendNotification();
1930 application.Render();
1932 // Double tap to select a word.
1933 TestGenerateTap( application, 3.0f, 25.0f );
1935 // Render and notify
1936 application.SendNotification();
1937 application.Render();
1939 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1940 Actor stencil = field.GetChildAt( 0u );
1942 // The highlight actor is drawn first, so is the first actor in the list
1943 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1944 DALI_TEST_CHECK( highlight );
1946 // The offscreen root actor has a container with all the actors which contain the text renderers.
1947 Actor container = stencil.GetChildAt( 1u );
1948 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1950 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1951 DALI_TEST_CHECK( renderer );
1957 int utcDaliTextFieldEvent04(void)
1959 ToolkitTestApplication application;
1960 tet_infoline(" utcDaliTextFieldEvent04");
1962 // Checks if the highlight actor is created.
1964 TextField field = TextField::New();
1965 DALI_TEST_CHECK( field );
1966 application.GetScene().Add( field );
1967 LoadMarkerImages(application, field);
1968 // Render and notify
1969 application.SendNotification();
1970 application.Render();
1972 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1973 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1974 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1975 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1976 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1978 // Avoid a crash when core load gl resources.
1979 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1980 // Render and notify
1981 application.SendNotification();
1982 application.Render();
1984 // Create a tap event to touch the text field.
1985 TestGenerateTap( application, 150.0f, 25.0f );
1986 // Render and notify
1987 application.SendNotification();
1988 application.Render();
1991 // Tap first to get the focus.
1992 TestGenerateTap( application, 1.0f, 25.0f );
1994 // Render and notify
1995 application.SendNotification();
1996 application.Render();
1998 // Double tap to select a word.
1999 TestGenerateTap( application, 1.0f, 25.0f );
2001 // Render and notify
2002 application.SendNotification();
2003 application.Render();
2006 TestGenerateTap( application, 0.0f, 40.0f );
2010 int utcDaliTextFieldEvent05(void)
2012 ToolkitTestApplication application;
2013 tet_infoline(" utcDaliTextFieldEvent05");
2015 // Checks dragging of cursor/grab handle
2017 TextField field = TextField::New();
2018 DALI_TEST_CHECK( field );
2019 application.GetScene().Add( field );
2020 LoadMarkerImages(application, field);
2021 // Render and notify
2022 application.SendNotification();
2023 application.Render();
2025 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2026 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2027 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2028 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2029 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2031 // Avoid a crash when core load gl resources.
2032 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2033 // Render and notify
2034 application.SendNotification();
2035 application.Render();
2037 // Create a tap event to touch the text field.
2038 TestGenerateTap( application, 150.0f, 25.0f );
2039 // Render and notify
2040 application.SendNotification();
2041 application.Render();
2043 // Tap first to get the focus.
2044 TestGenerateTap( application, 1.0f, 25.0f );
2046 // Render and notify
2047 application.SendNotification();
2048 application.Render();
2050 // Double tap to select a word.
2051 TestGenerateTap( application, 1.0f, 25.0f );
2053 // Render and notify
2054 application.SendNotification();
2055 application.Render();
2057 Actor stencil = field.GetChildAt( 1u );
2061 int utcDaliTextFieldEvent06(void)
2063 ToolkitTestApplication application;
2064 tet_infoline(" utcDaliTextFieldEvent06");
2066 // Checks Longpress when in edit mode
2068 TextField field = TextField::New();
2069 DALI_TEST_CHECK( field );
2070 application.GetScene().Add( field );
2071 LoadMarkerImages(application, field);
2072 // Render and notify
2073 application.SendNotification();
2074 application.Render();
2076 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2077 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2078 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2079 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2080 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2082 // Avoid a crash when core load gl resources.
2083 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2084 // Render and notify
2085 application.SendNotification();
2086 application.Render();
2088 // Create a tap event to touch the text field.
2089 TestGenerateTap( application, 150.0f, 25.0f );
2090 // Render and notify
2091 application.SendNotification();
2092 application.Render();
2095 // Tap first to get the focus.
2096 TestGenerateTap( application, 1.0f, 25.0f );
2098 // Render and notify
2099 application.SendNotification();
2100 application.Render();
2103 TestGenerateLongPress(application, 1.0f, 25.0f);
2105 // Render and notify
2106 application.SendNotification();
2107 application.Render();
2112 int utcDaliTextFieldEvent07(void)
2114 ToolkitTestApplication application;
2115 tet_infoline(" utcDaliTextFieldEvent07");
2117 // Checks Longpress to start edit mode
2119 TextField field = TextField::New();
2120 DALI_TEST_CHECK( field );
2121 application.GetScene().Add( field );
2122 LoadMarkerImages(application, field);
2123 // Render and notify
2124 application.SendNotification();
2125 application.Render();
2127 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2128 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2129 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2130 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2131 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2132 Property::Map propertyMap;
2133 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2134 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2136 // Avoid a crash when core load gl resources.
2137 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2138 // Render and notify
2139 application.SendNotification();
2140 application.Render();
2143 TestGenerateLongPress(application, 1.0f, 25.0f);
2145 // Render and notify
2146 application.SendNotification();
2147 application.Render();
2152 int utcDaliTextFieldEvent08(void)
2154 ToolkitTestApplication application;
2155 tet_infoline(" utcDaliTextFieldEvent08");
2157 Dali::Clipboard clipboard = Clipboard::Get();
2158 clipboard.SetItem("testTextFieldEvent");
2160 // Checks Longpress when only place holder text
2162 TextField field = TextField::New();
2163 DALI_TEST_CHECK( field );
2164 application.GetScene().Add( field );
2165 LoadMarkerImages(application, field);
2166 // Render and notify
2167 application.SendNotification();
2168 application.Render();
2170 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2171 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2172 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2173 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2174 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2176 // Avoid a crash when core load gl resources.
2177 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2178 // Render and notify
2179 application.SendNotification();
2180 application.Render();
2183 TestGenerateLongPress( application, 1.0f, 25.0f, 20 );
2185 // Render and notify
2186 application.SendNotification();
2187 application.Render();
2189 Wait(application, 500);
2191 TestEndLongPress( application, 1.0f, 25.0f, 520 );
2194 TestGenerateLongPress( application, 1.0f, 25.0f, 600 );
2196 // Render and notify
2197 application.Render();
2199 Wait(application, 500);
2201 Integration::Scene stage = application.GetScene();
2202 Layer layer = stage.GetRootLayer();
2203 Actor actor = layer.FindChildByName("optionPaste");
2207 Vector3 worldPosition = actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION );
2208 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2209 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2211 Dali::Integration::TouchEvent event;
2212 event = Dali::Integration::TouchEvent();
2213 event.AddPoint( GetPointDownInside( position ) );
2214 application.ProcessEvent( event );
2216 event = Dali::Integration::TouchEvent();
2217 event.AddPoint( GetPointUpInside( position ) );
2218 application.ProcessEvent( event );
2220 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2225 int utcDaliTextFieldEvent09(void)
2227 ToolkitTestApplication application;
2228 tet_infoline(" utcDaliTextFieldEvent09");
2230 TextField field = TextField::New();
2231 DALI_TEST_CHECK( field );
2232 application.GetScene().Add( field );
2233 LoadMarkerImages(application, field);
2234 // Render and notify
2235 application.SendNotification();
2236 application.Render();
2238 field.SetProperty( TextField::Property::TEXT, "Hello" );
2239 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2240 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2241 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2242 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2244 // Avoid a crash when core load gl resources.
2245 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2247 // Create a tap event to touch the text field.
2248 TestGenerateTap( application, 150.0f, 25.0f );
2249 application.SendNotification();
2250 application.Render();
2253 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2254 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2255 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2256 application.SendNotification();
2257 application.Render();
2259 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2260 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2261 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2262 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2263 application.SendNotification();
2264 application.Render();
2266 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2267 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2268 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2269 for( unsigned int index = 0u; index < 5u; ++index )
2271 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2272 application.SendNotification();
2273 application.Render();
2276 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2277 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2278 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2279 for( unsigned int index = 0u; index < 5u; ++index )
2281 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2282 application.SendNotification();
2283 application.Render();
2286 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2287 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2288 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2289 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2290 application.SendNotification();
2291 application.Render();
2292 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2293 application.SendNotification();
2294 application.Render();
2296 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2297 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2298 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2299 application.SendNotification();
2300 application.Render();
2302 Property::Map mapGet;
2303 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2304 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2305 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2310 int utcDaliTextFieldStyleWhilstSelected(void)
2312 ToolkitTestApplication application;
2313 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2315 // Change font and styles whilst text is selected whilst word selected
2317 TextField field = TextField::New();
2318 DALI_TEST_CHECK( field );
2319 application.GetScene().Add( field );
2320 LoadMarkerImages(application, field);
2321 // Render and notify
2322 application.SendNotification();
2323 application.Render();
2325 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2326 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2327 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2328 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2329 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2331 // Avoid a crash when core load gl resources.
2332 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2333 // Render and notify
2334 application.SendNotification();
2335 application.Render();
2337 // Create a tap event to touch the text field.
2338 TestGenerateTap( application, 150.0f, 25.0f );
2339 // Render and notify
2340 application.SendNotification();
2341 application.Render();
2344 // Tap first to get the focus.
2345 TestGenerateTap( application, 1.0f, 25.0f );
2347 // Render and notify
2348 application.SendNotification();
2349 application.Render();
2351 // Double tap to select a word.
2352 TestGenerateTap( application, 1.0f, 25.0f );
2354 // Render and notify
2355 application.SendNotification();
2356 application.Render();
2358 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2359 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2361 Property::Map fontStyleMapSet;
2362 Property::Map fontStyleMapGet;
2364 fontStyleMapSet.Insert( "weight", "bold" );
2365 fontStyleMapSet.Insert( "slant", "italic" );
2366 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2368 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2369 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2370 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2372 fontStyleMapSet.Clear();
2373 fontStyleMapSet.Insert( "width", "expanded" );
2374 fontStyleMapSet.Insert( "slant", "italic" );
2375 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2377 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2378 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2379 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2381 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2382 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2384 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2385 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2387 fontStyleMapSet.Clear();
2388 fontStyleMapSet.Insert( "weight", "bold" );
2389 fontStyleMapSet.Insert( "slant", "italic" );
2391 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2393 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2394 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2395 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2397 fontStyleMapSet.Clear();
2398 fontStyleMapSet.Insert( "width", "expanded" );
2400 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2402 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2403 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2404 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2406 // Press Escape to increase coverage
2407 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2408 application.SendNotification();
2409 application.Render();
2411 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2416 int utcDaliTextFieldEscKeyLoseFocus(void)
2418 ToolkitTestApplication application;
2419 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2421 // Creates a tap event. After creating a tap event the text field should
2422 // have the focus and add text with key events should be possible.
2424 TextField field = TextField::New();
2425 DALI_TEST_CHECK( field );
2427 application.GetScene().Add( field );
2429 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2430 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2431 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2433 // Avoid a crash when core load gl resources.
2434 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2436 // Render and notify
2437 application.SendNotification();
2438 application.Render();
2440 // Add a key event but as the text field has not the focus it should do nothing.
2441 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2442 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2444 // Render and notify
2445 application.SendNotification();
2446 application.Render();
2448 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2450 // Create a tap event to touch the text field.
2451 TestGenerateTap( application, 150.0f, 25.0f );
2453 // Render and notify
2454 application.SendNotification();
2455 application.Render();
2457 // Now the text field has the focus, so it can handle the key events.
2458 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2459 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2460 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2461 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2463 // Render and notify
2464 application.SendNotification();
2465 application.Render();
2467 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2469 // Generate a Esc key event. The text field should lose the focus.
2470 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2471 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2473 // Render and notify
2474 application.SendNotification();
2475 application.Render();
2477 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2479 // No more text should be introduced
2480 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2481 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2483 // Render and notify
2484 application.SendNotification();
2485 application.Render();
2487 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2492 int utcDaliTextFieldSomeSpecialKeys(void)
2494 ToolkitTestApplication application;
2495 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2497 // Checks some special keys when the text is selected.
2499 TextField field = TextField::New();
2500 DALI_TEST_CHECK( field );
2501 application.GetScene().Add( field );
2502 LoadMarkerImages(application, field);
2503 // Render and notify
2504 application.SendNotification();
2505 application.Render();
2507 const std::string longText( "This is a long text for the size of the text-field." );
2509 field.SetProperty( TextField::Property::TEXT, longText );
2510 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2511 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2512 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2513 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2515 // Avoid a crash when core load gl resources.
2516 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2517 // Render and notify
2518 application.SendNotification();
2519 application.Render();
2521 // Create a tap event to touch the text field.
2522 TestGenerateTap( application, 150.0f, 25.0f );
2524 // Render and notify
2525 application.SendNotification();
2526 application.Render();
2528 // Tap first to get the focus.
2529 TestGenerateTap( application, 1.0f, 25.0f );
2531 // Render and notify
2532 application.SendNotification();
2533 application.Render();
2535 // Double tap to select a word.
2536 TestGenerateTap( application, 1.0f, 25.0f );
2538 // Render and notify
2539 application.SendNotification();
2540 application.Render();
2542 // Generate a Esc key event. The text field should lose the focus.
2543 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2544 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2546 // Render and notify
2547 application.SendNotification();
2548 application.Render();
2550 // Generate a Esc key event. The text field should lose the focus.
2551 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2552 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2554 // Render and notify
2555 application.SendNotification();
2556 application.Render();
2558 // Generate a Esc key event. The text field should lose the focus.
2559 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2560 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2562 // Render and notify
2563 application.SendNotification();
2564 application.Render();
2566 // The text shouldn't be deleted.
2567 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2572 int utcDaliTextFieldSizeUpdate(void)
2574 ToolkitTestApplication application;
2575 tet_infoline("utcDaliTextFieldSizeUpdate");
2577 // Checks some special keys when the text is selected.
2578 TextField field = TextField::New();
2579 DALI_TEST_CHECK( field );
2580 application.GetScene().Add( field );
2582 float previousHeight = 0.0f;
2583 float currentHeight = 0.0f;
2584 const float fieldWidth = 1920.0f;
2587 // "ㅁ" is bigger then "ኢ"
2588 field.SetProperty( Actor::Property::SIZE, Vector2( fieldWidth ,10.0f ) );
2589 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2590 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2592 field.SetProperty( TextField::Property::TEXT, "ኢ");
2593 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2594 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2596 field.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2597 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2599 application.SendNotification();
2600 application.Render();
2602 previousHeight = field.GetHeightForWidth( fieldWidth );
2603 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2605 // Add another script characters ( glyph height is defferent )
2606 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2607 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2609 application.SendNotification();
2610 application.Render();
2612 currentHeight = field.GetHeightForWidth( fieldWidth );
2613 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2614 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2619 int utcDaliTextFieldExtremlyLargePointSize(void)
2621 ToolkitTestApplication application;
2622 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2624 TextField field = TextField::New();
2626 field.SetProperty( TextField::Property::TEXT, "Text" );
2627 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2628 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2629 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2630 application.GetScene().Add( field );
2634 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2635 application.SendNotification();
2636 DALI_TEST_CHECK( field );
2640 tet_result(TET_FAIL);
2645 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2647 ToolkitTestApplication application;
2648 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2649 TextField field = TextField::New();
2650 DALI_TEST_CHECK( field );
2651 application.GetScene().Add( field );
2653 Property::Map fontStyleMapGet;
2655 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2657 Property::Value* weightValue = NULL;
2658 Property::Value* widthValue = NULL;
2659 Property::Value* slantValue = NULL;
2660 weightValue = fontStyleMapGet.Find( "weight" );
2661 widthValue = fontStyleMapGet.Find( "width" );
2662 slantValue = fontStyleMapGet.Find( "slant" );
2663 DALI_TEST_CHECK( !weightValue );
2664 DALI_TEST_CHECK( !widthValue );
2665 DALI_TEST_CHECK( !slantValue );
2670 int UtcDaliTextFieldSettingPlaceholder(void)
2672 ToolkitTestApplication application;
2673 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
2675 TextField field = TextField::New();
2676 DALI_TEST_CHECK( field );
2677 application.GetScene().Add( field );
2679 // Check the placeholder property with pixel size
2680 Property::Map placeholderPixelSizeMapSet;
2681 Property::Map placeholderPixelSizeMapGet;
2682 Property::Map placeholderFontstyleMap;
2683 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2684 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2685 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
2686 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2687 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
2688 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
2690 placeholderFontstyleMap.Insert( "weight", "bold" );
2691 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2692 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
2694 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2695 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
2696 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
2698 // Check the placeholder property with point size
2699 Property::Map placeholderMapSet;
2700 Property::Map placeholderMapGet;
2701 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2702 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2703 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
2704 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2705 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
2706 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
2708 // Check the placeholder font style property
2709 placeholderFontstyleMap.Clear();
2711 placeholderFontstyleMap.Insert( "weight", "bold" );
2712 placeholderFontstyleMap.Insert( "width", "condensed" );
2713 placeholderFontstyleMap.Insert( "slant", "italic" );
2714 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2715 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2717 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2718 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2719 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2721 // Reset font style.
2722 placeholderFontstyleMap.Clear();
2723 placeholderFontstyleMap.Insert( "weight", "normal" );
2724 placeholderFontstyleMap.Insert( "slant", "oblique" );
2725 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2726 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2728 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2729 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2730 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2732 placeholderFontstyleMap.Clear();
2733 placeholderFontstyleMap.Insert( "slant", "roman" );
2734 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2735 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2737 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2739 placeholderFontstyleMap.Clear();
2740 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2742 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2743 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2744 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2745 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2750 int UtcDaliTextFieldSetPaddingProperty(void)
2752 ToolkitTestApplication application;
2753 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
2755 TextField field = TextField::New();
2756 DALI_TEST_CHECK( field );
2757 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2758 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2759 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2760 application.GetScene().Add( field );
2762 application.SendNotification();
2763 application.Render();
2765 Vector3 originalSize = field.GetNaturalSize();
2767 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2769 application.SendNotification();
2770 application.Render();
2772 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2774 Vector3 paddingAddedSize = field.GetNaturalSize();
2776 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2778 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2783 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
2785 ToolkitTestApplication application;
2786 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
2788 TextField field = TextField::New();
2789 DALI_TEST_CHECK( field );
2790 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2791 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2792 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2793 application.GetScene().Add( field );
2795 application.SendNotification();
2796 application.Render();
2798 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2799 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2801 // Check the enable shift selection property
2802 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
2803 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2805 application.SendNotification();
2806 application.Render();
2811 int UtcDaliTextFieldEnableGrabHandleProperty(void)
2813 ToolkitTestApplication application;
2814 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
2816 TextField field = TextField::New();
2817 DALI_TEST_CHECK( field );
2818 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2819 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2820 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2821 application.GetScene().Add( field );
2823 application.SendNotification();
2824 application.Render();
2826 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2827 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2829 // Check the enable grab handle property
2830 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
2831 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2833 application.SendNotification();
2834 application.Render();
2839 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
2841 ToolkitTestApplication application;
2842 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
2844 TextField field = TextField::New();
2845 DALI_TEST_CHECK( field );
2846 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2847 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2848 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2849 application.GetScene().Add( field );
2851 application.SendNotification();
2852 application.Render();
2854 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2855 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2857 // Check the match system language direction property
2858 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2859 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2861 application.SendNotification();
2862 application.Render();
2867 int utcDaliTextFieldLayoutDirectionCoverage(void)
2869 ToolkitTestApplication application;
2870 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
2872 // Creates a tap event. After creating a tap event the text field should
2873 // have the focus and add text with key events should be possible.
2874 TextField field = TextField::New();
2875 DALI_TEST_CHECK( field );
2877 application.GetScene().Add( field );
2879 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2880 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2881 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2883 // Avoid a crash when core load gl resources.
2884 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2886 // Render and notify
2887 application.SendNotification();
2888 application.Render();
2890 // init direction for coverage
2891 // Set horizontal alignment END
2892 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2894 // Create a tap event to touch the text field.
2895 TestGenerateTap( application, 150.0f, 25.0f );
2897 // Render and notify
2898 application.SendNotification();
2899 application.Render();
2901 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
2902 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2903 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
2905 // Set horizontal alignment BEGIN
2906 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
2908 // Create a tap event to touch the text field.
2909 TestGenerateTap( application, 150.0f, 25.0f );
2911 // Render and notify
2912 application.SendNotification();
2913 application.Render();
2915 // Set horizontal alignment CENTER
2916 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
2918 // Create a tap event to touch the text field.
2919 TestGenerateTap( application, 150.0f, 25.0f );
2921 // Render and notify
2922 application.SendNotification();
2923 application.Render();
2925 // Set horizontal alignment END
2926 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2928 // Create a tap event to touch the text field.
2929 TestGenerateTap( application, 150.0f, 25.0f );
2931 // Render and notify
2932 application.SendNotification();
2933 application.Render();
2935 // Generate a Esc key event. The text field should lose the focus.
2936 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2937 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2939 // Render and notify
2940 application.SendNotification();
2941 application.Render();
2943 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2948 int UtcDaliTextFieldGetInputMethodContext(void)
2950 ToolkitTestApplication application;
2951 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
2953 TextField field = TextField::New();
2954 DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );
2959 int UtcDaliTextFieldSelectWholeText(void)
2961 ToolkitTestApplication application;
2962 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
2964 TextField textField = TextField::New();
2966 application.GetScene().Add( textField );
2968 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2969 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2970 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2972 // Avoid a crash when core load gl resources.
2973 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2975 application.SendNotification();
2976 application.Render();
2978 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2980 DevelTextField::SelectWholeText( textField );
2982 application.SendNotification();
2983 application.Render();
2985 // Nothing should have been selected. The number of children is still 1
2986 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2988 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
2990 application.SendNotification();
2991 application.Render();
2993 DevelTextField::SelectWholeText( textField );
2995 application.SendNotification();
2996 application.Render();
2998 // Should be 2 children, the stencil and the layer
2999 DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
3001 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3002 Actor stencil = textField.GetChildAt( 0u );
3004 // The highlight actor is drawn first, so is the first actor in the list
3005 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3006 DALI_TEST_CHECK( highlight );
3011 int UtcDaliTextFieldSelectNone(void)
3013 ToolkitTestApplication application;
3014 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3016 TextField textField = TextField::New();
3018 application.GetScene().Add( textField );
3020 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3021 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3022 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3024 // Avoid a crash when core load gl resources.
3025 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3027 application.SendNotification();
3028 application.Render();
3030 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3032 application.SendNotification();
3033 application.Render();
3035 // Nothing is selected
3036 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3037 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3039 DevelTextField::SelectWholeText( textField );
3041 application.SendNotification();
3042 application.Render();
3044 // whole text is selected
3045 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3046 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3048 DevelTextField::SelectNone( textField );
3050 application.SendNotification();
3051 application.Render();
3053 // Nothing is selected
3054 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3055 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3060 int UtcDaliTextFieldSelectRange(void)
3062 ToolkitTestApplication application;
3063 tet_infoline(" UtcDaliTextFieldSelectRange ");
3065 TextField textField = TextField::New();
3067 application.GetScene().Add( textField );
3069 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3070 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3071 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3073 // Avoid a crash when core load gl resources.
3074 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3076 application.SendNotification();
3077 application.Render();
3079 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3081 application.SendNotification();
3082 application.Render();
3084 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 0);
3085 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 5);
3087 // Hello is selected
3088 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3089 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3091 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3092 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3094 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 6);
3095 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 11);
3097 // world is selected
3098 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3099 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3101 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3102 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3107 int UtcDaliTextFieldEnableEditing(void)
3109 ToolkitTestApplication application;
3110 tet_infoline(" UtcDaliTextFieldEnableEditing ");
3112 TextField textField = TextField::New();
3114 application.GetScene().Add( textField );
3116 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3117 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3118 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3120 // Avoid a crash when core load gl resources.
3121 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3123 application.SendNotification();
3124 application.Render();
3126 textField.SetKeyInputFocus();
3127 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, false );
3128 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3130 // Render and notify
3131 application.SendNotification();
3132 application.Render();
3134 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3135 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3138 textField.SetKeyInputFocus();
3139 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
3140 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3142 // Render and notify
3143 application.SendNotification();
3144 application.Render();
3146 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3147 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3152 int UtcDaliToolkitTextFieldFontSizeScale(void)
3154 ToolkitTestApplication application;
3155 tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
3157 TextField textField = TextField::New();
3158 textField.SetProperty( TextField::Property::POINT_SIZE, 30.f );
3159 textField.SetProperty( TextField::Property::TEXT, "Test" );
3160 Vector3 nonScaledSize = textField.GetNaturalSize();
3162 TextField textFieldScaled = TextField::New();
3163 textFieldScaled.SetProperty( TextField::Property::POINT_SIZE, 15.f );
3164 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3165 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3166 Vector3 scaledSize = textFieldScaled.GetNaturalSize();
3168 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3170 textField.SetProperty( TextField::Property::PIXEL_SIZE, 30.f );
3171 textField.SetProperty( TextField::Property::TEXT, "Test" );
3172 nonScaledSize = textField.GetNaturalSize();
3174 textFieldScaled.SetProperty( TextField::Property::PIXEL_SIZE, 15.f );
3175 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3176 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3177 scaledSize = textFieldScaled.GetNaturalSize();
3179 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3184 int UtcDaliTextFieldPrimaryCursorPosition(void)
3186 ToolkitTestApplication application;
3187 tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
3189 TextField textField = TextField::New();
3191 application.GetScene().Add( textField );
3193 textField.SetProperty( TextField::Property::TEXT, "ABCEF");
3194 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3195 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3196 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3198 // Avoid a crash when core load gl resources.
3199 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3201 textField.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
3202 application.SendNotification();
3203 application.Render();
3205 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3207 // Render and notify
3208 application.SendNotification();
3209 application.Render();
3211 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3212 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );