2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali/public-api/rendering/renderer.h>
23 #include <dali/integration-api/events/key-event-integ.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/devel-api/adaptor-framework/key-devel.h>
27 #include <dali/devel-api/text-abstraction/font-client.h>
28 #include <dali-toolkit-test-suite-utils.h>
29 #include <dali-toolkit/dali-toolkit.h>
30 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
31 #include <dali-toolkit/devel-api/text/rendering-backend.h>
32 #include "toolkit-clipboard.h"
35 using namespace Toolkit;
37 void dali_textfield_startup(void)
39 test_return_value = TET_UNDEF;
42 void dali_textfield_cleanup(void)
44 test_return_value = TET_PASS;
50 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
51 const char* const PROPERTY_NAME_TEXT = "text";
52 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
53 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
54 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
55 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
56 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
57 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
58 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
59 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
60 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
61 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
62 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
63 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
64 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
65 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
66 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
67 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
68 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
69 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
70 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
71 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
72 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
73 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
80 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
81 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
82 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
83 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
84 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
85 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
86 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
88 const char* const PROPERTY_NAME_UNDERLINE = "underline";
89 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
90 const char* const PROPERTY_NAME_SHADOW = "shadow";
91 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
92 const char* const PROPERTY_NAME_EMBOSS = "emboss";
93 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
94 const char* const PROPERTY_NAME_OUTLINE = "outline";
95 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
97 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
98 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
99 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
100 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
101 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
102 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
103 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
104 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
105 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
106 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
108 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
109 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
111 const float RENDER_FRAME_INTERVAL = 16.66f;
113 const unsigned int DEFAULT_FONT_SIZE = 1152u;
114 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
116 const int KEY_RETURN_CODE = 36;
117 const int KEY_A_CODE = 38;
118 const int KEY_D_CODE = 40;
120 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
122 static bool gTextChangedCallBackCalled;
123 static bool gMaxCharactersCallBackCalled;
124 static bool gInputStyleChangedCallbackCalled;
125 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
127 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
129 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
130 Integration::ResourcePointer resource(bitmap);
131 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
134 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
138 LoadBitmapResource( app.GetPlatform(), width, height );
140 Property::Map propertyMap;
141 propertyMap["filename"] = "image.png";
142 propertyMap["width"] = width;
143 propertyMap["height"] = height;
144 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
145 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
146 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
147 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
148 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
149 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
150 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
151 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
155 * Simulate time passed by.
157 * @note this will always process at least 1 frame (1/60 sec)
159 * @param application Test application instance
160 * @param duration Time to pass in milliseconds.
161 * @return The actual time passed in milliseconds
163 static int Wait(ToolkitTestApplication& application, int duration = 0)
167 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
169 application.SendNotification();
170 application.Render(RENDER_FRAME_INTERVAL);
171 time += RENDER_FRAME_INTERVAL;
177 Dali::Integration::Point GetPointDownInside( Vector2& pos )
179 Dali::Integration::Point point;
180 point.SetState( PointState::DOWN );
181 point.SetScreenPosition( pos );
185 Dali::Integration::Point GetPointUpInside( Vector2& pos )
187 Dali::Integration::Point point;
188 point.SetState( PointState::UP );
189 point.SetScreenPosition( pos );
193 struct CallbackFunctor
195 CallbackFunctor(bool* callbackFlag)
196 : mCallbackFlag( callbackFlag )
202 *mCallbackFlag = true;
207 static void TestTextChangedCallback( TextField control )
209 tet_infoline(" TestTextChangedCallback");
211 gTextChangedCallBackCalled = true;
214 static void TestMaxLengthReachedCallback( TextField control )
216 tet_infoline(" TestMaxLengthReachedCallback");
218 gMaxCharactersCallBackCalled = true;
221 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
223 tet_infoline(" TestInputStyleChangedCallback");
225 gInputStyleChangedCallbackCalled = true;
226 gInputStyleMask = mask;
229 // Generate a KeyEvent to send to Core.
230 Integration::KeyEvent GenerateKey( const std::string& keyName,
231 const std::string& logicalKey,
232 const std::string& keyString,
235 unsigned long timeStamp,
236 const Integration::KeyEvent::State& keyState,
237 const std::string& compose = "",
238 const std::string& deviceName = DEFAULT_DEVICE_NAME,
239 const Device::Class::Type& deviceClass = Device::Class::NONE,
240 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
242 return Integration::KeyEvent( keyName,
255 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
257 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
259 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
261 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
263 Property::Value* valueSet = NULL;
264 if ( valueGet.first.type == Property::Key::INDEX )
266 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
270 // Get Key is a string so searching Set Map for a string key
271 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
274 if( NULL != valueSet )
276 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
278 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
281 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
283 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
286 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
288 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
291 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
293 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
296 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
298 Vector2 vector2Get = valueGet.second.Get<Vector2>();
299 Vector2 vector2Set = valueSet->Get<Vector2>();
300 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
303 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
305 Vector4 vector4Get = valueGet.second.Get<Vector4>();
306 Vector4 vector4Set = valueSet->Get<Vector4>();
307 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 );
313 if ( valueGet.first.type == Property::Key::INDEX )
315 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
319 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
331 int UtcDaliToolkitTextFieldConstructorP(void)
333 ToolkitTestApplication application;
334 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
336 DALI_TEST_CHECK( !textField );
340 int UtcDaliToolkitTextFieldNewP(void)
342 ToolkitTestApplication application;
343 tet_infoline(" UtcDaliToolkitTextFieldNewP");
344 TextField textField = TextField::New();
345 DALI_TEST_CHECK( textField );
349 int UtcDaliToolkitTextFieldDownCastP(void)
351 ToolkitTestApplication application;
352 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
353 TextField textField1 = TextField::New();
354 BaseHandle object( textField1 );
356 TextField textField2 = TextField::DownCast( object );
357 DALI_TEST_CHECK( textField2 );
359 TextField textField3 = DownCast< TextField >( object );
360 DALI_TEST_CHECK( textField3 );
364 int UtcDaliToolkitTextFieldDownCastN(void)
366 ToolkitTestApplication application;
367 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
368 BaseHandle uninitializedObject;
369 TextField textField1 = TextField::DownCast( uninitializedObject );
370 DALI_TEST_CHECK( !textField1 );
372 TextField textField2 = DownCast< TextField >( uninitializedObject );
373 DALI_TEST_CHECK( !textField2 );
377 int UtcDaliToolkitTextFieldCopyConstructorP(void)
379 ToolkitTestApplication application;
380 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
381 TextField textField = TextField::New();
382 textField.SetProperty( TextField::Property::TEXT, "Test" );
384 TextField copy( textField );
385 DALI_TEST_CHECK( copy );
386 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
390 int UtcDaliTextFieldMoveConstructor(void)
392 ToolkitTestApplication application;
394 TextField textField = TextField::New();
395 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
396 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
398 TextField moved = std::move( textField );
399 DALI_TEST_CHECK( moved );
400 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
401 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
402 DALI_TEST_CHECK( !textField );
407 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
409 ToolkitTestApplication application;
410 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
411 TextField textField = TextField::New();
412 textField.SetProperty( TextField::Property::TEXT, "Test" );
414 TextField copy = textField;
415 DALI_TEST_CHECK( copy );
416 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
420 int UtcDaliTextFieldMoveAssignment(void)
422 ToolkitTestApplication application;
424 TextField textField = TextField::New();
425 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
426 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
429 moved = std::move( textField );
430 DALI_TEST_CHECK( moved );
431 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
432 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
433 DALI_TEST_CHECK( !textField );
438 int UtcDaliTextFieldNewP(void)
440 ToolkitTestApplication application;
441 tet_infoline(" UtcDaliToolkitTextFieldNewP");
442 TextField textField = TextField::New();
443 DALI_TEST_CHECK( textField );
447 // Positive test case for a method
448 int UtcDaliTextFieldGetPropertyP(void)
450 ToolkitTestApplication application;
451 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
452 TextField field = TextField::New();
453 DALI_TEST_CHECK( field );
455 // Check Property Indices are correct
456 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextField::Property::RENDERING_BACKEND );
457 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
458 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
459 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
460 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
461 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
462 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
463 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
464 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
465 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
466 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
467 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
468 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
469 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
470 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
471 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
472 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
473 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
474 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
475 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
476 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
477 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
478 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
479 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
480 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
481 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
482 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
483 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
484 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
485 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
486 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
487 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
488 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
489 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
490 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
491 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
492 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
493 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
494 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
495 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
496 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
497 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
498 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
499 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
500 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
501 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
502 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
503 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
504 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
505 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
506 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
507 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
508 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
509 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP );
510 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextField::Property::BACKGROUND );
515 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
518 Property::Map imageMap;
519 imageMap[mapKey] =mapValue;
521 field.SetProperty( property , imageMap );
522 Property::Value propValue = field.GetProperty( property );
523 Property::Map* resultMap = propValue.GetMap();
525 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
533 // Positive test case for a method
534 int UtcDaliTextFieldSetPropertyP(void)
536 ToolkitTestApplication application;
537 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
538 TextField field = TextField::New();
539 DALI_TEST_CHECK( field );
540 application.GetScene().Add( field );
542 // Note - we can't check the defaults since the stylesheets are platform-specific
544 // Check the render backend property.
545 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
546 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
548 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
549 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION );
551 // Check text property.
552 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
553 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
555 // Check placeholder text properties.
556 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
557 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
559 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
560 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
562 // Check font properties.
563 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
564 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
566 Property::Map fontStyleMapSet;
567 Property::Map fontStyleMapGet;
568 Property::Value* slantValue = NULL;
570 fontStyleMapSet.Insert( "weight", "bold" );
571 fontStyleMapSet.Insert( "width", "condensed" );
572 fontStyleMapSet.Insert( "slant", "italic" );
573 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
575 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
576 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
577 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
579 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
580 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
583 fontStyleMapSet.Clear();
584 fontStyleMapSet.Insert( "weight", "normal" );
585 fontStyleMapSet.Insert( "slant", "oblique" );
586 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
588 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
589 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
590 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
592 fontStyleMapSet.Clear();
593 fontStyleMapSet.Insert( "slant", "roman" );
594 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
595 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
597 // Replace 'roman' for 'normal'.
598 slantValue = fontStyleMapGet.Find( "slant" );
599 if( NULL != slantValue )
601 if( "normal" == slantValue->Get<std::string>() )
603 fontStyleMapGet["slant"] = "roman";
606 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
607 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
609 fontStyleMapSet.Clear();
611 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
612 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
613 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
614 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
616 // Check that the MAX_LENGTH property can be correctly set
617 const int maxNumberOfCharacters = 20;
618 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
619 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
621 // Check exceed policy
622 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
623 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
624 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
625 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
627 // Check that the Alignment properties can be correctly set
628 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
629 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
630 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
631 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
633 // Check text's color property
634 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
635 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
637 // Check placeholder text's color property.
638 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
639 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
641 // Check cursor properties
642 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
643 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
644 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
645 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
647 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
648 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
649 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
650 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
651 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
652 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
653 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
654 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
656 // Check scroll properties.
657 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
658 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
659 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
660 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
662 // Check handle images
663 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
664 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
665 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
666 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
667 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
669 // Check handle images
670 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
671 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
672 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
673 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
674 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
675 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
677 // Check the highlight color
678 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
679 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
681 // Decoration bounding box
682 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
683 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
685 // Check the input method setting
686 Property::Map propertyMap;
687 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
688 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
689 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
690 int inputVariation = 1;
691 propertyMap["PANEL_LAYOUT"] = panelLayout;
692 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
693 propertyMap["BUTTON_ACTION"] = buttonAction;
694 propertyMap["VARIATION"] = inputVariation;
695 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
697 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
699 DALI_TEST_CHECK( value.Get( map ) );
702 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
703 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
706 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
707 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
710 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
711 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
714 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
715 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
717 // Check input color property.
718 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
719 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
721 // Check the enable markup property.
722 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
723 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
724 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
726 // Check input font properties.
727 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
728 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
730 fontStyleMapSet.Clear();
731 fontStyleMapSet.Insert( "weight", "bold" );
732 fontStyleMapSet.Insert( "width", "condensed" );
733 fontStyleMapSet.Insert( "slant", "italic" );
735 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
736 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
737 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
738 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
740 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
741 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
743 // Reset input font style.
744 fontStyleMapSet.Clear();
745 fontStyleMapSet.Insert( "weight", "normal" );
746 fontStyleMapSet.Insert( "slant", "oblique" );
748 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
749 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
750 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
751 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
753 fontStyleMapSet.Clear();
754 fontStyleMapSet.Insert( "slant", "roman" );
756 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
757 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
759 // Replace 'roman' for 'normal'.
760 slantValue = fontStyleMapGet.Find( "slant" );
761 if( NULL != slantValue )
763 if( "normal" == slantValue->Get<std::string>() )
765 fontStyleMapGet["slant"] = "roman";
768 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
769 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
771 fontStyleMapSet.Clear();
773 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
774 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
775 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
776 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
778 Property::Map underlineMapSet;
779 Property::Map underlineMapGet;
781 underlineMapSet.Insert( "enable", true );
782 underlineMapSet.Insert( "color", Color::RED );
783 underlineMapSet.Insert( "height", 1 );
785 // Check the underline property
786 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
788 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
789 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
790 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
792 // Check the input underline property
793 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
794 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
796 // Check the shadow property
797 Property::Map shadowMapSet;
798 Property::Map shadowMapGet;
800 shadowMapSet.Insert( "color", Color::GREEN );
801 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
802 shadowMapSet.Insert( "blurRadius", 3.0f );
804 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
806 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
807 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
808 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
810 // Check the input shadow property
811 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
812 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
814 // Check the emboss property
815 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
816 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
818 // Check the input emboss property
819 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
820 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
822 // Check the outline property
824 // Test string type first
825 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
826 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
827 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
829 // Then test the property map type
830 Property::Map outlineMapSet;
831 Property::Map outlineMapGet;
833 outlineMapSet["color"] = Color::RED;
834 outlineMapSet["width"] = 2.0f;
836 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
838 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
839 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
840 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
842 // Check the input outline property
843 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
844 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
846 // Check the hidden input settings property
847 Property::Map hiddenMapSet;
848 Property::Map hiddenMapGet;
849 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
850 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
851 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
852 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
853 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
855 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
856 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
857 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
859 // Check the pixel size of font
860 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
861 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
863 // Check the enable selection property
864 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
865 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
867 // Check the placeholder property with pixel size
868 Property::Map placeholderPixelSizeMapSet;
869 Property::Map placeholderPixelSizeMapGet;
870 Property::Map placeholderFontstyleMap;
871 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
872 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
873 placeholderPixelSizeMapSet["color"] = Color::BLUE;
874 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
875 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
876 placeholderPixelSizeMapSet["ellipsis"] = true;
878 placeholderFontstyleMap.Insert( "weight", "bold" );
879 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
880 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
882 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
883 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
885 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
886 Property::Map placeholderConversionMap;
887 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
888 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
889 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
890 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
891 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
892 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
894 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
896 // Check the placeholder property with point size
897 Property::Map placeholderMapSet;
898 Property::Map placeholderMapGet;
899 placeholderMapSet["text"] = "Setting Placeholder Text";
900 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
901 placeholderMapSet["color"] = Color::RED;
902 placeholderMapSet["fontFamily"] = "Arial";
903 placeholderMapSet["pointSize"] = 12.0f;
904 placeholderMapSet["ellipsis"] = false;
906 // Check the placeholder font style property
907 placeholderFontstyleMap.Clear();
909 placeholderFontstyleMap.Insert( "weight", "bold" );
910 placeholderFontstyleMap.Insert( "width", "condensed" );
911 placeholderFontstyleMap.Insert( "slant", "italic" );
912 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
913 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
915 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
916 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
918 placeholderConversionMap.Clear();
919 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
920 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
921 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
922 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
923 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
924 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
926 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
929 placeholderFontstyleMap.Clear();
930 placeholderFontstyleMap.Insert( "weight", "normal" );
931 placeholderFontstyleMap.Insert( "slant", "oblique" );
932 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
933 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
935 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
936 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
938 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
939 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
941 placeholderFontstyleMap.Clear();
942 placeholderFontstyleMap.Insert( "slant", "roman" );
943 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
944 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
946 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
948 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
950 placeholderFontstyleMap.Clear();
951 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
952 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
954 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
955 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
956 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
958 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
960 // Check the ellipsis property
961 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
962 field.SetProperty( TextField::Property::ELLIPSIS, true );
963 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
965 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
966 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
968 // Test the ENABLE_GRAB_HANDLE_POPUP property
969 DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
970 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false );
971 DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
973 // Check the background property
974 field.SetProperty( DevelTextField::Property::BACKGROUND, Color::RED );
975 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::BACKGROUND ), Color::RED, TEST_LOCATION );
977 application.SendNotification();
978 application.Render();
983 // Positive Atlas Text Renderer test
984 int utcDaliTextFieldAtlasRenderP(void)
986 ToolkitTestApplication application;
987 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
988 StyleManager styleManager = StyleManager::Get();
989 styleManager.ApplyDefaultTheme();
990 TextField field = TextField::New();
991 DALI_TEST_CHECK( field );
993 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
995 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
997 application.GetScene().Add( field );
1001 // Render some text with the shared atlas backend
1002 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1003 application.SendNotification();
1004 application.Render();
1008 tet_result(TET_FAIL);
1013 // Positive test for the textChanged signal.
1014 int utcDaliTextFieldTextChangedP(void)
1016 ToolkitTestApplication application;
1017 tet_infoline(" utcDaliTextFieldTextChangedP");
1018 TextField field = TextField::New();
1019 DALI_TEST_CHECK( field );
1021 application.GetScene().Add( field );
1023 // connect to the text changed signal.
1024 ConnectionTracker* testTracker = new ConnectionTracker();
1025 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1026 bool textChangedSignal = false;
1027 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1029 gTextChangedCallBackCalled = false;
1030 field.SetProperty( TextField::Property::TEXT, "ABC" );
1031 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1032 DALI_TEST_CHECK( textChangedSignal );
1034 application.SendNotification();
1036 field.SetKeyInputFocus();
1038 gTextChangedCallBackCalled = false;
1039 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1040 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1045 // Negative test for the textChanged signal.
1046 int utcDaliTextFieldTextChangedN(void)
1048 ToolkitTestApplication application;
1049 tet_infoline(" utcDaliTextFieldTextChangedN");
1050 TextField field = TextField::New();
1051 DALI_TEST_CHECK( field );
1053 application.GetScene().Add( field );
1055 // connect to the text changed signal.
1056 ConnectionTracker* testTracker = new ConnectionTracker();
1057 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1058 bool textChangedSignal = false;
1059 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1061 gTextChangedCallBackCalled = false;
1062 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1063 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1064 DALI_TEST_CHECK( !textChangedSignal );
1069 // Positive test for Max Characters reached signal.
1070 int utcDaliTextFieldMaxCharactersReachedP(void)
1072 ToolkitTestApplication application;
1073 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1074 TextField field = TextField::New();
1075 DALI_TEST_CHECK( field );
1077 application.GetScene().Add( field );
1079 const int maxNumberOfCharacters = 1;
1080 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1082 field.SetKeyInputFocus();
1084 // connect to the text changed signal.
1085 ConnectionTracker* testTracker = new ConnectionTracker();
1086 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1087 bool maxLengthReachedSignal = false;
1088 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1090 gMaxCharactersCallBackCalled = false;
1092 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1093 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1095 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1096 DALI_TEST_CHECK( maxLengthReachedSignal );
1101 // Negative test for Max Characters reached signal.
1102 int utcDaliTextFieldMaxCharactersReachedN(void)
1104 ToolkitTestApplication application;
1105 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1106 TextField field = TextField::New();
1107 DALI_TEST_CHECK( field );
1109 application.GetScene().Add( field );
1111 const int maxNumberOfCharacters = 3;
1112 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1114 field.SetKeyInputFocus();
1116 // connect to the text changed signal.
1117 ConnectionTracker* testTracker = new ConnectionTracker();
1118 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1119 bool maxLengthReachedSignal = false;
1120 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1122 gMaxCharactersCallBackCalled = false;
1124 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1125 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1127 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1128 DALI_TEST_CHECK( !maxLengthReachedSignal );
1130 application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1132 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1133 DALI_TEST_CHECK( !maxLengthReachedSignal );
1138 int utcDaliTextFieldInputStyleChanged01(void)
1140 // The text-field emits signals when the input style changes. These changes of style are
1141 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1142 // can't be emitted during the size negotiation as the callbacks may update the UI.
1143 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1144 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1145 ToolkitTestApplication application;
1146 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1150 char* pathNamePtr = get_current_dir_name();
1151 const std::string pathName( pathNamePtr );
1152 free( pathNamePtr );
1154 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1155 fontClient.SetDpi( 93u, 93u );
1157 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1158 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1160 TextField field = TextField::New();
1161 DALI_TEST_CHECK( field );
1164 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1165 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1166 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1168 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1169 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1171 // connect to the text changed signal.
1172 ConnectionTracker* testTracker = new ConnectionTracker();
1173 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1174 bool inputStyleChangedSignal = false;
1175 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1177 application.GetScene().Add( field );
1179 // Render and notify
1180 application.SendNotification();
1181 application.Render();
1183 // Executes the idle callbacks added by the text control on the change of input style.
1184 application.RunIdles();
1186 gInputStyleChangedCallbackCalled = false;
1187 gInputStyleMask = TextField::InputStyle::NONE;
1188 inputStyleChangedSignal = false;
1190 // Create a tap event to touch the text field.
1191 TestGenerateTap( application, 18.0f, 25.0f );
1193 // Render and notify
1194 application.SendNotification();
1195 application.Render();
1197 // Executes the idle callbacks added by the text control on the change of input style.
1198 application.RunIdles();
1200 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1201 if( gInputStyleChangedCallbackCalled )
1203 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1205 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1206 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1208 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1209 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1211 DALI_TEST_CHECK( inputStyleChangedSignal );
1213 gInputStyleChangedCallbackCalled = false;
1214 gInputStyleMask = TextField::InputStyle::NONE;
1215 inputStyleChangedSignal = false;
1217 // Create a tap event to touch the text field.
1218 TestGenerateTap( application, 30.0f, 25.0f );
1220 // Render and notify
1221 application.SendNotification();
1222 application.Render();
1224 // Executes the idle callbacks added by the text control on the change of input style.
1225 application.RunIdles();
1227 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1228 DALI_TEST_CHECK( !inputStyleChangedSignal );
1230 gInputStyleChangedCallbackCalled = false;
1231 gInputStyleMask = TextField::InputStyle::NONE;
1232 inputStyleChangedSignal = false;
1234 // Create a tap event to touch the text field.
1235 TestGenerateTap( application, 43.0f, 25.0f );
1237 // Render and notify
1238 application.SendNotification();
1239 application.Render();
1241 // Executes the idle callbacks added by the text control on the change of input style.
1242 application.RunIdles();
1244 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1245 if( gInputStyleChangedCallbackCalled )
1247 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1249 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1250 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1252 DALI_TEST_CHECK( inputStyleChangedSignal );
1254 gInputStyleChangedCallbackCalled = false;
1255 gInputStyleMask = TextField::InputStyle::NONE;
1256 inputStyleChangedSignal = false;
1258 // Create a tap event to touch the text field.
1259 TestGenerateTap( application, 88.0f, 25.0f );
1261 // Render and notify
1262 application.SendNotification();
1263 application.Render();
1265 // Executes the idle callbacks added by the text control on the change of input style.
1266 application.RunIdles();
1268 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1269 if( gInputStyleChangedCallbackCalled )
1271 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1273 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1274 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1276 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1278 Property::Map fontStyleMapSet;
1279 fontStyleMapSet.Insert( "weight", "bold" );
1281 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1282 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1284 DALI_TEST_CHECK( inputStyleChangedSignal );
1286 gInputStyleChangedCallbackCalled = false;
1287 gInputStyleMask = TextField::InputStyle::NONE;
1288 inputStyleChangedSignal = false;
1290 // Create a tap event to touch the text field.
1291 TestGenerateTap( application, 115.0f, 25.0f );
1293 // Render and notify
1294 application.SendNotification();
1295 application.Render();
1297 // Executes the idle callbacks added by the text control on the change of input style.
1298 application.RunIdles();
1300 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1301 DALI_TEST_CHECK( !inputStyleChangedSignal );
1303 gInputStyleChangedCallbackCalled = false;
1304 gInputStyleMask = TextField::InputStyle::NONE;
1305 inputStyleChangedSignal = false;
1307 // Create a tap event to touch the text field.
1308 TestGenerateTap( application, 164.0f, 25.0f );
1310 // Render and notify
1311 application.SendNotification();
1312 application.Render();
1314 // Executes the idle callbacks added by the text control on the change of input style.
1315 application.RunIdles();
1317 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1318 if( gInputStyleChangedCallbackCalled )
1320 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1322 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1323 DALI_TEST_CHECK( style.empty() );
1325 DALI_TEST_CHECK( inputStyleChangedSignal );
1327 gInputStyleChangedCallbackCalled = false;
1328 gInputStyleMask = TextField::InputStyle::NONE;
1329 inputStyleChangedSignal = false;
1331 // Create a tap event to touch the text field.
1332 TestGenerateTap( application, 191.0f, 25.0f );
1334 // Render and notify
1335 application.SendNotification();
1336 application.Render();
1338 // Executes the idle callbacks added by the text control on the change of input style.
1339 application.RunIdles();
1341 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1342 DALI_TEST_CHECK( !inputStyleChangedSignal );
1347 int utcDaliTextFieldInputStyleChanged02(void)
1349 // The text-field emits signals when the input style changes. These changes of style are
1350 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1351 // can't be emitted during the size negotiation as the callbacks may update the UI.
1352 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1353 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1354 ToolkitTestApplication application;
1355 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1359 char* pathNamePtr = get_current_dir_name();
1360 const std::string pathName( pathNamePtr );
1361 free( pathNamePtr );
1363 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1364 fontClient.SetDpi( 93u, 93u );
1366 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1367 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1369 TextField field = TextField::New();
1370 DALI_TEST_CHECK( field );
1372 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1373 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1374 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1376 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1377 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>" );
1379 // connect to the text changed signal.
1380 ConnectionTracker* testTracker = new ConnectionTracker();
1381 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1382 bool inputStyleChangedSignal = false;
1383 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1385 application.GetScene().Add( field );
1387 // Render and notify
1388 application.SendNotification();
1389 application.Render();
1391 // Executes the idle callbacks added by the text control on the change of input style.
1392 application.RunIdles();
1394 gInputStyleChangedCallbackCalled = false;
1395 gInputStyleMask = TextField::InputStyle::NONE;
1396 inputStyleChangedSignal = false;
1398 // Create a tap event to touch the text field.
1399 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1400 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1402 // Render and notify
1403 application.SendNotification();
1404 application.Render();
1406 // Executes the idle callbacks added by the text control on the change of input style.
1407 application.RunIdles();
1409 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1410 if( gInputStyleChangedCallbackCalled )
1412 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1413 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1414 TextField::InputStyle::POINT_SIZE |
1415 TextField::InputStyle::COLOR ),
1418 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1419 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1421 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1422 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1424 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1425 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1427 DALI_TEST_CHECK( inputStyleChangedSignal );
1429 gInputStyleChangedCallbackCalled = false;
1430 gInputStyleMask = TextField::InputStyle::NONE;
1431 inputStyleChangedSignal = false;
1433 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1435 // Render and notify
1436 application.SendNotification();
1437 application.Render();
1439 // Executes the idle callbacks added by the text control on the change of input style.
1440 application.RunIdles();
1442 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1443 if( gInputStyleChangedCallbackCalled )
1445 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1446 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1449 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1450 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1452 DALI_TEST_CHECK( inputStyleChangedSignal );
1454 gInputStyleChangedCallbackCalled = false;
1455 gInputStyleMask = TextField::InputStyle::NONE;
1456 inputStyleChangedSignal = false;
1458 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1460 // Render and notify
1461 application.SendNotification();
1462 application.Render();
1464 // Executes the idle callbacks added by the text control on the change of input style.
1465 application.RunIdles();
1467 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1468 DALI_TEST_CHECK( !inputStyleChangedSignal );
1470 gInputStyleChangedCallbackCalled = false;
1471 gInputStyleMask = TextField::InputStyle::NONE;
1472 inputStyleChangedSignal = false;
1474 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1476 // Render and notify
1477 application.SendNotification();
1478 application.Render();
1480 // Executes the idle callbacks added by the text control on the change of input style.
1481 application.RunIdles();
1483 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1484 if( gInputStyleChangedCallbackCalled )
1486 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1487 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1490 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1491 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1493 DALI_TEST_CHECK( inputStyleChangedSignal );
1495 gInputStyleChangedCallbackCalled = false;
1496 gInputStyleMask = TextField::InputStyle::NONE;
1497 inputStyleChangedSignal = false;
1499 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1501 Property::Map fontStyleMapSet;
1502 fontStyleMapSet.Insert( "weight", "thin" );
1503 fontStyleMapSet.Insert( "width", "condensed" );
1504 fontStyleMapSet.Insert( "slant", "italic" );
1506 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1507 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1509 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1510 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1511 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1512 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1514 // Render and notify
1515 application.SendNotification();
1516 application.Render();
1518 // Executes the idle callbacks added by the text control on the change of input style.
1519 application.RunIdles();
1521 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1522 DALI_TEST_CHECK( !inputStyleChangedSignal );
1524 // Create a tap event to touch the text field.
1525 TestGenerateTap( application, 63.0f, 25.0f, 300 );
1527 // Render and notify
1528 application.SendNotification();
1529 application.Render();
1531 // Executes the idle callbacks added by the text control on the change of input style.
1532 application.RunIdles();
1534 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1535 if( gInputStyleChangedCallbackCalled )
1537 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1538 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1539 TextField::InputStyle::POINT_SIZE |
1540 TextField::InputStyle::FONT_STYLE |
1541 TextField::InputStyle::UNDERLINE |
1542 TextField::InputStyle::SHADOW |
1543 TextField::InputStyle::EMBOSS |
1544 TextField::InputStyle::OUTLINE ),
1547 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1548 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1550 DALI_TEST_CHECK( inputStyleChangedSignal );
1555 int utcDaliTextFieldEvent01(void)
1557 ToolkitTestApplication application;
1558 tet_infoline(" utcDaliTextFieldEvent01");
1560 // Creates a tap event. After creating a tap event the text field should
1561 // have the focus and add text with key events should be possible.
1563 TextField field = TextField::New();
1564 DALI_TEST_CHECK( field );
1566 application.GetScene().Add( field );
1568 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1569 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1570 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1572 // Render and notify
1573 application.SendNotification();
1574 application.Render();
1576 // Avoid a crash when core load gl resources.
1577 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1579 // Render and notify
1580 application.SendNotification();
1581 application.Render();
1583 // Add a key event but as the text field has not the focus it should do nothing.
1584 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1586 // Render and notify
1587 application.SendNotification();
1588 application.Render();
1590 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1592 // Create a tap event to touch the text field.
1593 TestGenerateTap( application, 150.0f, 25.0f );
1595 // Render and notify
1596 application.SendNotification();
1597 application.Render();
1599 // Pressing delete key should be fine even if there is no text in TextField.
1600 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 ) );
1601 // Render and notify
1602 application.SendNotification();
1603 application.Render();
1605 // Now the text field has the focus, so it can handle the key events.
1606 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1607 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1609 // Render and notify
1610 application.SendNotification();
1611 application.Render();
1613 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1615 // Create a second text field and send key events to it.
1616 TextField field2 = TextField::New();
1618 field2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1619 field2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1620 field2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1621 field2.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
1623 application.GetScene().Add( field2 );
1625 // Render and notify
1626 application.SendNotification();
1627 application.Render();
1629 // Create a tap event on the second text field.
1630 TestGenerateTap( application, 150.0f, 125.0f );
1632 // Render and notify
1633 application.SendNotification();
1634 application.Render();
1636 // The second text field has the focus. It should handle the key events.
1637 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1638 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1640 // Render and notify
1641 application.SendNotification();
1642 application.Render();
1644 // Check the text has been added to the second text field.
1645 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1650 int utcDaliTextFieldEvent02(void)
1652 ToolkitTestApplication application;
1653 tet_infoline(" utcDaliTextFieldEvent02");
1655 // Checks if the right number of actors are created.
1657 TextField field = TextField::New();
1658 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1659 DALI_TEST_CHECK( field );
1660 LoadMarkerImages(application, field);
1662 application.GetScene().Add( field );
1664 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1665 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1666 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1668 // Avoid a crash when core load gl resources.
1669 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1671 // Render and notify
1672 application.SendNotification();
1673 application.Render();
1675 // Check there are the expected number of children ( stencil ).
1676 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1678 Actor stencil = field.GetChildAt( 0u );
1679 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1681 // Create a tap event to touch the text field.
1682 TestGenerateTap( application, 150.0f, 25.0f, 300 );
1684 // Render and notify
1685 application.SendNotification();
1686 application.Render();
1688 Actor layer = field.GetChildAt( 1u );
1689 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1690 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1692 // Now the text field has the focus, so it can handle the key events.
1693 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1694 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1696 // Render and notify
1697 application.SendNotification();
1698 application.Render();
1700 // Checks the cursor and the renderer have been created.
1701 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1702 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1704 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1705 DALI_TEST_CHECK( cursor );
1707 // The offscreen root actor has a container with all the actors which contain the text renderers.
1708 Actor container = stencil.GetChildAt( 0u );
1709 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1711 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1712 DALI_TEST_CHECK( renderer );
1715 // Move the cursor and check the position changes.
1716 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1717 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1719 // Render and notify
1720 application.SendNotification();
1721 application.Render();
1723 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1724 DALI_TEST_CHECK( position2.x < position1.x );
1726 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1728 // Render and notify
1729 application.SendNotification();
1730 application.Render();
1732 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1733 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1736 // Move the cursor to the first position.
1737 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1738 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1740 // Render and notify
1741 application.SendNotification();
1742 application.Render();
1744 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1746 // Send some taps and check the cursor positions.
1748 // Try to tap at the beginning.
1749 TestGenerateTap( application, 1.0f, 25.0f, 900 );
1751 // Render and notify
1752 application.SendNotification();
1753 application.Render();
1755 // Cursor position should be the same than position1.
1756 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1758 DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
1760 // Tap away from the start position.
1761 TestGenerateTap( application, 16.0f, 25.0f, 1500 );
1763 // Render and notify
1764 application.SendNotification();
1765 application.Render();
1767 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1769 DALI_TEST_CHECK( position6.x > position5.x );
1771 // Remove all the text.
1772 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1773 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1774 field.SetProperty( TextField::Property::TEXT, "" );
1776 // Render and notify
1777 application.SendNotification();
1778 application.Render();
1780 // Cursor position should be the same than position2.
1781 Vector3 position7 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1783 DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
1785 // Should not be a renderer.
1786 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1788 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1789 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1790 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1792 application.SendNotification();
1793 application.Render();
1795 // There are renderer and decorator layer
1796 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1801 int utcDaliTextFieldEvent03(void)
1803 ToolkitTestApplication application;
1804 tet_infoline(" utcDaliTextFieldEvent03");
1806 // Checks if the highlight actor is created.
1808 TextField field = TextField::New();
1809 DALI_TEST_CHECK( field );
1811 application.GetScene().Add( field );
1813 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1814 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1815 field.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1816 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1817 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1819 // Avoid a crash when core load gl resources.
1820 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1821 LoadMarkerImages(application, field);
1823 // Render and notify
1824 application.SendNotification();
1825 application.Render();
1827 // Tap first to get the focus.
1828 TestGenerateTap( application, 3.0f, 25.0f );
1830 // Render and notify
1831 application.SendNotification();
1832 application.Render();
1834 // Double tap to select a word.
1835 TestGenerateTap( application, 3.0f, 25.0f );
1837 // Render and notify
1838 application.SendNotification();
1839 application.Render();
1841 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1842 Actor stencil = field.GetChildAt( 0u );
1844 // The highlight actor is drawn first, so is the first actor in the list
1845 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1846 DALI_TEST_CHECK( highlight );
1848 // The offscreen root actor has a container with all the actors which contain the text renderers.
1849 Actor container = stencil.GetChildAt( 1u );
1850 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1852 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1853 DALI_TEST_CHECK( renderer );
1859 int utcDaliTextFieldEvent04(void)
1861 ToolkitTestApplication application;
1862 tet_infoline(" utcDaliTextFieldEvent04");
1864 // Checks if the highlight actor is created.
1866 TextField field = TextField::New();
1867 DALI_TEST_CHECK( field );
1868 application.GetScene().Add( field );
1869 LoadMarkerImages(application, field);
1870 // Render and notify
1871 application.SendNotification();
1872 application.Render();
1874 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1875 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1876 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1877 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1878 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1880 // Avoid a crash when core load gl resources.
1881 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1882 // Render and notify
1883 application.SendNotification();
1884 application.Render();
1886 // Create a tap event to touch the text field.
1887 TestGenerateTap( application, 150.0f, 25.0f );
1888 // Render and notify
1889 application.SendNotification();
1890 application.Render();
1893 // Tap first to get the focus.
1894 TestGenerateTap( application, 1.0f, 25.0f );
1896 // Render and notify
1897 application.SendNotification();
1898 application.Render();
1900 // Double tap to select a word.
1901 TestGenerateTap( application, 1.0f, 25.0f );
1903 // Render and notify
1904 application.SendNotification();
1905 application.Render();
1908 TestGenerateTap( application, 0.0f, 40.0f );
1912 int utcDaliTextFieldEvent05(void)
1914 ToolkitTestApplication application;
1915 tet_infoline(" utcDaliTextFieldEvent05");
1917 // Checks dragging of cursor/grab handle
1919 TextField field = TextField::New();
1920 DALI_TEST_CHECK( field );
1921 application.GetScene().Add( field );
1922 LoadMarkerImages(application, field);
1923 // Render and notify
1924 application.SendNotification();
1925 application.Render();
1927 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1928 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1929 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1930 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1931 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1933 // Avoid a crash when core load gl resources.
1934 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1935 // Render and notify
1936 application.SendNotification();
1937 application.Render();
1939 // Create a tap event to touch the text field.
1940 TestGenerateTap( application, 150.0f, 25.0f );
1941 // Render and notify
1942 application.SendNotification();
1943 application.Render();
1945 // Tap first to get the focus.
1946 TestGenerateTap( application, 1.0f, 25.0f );
1948 // Render and notify
1949 application.SendNotification();
1950 application.Render();
1952 // Double tap to select a word.
1953 TestGenerateTap( application, 1.0f, 25.0f );
1955 // Render and notify
1956 application.SendNotification();
1957 application.Render();
1959 Actor stencil = field.GetChildAt( 1u );
1963 int utcDaliTextFieldEvent06(void)
1965 ToolkitTestApplication application;
1966 tet_infoline(" utcDaliTextFieldEvent06");
1968 // Checks Longpress when in edit mode
1970 TextField field = TextField::New();
1971 DALI_TEST_CHECK( field );
1972 application.GetScene().Add( field );
1973 LoadMarkerImages(application, field);
1974 // Render and notify
1975 application.SendNotification();
1976 application.Render();
1978 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1979 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1980 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1981 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1982 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1984 // Avoid a crash when core load gl resources.
1985 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1986 // Render and notify
1987 application.SendNotification();
1988 application.Render();
1990 // Create a tap event to touch the text field.
1991 TestGenerateTap( application, 150.0f, 25.0f );
1992 // Render and notify
1993 application.SendNotification();
1994 application.Render();
1997 // Tap first to get the focus.
1998 TestGenerateTap( application, 1.0f, 25.0f );
2000 // Render and notify
2001 application.SendNotification();
2002 application.Render();
2005 TestGenerateLongPress(application, 1.0f, 25.0f);
2007 // Render and notify
2008 application.SendNotification();
2009 application.Render();
2014 int utcDaliTextFieldEvent07(void)
2016 ToolkitTestApplication application;
2017 tet_infoline(" utcDaliTextFieldEvent07");
2019 // Checks Longpress to start edit mode
2021 TextField field = TextField::New();
2022 DALI_TEST_CHECK( field );
2023 application.GetScene().Add( field );
2024 LoadMarkerImages(application, field);
2025 // Render and notify
2026 application.SendNotification();
2027 application.Render();
2029 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2030 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2031 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2032 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2033 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2034 Property::Map propertyMap;
2035 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2036 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2038 // Avoid a crash when core load gl resources.
2039 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2040 // Render and notify
2041 application.SendNotification();
2042 application.Render();
2045 TestGenerateLongPress(application, 1.0f, 25.0f);
2047 // Render and notify
2048 application.SendNotification();
2049 application.Render();
2054 int utcDaliTextFieldEvent08(void)
2056 ToolkitTestApplication application;
2057 tet_infoline(" utcDaliTextFieldEvent08");
2059 Dali::Clipboard clipboard = Clipboard::Get();
2060 clipboard.SetItem("testTextFieldEvent");
2062 // Checks Longpress when only place holder text
2064 TextField field = TextField::New();
2065 DALI_TEST_CHECK( field );
2066 application.GetScene().Add( field );
2067 LoadMarkerImages(application, field);
2068 // Render and notify
2069 application.SendNotification();
2070 application.Render();
2072 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2073 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2074 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2075 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2076 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2078 // Avoid a crash when core load gl resources.
2079 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2080 // Render and notify
2081 application.SendNotification();
2082 application.Render();
2085 TestGenerateLongPress( application, 1.0f, 25.0f, 20 );
2087 // Render and notify
2088 application.SendNotification();
2089 application.Render();
2091 Wait(application, 500);
2093 TestEndLongPress( application, 1.0f, 25.0f, 520 );
2096 TestGenerateLongPress( application, 1.0f, 25.0f, 600 );
2098 // Render and notify
2099 application.Render();
2101 Wait(application, 500);
2103 Integration::Scene stage = application.GetScene();
2104 Layer layer = stage.GetRootLayer();
2105 Actor actor = layer.FindChildByName("optionPaste");
2109 Vector3 worldPosition = actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION );
2110 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2111 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2113 Dali::Integration::TouchEvent event;
2114 event = Dali::Integration::TouchEvent();
2115 event.AddPoint( GetPointDownInside( position ) );
2116 application.ProcessEvent( event );
2118 event = Dali::Integration::TouchEvent();
2119 event.AddPoint( GetPointUpInside( position ) );
2120 application.ProcessEvent( event );
2122 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2127 int utcDaliTextFieldEvent09(void)
2129 ToolkitTestApplication application;
2130 tet_infoline(" utcDaliTextFieldEvent09");
2132 TextField field = TextField::New();
2133 DALI_TEST_CHECK( field );
2134 application.GetScene().Add( field );
2135 LoadMarkerImages(application, field);
2136 // Render and notify
2137 application.SendNotification();
2138 application.Render();
2140 field.SetProperty( TextField::Property::TEXT, "Hello" );
2141 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2142 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2143 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2144 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2146 // Avoid a crash when core load gl resources.
2147 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2149 // Create a tap event to touch the text field.
2150 TestGenerateTap( application, 150.0f, 25.0f );
2151 application.SendNotification();
2152 application.Render();
2155 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2156 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2157 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2158 application.SendNotification();
2159 application.Render();
2161 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2162 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2163 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2164 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2165 application.SendNotification();
2166 application.Render();
2168 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2169 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2170 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2171 for( unsigned int index = 0u; index < 5u; ++index )
2173 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2174 application.SendNotification();
2175 application.Render();
2178 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2179 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2180 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2181 for( unsigned int index = 0u; index < 5u; ++index )
2183 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2184 application.SendNotification();
2185 application.Render();
2188 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2189 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2190 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2191 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2192 application.SendNotification();
2193 application.Render();
2194 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2195 application.SendNotification();
2196 application.Render();
2198 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2199 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2200 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2201 application.SendNotification();
2202 application.Render();
2204 Property::Map mapGet;
2205 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2206 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2207 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2212 int utcDaliTextFieldStyleWhilstSelected(void)
2214 ToolkitTestApplication application;
2215 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2217 // Change font and styles whilst text is selected whilst word selected
2219 TextField field = TextField::New();
2220 DALI_TEST_CHECK( field );
2221 application.GetScene().Add( field );
2222 LoadMarkerImages(application, field);
2223 // Render and notify
2224 application.SendNotification();
2225 application.Render();
2227 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2228 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2229 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2230 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2231 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2233 // Avoid a crash when core load gl resources.
2234 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2235 // Render and notify
2236 application.SendNotification();
2237 application.Render();
2239 // Create a tap event to touch the text field.
2240 TestGenerateTap( application, 150.0f, 25.0f );
2241 // Render and notify
2242 application.SendNotification();
2243 application.Render();
2246 // Tap first to get the focus.
2247 TestGenerateTap( application, 1.0f, 25.0f );
2249 // Render and notify
2250 application.SendNotification();
2251 application.Render();
2253 // Double tap to select a word.
2254 TestGenerateTap( application, 1.0f, 25.0f );
2256 // Render and notify
2257 application.SendNotification();
2258 application.Render();
2260 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2261 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2263 Property::Map fontStyleMapSet;
2264 Property::Map fontStyleMapGet;
2266 fontStyleMapSet.Insert( "weight", "bold" );
2267 fontStyleMapSet.Insert( "slant", "italic" );
2268 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2270 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2271 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2272 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2274 fontStyleMapSet.Clear();
2275 fontStyleMapSet.Insert( "width", "expanded" );
2276 fontStyleMapSet.Insert( "slant", "italic" );
2277 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2279 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2280 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2281 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2283 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2284 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2286 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2287 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2289 fontStyleMapSet.Clear();
2290 fontStyleMapSet.Insert( "weight", "bold" );
2291 fontStyleMapSet.Insert( "slant", "italic" );
2293 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2295 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2296 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2297 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2299 fontStyleMapSet.Clear();
2300 fontStyleMapSet.Insert( "width", "expanded" );
2302 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2304 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2305 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2306 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2308 // Press Escape to increase coverage
2309 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2310 application.SendNotification();
2311 application.Render();
2313 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2318 int utcDaliTextFieldEscKeyLoseFocus(void)
2320 ToolkitTestApplication application;
2321 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2323 // Creates a tap event. After creating a tap event the text field should
2324 // have the focus and add text with key events should be possible.
2326 TextField field = TextField::New();
2327 DALI_TEST_CHECK( field );
2329 application.GetScene().Add( field );
2331 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2332 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2333 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2335 // Avoid a crash when core load gl resources.
2336 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2338 // Render and notify
2339 application.SendNotification();
2340 application.Render();
2342 // Add a key event but as the text field has not the focus it should do nothing.
2343 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2344 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2346 // Render and notify
2347 application.SendNotification();
2348 application.Render();
2350 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2352 // Create a tap event to touch the text field.
2353 TestGenerateTap( application, 150.0f, 25.0f );
2355 // Render and notify
2356 application.SendNotification();
2357 application.Render();
2359 // Now the text field has the focus, so it can handle the key events.
2360 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2361 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2362 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2363 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2365 // Render and notify
2366 application.SendNotification();
2367 application.Render();
2369 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2371 // Generate a Esc key event. The text field should lose the focus.
2372 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2373 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2375 // Render and notify
2376 application.SendNotification();
2377 application.Render();
2379 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2381 // No more text should be introduced
2382 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2383 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2385 // Render and notify
2386 application.SendNotification();
2387 application.Render();
2389 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2394 int utcDaliTextFieldSomeSpecialKeys(void)
2396 ToolkitTestApplication application;
2397 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2399 // Checks some special keys when the text is selected.
2401 TextField field = TextField::New();
2402 DALI_TEST_CHECK( field );
2403 application.GetScene().Add( field );
2404 LoadMarkerImages(application, field);
2405 // Render and notify
2406 application.SendNotification();
2407 application.Render();
2409 const std::string longText( "This is a long text for the size of the text-field." );
2411 field.SetProperty( TextField::Property::TEXT, longText );
2412 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2413 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2414 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2415 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2417 // Avoid a crash when core load gl resources.
2418 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2419 // Render and notify
2420 application.SendNotification();
2421 application.Render();
2423 // Create a tap event to touch the text field.
2424 TestGenerateTap( application, 150.0f, 25.0f );
2426 // Render and notify
2427 application.SendNotification();
2428 application.Render();
2430 // Tap first to get the focus.
2431 TestGenerateTap( application, 1.0f, 25.0f );
2433 // Render and notify
2434 application.SendNotification();
2435 application.Render();
2437 // Double tap to select a word.
2438 TestGenerateTap( application, 1.0f, 25.0f );
2440 // Render and notify
2441 application.SendNotification();
2442 application.Render();
2444 // Generate a Esc key event. The text field should lose the focus.
2445 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2446 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2448 // Render and notify
2449 application.SendNotification();
2450 application.Render();
2452 // Generate a Esc key event. The text field should lose the focus.
2453 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2454 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2456 // Render and notify
2457 application.SendNotification();
2458 application.Render();
2460 // Generate a Esc key event. The text field should lose the focus.
2461 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2462 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2464 // Render and notify
2465 application.SendNotification();
2466 application.Render();
2468 // The text shouldn't be deleted.
2469 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2474 int utcDaliTextFieldSizeUpdate(void)
2476 ToolkitTestApplication application;
2477 tet_infoline("utcDaliTextFieldSizeUpdate");
2479 // Checks some special keys when the text is selected.
2480 TextField field = TextField::New();
2481 DALI_TEST_CHECK( field );
2482 application.GetScene().Add( field );
2484 float previousHeight = 0.0f;
2485 float currentHeight = 0.0f;
2486 const float fieldWidth = 1920.0f;
2489 // "ㅁ" is bigger then "ኢ"
2490 field.SetProperty( Actor::Property::SIZE, Vector2( fieldWidth ,10.0f ) );
2491 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2492 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2494 field.SetProperty( TextField::Property::TEXT, "ኢ");
2495 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2496 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2498 field.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2499 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2501 application.SendNotification();
2502 application.Render();
2504 previousHeight = field.GetHeightForWidth( fieldWidth );
2505 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2507 // Add another script characters ( glyph height is defferent )
2508 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2509 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2511 application.SendNotification();
2512 application.Render();
2514 currentHeight = field.GetHeightForWidth( fieldWidth );
2515 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2516 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2521 int utcDaliTextFieldExtremlyLargePointSize(void)
2523 ToolkitTestApplication application;
2524 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2526 TextField field = TextField::New();
2528 field.SetProperty( TextField::Property::TEXT, "Text" );
2529 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2530 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2531 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2532 application.GetScene().Add( field );
2536 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2537 application.SendNotification();
2538 DALI_TEST_CHECK( field );
2542 tet_result(TET_FAIL);
2547 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2549 ToolkitTestApplication application;
2550 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2551 TextField field = TextField::New();
2552 DALI_TEST_CHECK( field );
2553 application.GetScene().Add( field );
2555 Property::Map fontStyleMapGet;
2557 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2559 Property::Value* weightValue = NULL;
2560 Property::Value* widthValue = NULL;
2561 Property::Value* slantValue = NULL;
2562 weightValue = fontStyleMapGet.Find( "weight" );
2563 widthValue = fontStyleMapGet.Find( "width" );
2564 slantValue = fontStyleMapGet.Find( "slant" );
2565 DALI_TEST_CHECK( !weightValue );
2566 DALI_TEST_CHECK( !widthValue );
2567 DALI_TEST_CHECK( !slantValue );
2572 int UtcDaliTextFieldSettingPlaceholder(void)
2574 ToolkitTestApplication application;
2575 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
2577 TextField field = TextField::New();
2578 DALI_TEST_CHECK( field );
2579 application.GetScene().Add( field );
2581 // Check the placeholder property with pixel size
2582 Property::Map placeholderPixelSizeMapSet;
2583 Property::Map placeholderPixelSizeMapGet;
2584 Property::Map placeholderFontstyleMap;
2585 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2586 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2587 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
2588 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2589 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
2590 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
2592 placeholderFontstyleMap.Insert( "weight", "bold" );
2593 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2594 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
2596 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2597 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
2598 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
2600 // Check the placeholder property with point size
2601 Property::Map placeholderMapSet;
2602 Property::Map placeholderMapGet;
2603 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2604 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2605 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
2606 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2607 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
2608 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
2610 // Check the placeholder font style property
2611 placeholderFontstyleMap.Clear();
2613 placeholderFontstyleMap.Insert( "weight", "bold" );
2614 placeholderFontstyleMap.Insert( "width", "condensed" );
2615 placeholderFontstyleMap.Insert( "slant", "italic" );
2616 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2617 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2619 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2620 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2621 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2623 // Reset font style.
2624 placeholderFontstyleMap.Clear();
2625 placeholderFontstyleMap.Insert( "weight", "normal" );
2626 placeholderFontstyleMap.Insert( "slant", "oblique" );
2627 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2628 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2630 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2631 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2632 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2634 placeholderFontstyleMap.Clear();
2635 placeholderFontstyleMap.Insert( "slant", "roman" );
2636 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2637 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2639 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2641 placeholderFontstyleMap.Clear();
2642 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2644 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2645 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2646 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2647 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2652 int UtcDaliTextFieldSetPaddingProperty(void)
2654 ToolkitTestApplication application;
2655 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
2657 TextField field = TextField::New();
2658 DALI_TEST_CHECK( field );
2659 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2660 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2661 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2662 application.GetScene().Add( field );
2664 application.SendNotification();
2665 application.Render();
2667 Vector3 originalSize = field.GetNaturalSize();
2669 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2671 application.SendNotification();
2672 application.Render();
2674 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2676 Vector3 paddingAddedSize = field.GetNaturalSize();
2678 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2680 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2685 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
2687 ToolkitTestApplication application;
2688 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
2690 TextField field = TextField::New();
2691 DALI_TEST_CHECK( field );
2692 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2693 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2694 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2695 application.GetScene().Add( field );
2697 application.SendNotification();
2698 application.Render();
2700 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2701 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2703 // Check the enable shift selection property
2704 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
2705 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2707 application.SendNotification();
2708 application.Render();
2713 int UtcDaliTextFieldEnableGrabHandleProperty(void)
2715 ToolkitTestApplication application;
2716 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
2718 TextField field = TextField::New();
2719 DALI_TEST_CHECK( field );
2720 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2721 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2722 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2723 application.GetScene().Add( field );
2725 application.SendNotification();
2726 application.Render();
2728 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2729 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2731 // Check the enable grab handle property
2732 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
2733 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2735 application.SendNotification();
2736 application.Render();
2741 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
2743 ToolkitTestApplication application;
2744 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
2746 TextField field = TextField::New();
2747 DALI_TEST_CHECK( field );
2748 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2749 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2750 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2751 application.GetScene().Add( field );
2753 application.SendNotification();
2754 application.Render();
2756 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2757 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2759 // Check the match system language direction property
2760 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2761 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2763 application.SendNotification();
2764 application.Render();
2769 int utcDaliTextFieldLayoutDirectionCoverage(void)
2771 ToolkitTestApplication application;
2772 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
2774 // Creates a tap event. After creating a tap event the text field should
2775 // have the focus and add text with key events should be possible.
2776 TextField field = TextField::New();
2777 DALI_TEST_CHECK( field );
2779 application.GetScene().Add( field );
2781 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2782 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2783 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2785 // Avoid a crash when core load gl resources.
2786 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2788 // Render and notify
2789 application.SendNotification();
2790 application.Render();
2792 // init direction for coverage
2793 // Set horizontal alignment END
2794 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2796 // Create a tap event to touch the text field.
2797 TestGenerateTap( application, 150.0f, 25.0f );
2799 // Render and notify
2800 application.SendNotification();
2801 application.Render();
2803 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
2804 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2805 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
2807 // Set horizontal alignment BEGIN
2808 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
2810 // Create a tap event to touch the text field.
2811 TestGenerateTap( application, 150.0f, 25.0f );
2813 // Render and notify
2814 application.SendNotification();
2815 application.Render();
2817 // Set horizontal alignment CENTER
2818 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
2820 // Create a tap event to touch the text field.
2821 TestGenerateTap( application, 150.0f, 25.0f );
2823 // Render and notify
2824 application.SendNotification();
2825 application.Render();
2827 // Set horizontal alignment END
2828 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2830 // Create a tap event to touch the text field.
2831 TestGenerateTap( application, 150.0f, 25.0f );
2833 // Render and notify
2834 application.SendNotification();
2835 application.Render();
2837 // Generate a Esc key event. The text field should lose the focus.
2838 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2839 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2841 // Render and notify
2842 application.SendNotification();
2843 application.Render();
2845 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2850 int UtcDaliTextFieldGetInputMethodContext(void)
2852 ToolkitTestApplication application;
2853 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
2855 TextField field = TextField::New();
2856 DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );
2861 int UtcDaliTextFieldSelectWholeText(void)
2863 ToolkitTestApplication application;
2864 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
2866 TextField textField = TextField::New();
2868 application.GetScene().Add( textField );
2870 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2871 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2872 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2874 // Avoid a crash when core load gl resources.
2875 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2877 application.SendNotification();
2878 application.Render();
2880 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2882 DevelTextField::SelectWholeText( textField );
2884 application.SendNotification();
2885 application.Render();
2887 // Nothing should have been selected. The number of children is still 1
2888 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2890 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
2892 application.SendNotification();
2893 application.Render();
2895 DevelTextField::SelectWholeText( textField );
2897 application.SendNotification();
2898 application.Render();
2900 // Should be 2 children, the stencil and the layer
2901 DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
2903 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2904 Actor stencil = textField.GetChildAt( 0u );
2906 // The highlight actor is drawn first, so is the first actor in the list
2907 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2908 DALI_TEST_CHECK( highlight );
2913 int UtcDaliTextFieldSelectNone(void)
2915 ToolkitTestApplication application;
2916 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
2918 TextField textField = TextField::New();
2920 application.GetScene().Add( textField );
2922 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2923 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2924 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2926 // Avoid a crash when core load gl resources.
2927 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2929 application.SendNotification();
2930 application.Render();
2932 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
2934 application.SendNotification();
2935 application.Render();
2937 // Nothing is selected
2938 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
2939 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
2941 DevelTextField::SelectWholeText( textField );
2943 application.SendNotification();
2944 application.Render();
2946 // whole text is selected
2947 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
2948 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
2950 DevelTextField::SelectNone( textField );
2952 application.SendNotification();
2953 application.Render();
2955 // Nothing is selected
2956 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
2957 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
2962 int UtcDaliTextFieldSelectRange(void)
2964 ToolkitTestApplication application;
2965 tet_infoline(" UtcDaliTextFieldSelectRange ");
2967 TextField textField = TextField::New();
2969 application.GetScene().Add( textField );
2971 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2972 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2973 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2975 // Avoid a crash when core load gl resources.
2976 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2978 application.SendNotification();
2979 application.Render();
2981 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
2983 application.SendNotification();
2984 application.Render();
2986 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 0);
2987 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 5);
2989 // Hello is selected
2990 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
2991 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
2993 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
2994 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
2996 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 6);
2997 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 11);
2999 // world is selected
3000 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3001 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3003 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3004 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );