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 application.SendNotification();
1044 application.Render();
1045 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1046 DALI_TEST_CHECK( textChangedSignal );
1048 field.SetKeyInputFocus();
1050 gTextChangedCallBackCalled = false;
1051 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1052 application.SendNotification();
1053 application.Render();
1054 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1057 field.SetProperty( TextField::Property::TEXT, "" );
1058 application.SendNotification();
1059 application.Render();
1061 // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1062 gTextChangedCallBackCalled = false;
1063 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1064 application.SendNotification();
1065 application.Render();
1066 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1068 // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1069 gTextChangedCallBackCalled = false;
1070 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1071 application.SendNotification();
1072 application.Render();
1073 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1078 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1080 ToolkitTestApplication application;
1081 tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1082 TextField field = TextField::New();
1083 DALI_TEST_CHECK( field );
1086 application.GetScene().Add( field );
1088 // connect to the text changed signal.
1089 ConnectionTracker* testTracker = new ConnectionTracker();
1090 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1091 bool textChangedSignal = false;
1092 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1095 // get InputMethodContext
1097 InputMethodContext::EventData imfEvent;
1098 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext( field );
1100 field.SetKeyInputFocus();
1101 field.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
1104 gTextChangedCallBackCalled = false;
1105 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1106 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1107 application.SendNotification();
1108 application.Render();
1109 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1110 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1112 gTextChangedCallBackCalled = false;
1113 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1114 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1115 application.SendNotification();
1116 application.Render();
1117 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1118 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호"), TEST_LOCATION );
1120 gTextChangedCallBackCalled = false;
1121 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1122 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1123 application.SendNotification();
1124 application.Render();
1125 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1126 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1128 gTextChangedCallBackCalled = false;
1129 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1130 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1131 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1133 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1134 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1135 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1137 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1138 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1139 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1141 application.SendNotification();
1142 application.Render();
1143 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1144 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1150 // Negative test for the textChanged signal.
1151 int utcDaliTextFieldTextChangedN(void)
1153 ToolkitTestApplication application;
1154 tet_infoline(" utcDaliTextFieldTextChangedN");
1155 TextField field = TextField::New();
1156 DALI_TEST_CHECK( field );
1158 application.GetScene().Add( field );
1160 // connect to the text changed signal.
1161 ConnectionTracker* testTracker = new ConnectionTracker();
1162 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1163 bool textChangedSignal = false;
1164 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1166 gTextChangedCallBackCalled = false;
1167 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1168 application.SendNotification();
1169 application.Render();
1170 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1171 DALI_TEST_CHECK( !textChangedSignal );
1176 // Positive test for Max Characters reached signal.
1177 int utcDaliTextFieldMaxCharactersReachedP(void)
1179 ToolkitTestApplication application;
1180 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1181 TextField field = TextField::New();
1182 DALI_TEST_CHECK( field );
1184 application.GetScene().Add( field );
1186 const int maxNumberOfCharacters = 1;
1187 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1189 field.SetKeyInputFocus();
1191 // connect to the text changed signal.
1192 ConnectionTracker* testTracker = new ConnectionTracker();
1193 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1194 bool maxLengthReachedSignal = false;
1195 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1197 gMaxCharactersCallBackCalled = false;
1199 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1200 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1202 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1203 DALI_TEST_CHECK( maxLengthReachedSignal );
1208 // Negative test for Max Characters reached signal.
1209 int utcDaliTextFieldMaxCharactersReachedN(void)
1211 ToolkitTestApplication application;
1212 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1213 TextField field = TextField::New();
1214 DALI_TEST_CHECK( field );
1216 application.GetScene().Add( field );
1218 const int maxNumberOfCharacters = 3;
1219 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1221 field.SetKeyInputFocus();
1223 // connect to the text changed signal.
1224 ConnectionTracker* testTracker = new ConnectionTracker();
1225 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1226 bool maxLengthReachedSignal = false;
1227 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1229 gMaxCharactersCallBackCalled = false;
1231 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1232 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1234 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1235 DALI_TEST_CHECK( !maxLengthReachedSignal );
1237 application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1239 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1240 DALI_TEST_CHECK( !maxLengthReachedSignal );
1245 int utcDaliTextFieldInputStyleChanged01(void)
1247 // The text-field emits signals when the input style changes. These changes of style are
1248 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1249 // can't be emitted during the size negotiation as the callbacks may update the UI.
1250 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1251 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1252 ToolkitTestApplication application;
1253 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1257 char* pathNamePtr = get_current_dir_name();
1258 const std::string pathName( pathNamePtr );
1259 free( pathNamePtr );
1261 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1262 fontClient.SetDpi( 93u, 93u );
1264 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1265 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1267 TextField field = TextField::New();
1268 DALI_TEST_CHECK( field );
1271 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1272 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1273 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1275 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1276 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1278 // connect to the text changed signal.
1279 ConnectionTracker* testTracker = new ConnectionTracker();
1280 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1281 bool inputStyleChangedSignal = false;
1282 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1284 application.GetScene().Add( field );
1286 // Render and notify
1287 application.SendNotification();
1288 application.Render();
1290 // Executes the idle callbacks added by the text control on the change of input style.
1291 application.RunIdles();
1293 gInputStyleChangedCallbackCalled = false;
1294 gInputStyleMask = TextField::InputStyle::NONE;
1295 inputStyleChangedSignal = false;
1297 // Create a tap event to touch the text field.
1298 TestGenerateTap( application, 18.0f, 25.0f );
1300 // Render and notify
1301 application.SendNotification();
1302 application.Render();
1304 // Executes the idle callbacks added by the text control on the change of input style.
1305 application.RunIdles();
1307 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1308 if( gInputStyleChangedCallbackCalled )
1310 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1312 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1313 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1315 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1316 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1318 DALI_TEST_CHECK( inputStyleChangedSignal );
1320 gInputStyleChangedCallbackCalled = false;
1321 gInputStyleMask = TextField::InputStyle::NONE;
1322 inputStyleChangedSignal = false;
1324 // Create a tap event to touch the text field.
1325 TestGenerateTap( application, 30.0f, 25.0f );
1327 // Render and notify
1328 application.SendNotification();
1329 application.Render();
1331 // Executes the idle callbacks added by the text control on the change of input style.
1332 application.RunIdles();
1334 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1335 DALI_TEST_CHECK( !inputStyleChangedSignal );
1337 gInputStyleChangedCallbackCalled = false;
1338 gInputStyleMask = TextField::InputStyle::NONE;
1339 inputStyleChangedSignal = false;
1341 // Create a tap event to touch the text field.
1342 TestGenerateTap( application, 43.0f, 25.0f );
1344 // Render and notify
1345 application.SendNotification();
1346 application.Render();
1348 // Executes the idle callbacks added by the text control on the change of input style.
1349 application.RunIdles();
1351 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1352 if( gInputStyleChangedCallbackCalled )
1354 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1356 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1357 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1359 DALI_TEST_CHECK( inputStyleChangedSignal );
1361 gInputStyleChangedCallbackCalled = false;
1362 gInputStyleMask = TextField::InputStyle::NONE;
1363 inputStyleChangedSignal = false;
1365 // Create a tap event to touch the text field.
1366 TestGenerateTap( application, 88.0f, 25.0f );
1368 // Render and notify
1369 application.SendNotification();
1370 application.Render();
1372 // Executes the idle callbacks added by the text control on the change of input style.
1373 application.RunIdles();
1375 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1376 if( gInputStyleChangedCallbackCalled )
1378 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1380 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1381 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1383 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1385 Property::Map fontStyleMapSet;
1386 fontStyleMapSet.Insert( "weight", "bold" );
1388 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1389 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1391 DALI_TEST_CHECK( inputStyleChangedSignal );
1393 gInputStyleChangedCallbackCalled = false;
1394 gInputStyleMask = TextField::InputStyle::NONE;
1395 inputStyleChangedSignal = false;
1397 // Create a tap event to touch the text field.
1398 TestGenerateTap( application, 115.0f, 25.0f );
1400 // Render and notify
1401 application.SendNotification();
1402 application.Render();
1404 // Executes the idle callbacks added by the text control on the change of input style.
1405 application.RunIdles();
1407 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1408 DALI_TEST_CHECK( !inputStyleChangedSignal );
1410 gInputStyleChangedCallbackCalled = false;
1411 gInputStyleMask = TextField::InputStyle::NONE;
1412 inputStyleChangedSignal = false;
1414 // Create a tap event to touch the text field.
1415 TestGenerateTap( application, 164.0f, 25.0f );
1417 // Render and notify
1418 application.SendNotification();
1419 application.Render();
1421 // Executes the idle callbacks added by the text control on the change of input style.
1422 application.RunIdles();
1424 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1425 if( gInputStyleChangedCallbackCalled )
1427 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1429 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1430 DALI_TEST_CHECK( style.empty() );
1432 DALI_TEST_CHECK( inputStyleChangedSignal );
1434 gInputStyleChangedCallbackCalled = false;
1435 gInputStyleMask = TextField::InputStyle::NONE;
1436 inputStyleChangedSignal = false;
1438 // Create a tap event to touch the text field.
1439 TestGenerateTap( application, 191.0f, 25.0f );
1441 // Render and notify
1442 application.SendNotification();
1443 application.Render();
1445 // Executes the idle callbacks added by the text control on the change of input style.
1446 application.RunIdles();
1448 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1449 DALI_TEST_CHECK( !inputStyleChangedSignal );
1454 int utcDaliTextFieldInputStyleChanged02(void)
1456 // The text-field emits signals when the input style changes. These changes of style are
1457 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1458 // can't be emitted during the size negotiation as the callbacks may update the UI.
1459 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1460 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1461 ToolkitTestApplication application;
1462 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1466 char* pathNamePtr = get_current_dir_name();
1467 const std::string pathName( pathNamePtr );
1468 free( pathNamePtr );
1470 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1471 fontClient.SetDpi( 93u, 93u );
1473 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1474 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1476 TextField field = TextField::New();
1477 DALI_TEST_CHECK( field );
1479 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1480 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1481 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1483 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1484 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>" );
1486 // connect to the text changed signal.
1487 ConnectionTracker* testTracker = new ConnectionTracker();
1488 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1489 bool inputStyleChangedSignal = false;
1490 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1492 application.GetScene().Add( field );
1494 // Render and notify
1495 application.SendNotification();
1496 application.Render();
1498 // Executes the idle callbacks added by the text control on the change of input style.
1499 application.RunIdles();
1501 gInputStyleChangedCallbackCalled = false;
1502 gInputStyleMask = TextField::InputStyle::NONE;
1503 inputStyleChangedSignal = false;
1505 // Create a tap event to touch the text field.
1506 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1507 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1509 // Render and notify
1510 application.SendNotification();
1511 application.Render();
1513 // Executes the idle callbacks added by the text control on the change of input style.
1514 application.RunIdles();
1516 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1517 if( gInputStyleChangedCallbackCalled )
1519 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1520 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1521 TextField::InputStyle::POINT_SIZE |
1522 TextField::InputStyle::COLOR ),
1525 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1526 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1528 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1529 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1531 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1532 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1534 DALI_TEST_CHECK( inputStyleChangedSignal );
1536 gInputStyleChangedCallbackCalled = false;
1537 gInputStyleMask = TextField::InputStyle::NONE;
1538 inputStyleChangedSignal = false;
1540 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1542 // Render and notify
1543 application.SendNotification();
1544 application.Render();
1546 // Executes the idle callbacks added by the text control on the change of input style.
1547 application.RunIdles();
1549 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1550 if( gInputStyleChangedCallbackCalled )
1552 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1553 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1556 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1557 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1559 DALI_TEST_CHECK( inputStyleChangedSignal );
1561 gInputStyleChangedCallbackCalled = false;
1562 gInputStyleMask = TextField::InputStyle::NONE;
1563 inputStyleChangedSignal = false;
1565 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1567 // Render and notify
1568 application.SendNotification();
1569 application.Render();
1571 // Executes the idle callbacks added by the text control on the change of input style.
1572 application.RunIdles();
1574 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1575 DALI_TEST_CHECK( !inputStyleChangedSignal );
1577 gInputStyleChangedCallbackCalled = false;
1578 gInputStyleMask = TextField::InputStyle::NONE;
1579 inputStyleChangedSignal = false;
1581 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1583 // Render and notify
1584 application.SendNotification();
1585 application.Render();
1587 // Executes the idle callbacks added by the text control on the change of input style.
1588 application.RunIdles();
1590 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1591 if( gInputStyleChangedCallbackCalled )
1593 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1594 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1597 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1598 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1600 DALI_TEST_CHECK( inputStyleChangedSignal );
1602 gInputStyleChangedCallbackCalled = false;
1603 gInputStyleMask = TextField::InputStyle::NONE;
1604 inputStyleChangedSignal = false;
1606 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1608 Property::Map fontStyleMapSet;
1609 fontStyleMapSet.Insert( "weight", "thin" );
1610 fontStyleMapSet.Insert( "width", "condensed" );
1611 fontStyleMapSet.Insert( "slant", "italic" );
1613 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1614 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1616 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1617 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1618 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1619 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1621 // Render and notify
1622 application.SendNotification();
1623 application.Render();
1625 // Executes the idle callbacks added by the text control on the change of input style.
1626 application.RunIdles();
1628 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1629 DALI_TEST_CHECK( !inputStyleChangedSignal );
1631 // Create a tap event to touch the text field.
1632 TestGenerateTap( application, 63.0f, 25.0f, 300 );
1634 // Render and notify
1635 application.SendNotification();
1636 application.Render();
1638 // Executes the idle callbacks added by the text control on the change of input style.
1639 application.RunIdles();
1641 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1642 if( gInputStyleChangedCallbackCalled )
1644 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1645 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1646 TextField::InputStyle::POINT_SIZE |
1647 TextField::InputStyle::FONT_STYLE |
1648 TextField::InputStyle::UNDERLINE |
1649 TextField::InputStyle::SHADOW |
1650 TextField::InputStyle::EMBOSS |
1651 TextField::InputStyle::OUTLINE ),
1654 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1655 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1657 DALI_TEST_CHECK( inputStyleChangedSignal );
1662 int utcDaliTextFieldEvent01(void)
1664 ToolkitTestApplication application;
1665 tet_infoline(" utcDaliTextFieldEvent01");
1667 // Creates a tap event. After creating a tap event the text field should
1668 // have the focus and add text with key events should be possible.
1670 TextField field = TextField::New();
1671 DALI_TEST_CHECK( field );
1673 application.GetScene().Add( field );
1675 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1676 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1677 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1679 // Render and notify
1680 application.SendNotification();
1681 application.Render();
1683 // Avoid a crash when core load gl resources.
1684 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1686 // Render and notify
1687 application.SendNotification();
1688 application.Render();
1690 // Add a key event but as the text field has not the focus it should do nothing.
1691 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1693 // Render and notify
1694 application.SendNotification();
1695 application.Render();
1697 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1699 // Create a tap event to touch the text field.
1700 TestGenerateTap( application, 150.0f, 25.0f );
1702 // Render and notify
1703 application.SendNotification();
1704 application.Render();
1706 // Pressing delete key should be fine even if there is no text in TextField.
1707 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 ) );
1708 // Render and notify
1709 application.SendNotification();
1710 application.Render();
1712 // Now the text field has the focus, so it can handle the key events.
1713 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1714 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1716 // Render and notify
1717 application.SendNotification();
1718 application.Render();
1720 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1722 // Create a second text field and send key events to it.
1723 TextField field2 = TextField::New();
1725 field2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1726 field2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1727 field2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1728 field2.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
1730 application.GetScene().Add( field2 );
1732 // Render and notify
1733 application.SendNotification();
1734 application.Render();
1736 // Create a tap event on the second text field.
1737 TestGenerateTap( application, 150.0f, 125.0f );
1739 // Render and notify
1740 application.SendNotification();
1741 application.Render();
1743 // The second text field has the focus. It should handle the key events.
1744 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1745 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1747 // Render and notify
1748 application.SendNotification();
1749 application.Render();
1751 // Check the text has been added to the second text field.
1752 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1757 int utcDaliTextFieldEvent02(void)
1759 ToolkitTestApplication application;
1760 tet_infoline(" utcDaliTextFieldEvent02");
1762 // Checks if the right number of actors are created.
1764 TextField field = TextField::New();
1765 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1766 DALI_TEST_CHECK( field );
1767 LoadMarkerImages(application, field);
1769 application.GetScene().Add( field );
1771 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1772 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1773 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1775 // Avoid a crash when core load gl resources.
1776 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1778 // Render and notify
1779 application.SendNotification();
1780 application.Render();
1782 // Check there are the expected number of children ( stencil ).
1783 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1785 Actor stencil = field.GetChildAt( 0u );
1786 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1788 // Create a tap event to touch the text field.
1789 TestGenerateTap( application, 150.0f, 25.0f, 300 );
1791 // Render and notify
1792 application.SendNotification();
1793 application.Render();
1795 Actor layer = field.GetChildAt( 1u );
1796 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1797 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1799 // Now the text field has the focus, so it can handle the key events.
1800 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1801 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1803 // Render and notify
1804 application.SendNotification();
1805 application.Render();
1807 // Checks the cursor and the renderer have been created.
1808 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1809 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1811 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1812 DALI_TEST_CHECK( cursor );
1814 // The offscreen root actor has a container with all the actors which contain the text renderers.
1815 Actor container = stencil.GetChildAt( 0u );
1816 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1818 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1819 DALI_TEST_CHECK( renderer );
1822 // Move the cursor and check the position changes.
1823 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1824 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 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 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1831 DALI_TEST_CHECK( position2.x < position1.x );
1833 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1835 // Render and notify
1836 application.SendNotification();
1837 application.Render();
1839 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1840 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1843 // Move the cursor to the first position.
1844 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1845 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1847 // Render and notify
1848 application.SendNotification();
1849 application.Render();
1851 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1853 // Send some taps and check the cursor positions.
1855 // Try to tap at the beginning.
1856 TestGenerateTap( application, 1.0f, 25.0f, 900 );
1858 // Render and notify
1859 application.SendNotification();
1860 application.Render();
1862 // Cursor position should be the same than position1.
1863 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1865 DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
1867 // Tap away from the start position.
1868 TestGenerateTap( application, 16.0f, 25.0f, 1500 );
1870 // Render and notify
1871 application.SendNotification();
1872 application.Render();
1874 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1876 DALI_TEST_CHECK( position6.x > position5.x );
1878 // Remove all the text.
1879 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1880 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1881 field.SetProperty( TextField::Property::TEXT, "" );
1883 // Render and notify
1884 application.SendNotification();
1885 application.Render();
1887 // Cursor position should be the same than position2.
1888 Vector3 position7 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1890 DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
1892 // Should not be a renderer.
1893 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1895 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1896 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1897 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1899 application.SendNotification();
1900 application.Render();
1902 // There are renderer and decorator layer
1903 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1908 int utcDaliTextFieldEvent03(void)
1910 ToolkitTestApplication application;
1911 tet_infoline(" utcDaliTextFieldEvent03");
1913 // Checks if the highlight actor is created.
1915 TextField field = TextField::New();
1916 DALI_TEST_CHECK( field );
1918 application.GetScene().Add( field );
1920 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1921 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1922 field.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1923 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1924 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1926 // Avoid a crash when core load gl resources.
1927 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1928 LoadMarkerImages(application, field);
1930 // Render and notify
1931 application.SendNotification();
1932 application.Render();
1934 // Tap first to get the focus.
1935 TestGenerateTap( application, 3.0f, 25.0f );
1937 // Render and notify
1938 application.SendNotification();
1939 application.Render();
1941 // Double tap to select a word.
1942 TestGenerateTap( application, 3.0f, 25.0f );
1944 // Render and notify
1945 application.SendNotification();
1946 application.Render();
1948 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1949 Actor stencil = field.GetChildAt( 0u );
1951 // The highlight actor is drawn first, so is the first actor in the list
1952 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1953 DALI_TEST_CHECK( highlight );
1955 // The offscreen root actor has a container with all the actors which contain the text renderers.
1956 Actor container = stencil.GetChildAt( 1u );
1957 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1959 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1960 DALI_TEST_CHECK( renderer );
1966 int utcDaliTextFieldEvent04(void)
1968 ToolkitTestApplication application;
1969 tet_infoline(" utcDaliTextFieldEvent04");
1971 // Checks if the highlight actor is created.
1973 TextField field = TextField::New();
1974 DALI_TEST_CHECK( field );
1975 application.GetScene().Add( field );
1976 LoadMarkerImages(application, field);
1977 // Render and notify
1978 application.SendNotification();
1979 application.Render();
1981 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1982 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1983 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1984 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1985 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1987 // Avoid a crash when core load gl resources.
1988 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1989 // Render and notify
1990 application.SendNotification();
1991 application.Render();
1993 // Create a tap event to touch the text field.
1994 TestGenerateTap( application, 150.0f, 25.0f );
1995 // Render and notify
1996 application.SendNotification();
1997 application.Render();
2000 // Tap first to get the focus.
2001 TestGenerateTap( application, 1.0f, 25.0f );
2003 // Render and notify
2004 application.SendNotification();
2005 application.Render();
2007 // Double tap to select a word.
2008 TestGenerateTap( application, 1.0f, 25.0f );
2010 // Render and notify
2011 application.SendNotification();
2012 application.Render();
2015 TestGenerateTap( application, 0.0f, 40.0f );
2019 int utcDaliTextFieldEvent05(void)
2021 ToolkitTestApplication application;
2022 tet_infoline(" utcDaliTextFieldEvent05");
2024 // Checks dragging of cursor/grab handle
2026 TextField field = TextField::New();
2027 DALI_TEST_CHECK( field );
2028 application.GetScene().Add( field );
2029 LoadMarkerImages(application, field);
2030 // Render and notify
2031 application.SendNotification();
2032 application.Render();
2034 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2035 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2036 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2037 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2038 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2040 // Avoid a crash when core load gl resources.
2041 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2042 // Render and notify
2043 application.SendNotification();
2044 application.Render();
2046 // Create a tap event to touch the text field.
2047 TestGenerateTap( application, 150.0f, 25.0f );
2048 // Render and notify
2049 application.SendNotification();
2050 application.Render();
2052 // Tap first to get the focus.
2053 TestGenerateTap( application, 1.0f, 25.0f );
2055 // Render and notify
2056 application.SendNotification();
2057 application.Render();
2059 // Double tap to select a word.
2060 TestGenerateTap( application, 1.0f, 25.0f );
2062 // Render and notify
2063 application.SendNotification();
2064 application.Render();
2066 Actor stencil = field.GetChildAt( 1u );
2070 int utcDaliTextFieldEvent06(void)
2072 ToolkitTestApplication application;
2073 tet_infoline(" utcDaliTextFieldEvent06");
2075 // Checks Longpress when in edit mode
2077 TextField field = TextField::New();
2078 DALI_TEST_CHECK( field );
2079 application.GetScene().Add( field );
2080 LoadMarkerImages(application, field);
2081 // Render and notify
2082 application.SendNotification();
2083 application.Render();
2085 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2086 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2087 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2088 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2089 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2091 // Avoid a crash when core load gl resources.
2092 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2093 // Render and notify
2094 application.SendNotification();
2095 application.Render();
2097 // Create a tap event to touch the text field.
2098 TestGenerateTap( application, 150.0f, 25.0f );
2099 // Render and notify
2100 application.SendNotification();
2101 application.Render();
2104 // Tap first to get the focus.
2105 TestGenerateTap( application, 1.0f, 25.0f );
2107 // Render and notify
2108 application.SendNotification();
2109 application.Render();
2112 TestGenerateLongPress(application, 1.0f, 25.0f);
2114 // Render and notify
2115 application.SendNotification();
2116 application.Render();
2121 int utcDaliTextFieldEvent07(void)
2123 ToolkitTestApplication application;
2124 tet_infoline(" utcDaliTextFieldEvent07");
2126 // Checks Longpress to start edit mode
2128 TextField field = TextField::New();
2129 DALI_TEST_CHECK( field );
2130 application.GetScene().Add( field );
2131 LoadMarkerImages(application, field);
2132 // Render and notify
2133 application.SendNotification();
2134 application.Render();
2136 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2137 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2138 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2139 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2140 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2141 Property::Map propertyMap;
2142 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2143 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2145 // Avoid a crash when core load gl resources.
2146 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2147 // Render and notify
2148 application.SendNotification();
2149 application.Render();
2152 TestGenerateLongPress(application, 1.0f, 25.0f);
2154 // Render and notify
2155 application.SendNotification();
2156 application.Render();
2161 int utcDaliTextFieldEvent08(void)
2163 ToolkitTestApplication application;
2164 tet_infoline(" utcDaliTextFieldEvent08");
2166 Dali::Clipboard clipboard = Clipboard::Get();
2167 clipboard.SetItem("testTextFieldEvent");
2169 // Checks Longpress when only place holder text
2171 TextField field = TextField::New();
2172 DALI_TEST_CHECK( field );
2173 application.GetScene().Add( field );
2174 LoadMarkerImages(application, field);
2175 // Render and notify
2176 application.SendNotification();
2177 application.Render();
2179 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2180 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2181 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2182 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2183 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2185 // Avoid a crash when core load gl resources.
2186 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2187 // Render and notify
2188 application.SendNotification();
2189 application.Render();
2192 TestGenerateLongPress( application, 1.0f, 25.0f, 20 );
2194 // Render and notify
2195 application.SendNotification();
2196 application.Render();
2198 Wait(application, 500);
2200 TestEndLongPress( application, 1.0f, 25.0f, 520 );
2203 TestGenerateLongPress( application, 1.0f, 25.0f, 600 );
2205 // Render and notify
2206 application.Render();
2208 Wait(application, 500);
2210 Integration::Scene stage = application.GetScene();
2211 Layer layer = stage.GetRootLayer();
2212 Actor actor = layer.FindChildByName("optionPaste");
2216 Vector3 worldPosition = actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION );
2217 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2218 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2220 Dali::Integration::TouchEvent event;
2221 event = Dali::Integration::TouchEvent();
2222 event.AddPoint( GetPointDownInside( position ) );
2223 application.ProcessEvent( event );
2225 event = Dali::Integration::TouchEvent();
2226 event.AddPoint( GetPointUpInside( position ) );
2227 application.ProcessEvent( event );
2229 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2234 int utcDaliTextFieldEvent09(void)
2236 ToolkitTestApplication application;
2237 tet_infoline(" utcDaliTextFieldEvent09");
2239 TextField field = TextField::New();
2240 DALI_TEST_CHECK( field );
2241 application.GetScene().Add( field );
2242 LoadMarkerImages(application, field);
2243 // Render and notify
2244 application.SendNotification();
2245 application.Render();
2247 field.SetProperty( TextField::Property::TEXT, "Hello" );
2248 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2249 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2250 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2251 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2253 // Avoid a crash when core load gl resources.
2254 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2256 // Create a tap event to touch the text field.
2257 TestGenerateTap( application, 150.0f, 25.0f );
2258 application.SendNotification();
2259 application.Render();
2262 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2263 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2264 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2265 application.SendNotification();
2266 application.Render();
2268 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2269 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2270 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
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();
2275 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2276 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2277 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2278 for( unsigned int index = 0u; index < 5u; ++index )
2280 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2281 application.SendNotification();
2282 application.Render();
2285 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2286 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2287 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2288 for( unsigned int index = 0u; index < 5u; ++index )
2290 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2291 application.SendNotification();
2292 application.Render();
2295 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2296 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2297 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2298 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2299 application.SendNotification();
2300 application.Render();
2301 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2302 application.SendNotification();
2303 application.Render();
2305 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2306 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2307 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2308 application.SendNotification();
2309 application.Render();
2311 Property::Map mapGet;
2312 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2313 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2314 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2319 int utcDaliTextFieldStyleWhilstSelected(void)
2321 ToolkitTestApplication application;
2322 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2324 // Change font and styles whilst text is selected whilst word selected
2326 TextField field = TextField::New();
2327 DALI_TEST_CHECK( field );
2328 application.GetScene().Add( field );
2329 LoadMarkerImages(application, field);
2330 // Render and notify
2331 application.SendNotification();
2332 application.Render();
2334 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2335 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2336 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2337 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2338 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2340 // Avoid a crash when core load gl resources.
2341 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2342 // Render and notify
2343 application.SendNotification();
2344 application.Render();
2346 // Create a tap event to touch the text field.
2347 TestGenerateTap( application, 150.0f, 25.0f );
2348 // Render and notify
2349 application.SendNotification();
2350 application.Render();
2353 // Tap first to get the focus.
2354 TestGenerateTap( application, 1.0f, 25.0f );
2356 // Render and notify
2357 application.SendNotification();
2358 application.Render();
2360 // Double tap to select a word.
2361 TestGenerateTap( application, 1.0f, 25.0f );
2363 // Render and notify
2364 application.SendNotification();
2365 application.Render();
2367 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2368 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2370 Property::Map fontStyleMapSet;
2371 Property::Map fontStyleMapGet;
2373 fontStyleMapSet.Insert( "weight", "bold" );
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 fontStyleMapSet.Clear();
2382 fontStyleMapSet.Insert( "width", "expanded" );
2383 fontStyleMapSet.Insert( "slant", "italic" );
2384 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2386 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2387 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2388 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2390 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2391 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2393 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2394 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2396 fontStyleMapSet.Clear();
2397 fontStyleMapSet.Insert( "weight", "bold" );
2398 fontStyleMapSet.Insert( "slant", "italic" );
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 fontStyleMapSet.Clear();
2407 fontStyleMapSet.Insert( "width", "expanded" );
2409 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2411 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2412 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2413 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2415 // Press Escape to increase coverage
2416 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2417 application.SendNotification();
2418 application.Render();
2420 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2425 int utcDaliTextFieldEscKeyLoseFocus(void)
2427 ToolkitTestApplication application;
2428 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2430 // Creates a tap event. After creating a tap event the text field should
2431 // have the focus and add text with key events should be possible.
2433 TextField field = TextField::New();
2434 DALI_TEST_CHECK( field );
2436 application.GetScene().Add( field );
2438 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2439 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2440 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2442 // Avoid a crash when core load gl resources.
2443 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2445 // Render and notify
2446 application.SendNotification();
2447 application.Render();
2449 // Add a key event but as the text field has not the focus it should do nothing.
2450 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2451 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2453 // Render and notify
2454 application.SendNotification();
2455 application.Render();
2457 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2459 // Create a tap event to touch the text field.
2460 TestGenerateTap( application, 150.0f, 25.0f );
2462 // Render and notify
2463 application.SendNotification();
2464 application.Render();
2466 // Now the text field has the focus, so it can handle the key events.
2467 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2468 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2469 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2470 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2472 // Render and notify
2473 application.SendNotification();
2474 application.Render();
2476 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2478 // Generate a Esc key event. The text field should lose the focus.
2479 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2480 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2482 // Render and notify
2483 application.SendNotification();
2484 application.Render();
2486 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2488 // No more text should be introduced
2489 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2490 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2492 // Render and notify
2493 application.SendNotification();
2494 application.Render();
2496 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2501 int utcDaliTextFieldSomeSpecialKeys(void)
2503 ToolkitTestApplication application;
2504 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2506 // Checks some special keys when the text is selected.
2508 TextField field = TextField::New();
2509 DALI_TEST_CHECK( field );
2510 application.GetScene().Add( field );
2511 LoadMarkerImages(application, field);
2512 // Render and notify
2513 application.SendNotification();
2514 application.Render();
2516 const std::string longText( "This is a long text for the size of the text-field." );
2518 field.SetProperty( TextField::Property::TEXT, longText );
2519 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2520 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2521 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2522 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2524 // Avoid a crash when core load gl resources.
2525 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2526 // Render and notify
2527 application.SendNotification();
2528 application.Render();
2530 // Create a tap event to touch the text field.
2531 TestGenerateTap( application, 150.0f, 25.0f );
2533 // Render and notify
2534 application.SendNotification();
2535 application.Render();
2537 // Tap first to get the focus.
2538 TestGenerateTap( application, 1.0f, 25.0f );
2540 // Render and notify
2541 application.SendNotification();
2542 application.Render();
2544 // Double tap to select a word.
2545 TestGenerateTap( application, 1.0f, 25.0f );
2547 // Render and notify
2548 application.SendNotification();
2549 application.Render();
2551 // Generate a Esc key event. The text field should lose the focus.
2552 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2553 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2555 // Render and notify
2556 application.SendNotification();
2557 application.Render();
2559 // Generate a Esc key event. The text field should lose the focus.
2560 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2561 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2563 // Render and notify
2564 application.SendNotification();
2565 application.Render();
2567 // Generate a Esc key event. The text field should lose the focus.
2568 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2569 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2571 // Render and notify
2572 application.SendNotification();
2573 application.Render();
2575 // The text shouldn't be deleted.
2576 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2581 int utcDaliTextFieldSizeUpdate(void)
2583 ToolkitTestApplication application;
2584 tet_infoline("utcDaliTextFieldSizeUpdate");
2586 // Checks some special keys when the text is selected.
2587 TextField field = TextField::New();
2588 DALI_TEST_CHECK( field );
2589 application.GetScene().Add( field );
2591 float previousHeight = 0.0f;
2592 float currentHeight = 0.0f;
2593 const float fieldWidth = 1920.0f;
2596 // "ㅁ" is bigger then "ኢ"
2597 field.SetProperty( Actor::Property::SIZE, Vector2( fieldWidth ,10.0f ) );
2598 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2599 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2601 field.SetProperty( TextField::Property::TEXT, "ኢ");
2602 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2603 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2605 field.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2606 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2608 application.SendNotification();
2609 application.Render();
2611 previousHeight = field.GetHeightForWidth( fieldWidth );
2612 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2614 // Add another script characters ( glyph height is defferent )
2615 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2616 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2618 application.SendNotification();
2619 application.Render();
2621 currentHeight = field.GetHeightForWidth( fieldWidth );
2622 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2623 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2628 int utcDaliTextFieldExtremlyLargePointSize(void)
2630 ToolkitTestApplication application;
2631 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2633 TextField field = TextField::New();
2635 field.SetProperty( TextField::Property::TEXT, "Text" );
2636 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2637 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2638 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2639 application.GetScene().Add( field );
2643 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2644 application.SendNotification();
2645 DALI_TEST_CHECK( field );
2649 tet_result(TET_FAIL);
2654 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2656 ToolkitTestApplication application;
2657 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2658 TextField field = TextField::New();
2659 DALI_TEST_CHECK( field );
2660 application.GetScene().Add( field );
2662 Property::Map fontStyleMapGet;
2664 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2666 Property::Value* weightValue = NULL;
2667 Property::Value* widthValue = NULL;
2668 Property::Value* slantValue = NULL;
2669 weightValue = fontStyleMapGet.Find( "weight" );
2670 widthValue = fontStyleMapGet.Find( "width" );
2671 slantValue = fontStyleMapGet.Find( "slant" );
2672 DALI_TEST_CHECK( !weightValue );
2673 DALI_TEST_CHECK( !widthValue );
2674 DALI_TEST_CHECK( !slantValue );
2679 int UtcDaliTextFieldSettingPlaceholder(void)
2681 ToolkitTestApplication application;
2682 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
2684 TextField field = TextField::New();
2685 DALI_TEST_CHECK( field );
2686 application.GetScene().Add( field );
2688 // Check the placeholder property with pixel size
2689 Property::Map placeholderPixelSizeMapSet;
2690 Property::Map placeholderPixelSizeMapGet;
2691 Property::Map placeholderFontstyleMap;
2692 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2693 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2694 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
2695 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2696 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
2697 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
2699 placeholderFontstyleMap.Insert( "weight", "bold" );
2700 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2701 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
2703 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2704 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
2705 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
2707 // Check the placeholder property with point size
2708 Property::Map placeholderMapSet;
2709 Property::Map placeholderMapGet;
2710 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2711 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2712 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
2713 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2714 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
2715 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
2717 // Check the placeholder font style property
2718 placeholderFontstyleMap.Clear();
2720 placeholderFontstyleMap.Insert( "weight", "bold" );
2721 placeholderFontstyleMap.Insert( "width", "condensed" );
2722 placeholderFontstyleMap.Insert( "slant", "italic" );
2723 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2724 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2726 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2727 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2728 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2730 // Reset font style.
2731 placeholderFontstyleMap.Clear();
2732 placeholderFontstyleMap.Insert( "weight", "normal" );
2733 placeholderFontstyleMap.Insert( "slant", "oblique" );
2734 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2735 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2737 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2738 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2739 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2741 placeholderFontstyleMap.Clear();
2742 placeholderFontstyleMap.Insert( "slant", "roman" );
2743 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2744 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2746 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2748 placeholderFontstyleMap.Clear();
2749 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2751 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2752 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2753 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2754 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2759 int UtcDaliTextFieldSetPaddingProperty(void)
2761 ToolkitTestApplication application;
2762 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
2764 TextField field = TextField::New();
2765 DALI_TEST_CHECK( field );
2766 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2767 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2768 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2769 application.GetScene().Add( field );
2771 application.SendNotification();
2772 application.Render();
2774 Vector3 originalSize = field.GetNaturalSize();
2776 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2778 application.SendNotification();
2779 application.Render();
2781 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2783 Vector3 paddingAddedSize = field.GetNaturalSize();
2785 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2787 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2792 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
2794 ToolkitTestApplication application;
2795 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
2797 TextField field = TextField::New();
2798 DALI_TEST_CHECK( field );
2799 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2800 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2801 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2802 application.GetScene().Add( field );
2804 application.SendNotification();
2805 application.Render();
2807 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2808 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2810 // Check the enable shift selection property
2811 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
2812 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2814 application.SendNotification();
2815 application.Render();
2820 int UtcDaliTextFieldEnableGrabHandleProperty(void)
2822 ToolkitTestApplication application;
2823 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
2825 TextField field = TextField::New();
2826 DALI_TEST_CHECK( field );
2827 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2828 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2829 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2830 application.GetScene().Add( field );
2832 application.SendNotification();
2833 application.Render();
2835 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2836 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2838 // Check the enable grab handle property
2839 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
2840 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2842 application.SendNotification();
2843 application.Render();
2848 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
2850 ToolkitTestApplication application;
2851 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
2853 TextField field = TextField::New();
2854 DALI_TEST_CHECK( field );
2855 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2856 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2857 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2858 application.GetScene().Add( field );
2860 application.SendNotification();
2861 application.Render();
2863 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2864 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2866 // Check the match system language direction property
2867 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2868 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2870 application.SendNotification();
2871 application.Render();
2876 int utcDaliTextFieldLayoutDirectionCoverage(void)
2878 ToolkitTestApplication application;
2879 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
2881 // Creates a tap event. After creating a tap event the text field should
2882 // have the focus and add text with key events should be possible.
2883 TextField field = TextField::New();
2884 DALI_TEST_CHECK( field );
2886 application.GetScene().Add( field );
2888 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2889 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2890 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2892 // Avoid a crash when core load gl resources.
2893 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2895 // Render and notify
2896 application.SendNotification();
2897 application.Render();
2899 // init direction for coverage
2900 // Set horizontal alignment END
2901 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2903 // Create a tap event to touch the text field.
2904 TestGenerateTap( application, 150.0f, 25.0f );
2906 // Render and notify
2907 application.SendNotification();
2908 application.Render();
2910 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
2911 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2912 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
2914 // Set horizontal alignment BEGIN
2915 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
2917 // Create a tap event to touch the text field.
2918 TestGenerateTap( application, 150.0f, 25.0f );
2920 // Render and notify
2921 application.SendNotification();
2922 application.Render();
2924 // Set horizontal alignment CENTER
2925 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
2927 // Create a tap event to touch the text field.
2928 TestGenerateTap( application, 150.0f, 25.0f );
2930 // Render and notify
2931 application.SendNotification();
2932 application.Render();
2934 // Set horizontal alignment END
2935 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2937 // Create a tap event to touch the text field.
2938 TestGenerateTap( application, 150.0f, 25.0f );
2940 // Render and notify
2941 application.SendNotification();
2942 application.Render();
2944 // Generate a Esc key event. The text field should lose the focus.
2945 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2946 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2948 // Render and notify
2949 application.SendNotification();
2950 application.Render();
2952 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2957 int UtcDaliTextFieldGetInputMethodContext(void)
2959 ToolkitTestApplication application;
2960 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
2962 TextField field = TextField::New();
2963 DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );
2968 int UtcDaliTextFieldSelectWholeText(void)
2970 ToolkitTestApplication application;
2971 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
2973 TextField textField = TextField::New();
2975 application.GetScene().Add( textField );
2977 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2978 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2979 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2981 // Avoid a crash when core load gl resources.
2982 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2984 application.SendNotification();
2985 application.Render();
2987 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2989 DevelTextField::SelectWholeText( textField );
2991 application.SendNotification();
2992 application.Render();
2994 // Nothing should have been selected. The number of children is still 1
2995 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2997 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
2999 application.SendNotification();
3000 application.Render();
3002 DevelTextField::SelectWholeText( textField );
3004 application.SendNotification();
3005 application.Render();
3007 // Should be 2 children, the stencil and the layer
3008 DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
3010 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3011 Actor stencil = textField.GetChildAt( 0u );
3013 // The highlight actor is drawn first, so is the first actor in the list
3014 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3015 DALI_TEST_CHECK( highlight );
3020 int UtcDaliTextFieldSelectNone(void)
3022 ToolkitTestApplication application;
3023 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3025 TextField textField = TextField::New();
3027 application.GetScene().Add( textField );
3029 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3030 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3031 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3033 // Avoid a crash when core load gl resources.
3034 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3036 application.SendNotification();
3037 application.Render();
3039 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3041 application.SendNotification();
3042 application.Render();
3044 // Nothing is selected
3045 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3046 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3048 DevelTextField::SelectWholeText( textField );
3050 application.SendNotification();
3051 application.Render();
3053 // whole text is selected
3054 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3055 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3057 DevelTextField::SelectNone( textField );
3059 application.SendNotification();
3060 application.Render();
3062 // Nothing is selected
3063 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3064 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3069 int UtcDaliTextFieldSelectRange(void)
3071 ToolkitTestApplication application;
3072 tet_infoline(" UtcDaliTextFieldSelectRange ");
3074 TextField textField = TextField::New();
3076 application.GetScene().Add( textField );
3078 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3079 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3080 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3082 // Avoid a crash when core load gl resources.
3083 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3085 application.SendNotification();
3086 application.Render();
3088 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3090 application.SendNotification();
3091 application.Render();
3093 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 0);
3094 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 5);
3096 // Hello is selected
3097 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3098 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3100 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3101 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3103 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 6);
3104 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 11);
3106 // world is selected
3107 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3108 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3110 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3111 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3116 int UtcDaliTextFieldEnableEditing(void)
3118 ToolkitTestApplication application;
3119 tet_infoline(" UtcDaliTextFieldEnableEditing ");
3121 TextField textField = TextField::New();
3123 application.GetScene().Add( textField );
3125 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3126 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3127 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3129 // Avoid a crash when core load gl resources.
3130 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3132 application.SendNotification();
3133 application.Render();
3135 textField.SetKeyInputFocus();
3136 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, false );
3137 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3139 // Render and notify
3140 application.SendNotification();
3141 application.Render();
3143 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3144 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3147 textField.SetKeyInputFocus();
3148 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
3149 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3151 // Render and notify
3152 application.SendNotification();
3153 application.Render();
3155 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3156 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3161 int UtcDaliToolkitTextFieldFontSizeScale(void)
3163 ToolkitTestApplication application;
3164 tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
3166 TextField textField = TextField::New();
3167 textField.SetProperty( TextField::Property::POINT_SIZE, 30.f );
3168 textField.SetProperty( TextField::Property::TEXT, "Test" );
3169 Vector3 nonScaledSize = textField.GetNaturalSize();
3171 TextField textFieldScaled = TextField::New();
3172 textFieldScaled.SetProperty( TextField::Property::POINT_SIZE, 15.f );
3173 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3174 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3175 Vector3 scaledSize = textFieldScaled.GetNaturalSize();
3177 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3179 textField.SetProperty( TextField::Property::PIXEL_SIZE, 30.f );
3180 textField.SetProperty( TextField::Property::TEXT, "Test" );
3181 nonScaledSize = textField.GetNaturalSize();
3183 textFieldScaled.SetProperty( TextField::Property::PIXEL_SIZE, 15.f );
3184 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3185 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3186 scaledSize = textFieldScaled.GetNaturalSize();
3188 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3193 int UtcDaliTextFieldPrimaryCursorPosition(void)
3195 ToolkitTestApplication application;
3196 tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
3198 TextField textField = TextField::New();
3200 application.GetScene().Add( textField );
3202 textField.SetProperty( TextField::Property::TEXT, "ABCEF");
3203 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3204 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3205 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3207 // Avoid a crash when core load gl resources.
3208 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3210 textField.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
3211 application.SendNotification();
3212 application.Render();
3214 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3216 // Render and notify
3217 application.SendNotification();
3218 application.Render();
3220 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3221 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );