2 * Copyright (c) 2018 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/tap-gesture-event.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/integration-api/events/pan-gesture-event.h>
27 #include <dali/integration-api/events/long-press-gesture-event.h>
28 #include <dali/devel-api/adaptor-framework/key-devel.h>
29 #include <dali-toolkit-test-suite-utils.h>
30 #include <dali-toolkit/dali-toolkit.h>
31 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.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_SHADOW_OFFSET = "shadowOffset";
64 const char* const PROPERTY_NAME_SHADOW_COLOR = "shadowColor";
65 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
66 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
67 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
68 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
69 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
70 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
71 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
72 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
73 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
74 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
80 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
81 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
82 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
83 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
84 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
85 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
86 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
87 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
88 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
90 const char* const PROPERTY_NAME_UNDERLINE = "underline";
91 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
92 const char* const PROPERTY_NAME_SHADOW = "shadow";
93 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
94 const char* const PROPERTY_NAME_EMBOSS = "emboss";
95 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
96 const char* const PROPERTY_NAME_OUTLINE = "outline";
97 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
99 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
100 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
101 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
102 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
103 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
104 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
105 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
107 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
109 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
110 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
112 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
113 const float RENDER_FRAME_INTERVAL = 16.66f;
115 const float TO_MILLISECONDS = 1000.f;
116 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
118 const float SCROLL_THRESHOLD = 10.f;
119 const float SCROLL_SPEED = 300.f;
121 const unsigned int DEFAULT_FONT_SIZE = 1152u;
122 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
124 const int KEY_RETURN_CODE = 36;
125 const int KEY_A_CODE = 38;
126 const int KEY_D_CODE = 40;
128 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
130 static bool gTextChangedCallBackCalled;
131 static bool gMaxCharactersCallBackCalled;
132 static bool gInputStyleChangedCallbackCalled;
133 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
135 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
137 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
138 Integration::ResourcePointer resource(bitmap);
139 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
142 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
146 LoadBitmapResource( app.GetPlatform(), width, height );
148 Property::Map propertyMap;
149 propertyMap["filename"] = "image.png";
150 propertyMap["width"] = width;
151 propertyMap["height"] = height;
152 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
153 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
154 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
155 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
156 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
157 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
158 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
159 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
162 // Generate a PanGestureEvent to send to Core
163 static Integration::PanGestureEvent GeneratePan(
164 Gesture::State state,
165 const Vector2& previousPosition,
166 const Vector2& currentPosition,
167 unsigned long timeDelta,
168 unsigned int numberOfTouches = 1)
170 Integration::PanGestureEvent pan(state);
172 pan.previousPosition = previousPosition;
173 pan.currentPosition = currentPosition;
174 pan.timeDelta = timeDelta;
175 pan.numberOfTouches = numberOfTouches;
181 * Helper to generate PanGestureEvent
183 * @param[in] application Application instance
184 * @param[in] state The Gesture State
185 * @param[in] pos The current position of touch.
187 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
191 if( (state == Gesture::Started) ||
192 (state == Gesture::Possible) )
198 application.ProcessEvent(GeneratePan(state, last, pos, 16));
205 * Simulate time passed by.
207 * @note this will always process at least 1 frame (1/60 sec)
209 * @param application Test application instance
210 * @param duration Time to pass in milliseconds.
211 * @return The actual time passed in milliseconds
213 static int Wait(ToolkitTestApplication& application, int duration = 0)
217 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
219 application.SendNotification();
220 application.Render(RENDER_FRAME_INTERVAL);
221 time += RENDER_FRAME_INTERVAL;
227 Dali::Integration::Point GetPointDownInside( Vector2& pos )
229 Dali::Integration::Point point;
230 point.SetState( PointState::DOWN );
231 point.SetScreenPosition( pos );
235 Dali::Integration::Point GetPointUpInside( Vector2& pos )
237 Dali::Integration::Point point;
238 point.SetState( PointState::UP );
239 point.SetScreenPosition( pos );
243 struct CallbackFunctor
245 CallbackFunctor(bool* callbackFlag)
246 : mCallbackFlag( callbackFlag )
252 *mCallbackFlag = true;
257 static void TestTextChangedCallback( TextField control )
259 tet_infoline(" TestTextChangedCallback");
261 gTextChangedCallBackCalled = true;
264 static void TestMaxLengthReachedCallback( TextField control )
266 tet_infoline(" TestMaxLengthReachedCallback");
268 gMaxCharactersCallBackCalled = true;
271 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
273 tet_infoline(" TestInputStyleChangedCallback");
275 gInputStyleChangedCallbackCalled = true;
276 gInputStyleMask = mask;
279 // Generate a TapGestureEvent to send to Core.
280 Integration::TapGestureEvent GenerateTap(
281 Gesture::State state,
282 unsigned int numberOfTaps,
283 unsigned int numberOfTouches,
286 Integration::TapGestureEvent tap( state );
288 tap.numberOfTaps = numberOfTaps;
289 tap.numberOfTouches = numberOfTouches;
295 Integration::LongPressGestureEvent GenerateLongPress(
296 Gesture::State state,
297 unsigned int numberOfTouches,
300 Integration::LongPressGestureEvent longPress( state );
302 longPress.numberOfTouches = numberOfTouches;
303 longPress.point = point;
307 // Generate a KeyEvent to send to Core.
308 Integration::KeyEvent GenerateKey( const std::string& keyName,
309 const std::string& keyString,
312 unsigned long timeStamp,
313 const Integration::KeyEvent::State& keyState,
314 const std::string& compose = "",
315 const std::string& deviceName = DEFAULT_DEVICE_NAME,
316 const Device::Class::Type& deviceClass = Device::Class::NONE,
317 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
319 return Integration::KeyEvent( keyName,
331 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
333 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
335 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
337 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
339 Property::Value* valueSet = NULL;
340 if ( valueGet.first.type == Property::Key::INDEX )
342 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
346 // Get Key is a string so searching Set Map for a string key
347 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
350 if( NULL != valueSet )
352 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
354 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
357 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
359 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
362 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
364 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
367 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
369 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
372 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
374 Vector2 vector2Get = valueGet.second.Get<Vector2>();
375 Vector2 vector2Set = valueSet->Get<Vector2>();
376 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
379 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
381 Vector4 vector4Get = valueGet.second.Get<Vector4>();
382 Vector4 vector4Set = valueSet->Get<Vector4>();
383 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 );
389 if ( valueGet.first.type == Property::Key::INDEX )
391 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
395 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
407 int UtcDaliToolkitTextFieldConstructorP(void)
409 ToolkitTestApplication application;
410 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
412 DALI_TEST_CHECK( !textField );
416 int UtcDaliToolkitTextFieldNewP(void)
418 ToolkitTestApplication application;
419 tet_infoline(" UtcDaliToolkitTextFieldNewP");
420 TextField textField = TextField::New();
421 DALI_TEST_CHECK( textField );
425 int UtcDaliToolkitTextFieldDownCastP(void)
427 ToolkitTestApplication application;
428 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
429 TextField textField1 = TextField::New();
430 BaseHandle object( textField1 );
432 TextField textField2 = TextField::DownCast( object );
433 DALI_TEST_CHECK( textField2 );
435 TextField textField3 = DownCast< TextField >( object );
436 DALI_TEST_CHECK( textField3 );
440 int UtcDaliToolkitTextFieldDownCastN(void)
442 ToolkitTestApplication application;
443 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
444 BaseHandle uninitializedObject;
445 TextField textField1 = TextField::DownCast( uninitializedObject );
446 DALI_TEST_CHECK( !textField1 );
448 TextField textField2 = DownCast< TextField >( uninitializedObject );
449 DALI_TEST_CHECK( !textField2 );
453 int UtcDaliToolkitTextFieldCopyConstructorP(void)
455 ToolkitTestApplication application;
456 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
457 TextField textField = TextField::New();
458 textField.SetProperty( TextField::Property::TEXT, "Test" );
460 TextField copy( textField );
461 DALI_TEST_CHECK( copy );
462 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
466 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
468 ToolkitTestApplication application;
469 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
470 TextField textField = TextField::New();
471 textField.SetProperty( TextField::Property::TEXT, "Test" );
473 TextField copy = textField;
474 DALI_TEST_CHECK( copy );
475 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
479 int UtcDaliTextFieldNewP(void)
481 ToolkitTestApplication application;
482 tet_infoline(" UtcDaliToolkitTextFieldNewP");
483 TextField textField = TextField::New();
484 DALI_TEST_CHECK( textField );
488 // Positive test case for a method
489 int UtcDaliTextFieldGetPropertyP(void)
491 ToolkitTestApplication application;
492 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
493 TextField field = TextField::New();
494 DALI_TEST_CHECK( field );
496 // Check Property Indices are correct
497 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
498 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
499 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
500 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
501 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
502 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
503 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
504 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
505 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
506 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
507 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
508 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
509 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
510 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextField::Property::SHADOW_OFFSET );
511 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextField::Property::SHADOW_COLOR );
512 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
513 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
514 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
515 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
516 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
517 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
518 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
519 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
520 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
521 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
522 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
523 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
524 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
525 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
526 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
527 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
528 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
529 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
530 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
531 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
532 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
533 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
534 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
535 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
536 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
537 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
538 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
539 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
540 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
541 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
542 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
543 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
544 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
545 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
546 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
547 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
548 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
549 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
550 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
555 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
558 Property::Map imageMap;
559 imageMap[mapKey] =mapValue;
561 field.SetProperty( property , imageMap );
562 Property::Value propValue = field.GetProperty( property );
563 Property::Map* resultMap = propValue.GetMap();
565 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
573 // Positive test case for a method
574 int UtcDaliTextFieldSetPropertyP(void)
576 ToolkitTestApplication application;
577 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
578 TextField field = TextField::New();
579 DALI_TEST_CHECK( field );
580 Stage::GetCurrent().Add( field );
582 // Note - we can't check the defaults since the stylesheets are platform-specific
584 // Check the render backend property.
585 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
586 DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
588 // Check text property.
589 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
590 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
592 // Check placeholder text properties.
593 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
594 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
596 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
597 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
599 // Check font properties.
600 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
601 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
603 Property::Map fontStyleMapSet;
604 Property::Map fontStyleMapGet;
605 Property::Value* slantValue = NULL;
607 fontStyleMapSet.Insert( "weight", "bold" );
608 fontStyleMapSet.Insert( "width", "condensed" );
609 fontStyleMapSet.Insert( "slant", "italic" );
610 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 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
617 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
620 fontStyleMapSet.Clear();
621 fontStyleMapSet.Insert( "weight", "normal" );
622 fontStyleMapSet.Insert( "slant", "oblique" );
623 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
625 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
626 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
627 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
629 fontStyleMapSet.Clear();
630 fontStyleMapSet.Insert( "slant", "roman" );
631 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
632 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
634 // Replace 'roman' for 'normal'.
635 slantValue = fontStyleMapGet.Find( "slant" );
636 if( NULL != slantValue )
638 if( "normal" == slantValue->Get<std::string>() )
640 fontStyleMapGet["slant"] = "roman";
643 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
644 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
646 fontStyleMapSet.Clear();
648 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
649 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
650 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
651 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
653 // Check that the MAX_LENGTH property can be correctly set
654 const int maxNumberOfCharacters = 20;
655 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
656 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
658 // Check exceed policy
659 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
660 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
661 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
662 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
664 // Check that the Alignment properties can be correctly set
665 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
666 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
667 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
668 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
670 // Check text's color property
671 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
672 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
674 // Check placeholder text's color property.
675 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
676 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
678 // Check shadow properties.
679 field.SetProperty( TextField::Property::SHADOW_OFFSET, Vector2( 1.f, 1.f ) );
680 DALI_TEST_EQUALS( field.GetProperty<Vector2>( TextField::Property::SHADOW_OFFSET ), Vector2( 1.f, 1.f ), TEST_LOCATION );
681 field.SetProperty( TextField::Property::SHADOW_COLOR, Color::GREEN );
682 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SHADOW_COLOR ), Color::GREEN, TEST_LOCATION );
684 // Check cursor properties
685 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
686 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
687 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
688 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
690 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
691 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
692 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
693 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
694 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
695 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
696 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
697 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
699 // Check scroll properties.
700 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
701 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
702 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
703 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
705 // Check handle images
706 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
707 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
708 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
709 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
710 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
712 // Check handle images
713 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
714 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
715 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
716 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
717 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
718 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
720 // Check the highlight color
721 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
722 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
724 // Decoration bounding box
725 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
726 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
728 // Check the input method setting
729 Property::Map propertyMap;
730 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
731 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
732 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
733 int inputVariation = 1;
734 propertyMap["PANEL_LAYOUT"] = panelLayout;
735 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
736 propertyMap["BUTTON_ACTION"] = buttonAction;
737 propertyMap["VARIATION"] = inputVariation;
738 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
740 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
742 DALI_TEST_CHECK( value.Get( map ) );
745 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
746 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
749 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
750 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
753 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
754 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
757 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
758 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
760 // Check input color property.
761 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
762 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
764 // Check the enable markup property.
765 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
766 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
767 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
769 // Check input font properties.
770 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
771 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
773 fontStyleMapSet.Clear();
774 fontStyleMapSet.Insert( "weight", "bold" );
775 fontStyleMapSet.Insert( "width", "condensed" );
776 fontStyleMapSet.Insert( "slant", "italic" );
778 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
779 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
780 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
781 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
783 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
784 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
786 // Reset input font style.
787 fontStyleMapSet.Clear();
788 fontStyleMapSet.Insert( "weight", "normal" );
789 fontStyleMapSet.Insert( "slant", "oblique" );
791 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
792 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
793 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
794 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
796 fontStyleMapSet.Clear();
797 fontStyleMapSet.Insert( "slant", "roman" );
799 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
800 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
802 // Replace 'roman' for 'normal'.
803 slantValue = fontStyleMapGet.Find( "slant" );
804 if( NULL != slantValue )
806 if( "normal" == slantValue->Get<std::string>() )
808 fontStyleMapGet["slant"] = "roman";
811 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
812 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
814 fontStyleMapSet.Clear();
816 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
817 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
818 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
819 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
821 Property::Map underlineMapSet;
822 Property::Map underlineMapGet;
824 underlineMapSet.Insert( "enable", "true" );
825 underlineMapSet.Insert( "color", "red" );
826 underlineMapSet.Insert( "height", "1" );
828 // Check the underline property
829 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
831 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
832 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
833 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
835 // Check the input underline property
836 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
837 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
839 // Check the shadow property
840 Property::Map shadowMapSet;
841 Property::Map shadowMapGet;
843 shadowMapSet.Insert( "color", Color::GREEN );
844 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
845 shadowMapSet.Insert( "blurRadius", 3.0f );
847 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
849 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
850 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
851 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
853 // Check the input shadow property
854 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
855 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
857 // Check the emboss property
858 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
859 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
861 // Check the input emboss property
862 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
863 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
865 // Check the outline property
867 // Test string type first
868 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
869 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
870 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
872 // Then test the property map type
873 Property::Map outlineMapSet;
874 Property::Map outlineMapGet;
876 outlineMapSet["color"] = Color::RED;
877 outlineMapSet["width"] = 2.0f;
879 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
881 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
882 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
883 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
885 // Check the input outline property
886 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
887 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
889 // Check the hidden input settings property
890 Property::Map hiddenMapSet;
891 Property::Map hiddenMapGet;
892 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
893 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
894 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
895 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
896 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
898 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
899 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
900 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
902 // Check the pixel size of font
903 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
904 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
906 // Check the enable selection property
907 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
908 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
910 // Check the placeholder property with pixel size
911 Property::Map placeholderPixelSizeMapSet;
912 Property::Map placeholderPixelSizeMapGet;
913 Property::Map placeholderFontstyleMap;
914 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
915 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
916 placeholderPixelSizeMapSet["color"] = Color::BLUE;
917 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
918 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
919 placeholderPixelSizeMapSet["ellipsis"] = true;
921 placeholderFontstyleMap.Insert( "weight", "bold" );
922 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
923 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
925 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
926 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
928 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
929 Property::Map placeholderConversionMap;
930 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
931 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
932 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
933 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
934 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
935 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
937 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
939 // Check the placeholder property with point size
940 Property::Map placeholderMapSet;
941 Property::Map placeholderMapGet;
942 placeholderMapSet["text"] = "Setting Placeholder Text";
943 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
944 placeholderMapSet["color"] = Color::RED;
945 placeholderMapSet["fontFamily"] = "Arial";
946 placeholderMapSet["pointSize"] = 12.0f;
947 placeholderMapSet["ellipsis"] = false;
949 // Check the placeholder font style property
950 placeholderFontstyleMap.Clear();
952 placeholderFontstyleMap.Insert( "weight", "bold" );
953 placeholderFontstyleMap.Insert( "width", "condensed" );
954 placeholderFontstyleMap.Insert( "slant", "italic" );
955 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
956 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
958 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
959 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
961 placeholderConversionMap.Clear();
962 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
963 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
964 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
965 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
966 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
967 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
969 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
972 placeholderFontstyleMap.Clear();
973 placeholderFontstyleMap.Insert( "weight", "normal" );
974 placeholderFontstyleMap.Insert( "slant", "oblique" );
975 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
976 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
978 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
979 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
981 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
982 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
984 placeholderFontstyleMap.Clear();
985 placeholderFontstyleMap.Insert( "slant", "roman" );
986 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
987 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
989 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
991 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
993 placeholderFontstyleMap.Clear();
994 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
995 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
997 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
998 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
999 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1001 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1003 // Check the ellipsis property
1004 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1005 field.SetProperty( TextField::Property::ELLIPSIS, true );
1006 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1008 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
1009 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1011 application.SendNotification();
1012 application.Render();
1017 // Positive Atlas Text Renderer test
1018 int utcDaliTextFieldAtlasRenderP(void)
1020 ToolkitTestApplication application;
1021 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1022 StyleManager styleManager = StyleManager::Get();
1023 styleManager.ApplyDefaultTheme();
1024 TextField field = TextField::New();
1025 DALI_TEST_CHECK( field );
1027 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1029 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1031 Stage::GetCurrent().Add( field );
1035 // Render some text with the shared atlas backend
1036 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
1037 application.SendNotification();
1038 application.Render();
1042 tet_result(TET_FAIL);
1047 // Positive test for the textChanged signal.
1048 int utcDaliTextFieldTextChangedP(void)
1050 ToolkitTestApplication application;
1051 tet_infoline(" utcDaliTextFieldTextChangedP");
1052 TextField field = TextField::New();
1053 DALI_TEST_CHECK( field );
1055 Stage::GetCurrent().Add( field );
1057 // connect to the text changed signal.
1058 ConnectionTracker* testTracker = new ConnectionTracker();
1059 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1060 bool textChangedSignal = false;
1061 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1063 gTextChangedCallBackCalled = false;
1064 field.SetProperty( TextField::Property::TEXT, "ABC" );
1065 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1066 DALI_TEST_CHECK( textChangedSignal );
1068 application.SendNotification();
1070 field.SetKeyInputFocus();
1072 gTextChangedCallBackCalled = false;
1073 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1074 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1079 // Negative test for the textChanged signal.
1080 int utcDaliTextFieldTextChangedN(void)
1082 ToolkitTestApplication application;
1083 tet_infoline(" utcDaliTextFieldTextChangedN");
1084 TextField field = TextField::New();
1085 DALI_TEST_CHECK( field );
1087 Stage::GetCurrent().Add( field );
1089 // connect to the text changed signal.
1090 ConnectionTracker* testTracker = new ConnectionTracker();
1091 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1092 bool textChangedSignal = false;
1093 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1095 gTextChangedCallBackCalled = false;
1096 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1097 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1098 DALI_TEST_CHECK( !textChangedSignal );
1103 // Positive test for Max Characters reached signal.
1104 int utcDaliTextFieldMaxCharactersReachedP(void)
1106 ToolkitTestApplication application;
1107 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1108 TextField field = TextField::New();
1109 DALI_TEST_CHECK( field );
1111 Stage::GetCurrent().Add( field );
1113 const int maxNumberOfCharacters = 1;
1114 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1116 field.SetKeyInputFocus();
1118 // connect to the text changed signal.
1119 ConnectionTracker* testTracker = new ConnectionTracker();
1120 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1121 bool maxLengthReachedSignal = false;
1122 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1124 gMaxCharactersCallBackCalled = false;
1126 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1127 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1129 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1130 DALI_TEST_CHECK( maxLengthReachedSignal );
1135 // Negative test for Max Characters reached signal.
1136 int utcDaliTextFieldMaxCharactersReachedN(void)
1138 ToolkitTestApplication application;
1139 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1140 TextField field = TextField::New();
1141 DALI_TEST_CHECK( field );
1143 Stage::GetCurrent().Add( field );
1145 const int maxNumberOfCharacters = 3;
1146 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1148 field.SetKeyInputFocus();
1150 // connect to the text changed signal.
1151 ConnectionTracker* testTracker = new ConnectionTracker();
1152 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1153 bool maxLengthReachedSignal = false;
1154 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1156 gMaxCharactersCallBackCalled = false;
1158 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1159 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1161 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1162 DALI_TEST_CHECK( !maxLengthReachedSignal );
1164 application.ProcessEvent( GenerateKey( "Return", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::Down, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1166 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1167 DALI_TEST_CHECK( !maxLengthReachedSignal );
1172 int utcDaliTextFieldInputStyleChanged01(void)
1174 ToolkitTestApplication application;
1175 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1177 // The text-field emits signals when the input style changes. These changes of style are
1178 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1179 // can't be emitted during the size negotiation as the callbacks may update the UI.
1180 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1181 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1182 application.CreateAdaptor();
1186 char* pathNamePtr = get_current_dir_name();
1187 const std::string pathName( pathNamePtr );
1188 free( pathNamePtr );
1190 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1191 fontClient.SetDpi( 93u, 93u );
1193 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1194 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1196 TextField field = TextField::New();
1197 DALI_TEST_CHECK( field );
1200 field.SetSize( 300.f, 50.f );
1201 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1202 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1204 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1205 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1207 // connect to the text changed signal.
1208 ConnectionTracker* testTracker = new ConnectionTracker();
1209 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1210 bool inputStyleChangedSignal = false;
1211 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1213 Stage::GetCurrent().Add( field );
1215 // Render and notify
1216 application.SendNotification();
1217 application.Render();
1219 // Executes the idle callbacks added by the text control on the change of input style.
1220 application.RunIdles();
1222 gInputStyleChangedCallbackCalled = false;
1223 gInputStyleMask = TextField::InputStyle::NONE;
1224 inputStyleChangedSignal = false;
1226 // Create a tap event to touch the text field.
1227 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1228 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1230 // Render and notify
1231 application.SendNotification();
1232 application.Render();
1234 // Executes the idle callbacks added by the text control on the change of input style.
1235 application.RunIdles();
1237 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1238 if( gInputStyleChangedCallbackCalled )
1240 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1242 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1243 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1245 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1246 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1248 DALI_TEST_CHECK( inputStyleChangedSignal );
1250 gInputStyleChangedCallbackCalled = false;
1251 gInputStyleMask = TextField::InputStyle::NONE;
1252 inputStyleChangedSignal = false;
1254 // Create a tap event to touch the text field.
1255 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1256 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1258 // Render and notify
1259 application.SendNotification();
1260 application.Render();
1262 // Executes the idle callbacks added by the text control on the change of input style.
1263 application.RunIdles();
1265 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1266 DALI_TEST_CHECK( !inputStyleChangedSignal );
1268 gInputStyleChangedCallbackCalled = false;
1269 gInputStyleMask = TextField::InputStyle::NONE;
1270 inputStyleChangedSignal = false;
1272 // Create a tap event to touch the text field.
1273 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1274 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1276 // Render and notify
1277 application.SendNotification();
1278 application.Render();
1280 // Executes the idle callbacks added by the text control on the change of input style.
1281 application.RunIdles();
1283 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1284 if( gInputStyleChangedCallbackCalled )
1286 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1288 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1289 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1291 DALI_TEST_CHECK( inputStyleChangedSignal );
1293 gInputStyleChangedCallbackCalled = false;
1294 gInputStyleMask = TextField::InputStyle::NONE;
1295 inputStyleChangedSignal = false;
1297 // Create a tap event to touch the text field.
1298 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1299 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1301 // Render and notify
1302 application.SendNotification();
1303 application.Render();
1305 // Executes the idle callbacks added by the text control on the change of input style.
1306 application.RunIdles();
1308 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1309 if( gInputStyleChangedCallbackCalled )
1311 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1313 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1314 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1316 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1318 Property::Map fontStyleMapSet;
1319 fontStyleMapSet.Insert( "weight", "bold" );
1321 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1322 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1324 DALI_TEST_CHECK( inputStyleChangedSignal );
1326 gInputStyleChangedCallbackCalled = false;
1327 gInputStyleMask = TextField::InputStyle::NONE;
1328 inputStyleChangedSignal = false;
1330 // Create a tap event to touch the text field.
1331 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1332 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
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 );
1344 gInputStyleChangedCallbackCalled = false;
1345 gInputStyleMask = TextField::InputStyle::NONE;
1346 inputStyleChangedSignal = false;
1348 // Create a tap event to touch the text field.
1349 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1350 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1352 // Render and notify
1353 application.SendNotification();
1354 application.Render();
1356 // Executes the idle callbacks added by the text control on the change of input style.
1357 application.RunIdles();
1359 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1360 if( gInputStyleChangedCallbackCalled )
1362 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1364 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1365 DALI_TEST_CHECK( style.empty() );
1367 DALI_TEST_CHECK( inputStyleChangedSignal );
1369 gInputStyleChangedCallbackCalled = false;
1370 gInputStyleMask = TextField::InputStyle::NONE;
1371 inputStyleChangedSignal = false;
1373 // Create a tap event to touch the text field.
1374 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1375 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1377 // Render and notify
1378 application.SendNotification();
1379 application.Render();
1381 // Executes the idle callbacks added by the text control on the change of input style.
1382 application.RunIdles();
1384 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1385 DALI_TEST_CHECK( !inputStyleChangedSignal );
1390 int utcDaliTextFieldInputStyleChanged02(void)
1392 ToolkitTestApplication application;
1393 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1395 // The text-field emits signals when the input style changes. These changes of style are
1396 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1397 // can't be emitted during the size negotiation as the callbacks may update the UI.
1398 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1399 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1400 application.CreateAdaptor();
1404 char* pathNamePtr = get_current_dir_name();
1405 const std::string pathName( pathNamePtr );
1406 free( pathNamePtr );
1408 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1409 fontClient.SetDpi( 93u, 93u );
1411 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1412 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1414 TextField field = TextField::New();
1415 DALI_TEST_CHECK( field );
1418 field.SetSize( 300.f, 50.f );
1419 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1420 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1422 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1423 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>" );
1425 // connect to the text changed signal.
1426 ConnectionTracker* testTracker = new ConnectionTracker();
1427 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1428 bool inputStyleChangedSignal = false;
1429 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1431 Stage::GetCurrent().Add( field );
1433 // Render and notify
1434 application.SendNotification();
1435 application.Render();
1437 // Executes the idle callbacks added by the text control on the change of input style.
1438 application.RunIdles();
1440 gInputStyleChangedCallbackCalled = false;
1441 gInputStyleMask = TextField::InputStyle::NONE;
1442 inputStyleChangedSignal = false;
1444 // Create a tap event to touch the text field.
1445 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1446 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1447 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1448 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1450 // Render and notify
1451 application.SendNotification();
1452 application.Render();
1454 // Executes the idle callbacks added by the text control on the change of input style.
1455 application.RunIdles();
1457 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1458 if( gInputStyleChangedCallbackCalled )
1460 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1461 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1462 TextField::InputStyle::POINT_SIZE |
1463 TextField::InputStyle::COLOR ),
1466 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1467 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1469 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1470 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1472 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1473 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1475 DALI_TEST_CHECK( inputStyleChangedSignal );
1477 gInputStyleChangedCallbackCalled = false;
1478 gInputStyleMask = TextField::InputStyle::NONE;
1479 inputStyleChangedSignal = false;
1481 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1483 // Render and notify
1484 application.SendNotification();
1485 application.Render();
1487 // Executes the idle callbacks added by the text control on the change of input style.
1488 application.RunIdles();
1490 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1491 if( gInputStyleChangedCallbackCalled )
1493 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1494 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1497 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1498 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1500 DALI_TEST_CHECK( inputStyleChangedSignal );
1502 gInputStyleChangedCallbackCalled = false;
1503 gInputStyleMask = TextField::InputStyle::NONE;
1504 inputStyleChangedSignal = false;
1506 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1508 // Render and notify
1509 application.SendNotification();
1510 application.Render();
1512 // Executes the idle callbacks added by the text control on the change of input style.
1513 application.RunIdles();
1515 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1516 DALI_TEST_CHECK( !inputStyleChangedSignal );
1518 gInputStyleChangedCallbackCalled = false;
1519 gInputStyleMask = TextField::InputStyle::NONE;
1520 inputStyleChangedSignal = false;
1522 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1524 // Render and notify
1525 application.SendNotification();
1526 application.Render();
1528 // Executes the idle callbacks added by the text control on the change of input style.
1529 application.RunIdles();
1531 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1532 if( gInputStyleChangedCallbackCalled )
1534 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1535 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1538 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1539 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1541 DALI_TEST_CHECK( inputStyleChangedSignal );
1543 gInputStyleChangedCallbackCalled = false;
1544 gInputStyleMask = TextField::InputStyle::NONE;
1545 inputStyleChangedSignal = false;
1547 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1549 Property::Map fontStyleMapSet;
1550 fontStyleMapSet.Insert( "weight", "thin" );
1551 fontStyleMapSet.Insert( "width", "condensed" );
1552 fontStyleMapSet.Insert( "slant", "italic" );
1554 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1555 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1557 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1558 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1559 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1560 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1562 // Render and notify
1563 application.SendNotification();
1564 application.Render();
1566 // Executes the idle callbacks added by the text control on the change of input style.
1567 application.RunIdles();
1569 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1570 DALI_TEST_CHECK( !inputStyleChangedSignal );
1572 // Create a tap event to touch the text field.
1573 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1574 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1576 // Render and notify
1577 application.SendNotification();
1578 application.Render();
1580 // Executes the idle callbacks added by the text control on the change of input style.
1581 application.RunIdles();
1583 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1584 if( gInputStyleChangedCallbackCalled )
1586 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1587 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1588 TextField::InputStyle::POINT_SIZE |
1589 TextField::InputStyle::FONT_STYLE |
1590 TextField::InputStyle::UNDERLINE |
1591 TextField::InputStyle::SHADOW |
1592 TextField::InputStyle::EMBOSS |
1593 TextField::InputStyle::OUTLINE ),
1596 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1597 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1599 DALI_TEST_CHECK( inputStyleChangedSignal );
1604 int utcDaliTextFieldEvent01(void)
1606 ToolkitTestApplication application;
1607 tet_infoline(" utcDaliTextFieldEvent01");
1609 // Creates a tap event. After creating a tap event the text field should
1610 // have the focus and add text with key events should be possible.
1612 TextField field = TextField::New();
1613 DALI_TEST_CHECK( field );
1615 Stage::GetCurrent().Add( field );
1617 field.SetSize( 300.f, 50.f );
1618 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1619 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1621 // Avoid a crash when core load gl resources.
1622 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1624 // Render and notify
1625 application.SendNotification();
1626 application.Render();
1628 // Add a key event but as the text field has not the focus it should do nothing.
1629 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1631 // Render and notify
1632 application.SendNotification();
1633 application.Render();
1635 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1637 // Create a tap event to touch the text field.
1638 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1639 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1641 // Render and notify
1642 application.SendNotification();
1643 application.Render();
1645 // Pressing delete key should be fine even if there is no text in TextField.
1646 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 ) );
1647 // Render and notify
1648 application.SendNotification();
1649 application.Render();
1651 // Now the text field has the focus, so it can handle the key events.
1652 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1653 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1655 // Render and notify
1656 application.SendNotification();
1657 application.Render();
1659 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1661 // Create a second text field and send key events to it.
1662 TextField field2 = TextField::New();
1664 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1665 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1666 field2.SetSize( 100.f, 100.f );
1667 field2.SetPosition( 100.f, 100.f );
1669 Stage::GetCurrent().Add( field2 );
1671 // Render and notify
1672 application.SendNotification();
1673 application.Render();
1675 // Create a tap event on the second text field.
1676 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1677 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1679 // Render and notify
1680 application.SendNotification();
1681 application.Render();
1683 // The second text field has the focus. It should handle the key events.
1684 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1685 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1687 // Render and notify
1688 application.SendNotification();
1689 application.Render();
1691 // Check the text has been added to the second text field.
1692 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1697 int utcDaliTextFieldEvent02(void)
1699 ToolkitTestApplication application;
1700 tet_infoline(" utcDaliTextFieldEvent02");
1702 // Checks if the right number of actors are created.
1704 TextField field = TextField::New();
1705 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1706 DALI_TEST_CHECK( field );
1707 LoadMarkerImages(application, field);
1709 Stage::GetCurrent().Add( field );
1711 field.SetSize( 300.f, 50.f );
1712 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1713 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1715 // Avoid a crash when core load gl resources.
1716 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1718 // Render and notify
1719 application.SendNotification();
1720 application.Render();
1722 // Check there are the expected number of children ( stencil ).
1723 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1725 Actor stencil = field.GetChildAt( 0u );
1726 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1728 // Create a tap event to touch the text field.
1729 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1730 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1732 // Render and notify
1733 application.SendNotification();
1734 application.Render();
1736 Actor layer = field.GetChildAt( 1u );
1737 DALI_TEST_CHECK( layer.IsLayer() );
1739 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1740 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1742 // Now the text field has the focus, so it can handle the key events.
1743 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1744 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1746 // Render and notify
1747 application.SendNotification();
1748 application.Render();
1750 // Checks the cursor and the renderer have been created.
1751 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1752 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1754 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1755 DALI_TEST_CHECK( cursor );
1757 // The offscreen root actor has a container with all the actors which contain the text renderers.
1758 Actor container = stencil.GetChildAt( 0u );
1759 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1761 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1762 DALI_TEST_CHECK( renderer );
1765 // Move the cursor and check the position changes.
1766 Vector3 position1 = cursor.GetCurrentPosition();
1768 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1769 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1771 // Render and notify
1772 application.SendNotification();
1773 application.Render();
1775 Vector3 position2 = cursor.GetCurrentPosition();
1777 DALI_TEST_CHECK( position2.x < position1.x );
1779 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1780 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1782 // Render and notify
1783 application.SendNotification();
1784 application.Render();
1786 Vector3 position3 = cursor.GetCurrentPosition();
1788 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1790 // Send some taps and check the cursor positions.
1792 // Try to tap at the beginning.
1793 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1794 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1796 // Render and notify
1797 application.SendNotification();
1798 application.Render();
1800 // Cursor position should be the same than position1.
1801 Vector3 position4 = cursor.GetCurrentPosition();
1803 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1805 // Tap away from the start position.
1806 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1807 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1809 // Render and notify
1810 application.SendNotification();
1811 application.Render();
1813 Vector3 position5 = cursor.GetCurrentPosition();
1815 DALI_TEST_CHECK( position5.x > position4.x );
1817 // Remove all the text.
1818 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1819 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1820 field.SetProperty( TextField::Property::TEXT, "" );
1822 // Render and notify
1823 application.SendNotification();
1824 application.Render();
1826 // Cursor position should be the same than position2.
1827 Vector3 position6 = cursor.GetCurrentPosition();
1829 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1831 // Should not be a renderer.
1832 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1834 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1835 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1836 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1838 application.SendNotification();
1839 application.Render();
1841 // There are renderer and decorator layer
1842 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1847 int utcDaliTextFieldEvent03(void)
1849 ToolkitTestApplication application;
1850 tet_infoline(" utcDaliTextFieldEvent03");
1852 // Checks if the highlight actor is created.
1854 TextField field = TextField::New();
1855 DALI_TEST_CHECK( field );
1857 Stage::GetCurrent().Add( field );
1859 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1860 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1861 field.SetSize( 30.f, 50.f );
1862 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1863 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1865 // Avoid a crash when core load gl resources.
1866 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1867 LoadMarkerImages(application, field);
1869 // Render and notify
1870 application.SendNotification();
1871 application.Render();
1873 // Tap first to get the focus.
1874 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1875 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1877 // Render and notify
1878 application.SendNotification();
1879 application.Render();
1881 // Double tap to select a word.
1882 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1883 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1885 // Render and notify
1886 application.SendNotification();
1887 application.Render();
1889 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1890 Actor stencil = field.GetChildAt( 0u );
1892 // The highlight actor is drawn first, so is the first actor in the list
1893 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1894 DALI_TEST_CHECK( highlight );
1896 // The offscreen root actor has a container with all the actors which contain the text renderers.
1897 Actor container = stencil.GetChildAt( 1u );
1898 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1900 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1901 DALI_TEST_CHECK( renderer );
1907 int utcDaliTextFieldEvent04(void)
1909 ToolkitTestApplication application;
1910 tet_infoline(" utcDaliTextFieldEvent04");
1912 // Checks if the highlight actor is created.
1914 TextField field = TextField::New();
1915 DALI_TEST_CHECK( field );
1916 Stage::GetCurrent().Add( field );
1917 LoadMarkerImages(application, field);
1918 // Render and notify
1919 application.SendNotification();
1920 application.Render();
1922 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1923 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1924 field.SetSize( 300.f, 50.f );
1925 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1926 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1928 // Avoid a crash when core load gl resources.
1929 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1930 // Render and notify
1931 application.SendNotification();
1932 application.Render();
1934 // Create a tap event to touch the text field.
1935 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1936 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1937 // Render and notify
1938 application.SendNotification();
1939 application.Render();
1942 // Tap first to get the focus.
1943 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1944 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1946 // Render and notify
1947 application.SendNotification();
1948 application.Render();
1950 // Double tap to select a word.
1951 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1952 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1954 // Render and notify
1955 application.SendNotification();
1956 application.Render();
1959 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1960 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1964 int utcDaliTextFieldEvent05(void)
1966 ToolkitTestApplication application;
1967 tet_infoline(" utcDaliTextFieldEvent05");
1969 // Checks dragging of cursor/grab handle
1971 TextField field = TextField::New();
1972 DALI_TEST_CHECK( field );
1973 Stage::GetCurrent().Add( field );
1974 LoadMarkerImages(application, field);
1975 // Render and notify
1976 application.SendNotification();
1977 application.Render();
1979 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1980 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1981 field.SetSize( 300.f, 50.f );
1982 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1983 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1985 // Avoid a crash when core load gl resources.
1986 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1987 // Render and notify
1988 application.SendNotification();
1989 application.Render();
1991 // Create a tap event to touch the text field.
1992 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1993 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1994 // Render and notify
1995 application.SendNotification();
1996 application.Render();
1998 // Tap first to get the focus.
1999 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2000 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2002 // Render and notify
2003 application.SendNotification();
2004 application.Render();
2006 // Double tap to select a word.
2007 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2008 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2010 // Render and notify
2011 application.SendNotification();
2012 application.Render();
2014 // drag grab handle right
2015 Vector2 pos(0.0f, 40.0f);
2016 SendPan(application, Gesture::Possible, pos);
2017 SendPan(application, Gesture::Started, pos);
2019 Wait(application, 100);
2021 for(int i = 0;i<20;i++)
2023 SendPan(application, Gesture::Continuing, pos);
2028 SendPan(application, Gesture::Finished, pos);
2029 Wait(application, RENDER_FRAME_INTERVAL);
2031 Actor stencil = field.GetChildAt( 1u );
2035 int utcDaliTextFieldEvent06(void)
2037 ToolkitTestApplication application;
2038 tet_infoline(" utcDaliTextFieldEvent06");
2040 // Checks Longpress when in edit mode
2042 TextField field = TextField::New();
2043 DALI_TEST_CHECK( field );
2044 Stage::GetCurrent().Add( field );
2045 LoadMarkerImages(application, field);
2046 // Render and notify
2047 application.SendNotification();
2048 application.Render();
2050 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2051 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2052 field.SetSize( 300.f, 50.f );
2053 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2054 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2056 // Avoid a crash when core load gl resources.
2057 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2058 // Render and notify
2059 application.SendNotification();
2060 application.Render();
2062 // Create a tap event to touch the text field.
2063 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2064 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2065 // Render and notify
2066 application.SendNotification();
2067 application.Render();
2070 // Tap first to get the focus.
2071 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2072 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2074 // Render and notify
2075 application.SendNotification();
2076 application.Render();
2079 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2080 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2082 // Render and notify
2083 application.SendNotification();
2084 application.Render();
2089 int utcDaliTextFieldEvent07(void)
2091 ToolkitTestApplication application;
2092 tet_infoline(" utcDaliTextFieldEvent07");
2094 // Checks Longpress to start edit mode
2096 TextField field = TextField::New();
2097 DALI_TEST_CHECK( field );
2098 Stage::GetCurrent().Add( field );
2099 LoadMarkerImages(application, field);
2100 // Render and notify
2101 application.SendNotification();
2102 application.Render();
2104 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2105 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2106 field.SetSize( 300.f, 50.f );
2107 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2108 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2109 Property::Map propertyMap;
2110 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2111 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2113 // Avoid a crash when core load gl resources.
2114 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2115 // Render and notify
2116 application.SendNotification();
2117 application.Render();
2120 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2121 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2123 // Render and notify
2124 application.SendNotification();
2125 application.Render();
2130 int utcDaliTextFieldEvent08(void)
2132 ToolkitTestApplication application;
2133 tet_infoline(" utcDaliTextFieldEvent08");
2135 Dali::Clipboard clipboard = Clipboard::Get();
2136 clipboard.SetItem("testTextFieldEvent");
2138 // Checks Longpress when only place holder text
2140 TextField field = TextField::New();
2141 DALI_TEST_CHECK( field );
2142 Stage::GetCurrent().Add( field );
2143 LoadMarkerImages(application, field);
2144 // Render and notify
2145 application.SendNotification();
2146 application.Render();
2148 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2149 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2150 field.SetSize( 300.f, 50.f );
2151 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2152 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2154 // Avoid a crash when core load gl resources.
2155 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2156 // Render and notify
2157 application.SendNotification();
2158 application.Render();
2161 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2162 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2164 // Render and notify
2165 application.SendNotification();
2166 application.Render();
2168 Wait(application, 500);
2171 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2172 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2174 // Render and notify
2175 application.SendNotification();
2176 application.Render();
2178 Wait(application, 500);
2180 Stage stage = Stage::GetCurrent();
2181 Layer layer = stage.GetRootLayer();
2182 Actor actor = layer.FindChildByName("optionPaste");
2186 Vector3 worldPosition = actor.GetCurrentWorldPosition();
2187 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2188 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2190 Dali::Integration::TouchEvent event;
2191 event = Dali::Integration::TouchEvent();
2192 event.AddPoint( GetPointDownInside( position ) );
2193 application.ProcessEvent( event );
2195 event = Dali::Integration::TouchEvent();
2196 event.AddPoint( GetPointUpInside( position ) );
2197 application.ProcessEvent( event );
2199 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2204 int utcDaliTextFieldEvent09(void)
2206 ToolkitTestApplication application;
2207 tet_infoline(" utcDaliTextFieldEvent09");
2209 TextField field = TextField::New();
2210 DALI_TEST_CHECK( field );
2211 Stage::GetCurrent().Add( field );
2212 LoadMarkerImages(application, field);
2213 // Render and notify
2214 application.SendNotification();
2215 application.Render();
2217 field.SetProperty( TextField::Property::TEXT, "Hello" );
2218 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2219 field.SetSize( 300.f, 50.f );
2220 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2221 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2223 // Avoid a crash when core load gl resources.
2224 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2226 // Create a tap event to touch the text field.
2227 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2228 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2229 application.SendNotification();
2230 application.Render();
2233 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2234 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2235 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2236 application.SendNotification();
2237 application.Render();
2239 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2240 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2241 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2242 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2243 application.SendNotification();
2244 application.Render();
2246 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2247 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2248 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2249 for( unsigned int index = 0u; index < 5u; ++index )
2251 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2252 application.SendNotification();
2253 application.Render();
2256 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2257 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2258 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2259 for( unsigned int index = 0u; index < 5u; ++index )
2261 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2262 application.SendNotification();
2263 application.Render();
2266 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2267 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2268 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2269 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2270 application.SendNotification();
2271 application.Render();
2272 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2273 application.SendNotification();
2274 application.Render();
2276 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2277 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2278 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2279 application.SendNotification();
2280 application.Render();
2282 Property::Map mapGet;
2283 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2284 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2285 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2290 int utcDaliTextFieldStyleWhilstSelected(void)
2292 ToolkitTestApplication application;
2293 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2295 // Change font and styles whilst text is selected whilst word selected
2297 TextField field = TextField::New();
2298 DALI_TEST_CHECK( field );
2299 Stage::GetCurrent().Add( field );
2300 LoadMarkerImages(application, field);
2301 // Render and notify
2302 application.SendNotification();
2303 application.Render();
2305 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2306 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2307 field.SetSize( 300.f, 50.f );
2308 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2309 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2311 // Avoid a crash when core load gl resources.
2312 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2313 // Render and notify
2314 application.SendNotification();
2315 application.Render();
2317 // Create a tap event to touch the text field.
2318 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2319 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2320 // Render and notify
2321 application.SendNotification();
2322 application.Render();
2325 // Tap first to get the focus.
2326 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2327 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2329 // Render and notify
2330 application.SendNotification();
2331 application.Render();
2333 // Double tap to select a word.
2334 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2335 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2337 // Render and notify
2338 application.SendNotification();
2339 application.Render();
2341 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2342 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2344 Property::Map fontStyleMapSet;
2345 Property::Map fontStyleMapGet;
2347 fontStyleMapSet.Insert( "weight", "bold" );
2348 fontStyleMapSet.Insert( "slant", "italic" );
2349 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2351 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2352 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2353 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2355 fontStyleMapSet.Clear();
2356 fontStyleMapSet.Insert( "width", "expanded" );
2357 fontStyleMapSet.Insert( "slant", "italic" );
2358 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2360 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2361 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2362 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2364 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2365 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2367 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2368 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2370 fontStyleMapSet.Clear();
2371 fontStyleMapSet.Insert( "weight", "bold" );
2372 fontStyleMapSet.Insert( "slant", "italic" );
2374 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2376 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2377 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2378 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2380 fontStyleMapSet.Clear();
2381 fontStyleMapSet.Insert( "width", "expanded" );
2383 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2385 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2386 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2387 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2389 // Press Escape to increase coverage
2390 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2391 application.SendNotification();
2392 application.Render();
2394 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2399 int utcDaliTextFieldEscKeyLoseFocus(void)
2401 ToolkitTestApplication application;
2402 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2404 // Creates a tap event. After creating a tap event the text field should
2405 // have the focus and add text with key events should be possible.
2407 TextField field = TextField::New();
2408 DALI_TEST_CHECK( field );
2410 Stage::GetCurrent().Add( field );
2412 field.SetSize( 300.f, 50.f );
2413 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2414 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2416 // Avoid a crash when core load gl resources.
2417 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2419 // Render and notify
2420 application.SendNotification();
2421 application.Render();
2423 // Add a key event but as the text field has not the focus it should do nothing.
2424 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2425 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2427 // Render and notify
2428 application.SendNotification();
2429 application.Render();
2431 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2433 // Create a tap event to touch the text field.
2434 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2435 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2437 // Render and notify
2438 application.SendNotification();
2439 application.Render();
2441 // Now the text field has the focus, so it can handle the key events.
2442 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2443 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2444 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2445 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2447 // Render and notify
2448 application.SendNotification();
2449 application.Render();
2451 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2453 // Generate a Esc key event. The text field should lose the focus.
2454 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2455 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2457 // Render and notify
2458 application.SendNotification();
2459 application.Render();
2461 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2463 // No more text should be introduced
2464 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2465 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2467 // Render and notify
2468 application.SendNotification();
2469 application.Render();
2471 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2476 int utcDaliTextFieldSomeSpecialKeys(void)
2478 ToolkitTestApplication application;
2479 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2481 // Checks some special keys when the text is selected.
2483 TextField field = TextField::New();
2484 DALI_TEST_CHECK( field );
2485 Stage::GetCurrent().Add( field );
2486 LoadMarkerImages(application, field);
2487 // Render and notify
2488 application.SendNotification();
2489 application.Render();
2491 const std::string longText( "This is a long text for the size of the text-field." );
2493 field.SetProperty( TextField::Property::TEXT, longText );
2494 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2495 field.SetSize( 300.f, 50.f );
2496 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2497 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2499 // Avoid a crash when core load gl resources.
2500 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2501 // Render and notify
2502 application.SendNotification();
2503 application.Render();
2505 // Create a tap event to touch the text field.
2506 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2507 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2509 // Render and notify
2510 application.SendNotification();
2511 application.Render();
2513 // Tap first to get the focus.
2514 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2515 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2517 // Render and notify
2518 application.SendNotification();
2519 application.Render();
2521 // Double tap to select a word.
2522 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2523 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2525 // Render and notify
2526 application.SendNotification();
2527 application.Render();
2529 // Generate a Esc key event. The text field should lose the focus.
2530 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2531 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2533 // Render and notify
2534 application.SendNotification();
2535 application.Render();
2537 // Generate a Esc key event. The text field should lose the focus.
2538 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2539 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2541 // Render and notify
2542 application.SendNotification();
2543 application.Render();
2545 // Generate a Esc key event. The text field should lose the focus.
2546 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2547 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2549 // Render and notify
2550 application.SendNotification();
2551 application.Render();
2553 // The text shouldn't be deleted.
2554 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2559 int utcDaliTextFieldSizeUpdate(void)
2561 ToolkitTestApplication application;
2562 tet_infoline("utcDaliTextFieldSizeUpdate");
2564 // Checks some special keys when the text is selected.
2565 TextField field = TextField::New();
2566 DALI_TEST_CHECK( field );
2567 Stage::GetCurrent().Add( field );
2569 float previousHeight = 0.0f;
2570 float currentHeight = 0.0f;
2571 const float fieldWidth = 1920.0f;
2574 // "ㅁ" is bigger then "ኢ"
2575 field.SetSize( Vector2( fieldWidth ,10.0f ) );
2576 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2577 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2579 field.SetProperty( TextField::Property::TEXT, "ኢ");
2580 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2581 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2583 field.SetKeyboardFocusable(true);
2584 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2586 application.SendNotification();
2587 application.Render();
2589 previousHeight = field.GetHeightForWidth( fieldWidth );
2590 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2592 // Add another script characters ( glyph height is defferent )
2593 application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2594 application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2596 application.SendNotification();
2597 application.Render();
2599 currentHeight = field.GetHeightForWidth( fieldWidth );
2600 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2601 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2606 int utcDaliTextFieldExtremlyLargePointSize(void)
2608 ToolkitTestApplication application;
2609 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2611 TextField field = TextField::New();
2613 field.SetProperty( TextField::Property::TEXT, "Text" );
2614 field.SetSize( 300.f, 50.f );
2615 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2616 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2617 Stage::GetCurrent().Add( field );
2621 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2622 application.SendNotification();
2623 DALI_TEST_CHECK( field );
2627 tet_result(TET_FAIL);
2632 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2634 ToolkitTestApplication application;
2635 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2636 TextField field = TextField::New();
2637 DALI_TEST_CHECK( field );
2638 Stage::GetCurrent().Add( field );
2640 Property::Map fontStyleMapGet;
2642 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2644 Property::Value* weightValue = NULL;
2645 Property::Value* widthValue = NULL;
2646 Property::Value* slantValue = NULL;
2647 weightValue = fontStyleMapGet.Find( "weight" );
2648 widthValue = fontStyleMapGet.Find( "width" );
2649 slantValue = fontStyleMapGet.Find( "slant" );
2650 DALI_TEST_CHECK( !weightValue );
2651 DALI_TEST_CHECK( !widthValue );
2652 DALI_TEST_CHECK( !slantValue );
2657 int UtcDaliTextFieldSettingPlaceholder(void)
2659 ToolkitTestApplication application;
2660 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
2662 TextField field = TextField::New();
2663 DALI_TEST_CHECK( field );
2664 Stage::GetCurrent().Add( field );
2666 // Check the placeholder property with pixel size
2667 Property::Map placeholderPixelSizeMapSet;
2668 Property::Map placeholderPixelSizeMapGet;
2669 Property::Map placeholderFontstyleMap;
2670 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2671 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2672 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
2673 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2674 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
2675 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
2677 placeholderFontstyleMap.Insert( "weight", "bold" );
2678 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2679 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
2681 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2682 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
2683 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
2685 // Check the placeholder property with point size
2686 Property::Map placeholderMapSet;
2687 Property::Map placeholderMapGet;
2688 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2689 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2690 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
2691 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2692 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
2693 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
2695 // Check the placeholder font style property
2696 placeholderFontstyleMap.Clear();
2698 placeholderFontstyleMap.Insert( "weight", "bold" );
2699 placeholderFontstyleMap.Insert( "width", "condensed" );
2700 placeholderFontstyleMap.Insert( "slant", "italic" );
2701 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2702 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2704 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2705 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2706 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2708 // Reset font style.
2709 placeholderFontstyleMap.Clear();
2710 placeholderFontstyleMap.Insert( "weight", "normal" );
2711 placeholderFontstyleMap.Insert( "slant", "oblique" );
2712 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2713 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2715 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2716 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2717 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2719 placeholderFontstyleMap.Clear();
2720 placeholderFontstyleMap.Insert( "slant", "roman" );
2721 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2722 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2724 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2726 placeholderFontstyleMap.Clear();
2727 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2729 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2730 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2731 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2732 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2737 int UtcDaliTextFieldSetPaddingProperty(void)
2739 ToolkitTestApplication application;
2740 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
2742 TextField field = TextField::New();
2743 DALI_TEST_CHECK( field );
2744 field.SetSize( 300.f, 50.f );
2745 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2746 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2747 Stage::GetCurrent().Add( field );
2749 application.SendNotification();
2750 application.Render();
2752 Vector3 originalSize = field.GetNaturalSize();
2754 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2756 application.SendNotification();
2757 application.Render();
2759 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2761 Vector3 paddingAddedSize = field.GetNaturalSize();
2763 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2765 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2770 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
2772 ToolkitTestApplication application;
2773 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
2775 TextField field = TextField::New();
2776 DALI_TEST_CHECK( field );
2777 field.SetSize( 300.f, 50.f );
2778 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2779 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2780 Stage::GetCurrent().Add( field );
2782 application.SendNotification();
2783 application.Render();
2785 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2786 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2788 // Check the enable shift selection property
2789 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
2790 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2792 application.SendNotification();
2793 application.Render();
2798 int UtcDaliTextFieldEnableGrabHandleProperty(void)
2800 ToolkitTestApplication application;
2801 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
2803 TextField field = TextField::New();
2804 DALI_TEST_CHECK( field );
2805 field.SetSize( 300.f, 50.f );
2806 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2807 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2808 Stage::GetCurrent().Add( field );
2810 application.SendNotification();
2811 application.Render();
2813 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2814 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2816 // Check the enable grab handle property
2817 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
2818 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2820 application.SendNotification();
2821 application.Render();
2826 int UtcDaliTextFieldGetInputMethodContext(void)
2828 ToolkitTestApplication application;
2829 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
2831 TextField field = TextField::New();
2832 DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );