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";
106 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
108 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
110 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
111 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
113 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
114 const float RENDER_FRAME_INTERVAL = 16.66f;
116 const float TO_MILLISECONDS = 1000.f;
117 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
119 const float SCROLL_THRESHOLD = 10.f;
120 const float SCROLL_SPEED = 300.f;
122 const unsigned int DEFAULT_FONT_SIZE = 1152u;
123 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
125 const int KEY_RETURN_CODE = 36;
126 const int KEY_A_CODE = 38;
127 const int KEY_D_CODE = 40;
129 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
131 static bool gTextChangedCallBackCalled;
132 static bool gMaxCharactersCallBackCalled;
133 static bool gInputStyleChangedCallbackCalled;
134 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
136 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
138 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
139 Integration::ResourcePointer resource(bitmap);
140 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
143 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
147 LoadBitmapResource( app.GetPlatform(), width, height );
149 Property::Map propertyMap;
150 propertyMap["filename"] = "image.png";
151 propertyMap["width"] = width;
152 propertyMap["height"] = height;
153 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
154 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
155 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
156 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
157 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
158 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
159 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
160 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
163 // Generate a PanGestureEvent to send to Core
164 static Integration::PanGestureEvent GeneratePan(
165 Gesture::State state,
166 const Vector2& previousPosition,
167 const Vector2& currentPosition,
168 unsigned long timeDelta,
169 unsigned int numberOfTouches = 1)
171 Integration::PanGestureEvent pan(state);
173 pan.previousPosition = previousPosition;
174 pan.currentPosition = currentPosition;
175 pan.timeDelta = timeDelta;
176 pan.numberOfTouches = numberOfTouches;
182 * Helper to generate PanGestureEvent
184 * @param[in] application Application instance
185 * @param[in] state The Gesture State
186 * @param[in] pos The current position of touch.
188 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
192 if( (state == Gesture::Started) ||
193 (state == Gesture::Possible) )
199 application.ProcessEvent(GeneratePan(state, last, pos, 16));
206 * Simulate time passed by.
208 * @note this will always process at least 1 frame (1/60 sec)
210 * @param application Test application instance
211 * @param duration Time to pass in milliseconds.
212 * @return The actual time passed in milliseconds
214 static int Wait(ToolkitTestApplication& application, int duration = 0)
218 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
220 application.SendNotification();
221 application.Render(RENDER_FRAME_INTERVAL);
222 time += RENDER_FRAME_INTERVAL;
228 Dali::Integration::Point GetPointDownInside( Vector2& pos )
230 Dali::Integration::Point point;
231 point.SetState( PointState::DOWN );
232 point.SetScreenPosition( pos );
236 Dali::Integration::Point GetPointUpInside( Vector2& pos )
238 Dali::Integration::Point point;
239 point.SetState( PointState::UP );
240 point.SetScreenPosition( pos );
244 struct CallbackFunctor
246 CallbackFunctor(bool* callbackFlag)
247 : mCallbackFlag( callbackFlag )
253 *mCallbackFlag = true;
258 static void TestTextChangedCallback( TextField control )
260 tet_infoline(" TestTextChangedCallback");
262 gTextChangedCallBackCalled = true;
265 static void TestMaxLengthReachedCallback( TextField control )
267 tet_infoline(" TestMaxLengthReachedCallback");
269 gMaxCharactersCallBackCalled = true;
272 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
274 tet_infoline(" TestInputStyleChangedCallback");
276 gInputStyleChangedCallbackCalled = true;
277 gInputStyleMask = mask;
280 // Generate a TapGestureEvent to send to Core.
281 Integration::TapGestureEvent GenerateTap(
282 Gesture::State state,
283 unsigned int numberOfTaps,
284 unsigned int numberOfTouches,
287 Integration::TapGestureEvent tap( state );
289 tap.numberOfTaps = numberOfTaps;
290 tap.numberOfTouches = numberOfTouches;
296 Integration::LongPressGestureEvent GenerateLongPress(
297 Gesture::State state,
298 unsigned int numberOfTouches,
301 Integration::LongPressGestureEvent longPress( state );
303 longPress.numberOfTouches = numberOfTouches;
304 longPress.point = point;
308 // Generate a KeyEvent to send to Core.
309 Integration::KeyEvent GenerateKey( const std::string& keyName,
310 const std::string& keyString,
313 unsigned long timeStamp,
314 const Integration::KeyEvent::State& keyState,
315 const std::string& compose = "",
316 const std::string& deviceName = DEFAULT_DEVICE_NAME,
317 const Device::Class::Type& deviceClass = Device::Class::NONE,
318 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
320 return Integration::KeyEvent( keyName,
332 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
334 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
336 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
338 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
340 Property::Value* valueSet = NULL;
341 if ( valueGet.first.type == Property::Key::INDEX )
343 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
347 // Get Key is a string so searching Set Map for a string key
348 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
351 if( NULL != valueSet )
353 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
355 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
358 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
360 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
363 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
365 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
368 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
370 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
373 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
375 Vector2 vector2Get = valueGet.second.Get<Vector2>();
376 Vector2 vector2Set = valueSet->Get<Vector2>();
377 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
380 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
382 Vector4 vector4Get = valueGet.second.Get<Vector4>();
383 Vector4 vector4Set = valueSet->Get<Vector4>();
384 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 );
390 if ( valueGet.first.type == Property::Key::INDEX )
392 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
396 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
408 int UtcDaliToolkitTextFieldConstructorP(void)
410 ToolkitTestApplication application;
411 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
413 DALI_TEST_CHECK( !textField );
417 int UtcDaliToolkitTextFieldNewP(void)
419 ToolkitTestApplication application;
420 tet_infoline(" UtcDaliToolkitTextFieldNewP");
421 TextField textField = TextField::New();
422 DALI_TEST_CHECK( textField );
426 int UtcDaliToolkitTextFieldDownCastP(void)
428 ToolkitTestApplication application;
429 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
430 TextField textField1 = TextField::New();
431 BaseHandle object( textField1 );
433 TextField textField2 = TextField::DownCast( object );
434 DALI_TEST_CHECK( textField2 );
436 TextField textField3 = DownCast< TextField >( object );
437 DALI_TEST_CHECK( textField3 );
441 int UtcDaliToolkitTextFieldDownCastN(void)
443 ToolkitTestApplication application;
444 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
445 BaseHandle uninitializedObject;
446 TextField textField1 = TextField::DownCast( uninitializedObject );
447 DALI_TEST_CHECK( !textField1 );
449 TextField textField2 = DownCast< TextField >( uninitializedObject );
450 DALI_TEST_CHECK( !textField2 );
454 int UtcDaliToolkitTextFieldCopyConstructorP(void)
456 ToolkitTestApplication application;
457 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
458 TextField textField = TextField::New();
459 textField.SetProperty( TextField::Property::TEXT, "Test" );
461 TextField copy( textField );
462 DALI_TEST_CHECK( copy );
463 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
467 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
469 ToolkitTestApplication application;
470 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
471 TextField textField = TextField::New();
472 textField.SetProperty( TextField::Property::TEXT, "Test" );
474 TextField copy = textField;
475 DALI_TEST_CHECK( copy );
476 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
480 int UtcDaliTextFieldNewP(void)
482 ToolkitTestApplication application;
483 tet_infoline(" UtcDaliToolkitTextFieldNewP");
484 TextField textField = TextField::New();
485 DALI_TEST_CHECK( textField );
489 // Positive test case for a method
490 int UtcDaliTextFieldGetPropertyP(void)
492 ToolkitTestApplication application;
493 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
494 TextField field = TextField::New();
495 DALI_TEST_CHECK( field );
497 // Check Property Indices are correct
498 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
499 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
500 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
501 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
502 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
503 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
504 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
505 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
506 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
507 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
508 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
509 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
510 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
511 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextField::Property::SHADOW_OFFSET );
512 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextField::Property::SHADOW_COLOR );
513 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
514 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
515 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
516 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
517 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
518 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
519 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
520 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
521 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
522 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
523 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
524 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
525 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
526 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
527 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
528 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
529 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
530 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
531 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
532 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
533 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
534 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
535 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
536 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
537 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
538 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
539 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
540 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
541 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
542 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
543 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
544 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
545 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
546 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
547 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
548 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
549 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
550 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
551 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
552 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
557 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
560 Property::Map imageMap;
561 imageMap[mapKey] =mapValue;
563 field.SetProperty( property , imageMap );
564 Property::Value propValue = field.GetProperty( property );
565 Property::Map* resultMap = propValue.GetMap();
567 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
575 // Positive test case for a method
576 int UtcDaliTextFieldSetPropertyP(void)
578 ToolkitTestApplication application;
579 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
580 TextField field = TextField::New();
581 DALI_TEST_CHECK( field );
582 Stage::GetCurrent().Add( field );
584 // Note - we can't check the defaults since the stylesheets are platform-specific
586 // Check the render backend property.
587 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
588 DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
590 // Check text property.
591 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
592 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
594 // Check placeholder text properties.
595 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
596 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
598 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
599 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
601 // Check font properties.
602 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
603 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
605 Property::Map fontStyleMapSet;
606 Property::Map fontStyleMapGet;
607 Property::Value* slantValue = NULL;
609 fontStyleMapSet.Insert( "weight", "bold" );
610 fontStyleMapSet.Insert( "width", "condensed" );
611 fontStyleMapSet.Insert( "slant", "italic" );
612 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
614 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
615 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
616 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
618 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
619 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
622 fontStyleMapSet.Clear();
623 fontStyleMapSet.Insert( "weight", "normal" );
624 fontStyleMapSet.Insert( "slant", "oblique" );
625 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
627 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
628 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
629 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
631 fontStyleMapSet.Clear();
632 fontStyleMapSet.Insert( "slant", "roman" );
633 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
634 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
636 // Replace 'roman' for 'normal'.
637 slantValue = fontStyleMapGet.Find( "slant" );
638 if( NULL != slantValue )
640 if( "normal" == slantValue->Get<std::string>() )
642 fontStyleMapGet["slant"] = "roman";
645 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
646 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
648 fontStyleMapSet.Clear();
650 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
651 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
652 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
653 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
655 // Check that the MAX_LENGTH property can be correctly set
656 const int maxNumberOfCharacters = 20;
657 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
658 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
660 // Check exceed policy
661 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
662 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
663 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
664 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
666 // Check that the Alignment properties can be correctly set
667 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
668 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
669 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
670 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
672 // Check text's color property
673 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
674 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
676 // Check placeholder text's color property.
677 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
678 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
680 // Check shadow properties.
681 field.SetProperty( TextField::Property::SHADOW_OFFSET, Vector2( 1.f, 1.f ) );
682 DALI_TEST_EQUALS( field.GetProperty<Vector2>( TextField::Property::SHADOW_OFFSET ), Vector2( 1.f, 1.f ), TEST_LOCATION );
683 field.SetProperty( TextField::Property::SHADOW_COLOR, Color::GREEN );
684 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SHADOW_COLOR ), Color::GREEN, TEST_LOCATION );
686 // Check cursor properties
687 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
688 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
689 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
690 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
692 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
693 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
694 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
695 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
696 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
697 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
698 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
699 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
701 // Check scroll properties.
702 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
703 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
704 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
705 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
707 // Check handle images
708 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
709 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
710 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
711 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
712 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
714 // Check handle images
715 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
716 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
717 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
718 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
719 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
720 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
722 // Check the highlight color
723 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
724 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
726 // Decoration bounding box
727 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
728 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
730 // Check the input method setting
731 Property::Map propertyMap;
732 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
733 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
734 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
735 int inputVariation = 1;
736 propertyMap["PANEL_LAYOUT"] = panelLayout;
737 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
738 propertyMap["BUTTON_ACTION"] = buttonAction;
739 propertyMap["VARIATION"] = inputVariation;
740 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
742 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
744 DALI_TEST_CHECK( value.Get( map ) );
747 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
748 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
751 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
752 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
755 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
756 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
759 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
760 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
762 // Check input color property.
763 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
764 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
766 // Check the enable markup property.
767 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
768 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
769 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
771 // Check input font properties.
772 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
773 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
775 fontStyleMapSet.Clear();
776 fontStyleMapSet.Insert( "weight", "bold" );
777 fontStyleMapSet.Insert( "width", "condensed" );
778 fontStyleMapSet.Insert( "slant", "italic" );
780 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
781 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
782 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
783 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
785 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
786 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
788 // Reset input font style.
789 fontStyleMapSet.Clear();
790 fontStyleMapSet.Insert( "weight", "normal" );
791 fontStyleMapSet.Insert( "slant", "oblique" );
793 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
794 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
795 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
796 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
798 fontStyleMapSet.Clear();
799 fontStyleMapSet.Insert( "slant", "roman" );
801 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
802 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
804 // Replace 'roman' for 'normal'.
805 slantValue = fontStyleMapGet.Find( "slant" );
806 if( NULL != slantValue )
808 if( "normal" == slantValue->Get<std::string>() )
810 fontStyleMapGet["slant"] = "roman";
813 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
814 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
816 fontStyleMapSet.Clear();
818 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
819 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
820 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
821 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
823 Property::Map underlineMapSet;
824 Property::Map underlineMapGet;
826 underlineMapSet.Insert( "enable", "true" );
827 underlineMapSet.Insert( "color", "red" );
828 underlineMapSet.Insert( "height", "1" );
830 // Check the underline property
831 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
833 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
834 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
835 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
837 // Check the input underline property
838 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
839 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
841 // Check the shadow property
842 Property::Map shadowMapSet;
843 Property::Map shadowMapGet;
845 shadowMapSet.Insert( "color", Color::GREEN );
846 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
847 shadowMapSet.Insert( "blurRadius", 3.0f );
849 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
851 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
852 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
853 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
855 // Check the input shadow property
856 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
857 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
859 // Check the emboss property
860 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
861 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
863 // Check the input emboss property
864 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
865 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
867 // Check the outline property
869 // Test string type first
870 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
871 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
872 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
874 // Then test the property map type
875 Property::Map outlineMapSet;
876 Property::Map outlineMapGet;
878 outlineMapSet["color"] = Color::RED;
879 outlineMapSet["width"] = 2.0f;
881 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
883 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
884 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
885 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
887 // Check the input outline property
888 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
889 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
891 // Check the hidden input settings property
892 Property::Map hiddenMapSet;
893 Property::Map hiddenMapGet;
894 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
895 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
896 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
897 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
898 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
900 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
901 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
902 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
904 // Check the pixel size of font
905 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
906 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
908 // Check the enable selection property
909 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
910 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
912 // Check the placeholder property with pixel size
913 Property::Map placeholderPixelSizeMapSet;
914 Property::Map placeholderPixelSizeMapGet;
915 Property::Map placeholderFontstyleMap;
916 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
917 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
918 placeholderPixelSizeMapSet["color"] = Color::BLUE;
919 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
920 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
921 placeholderPixelSizeMapSet["ellipsis"] = true;
923 placeholderFontstyleMap.Insert( "weight", "bold" );
924 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
925 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
927 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
928 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
930 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
931 Property::Map placeholderConversionMap;
932 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
933 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
934 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
935 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
936 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
937 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
939 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
941 // Check the placeholder property with point size
942 Property::Map placeholderMapSet;
943 Property::Map placeholderMapGet;
944 placeholderMapSet["text"] = "Setting Placeholder Text";
945 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
946 placeholderMapSet["color"] = Color::RED;
947 placeholderMapSet["fontFamily"] = "Arial";
948 placeholderMapSet["pointSize"] = 12.0f;
949 placeholderMapSet["ellipsis"] = false;
951 // Check the placeholder font style property
952 placeholderFontstyleMap.Clear();
954 placeholderFontstyleMap.Insert( "weight", "bold" );
955 placeholderFontstyleMap.Insert( "width", "condensed" );
956 placeholderFontstyleMap.Insert( "slant", "italic" );
957 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
958 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
960 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
961 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
963 placeholderConversionMap.Clear();
964 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
965 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
966 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
967 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
968 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
969 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
971 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
974 placeholderFontstyleMap.Clear();
975 placeholderFontstyleMap.Insert( "weight", "normal" );
976 placeholderFontstyleMap.Insert( "slant", "oblique" );
977 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
978 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
980 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
981 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
983 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
984 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
986 placeholderFontstyleMap.Clear();
987 placeholderFontstyleMap.Insert( "slant", "roman" );
988 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
989 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
991 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
993 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
995 placeholderFontstyleMap.Clear();
996 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
997 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
999 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1000 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1001 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1003 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1005 // Check the ellipsis property
1006 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1007 field.SetProperty( TextField::Property::ELLIPSIS, true );
1008 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1010 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
1011 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1013 application.SendNotification();
1014 application.Render();
1019 // Positive Atlas Text Renderer test
1020 int utcDaliTextFieldAtlasRenderP(void)
1022 ToolkitTestApplication application;
1023 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1024 StyleManager styleManager = StyleManager::Get();
1025 styleManager.ApplyDefaultTheme();
1026 TextField field = TextField::New();
1027 DALI_TEST_CHECK( field );
1029 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1031 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1033 Stage::GetCurrent().Add( field );
1037 // Render some text with the shared atlas backend
1038 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
1039 application.SendNotification();
1040 application.Render();
1044 tet_result(TET_FAIL);
1049 // Positive test for the textChanged signal.
1050 int utcDaliTextFieldTextChangedP(void)
1052 ToolkitTestApplication application;
1053 tet_infoline(" utcDaliTextFieldTextChangedP");
1054 TextField field = TextField::New();
1055 DALI_TEST_CHECK( field );
1057 Stage::GetCurrent().Add( field );
1059 // connect to the text changed signal.
1060 ConnectionTracker* testTracker = new ConnectionTracker();
1061 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1062 bool textChangedSignal = false;
1063 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1065 gTextChangedCallBackCalled = false;
1066 field.SetProperty( TextField::Property::TEXT, "ABC" );
1067 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1068 DALI_TEST_CHECK( textChangedSignal );
1070 application.SendNotification();
1072 field.SetKeyInputFocus();
1074 gTextChangedCallBackCalled = false;
1075 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1076 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1081 // Negative test for the textChanged signal.
1082 int utcDaliTextFieldTextChangedN(void)
1084 ToolkitTestApplication application;
1085 tet_infoline(" utcDaliTextFieldTextChangedN");
1086 TextField field = TextField::New();
1087 DALI_TEST_CHECK( field );
1089 Stage::GetCurrent().Add( field );
1091 // connect to the text changed signal.
1092 ConnectionTracker* testTracker = new ConnectionTracker();
1093 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1094 bool textChangedSignal = false;
1095 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1097 gTextChangedCallBackCalled = false;
1098 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1099 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1100 DALI_TEST_CHECK( !textChangedSignal );
1105 // Positive test for Max Characters reached signal.
1106 int utcDaliTextFieldMaxCharactersReachedP(void)
1108 ToolkitTestApplication application;
1109 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1110 TextField field = TextField::New();
1111 DALI_TEST_CHECK( field );
1113 Stage::GetCurrent().Add( field );
1115 const int maxNumberOfCharacters = 1;
1116 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1118 field.SetKeyInputFocus();
1120 // connect to the text changed signal.
1121 ConnectionTracker* testTracker = new ConnectionTracker();
1122 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1123 bool maxLengthReachedSignal = false;
1124 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1126 gMaxCharactersCallBackCalled = false;
1128 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1129 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1131 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1132 DALI_TEST_CHECK( maxLengthReachedSignal );
1137 // Negative test for Max Characters reached signal.
1138 int utcDaliTextFieldMaxCharactersReachedN(void)
1140 ToolkitTestApplication application;
1141 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1142 TextField field = TextField::New();
1143 DALI_TEST_CHECK( field );
1145 Stage::GetCurrent().Add( field );
1147 const int maxNumberOfCharacters = 3;
1148 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1150 field.SetKeyInputFocus();
1152 // connect to the text changed signal.
1153 ConnectionTracker* testTracker = new ConnectionTracker();
1154 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1155 bool maxLengthReachedSignal = false;
1156 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1158 gMaxCharactersCallBackCalled = false;
1160 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1161 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1163 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1164 DALI_TEST_CHECK( !maxLengthReachedSignal );
1166 application.ProcessEvent( GenerateKey( "Return", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::Down, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1168 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1169 DALI_TEST_CHECK( !maxLengthReachedSignal );
1174 int utcDaliTextFieldInputStyleChanged01(void)
1176 ToolkitTestApplication application;
1177 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1179 // The text-field emits signals when the input style changes. These changes of style are
1180 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1181 // can't be emitted during the size negotiation as the callbacks may update the UI.
1182 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1183 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1184 application.CreateAdaptor();
1188 char* pathNamePtr = get_current_dir_name();
1189 const std::string pathName( pathNamePtr );
1190 free( pathNamePtr );
1192 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1193 fontClient.SetDpi( 93u, 93u );
1195 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1196 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1198 TextField field = TextField::New();
1199 DALI_TEST_CHECK( field );
1202 field.SetSize( 300.f, 50.f );
1203 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1204 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1206 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1207 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1209 // connect to the text changed signal.
1210 ConnectionTracker* testTracker = new ConnectionTracker();
1211 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1212 bool inputStyleChangedSignal = false;
1213 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1215 Stage::GetCurrent().Add( field );
1217 // Render and notify
1218 application.SendNotification();
1219 application.Render();
1221 // Executes the idle callbacks added by the text control on the change of input style.
1222 application.RunIdles();
1224 gInputStyleChangedCallbackCalled = false;
1225 gInputStyleMask = TextField::InputStyle::NONE;
1226 inputStyleChangedSignal = false;
1228 // Create a tap event to touch the text field.
1229 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1230 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1232 // Render and notify
1233 application.SendNotification();
1234 application.Render();
1236 // Executes the idle callbacks added by the text control on the change of input style.
1237 application.RunIdles();
1239 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1240 if( gInputStyleChangedCallbackCalled )
1242 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1244 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1245 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1247 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1248 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1250 DALI_TEST_CHECK( inputStyleChangedSignal );
1252 gInputStyleChangedCallbackCalled = false;
1253 gInputStyleMask = TextField::InputStyle::NONE;
1254 inputStyleChangedSignal = false;
1256 // Create a tap event to touch the text field.
1257 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1258 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1260 // Render and notify
1261 application.SendNotification();
1262 application.Render();
1264 // Executes the idle callbacks added by the text control on the change of input style.
1265 application.RunIdles();
1267 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1268 DALI_TEST_CHECK( !inputStyleChangedSignal );
1270 gInputStyleChangedCallbackCalled = false;
1271 gInputStyleMask = TextField::InputStyle::NONE;
1272 inputStyleChangedSignal = false;
1274 // Create a tap event to touch the text field.
1275 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1276 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1278 // Render and notify
1279 application.SendNotification();
1280 application.Render();
1282 // Executes the idle callbacks added by the text control on the change of input style.
1283 application.RunIdles();
1285 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1286 if( gInputStyleChangedCallbackCalled )
1288 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1290 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1291 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1293 DALI_TEST_CHECK( inputStyleChangedSignal );
1295 gInputStyleChangedCallbackCalled = false;
1296 gInputStyleMask = TextField::InputStyle::NONE;
1297 inputStyleChangedSignal = false;
1299 // Create a tap event to touch the text field.
1300 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1301 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1303 // Render and notify
1304 application.SendNotification();
1305 application.Render();
1307 // Executes the idle callbacks added by the text control on the change of input style.
1308 application.RunIdles();
1310 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1311 if( gInputStyleChangedCallbackCalled )
1313 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1315 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1316 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1318 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1320 Property::Map fontStyleMapSet;
1321 fontStyleMapSet.Insert( "weight", "bold" );
1323 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1324 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1326 DALI_TEST_CHECK( inputStyleChangedSignal );
1328 gInputStyleChangedCallbackCalled = false;
1329 gInputStyleMask = TextField::InputStyle::NONE;
1330 inputStyleChangedSignal = false;
1332 // Create a tap event to touch the text field.
1333 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1334 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1336 // Render and notify
1337 application.SendNotification();
1338 application.Render();
1340 // Executes the idle callbacks added by the text control on the change of input style.
1341 application.RunIdles();
1343 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1344 DALI_TEST_CHECK( !inputStyleChangedSignal );
1346 gInputStyleChangedCallbackCalled = false;
1347 gInputStyleMask = TextField::InputStyle::NONE;
1348 inputStyleChangedSignal = false;
1350 // Create a tap event to touch the text field.
1351 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1352 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1354 // Render and notify
1355 application.SendNotification();
1356 application.Render();
1358 // Executes the idle callbacks added by the text control on the change of input style.
1359 application.RunIdles();
1361 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1362 if( gInputStyleChangedCallbackCalled )
1364 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1366 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1367 DALI_TEST_CHECK( style.empty() );
1369 DALI_TEST_CHECK( inputStyleChangedSignal );
1371 gInputStyleChangedCallbackCalled = false;
1372 gInputStyleMask = TextField::InputStyle::NONE;
1373 inputStyleChangedSignal = false;
1375 // Create a tap event to touch the text field.
1376 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1377 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1379 // Render and notify
1380 application.SendNotification();
1381 application.Render();
1383 // Executes the idle callbacks added by the text control on the change of input style.
1384 application.RunIdles();
1386 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1387 DALI_TEST_CHECK( !inputStyleChangedSignal );
1392 int utcDaliTextFieldInputStyleChanged02(void)
1394 ToolkitTestApplication application;
1395 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1397 // The text-field emits signals when the input style changes. These changes of style are
1398 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1399 // can't be emitted during the size negotiation as the callbacks may update the UI.
1400 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1401 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1402 application.CreateAdaptor();
1406 char* pathNamePtr = get_current_dir_name();
1407 const std::string pathName( pathNamePtr );
1408 free( pathNamePtr );
1410 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1411 fontClient.SetDpi( 93u, 93u );
1413 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1414 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1416 TextField field = TextField::New();
1417 DALI_TEST_CHECK( field );
1420 field.SetSize( 300.f, 50.f );
1421 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1422 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1424 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1425 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>" );
1427 // connect to the text changed signal.
1428 ConnectionTracker* testTracker = new ConnectionTracker();
1429 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1430 bool inputStyleChangedSignal = false;
1431 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1433 Stage::GetCurrent().Add( field );
1435 // Render and notify
1436 application.SendNotification();
1437 application.Render();
1439 // Executes the idle callbacks added by the text control on the change of input style.
1440 application.RunIdles();
1442 gInputStyleChangedCallbackCalled = false;
1443 gInputStyleMask = TextField::InputStyle::NONE;
1444 inputStyleChangedSignal = false;
1446 // Create a tap event to touch the text field.
1447 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1448 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1449 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1450 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1452 // Render and notify
1453 application.SendNotification();
1454 application.Render();
1456 // Executes the idle callbacks added by the text control on the change of input style.
1457 application.RunIdles();
1459 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1460 if( gInputStyleChangedCallbackCalled )
1462 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1463 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1464 TextField::InputStyle::POINT_SIZE |
1465 TextField::InputStyle::COLOR ),
1468 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1469 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1471 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1472 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1474 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1475 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1477 DALI_TEST_CHECK( inputStyleChangedSignal );
1479 gInputStyleChangedCallbackCalled = false;
1480 gInputStyleMask = TextField::InputStyle::NONE;
1481 inputStyleChangedSignal = false;
1483 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1485 // Render and notify
1486 application.SendNotification();
1487 application.Render();
1489 // Executes the idle callbacks added by the text control on the change of input style.
1490 application.RunIdles();
1492 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1493 if( gInputStyleChangedCallbackCalled )
1495 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1496 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1499 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1500 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1502 DALI_TEST_CHECK( inputStyleChangedSignal );
1504 gInputStyleChangedCallbackCalled = false;
1505 gInputStyleMask = TextField::InputStyle::NONE;
1506 inputStyleChangedSignal = false;
1508 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1510 // Render and notify
1511 application.SendNotification();
1512 application.Render();
1514 // Executes the idle callbacks added by the text control on the change of input style.
1515 application.RunIdles();
1517 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1518 DALI_TEST_CHECK( !inputStyleChangedSignal );
1520 gInputStyleChangedCallbackCalled = false;
1521 gInputStyleMask = TextField::InputStyle::NONE;
1522 inputStyleChangedSignal = false;
1524 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1526 // Render and notify
1527 application.SendNotification();
1528 application.Render();
1530 // Executes the idle callbacks added by the text control on the change of input style.
1531 application.RunIdles();
1533 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1534 if( gInputStyleChangedCallbackCalled )
1536 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1537 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1540 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1541 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1543 DALI_TEST_CHECK( inputStyleChangedSignal );
1545 gInputStyleChangedCallbackCalled = false;
1546 gInputStyleMask = TextField::InputStyle::NONE;
1547 inputStyleChangedSignal = false;
1549 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1551 Property::Map fontStyleMapSet;
1552 fontStyleMapSet.Insert( "weight", "thin" );
1553 fontStyleMapSet.Insert( "width", "condensed" );
1554 fontStyleMapSet.Insert( "slant", "italic" );
1556 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1557 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1559 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1560 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1561 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1562 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1564 // Render and notify
1565 application.SendNotification();
1566 application.Render();
1568 // Executes the idle callbacks added by the text control on the change of input style.
1569 application.RunIdles();
1571 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1572 DALI_TEST_CHECK( !inputStyleChangedSignal );
1574 // Create a tap event to touch the text field.
1575 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1576 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1578 // Render and notify
1579 application.SendNotification();
1580 application.Render();
1582 // Executes the idle callbacks added by the text control on the change of input style.
1583 application.RunIdles();
1585 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1586 if( gInputStyleChangedCallbackCalled )
1588 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1589 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1590 TextField::InputStyle::POINT_SIZE |
1591 TextField::InputStyle::FONT_STYLE |
1592 TextField::InputStyle::UNDERLINE |
1593 TextField::InputStyle::SHADOW |
1594 TextField::InputStyle::EMBOSS |
1595 TextField::InputStyle::OUTLINE ),
1598 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1599 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1601 DALI_TEST_CHECK( inputStyleChangedSignal );
1606 int utcDaliTextFieldEvent01(void)
1608 ToolkitTestApplication application;
1609 tet_infoline(" utcDaliTextFieldEvent01");
1611 // Creates a tap event. After creating a tap event the text field should
1612 // have the focus and add text with key events should be possible.
1614 TextField field = TextField::New();
1615 DALI_TEST_CHECK( field );
1617 Stage::GetCurrent().Add( field );
1619 field.SetSize( 300.f, 50.f );
1620 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1621 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1623 // Avoid a crash when core load gl resources.
1624 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1626 // Render and notify
1627 application.SendNotification();
1628 application.Render();
1630 // Add a key event but as the text field has not the focus it should do nothing.
1631 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1633 // Render and notify
1634 application.SendNotification();
1635 application.Render();
1637 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1639 // Create a tap event to touch the text field.
1640 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1641 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1643 // Render and notify
1644 application.SendNotification();
1645 application.Render();
1647 // Pressing delete key should be fine even if there is no text in TextField.
1648 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 ) );
1649 // Render and notify
1650 application.SendNotification();
1651 application.Render();
1653 // Now the text field has the focus, so it can handle the key events.
1654 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1655 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1657 // Render and notify
1658 application.SendNotification();
1659 application.Render();
1661 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1663 // Create a second text field and send key events to it.
1664 TextField field2 = TextField::New();
1666 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1667 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1668 field2.SetSize( 100.f, 100.f );
1669 field2.SetPosition( 100.f, 100.f );
1671 Stage::GetCurrent().Add( field2 );
1673 // Render and notify
1674 application.SendNotification();
1675 application.Render();
1677 // Create a tap event on the second text field.
1678 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1679 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1681 // Render and notify
1682 application.SendNotification();
1683 application.Render();
1685 // The second text field has the focus. It should handle the key events.
1686 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1687 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1689 // Render and notify
1690 application.SendNotification();
1691 application.Render();
1693 // Check the text has been added to the second text field.
1694 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1699 int utcDaliTextFieldEvent02(void)
1701 ToolkitTestApplication application;
1702 tet_infoline(" utcDaliTextFieldEvent02");
1704 // Checks if the right number of actors are created.
1706 TextField field = TextField::New();
1707 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1708 DALI_TEST_CHECK( field );
1709 LoadMarkerImages(application, field);
1711 Stage::GetCurrent().Add( field );
1713 field.SetSize( 300.f, 50.f );
1714 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1715 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1717 // Avoid a crash when core load gl resources.
1718 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1720 // Render and notify
1721 application.SendNotification();
1722 application.Render();
1724 // Check there are the expected number of children ( stencil ).
1725 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1727 Actor stencil = field.GetChildAt( 0u );
1728 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1730 // Create a tap event to touch the text field.
1731 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1732 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1734 // Render and notify
1735 application.SendNotification();
1736 application.Render();
1738 Actor layer = field.GetChildAt( 1u );
1739 DALI_TEST_CHECK( layer.IsLayer() );
1741 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1742 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1744 // Now the text field has the focus, so it can handle the key events.
1745 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1746 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1748 // Render and notify
1749 application.SendNotification();
1750 application.Render();
1752 // Checks the cursor and the renderer have been created.
1753 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1754 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1756 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1757 DALI_TEST_CHECK( cursor );
1759 // The offscreen root actor has a container with all the actors which contain the text renderers.
1760 Actor container = stencil.GetChildAt( 0u );
1761 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1763 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1764 DALI_TEST_CHECK( renderer );
1767 // Move the cursor and check the position changes.
1768 Vector3 position1 = cursor.GetCurrentPosition();
1770 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1771 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1773 // Render and notify
1774 application.SendNotification();
1775 application.Render();
1777 Vector3 position2 = cursor.GetCurrentPosition();
1779 DALI_TEST_CHECK( position2.x < position1.x );
1781 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1782 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1784 // Render and notify
1785 application.SendNotification();
1786 application.Render();
1788 Vector3 position3 = cursor.GetCurrentPosition();
1790 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1792 // Send some taps and check the cursor positions.
1794 // Try to tap at the beginning.
1795 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1796 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1798 // Render and notify
1799 application.SendNotification();
1800 application.Render();
1802 // Cursor position should be the same than position1.
1803 Vector3 position4 = cursor.GetCurrentPosition();
1805 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1807 // Tap away from the start position.
1808 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1809 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1811 // Render and notify
1812 application.SendNotification();
1813 application.Render();
1815 Vector3 position5 = cursor.GetCurrentPosition();
1817 DALI_TEST_CHECK( position5.x > position4.x );
1819 // Remove all the text.
1820 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1821 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1822 field.SetProperty( TextField::Property::TEXT, "" );
1824 // Render and notify
1825 application.SendNotification();
1826 application.Render();
1828 // Cursor position should be the same than position2.
1829 Vector3 position6 = cursor.GetCurrentPosition();
1831 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1833 // Should not be a renderer.
1834 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1836 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1837 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1838 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1840 application.SendNotification();
1841 application.Render();
1843 // There are renderer and decorator layer
1844 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1849 int utcDaliTextFieldEvent03(void)
1851 ToolkitTestApplication application;
1852 tet_infoline(" utcDaliTextFieldEvent03");
1854 // Checks if the highlight actor is created.
1856 TextField field = TextField::New();
1857 DALI_TEST_CHECK( field );
1859 Stage::GetCurrent().Add( field );
1861 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1862 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1863 field.SetSize( 30.f, 50.f );
1864 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1865 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1867 // Avoid a crash when core load gl resources.
1868 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1869 LoadMarkerImages(application, field);
1871 // Render and notify
1872 application.SendNotification();
1873 application.Render();
1875 // Tap first to get the focus.
1876 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1877 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1879 // Render and notify
1880 application.SendNotification();
1881 application.Render();
1883 // Double tap to select a word.
1884 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1885 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1887 // Render and notify
1888 application.SendNotification();
1889 application.Render();
1891 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1892 Actor stencil = field.GetChildAt( 0u );
1894 // The highlight actor is drawn first, so is the first actor in the list
1895 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1896 DALI_TEST_CHECK( highlight );
1898 // The offscreen root actor has a container with all the actors which contain the text renderers.
1899 Actor container = stencil.GetChildAt( 1u );
1900 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1902 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1903 DALI_TEST_CHECK( renderer );
1909 int utcDaliTextFieldEvent04(void)
1911 ToolkitTestApplication application;
1912 tet_infoline(" utcDaliTextFieldEvent04");
1914 // Checks if the highlight actor is created.
1916 TextField field = TextField::New();
1917 DALI_TEST_CHECK( field );
1918 Stage::GetCurrent().Add( field );
1919 LoadMarkerImages(application, field);
1920 // Render and notify
1921 application.SendNotification();
1922 application.Render();
1924 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1925 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1926 field.SetSize( 300.f, 50.f );
1927 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1928 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1930 // Avoid a crash when core load gl resources.
1931 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1932 // Render and notify
1933 application.SendNotification();
1934 application.Render();
1936 // Create a tap event to touch the text field.
1937 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1938 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1939 // Render and notify
1940 application.SendNotification();
1941 application.Render();
1944 // Tap first to get the focus.
1945 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1946 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1948 // Render and notify
1949 application.SendNotification();
1950 application.Render();
1952 // Double tap to select a word.
1953 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1954 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1956 // Render and notify
1957 application.SendNotification();
1958 application.Render();
1961 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1962 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1966 int utcDaliTextFieldEvent05(void)
1968 ToolkitTestApplication application;
1969 tet_infoline(" utcDaliTextFieldEvent05");
1971 // Checks dragging of cursor/grab handle
1973 TextField field = TextField::New();
1974 DALI_TEST_CHECK( field );
1975 Stage::GetCurrent().Add( field );
1976 LoadMarkerImages(application, field);
1977 // Render and notify
1978 application.SendNotification();
1979 application.Render();
1981 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1982 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1983 field.SetSize( 300.f, 50.f );
1984 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1985 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1987 // Avoid a crash when core load gl resources.
1988 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1989 // Render and notify
1990 application.SendNotification();
1991 application.Render();
1993 // Create a tap event to touch the text field.
1994 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1995 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1996 // Render and notify
1997 application.SendNotification();
1998 application.Render();
2000 // Tap first to get the focus.
2001 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2002 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2004 // Render and notify
2005 application.SendNotification();
2006 application.Render();
2008 // Double tap to select a word.
2009 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2010 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2012 // Render and notify
2013 application.SendNotification();
2014 application.Render();
2016 // drag grab handle right
2017 Vector2 pos(0.0f, 40.0f);
2018 SendPan(application, Gesture::Possible, pos);
2019 SendPan(application, Gesture::Started, pos);
2021 Wait(application, 100);
2023 for(int i = 0;i<20;i++)
2025 SendPan(application, Gesture::Continuing, pos);
2030 SendPan(application, Gesture::Finished, pos);
2031 Wait(application, RENDER_FRAME_INTERVAL);
2033 Actor stencil = field.GetChildAt( 1u );
2037 int utcDaliTextFieldEvent06(void)
2039 ToolkitTestApplication application;
2040 tet_infoline(" utcDaliTextFieldEvent06");
2042 // Checks Longpress when in edit mode
2044 TextField field = TextField::New();
2045 DALI_TEST_CHECK( field );
2046 Stage::GetCurrent().Add( field );
2047 LoadMarkerImages(application, field);
2048 // Render and notify
2049 application.SendNotification();
2050 application.Render();
2052 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2053 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2054 field.SetSize( 300.f, 50.f );
2055 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2056 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2058 // Avoid a crash when core load gl resources.
2059 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2060 // Render and notify
2061 application.SendNotification();
2062 application.Render();
2064 // Create a tap event to touch the text field.
2065 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2066 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2067 // Render and notify
2068 application.SendNotification();
2069 application.Render();
2072 // Tap first to get the focus.
2073 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2074 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2076 // Render and notify
2077 application.SendNotification();
2078 application.Render();
2081 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2082 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2084 // Render and notify
2085 application.SendNotification();
2086 application.Render();
2091 int utcDaliTextFieldEvent07(void)
2093 ToolkitTestApplication application;
2094 tet_infoline(" utcDaliTextFieldEvent07");
2096 // Checks Longpress to start edit mode
2098 TextField field = TextField::New();
2099 DALI_TEST_CHECK( field );
2100 Stage::GetCurrent().Add( field );
2101 LoadMarkerImages(application, field);
2102 // Render and notify
2103 application.SendNotification();
2104 application.Render();
2106 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2107 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2108 field.SetSize( 300.f, 50.f );
2109 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2110 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2111 Property::Map propertyMap;
2112 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2113 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2115 // Avoid a crash when core load gl resources.
2116 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2117 // Render and notify
2118 application.SendNotification();
2119 application.Render();
2122 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2123 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2125 // Render and notify
2126 application.SendNotification();
2127 application.Render();
2132 int utcDaliTextFieldEvent08(void)
2134 ToolkitTestApplication application;
2135 tet_infoline(" utcDaliTextFieldEvent08");
2137 Dali::Clipboard clipboard = Clipboard::Get();
2138 clipboard.SetItem("testTextFieldEvent");
2140 // Checks Longpress when only place holder text
2142 TextField field = TextField::New();
2143 DALI_TEST_CHECK( field );
2144 Stage::GetCurrent().Add( field );
2145 LoadMarkerImages(application, field);
2146 // Render and notify
2147 application.SendNotification();
2148 application.Render();
2150 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2151 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2152 field.SetSize( 300.f, 50.f );
2153 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2154 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2156 // Avoid a crash when core load gl resources.
2157 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2158 // Render and notify
2159 application.SendNotification();
2160 application.Render();
2163 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2164 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2166 // Render and notify
2167 application.SendNotification();
2168 application.Render();
2170 Wait(application, 500);
2173 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2174 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2176 // Render and notify
2177 application.SendNotification();
2178 application.Render();
2180 Wait(application, 500);
2182 Stage stage = Stage::GetCurrent();
2183 Layer layer = stage.GetRootLayer();
2184 Actor actor = layer.FindChildByName("optionPaste");
2188 Vector3 worldPosition = actor.GetCurrentWorldPosition();
2189 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2190 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2192 Dali::Integration::TouchEvent event;
2193 event = Dali::Integration::TouchEvent();
2194 event.AddPoint( GetPointDownInside( position ) );
2195 application.ProcessEvent( event );
2197 event = Dali::Integration::TouchEvent();
2198 event.AddPoint( GetPointUpInside( position ) );
2199 application.ProcessEvent( event );
2201 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2206 int utcDaliTextFieldEvent09(void)
2208 ToolkitTestApplication application;
2209 tet_infoline(" utcDaliTextFieldEvent09");
2211 TextField field = TextField::New();
2212 DALI_TEST_CHECK( field );
2213 Stage::GetCurrent().Add( field );
2214 LoadMarkerImages(application, field);
2215 // Render and notify
2216 application.SendNotification();
2217 application.Render();
2219 field.SetProperty( TextField::Property::TEXT, "Hello" );
2220 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2221 field.SetSize( 300.f, 50.f );
2222 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2223 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2225 // Avoid a crash when core load gl resources.
2226 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2228 // Create a tap event to touch the text field.
2229 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2230 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2231 application.SendNotification();
2232 application.Render();
2235 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2236 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2237 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2238 application.SendNotification();
2239 application.Render();
2241 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2242 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2243 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2244 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2245 application.SendNotification();
2246 application.Render();
2248 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2249 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2250 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2251 for( unsigned int index = 0u; index < 5u; ++index )
2253 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2254 application.SendNotification();
2255 application.Render();
2258 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2259 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2260 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2261 for( unsigned int index = 0u; index < 5u; ++index )
2263 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2264 application.SendNotification();
2265 application.Render();
2268 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2269 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2270 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2271 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2272 application.SendNotification();
2273 application.Render();
2274 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2275 application.SendNotification();
2276 application.Render();
2278 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2279 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2280 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2281 application.SendNotification();
2282 application.Render();
2284 Property::Map mapGet;
2285 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2286 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2287 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2292 int utcDaliTextFieldStyleWhilstSelected(void)
2294 ToolkitTestApplication application;
2295 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2297 // Change font and styles whilst text is selected whilst word selected
2299 TextField field = TextField::New();
2300 DALI_TEST_CHECK( field );
2301 Stage::GetCurrent().Add( field );
2302 LoadMarkerImages(application, field);
2303 // Render and notify
2304 application.SendNotification();
2305 application.Render();
2307 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2308 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2309 field.SetSize( 300.f, 50.f );
2310 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2311 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2313 // Avoid a crash when core load gl resources.
2314 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2315 // Render and notify
2316 application.SendNotification();
2317 application.Render();
2319 // Create a tap event to touch the text field.
2320 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2321 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2322 // Render and notify
2323 application.SendNotification();
2324 application.Render();
2327 // Tap first to get the focus.
2328 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2329 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2331 // Render and notify
2332 application.SendNotification();
2333 application.Render();
2335 // Double tap to select a word.
2336 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2337 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2339 // Render and notify
2340 application.SendNotification();
2341 application.Render();
2343 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2344 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2346 Property::Map fontStyleMapSet;
2347 Property::Map fontStyleMapGet;
2349 fontStyleMapSet.Insert( "weight", "bold" );
2350 fontStyleMapSet.Insert( "slant", "italic" );
2351 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2353 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2354 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2355 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2357 fontStyleMapSet.Clear();
2358 fontStyleMapSet.Insert( "width", "expanded" );
2359 fontStyleMapSet.Insert( "slant", "italic" );
2360 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2362 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2363 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2364 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2366 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2367 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2369 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2370 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2372 fontStyleMapSet.Clear();
2373 fontStyleMapSet.Insert( "weight", "bold" );
2374 fontStyleMapSet.Insert( "slant", "italic" );
2376 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2378 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2379 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2380 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2382 fontStyleMapSet.Clear();
2383 fontStyleMapSet.Insert( "width", "expanded" );
2385 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2387 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2388 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2389 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2391 // Press Escape to increase coverage
2392 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2393 application.SendNotification();
2394 application.Render();
2396 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2401 int utcDaliTextFieldEscKeyLoseFocus(void)
2403 ToolkitTestApplication application;
2404 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2406 // Creates a tap event. After creating a tap event the text field should
2407 // have the focus and add text with key events should be possible.
2409 TextField field = TextField::New();
2410 DALI_TEST_CHECK( field );
2412 Stage::GetCurrent().Add( field );
2414 field.SetSize( 300.f, 50.f );
2415 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2416 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2418 // Avoid a crash when core load gl resources.
2419 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2421 // Render and notify
2422 application.SendNotification();
2423 application.Render();
2425 // Add a key event but as the text field has not the focus it should do nothing.
2426 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2427 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2429 // Render and notify
2430 application.SendNotification();
2431 application.Render();
2433 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2435 // Create a tap event to touch the text field.
2436 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2437 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2439 // Render and notify
2440 application.SendNotification();
2441 application.Render();
2443 // Now the text field has the focus, so it can handle the key events.
2444 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2445 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2446 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2447 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2449 // Render and notify
2450 application.SendNotification();
2451 application.Render();
2453 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2455 // Generate a Esc key event. The text field should lose the focus.
2456 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2457 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2459 // Render and notify
2460 application.SendNotification();
2461 application.Render();
2463 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2465 // No more text should be introduced
2466 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2467 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2469 // Render and notify
2470 application.SendNotification();
2471 application.Render();
2473 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2478 int utcDaliTextFieldSomeSpecialKeys(void)
2480 ToolkitTestApplication application;
2481 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2483 // Checks some special keys when the text is selected.
2485 TextField field = TextField::New();
2486 DALI_TEST_CHECK( field );
2487 Stage::GetCurrent().Add( field );
2488 LoadMarkerImages(application, field);
2489 // Render and notify
2490 application.SendNotification();
2491 application.Render();
2493 const std::string longText( "This is a long text for the size of the text-field." );
2495 field.SetProperty( TextField::Property::TEXT, longText );
2496 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2497 field.SetSize( 300.f, 50.f );
2498 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2499 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2501 // Avoid a crash when core load gl resources.
2502 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2503 // Render and notify
2504 application.SendNotification();
2505 application.Render();
2507 // Create a tap event to touch the text field.
2508 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2509 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2511 // Render and notify
2512 application.SendNotification();
2513 application.Render();
2515 // Tap first to get the focus.
2516 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2517 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2519 // Render and notify
2520 application.SendNotification();
2521 application.Render();
2523 // Double tap to select a word.
2524 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2525 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2527 // Render and notify
2528 application.SendNotification();
2529 application.Render();
2531 // Generate a Esc key event. The text field should lose the focus.
2532 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2533 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2535 // Render and notify
2536 application.SendNotification();
2537 application.Render();
2539 // Generate a Esc key event. The text field should lose the focus.
2540 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2541 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2543 // Render and notify
2544 application.SendNotification();
2545 application.Render();
2547 // Generate a Esc key event. The text field should lose the focus.
2548 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2549 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2551 // Render and notify
2552 application.SendNotification();
2553 application.Render();
2555 // The text shouldn't be deleted.
2556 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2561 int utcDaliTextFieldSizeUpdate(void)
2563 ToolkitTestApplication application;
2564 tet_infoline("utcDaliTextFieldSizeUpdate");
2566 // Checks some special keys when the text is selected.
2567 TextField field = TextField::New();
2568 DALI_TEST_CHECK( field );
2569 Stage::GetCurrent().Add( field );
2571 float previousHeight = 0.0f;
2572 float currentHeight = 0.0f;
2573 const float fieldWidth = 1920.0f;
2576 // "ㅁ" is bigger then "ኢ"
2577 field.SetSize( Vector2( fieldWidth ,10.0f ) );
2578 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2579 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2581 field.SetProperty( TextField::Property::TEXT, "ኢ");
2582 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2583 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2585 field.SetKeyboardFocusable(true);
2586 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2588 application.SendNotification();
2589 application.Render();
2591 previousHeight = field.GetHeightForWidth( fieldWidth );
2592 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2594 // Add another script characters ( glyph height is defferent )
2595 application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2596 application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2598 application.SendNotification();
2599 application.Render();
2601 currentHeight = field.GetHeightForWidth( fieldWidth );
2602 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2603 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2608 int utcDaliTextFieldExtremlyLargePointSize(void)
2610 ToolkitTestApplication application;
2611 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2613 TextField field = TextField::New();
2615 field.SetProperty( TextField::Property::TEXT, "Text" );
2616 field.SetSize( 300.f, 50.f );
2617 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2618 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2619 Stage::GetCurrent().Add( field );
2623 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2624 application.SendNotification();
2625 DALI_TEST_CHECK( field );
2629 tet_result(TET_FAIL);
2634 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2636 ToolkitTestApplication application;
2637 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2638 TextField field = TextField::New();
2639 DALI_TEST_CHECK( field );
2640 Stage::GetCurrent().Add( field );
2642 Property::Map fontStyleMapGet;
2644 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2646 Property::Value* weightValue = NULL;
2647 Property::Value* widthValue = NULL;
2648 Property::Value* slantValue = NULL;
2649 weightValue = fontStyleMapGet.Find( "weight" );
2650 widthValue = fontStyleMapGet.Find( "width" );
2651 slantValue = fontStyleMapGet.Find( "slant" );
2652 DALI_TEST_CHECK( !weightValue );
2653 DALI_TEST_CHECK( !widthValue );
2654 DALI_TEST_CHECK( !slantValue );
2659 int UtcDaliTextFieldSettingPlaceholder(void)
2661 ToolkitTestApplication application;
2662 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
2664 TextField field = TextField::New();
2665 DALI_TEST_CHECK( field );
2666 Stage::GetCurrent().Add( field );
2668 // Check the placeholder property with pixel size
2669 Property::Map placeholderPixelSizeMapSet;
2670 Property::Map placeholderPixelSizeMapGet;
2671 Property::Map placeholderFontstyleMap;
2672 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2673 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2674 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
2675 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2676 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
2677 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
2679 placeholderFontstyleMap.Insert( "weight", "bold" );
2680 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2681 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
2683 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2684 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
2685 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
2687 // Check the placeholder property with point size
2688 Property::Map placeholderMapSet;
2689 Property::Map placeholderMapGet;
2690 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2691 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2692 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
2693 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2694 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
2695 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
2697 // Check the placeholder font style property
2698 placeholderFontstyleMap.Clear();
2700 placeholderFontstyleMap.Insert( "weight", "bold" );
2701 placeholderFontstyleMap.Insert( "width", "condensed" );
2702 placeholderFontstyleMap.Insert( "slant", "italic" );
2703 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2704 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2706 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2707 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2708 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2710 // Reset font style.
2711 placeholderFontstyleMap.Clear();
2712 placeholderFontstyleMap.Insert( "weight", "normal" );
2713 placeholderFontstyleMap.Insert( "slant", "oblique" );
2714 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2715 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2717 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2718 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2719 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2721 placeholderFontstyleMap.Clear();
2722 placeholderFontstyleMap.Insert( "slant", "roman" );
2723 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2724 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2726 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2728 placeholderFontstyleMap.Clear();
2729 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2731 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2732 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2733 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2734 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2739 int UtcDaliTextFieldSetPaddingProperty(void)
2741 ToolkitTestApplication application;
2742 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
2744 TextField field = TextField::New();
2745 DALI_TEST_CHECK( field );
2746 field.SetSize( 300.f, 50.f );
2747 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2748 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2749 Stage::GetCurrent().Add( field );
2751 application.SendNotification();
2752 application.Render();
2754 Vector3 originalSize = field.GetNaturalSize();
2756 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2758 application.SendNotification();
2759 application.Render();
2761 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2763 Vector3 paddingAddedSize = field.GetNaturalSize();
2765 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2767 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2772 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
2774 ToolkitTestApplication application;
2775 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
2777 TextField field = TextField::New();
2778 DALI_TEST_CHECK( field );
2779 field.SetSize( 300.f, 50.f );
2780 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2781 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2782 Stage::GetCurrent().Add( field );
2784 application.SendNotification();
2785 application.Render();
2787 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2788 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2790 // Check the enable shift selection property
2791 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
2792 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2794 application.SendNotification();
2795 application.Render();
2800 int UtcDaliTextFieldEnableGrabHandleProperty(void)
2802 ToolkitTestApplication application;
2803 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
2805 TextField field = TextField::New();
2806 DALI_TEST_CHECK( field );
2807 field.SetSize( 300.f, 50.f );
2808 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2809 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2810 Stage::GetCurrent().Add( field );
2812 application.SendNotification();
2813 application.Render();
2815 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2816 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2818 // Check the enable grab handle property
2819 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
2820 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2822 application.SendNotification();
2823 application.Render();
2828 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
2830 ToolkitTestApplication application;
2831 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
2833 TextField field = TextField::New();
2834 DALI_TEST_CHECK( field );
2835 field.SetSize( 300.f, 50.f );
2836 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2837 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2838 Stage::GetCurrent().Add( field );
2840 application.SendNotification();
2841 application.Render();
2843 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2844 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2846 // Check the match system language direction property
2847 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2848 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2850 application.SendNotification();
2851 application.Render();
2856 int utcDaliTextFieldLayoutDirectionCoverage(void)
2858 ToolkitTestApplication application;
2859 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
2861 // Creates a tap event. After creating a tap event the text field should
2862 // have the focus and add text with key events should be possible.
2863 TextField field = TextField::New();
2864 DALI_TEST_CHECK( field );
2866 Stage::GetCurrent().Add( field );
2868 field.SetSize( 300.f, 50.f );
2869 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2870 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2872 // Avoid a crash when core load gl resources.
2873 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2875 // Render and notify
2876 application.SendNotification();
2877 application.Render();
2879 // init direction for coverage
2880 // Set horizontal alignment END
2881 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2883 // Create a tap event to touch the text field.
2884 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2885 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2887 // Render and notify
2888 application.SendNotification();
2889 application.Render();
2891 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
2892 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2893 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
2895 // Set horizontal alignment BEGIN
2896 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
2898 // Create a tap event to touch the text field.
2899 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2900 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2902 // Render and notify
2903 application.SendNotification();
2904 application.Render();
2906 // Set horizontal alignment CENTER
2907 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
2909 // Create a tap event to touch the text field.
2910 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2911 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2913 // Render and notify
2914 application.SendNotification();
2915 application.Render();
2917 // Set horizontal alignment END
2918 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2920 // Create a tap event to touch the text field.
2921 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2922 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2924 // Render and notify
2925 application.SendNotification();
2926 application.Render();
2928 // Generate a Esc key event. The text field should lose the focus.
2929 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2930 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2932 // Render and notify
2933 application.SendNotification();
2934 application.Render();
2936 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2942 int UtcDaliTextFieldGetInputMethodContext(void)
2944 ToolkitTestApplication application;
2945 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
2947 TextField field = TextField::New();
2948 DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );