2 * Copyright (c) 2019 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_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
64 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
65 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
66 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
67 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
68 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
69 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
70 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
71 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
72 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
73 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
80 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
81 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
82 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
83 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
84 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
85 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
86 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
88 const char* const PROPERTY_NAME_UNDERLINE = "underline";
89 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
90 const char* const PROPERTY_NAME_SHADOW = "shadow";
91 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
92 const char* const PROPERTY_NAME_EMBOSS = "emboss";
93 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
94 const char* const PROPERTY_NAME_OUTLINE = "outline";
95 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
97 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
98 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
99 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
100 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
101 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
102 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
103 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
104 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
105 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
107 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
108 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
110 const float RENDER_FRAME_INTERVAL = 16.66f;
112 const unsigned int DEFAULT_FONT_SIZE = 1152u;
113 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
115 const int KEY_RETURN_CODE = 36;
116 const int KEY_A_CODE = 38;
117 const int KEY_D_CODE = 40;
119 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
121 static bool gTextChangedCallBackCalled;
122 static bool gMaxCharactersCallBackCalled;
123 static bool gInputStyleChangedCallbackCalled;
124 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
126 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
128 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
129 Integration::ResourcePointer resource(bitmap);
130 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
133 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
137 LoadBitmapResource( app.GetPlatform(), width, height );
139 Property::Map propertyMap;
140 propertyMap["filename"] = "image.png";
141 propertyMap["width"] = width;
142 propertyMap["height"] = height;
143 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
144 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
145 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
146 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
147 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
148 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
149 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
150 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
153 // Generate a PanGestureEvent to send to Core
154 static Integration::PanGestureEvent GeneratePan(
155 Gesture::State state,
156 const Vector2& previousPosition,
157 const Vector2& currentPosition,
158 unsigned long timeDelta,
159 unsigned int numberOfTouches = 1)
161 Integration::PanGestureEvent pan(state);
163 pan.previousPosition = previousPosition;
164 pan.currentPosition = currentPosition;
165 pan.timeDelta = timeDelta;
166 pan.numberOfTouches = numberOfTouches;
172 * Helper to generate PanGestureEvent
174 * @param[in] application Application instance
175 * @param[in] state The Gesture State
176 * @param[in] pos The current position of touch.
178 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
182 if( (state == Gesture::Started) ||
183 (state == Gesture::Possible) )
189 application.ProcessEvent(GeneratePan(state, last, pos, 16));
196 * Simulate time passed by.
198 * @note this will always process at least 1 frame (1/60 sec)
200 * @param application Test application instance
201 * @param duration Time to pass in milliseconds.
202 * @return The actual time passed in milliseconds
204 static int Wait(ToolkitTestApplication& application, int duration = 0)
208 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
210 application.SendNotification();
211 application.Render(RENDER_FRAME_INTERVAL);
212 time += RENDER_FRAME_INTERVAL;
218 Dali::Integration::Point GetPointDownInside( Vector2& pos )
220 Dali::Integration::Point point;
221 point.SetState( PointState::DOWN );
222 point.SetScreenPosition( pos );
226 Dali::Integration::Point GetPointUpInside( Vector2& pos )
228 Dali::Integration::Point point;
229 point.SetState( PointState::UP );
230 point.SetScreenPosition( pos );
234 struct CallbackFunctor
236 CallbackFunctor(bool* callbackFlag)
237 : mCallbackFlag( callbackFlag )
243 *mCallbackFlag = true;
248 static void TestTextChangedCallback( TextField control )
250 tet_infoline(" TestTextChangedCallback");
252 gTextChangedCallBackCalled = true;
255 static void TestMaxLengthReachedCallback( TextField control )
257 tet_infoline(" TestMaxLengthReachedCallback");
259 gMaxCharactersCallBackCalled = true;
262 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
264 tet_infoline(" TestInputStyleChangedCallback");
266 gInputStyleChangedCallbackCalled = true;
267 gInputStyleMask = mask;
270 // Generate a TapGestureEvent to send to Core.
271 Integration::TapGestureEvent GenerateTap(
272 Gesture::State state,
273 unsigned int numberOfTaps,
274 unsigned int numberOfTouches,
277 Integration::TapGestureEvent tap( state );
279 tap.numberOfTaps = numberOfTaps;
280 tap.numberOfTouches = numberOfTouches;
286 Integration::LongPressGestureEvent GenerateLongPress(
287 Gesture::State state,
288 unsigned int numberOfTouches,
291 Integration::LongPressGestureEvent longPress( state );
293 longPress.numberOfTouches = numberOfTouches;
294 longPress.point = point;
298 // Generate a KeyEvent to send to Core.
299 Integration::KeyEvent GenerateKey( const std::string& keyName,
300 const std::string& logicalKey,
301 const std::string& keyString,
304 unsigned long timeStamp,
305 const Integration::KeyEvent::State& keyState,
306 const std::string& compose = "",
307 const std::string& deviceName = DEFAULT_DEVICE_NAME,
308 const Device::Class::Type& deviceClass = Device::Class::NONE,
309 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
311 return Integration::KeyEvent( keyName,
324 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
326 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
328 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
330 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
332 Property::Value* valueSet = NULL;
333 if ( valueGet.first.type == Property::Key::INDEX )
335 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
339 // Get Key is a string so searching Set Map for a string key
340 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
343 if( NULL != valueSet )
345 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
347 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
350 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
352 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
355 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
357 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
360 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
362 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
365 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
367 Vector2 vector2Get = valueGet.second.Get<Vector2>();
368 Vector2 vector2Set = valueSet->Get<Vector2>();
369 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
372 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
374 Vector4 vector4Get = valueGet.second.Get<Vector4>();
375 Vector4 vector4Set = valueSet->Get<Vector4>();
376 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 );
382 if ( valueGet.first.type == Property::Key::INDEX )
384 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
388 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
400 int UtcDaliToolkitTextFieldConstructorP(void)
402 ToolkitTestApplication application;
403 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
405 DALI_TEST_CHECK( !textField );
409 int UtcDaliToolkitTextFieldNewP(void)
411 ToolkitTestApplication application;
412 tet_infoline(" UtcDaliToolkitTextFieldNewP");
413 TextField textField = TextField::New();
414 DALI_TEST_CHECK( textField );
418 int UtcDaliToolkitTextFieldDownCastP(void)
420 ToolkitTestApplication application;
421 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
422 TextField textField1 = TextField::New();
423 BaseHandle object( textField1 );
425 TextField textField2 = TextField::DownCast( object );
426 DALI_TEST_CHECK( textField2 );
428 TextField textField3 = DownCast< TextField >( object );
429 DALI_TEST_CHECK( textField3 );
433 int UtcDaliToolkitTextFieldDownCastN(void)
435 ToolkitTestApplication application;
436 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
437 BaseHandle uninitializedObject;
438 TextField textField1 = TextField::DownCast( uninitializedObject );
439 DALI_TEST_CHECK( !textField1 );
441 TextField textField2 = DownCast< TextField >( uninitializedObject );
442 DALI_TEST_CHECK( !textField2 );
446 int UtcDaliToolkitTextFieldCopyConstructorP(void)
448 ToolkitTestApplication application;
449 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
450 TextField textField = TextField::New();
451 textField.SetProperty( TextField::Property::TEXT, "Test" );
453 TextField copy( textField );
454 DALI_TEST_CHECK( copy );
455 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
459 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
461 ToolkitTestApplication application;
462 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
463 TextField textField = TextField::New();
464 textField.SetProperty( TextField::Property::TEXT, "Test" );
466 TextField copy = textField;
467 DALI_TEST_CHECK( copy );
468 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
472 int UtcDaliTextFieldNewP(void)
474 ToolkitTestApplication application;
475 tet_infoline(" UtcDaliToolkitTextFieldNewP");
476 TextField textField = TextField::New();
477 DALI_TEST_CHECK( textField );
481 // Positive test case for a method
482 int UtcDaliTextFieldGetPropertyP(void)
484 ToolkitTestApplication application;
485 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
486 TextField field = TextField::New();
487 DALI_TEST_CHECK( field );
489 // Check Property Indices are correct
490 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
491 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
492 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
493 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
494 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
495 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
496 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
497 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
498 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
499 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
500 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
501 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
502 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
503 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
504 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
505 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
506 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
507 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
508 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
509 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
510 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
511 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
512 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
513 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
514 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
515 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
516 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
517 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
518 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
519 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
520 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
521 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
522 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
523 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
524 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
525 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
526 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
527 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
528 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
529 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
530 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
531 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
532 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
533 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
534 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
535 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
536 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
537 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
538 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
539 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
540 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
541 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
542 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
543 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP );
548 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
551 Property::Map imageMap;
552 imageMap[mapKey] =mapValue;
554 field.SetProperty( property , imageMap );
555 Property::Value propValue = field.GetProperty( property );
556 Property::Map* resultMap = propValue.GetMap();
558 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
566 // Positive test case for a method
567 int UtcDaliTextFieldSetPropertyP(void)
569 ToolkitTestApplication application;
570 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
571 TextField field = TextField::New();
572 DALI_TEST_CHECK( field );
573 Stage::GetCurrent().Add( field );
575 // Note - we can't check the defaults since the stylesheets are platform-specific
577 // Check the render backend property.
578 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
579 DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
581 // Check text property.
582 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
583 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
585 // Check placeholder text properties.
586 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
587 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
589 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
590 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
592 // Check font properties.
593 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
594 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
596 Property::Map fontStyleMapSet;
597 Property::Map fontStyleMapGet;
598 Property::Value* slantValue = NULL;
600 fontStyleMapSet.Insert( "weight", "bold" );
601 fontStyleMapSet.Insert( "width", "condensed" );
602 fontStyleMapSet.Insert( "slant", "italic" );
603 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
605 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
606 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
607 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
609 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
610 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
613 fontStyleMapSet.Clear();
614 fontStyleMapSet.Insert( "weight", "normal" );
615 fontStyleMapSet.Insert( "slant", "oblique" );
616 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
618 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
619 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
620 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
622 fontStyleMapSet.Clear();
623 fontStyleMapSet.Insert( "slant", "roman" );
624 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
625 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
627 // Replace 'roman' for 'normal'.
628 slantValue = fontStyleMapGet.Find( "slant" );
629 if( NULL != slantValue )
631 if( "normal" == slantValue->Get<std::string>() )
633 fontStyleMapGet["slant"] = "roman";
636 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
637 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
639 fontStyleMapSet.Clear();
641 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
642 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
643 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
644 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
646 // Check that the MAX_LENGTH property can be correctly set
647 const int maxNumberOfCharacters = 20;
648 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
649 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
651 // Check exceed policy
652 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
653 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
654 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
655 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
657 // Check that the Alignment properties can be correctly set
658 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
659 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
660 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
661 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
663 // Check text's color property
664 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
665 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
667 // Check placeholder text's color property.
668 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
669 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
671 // Check cursor properties
672 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
673 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
674 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
675 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
677 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
678 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
679 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
680 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
681 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
682 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
683 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
684 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
686 // Check scroll properties.
687 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
688 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
689 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
690 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
692 // Check handle images
693 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
694 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
695 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
696 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
697 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
699 // Check handle images
700 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
701 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
702 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
703 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
704 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
705 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
707 // Check the highlight color
708 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
709 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
711 // Decoration bounding box
712 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
713 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
715 // Check the input method setting
716 Property::Map propertyMap;
717 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
718 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
719 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
720 int inputVariation = 1;
721 propertyMap["PANEL_LAYOUT"] = panelLayout;
722 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
723 propertyMap["BUTTON_ACTION"] = buttonAction;
724 propertyMap["VARIATION"] = inputVariation;
725 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
727 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
729 DALI_TEST_CHECK( value.Get( map ) );
732 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
733 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
736 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
737 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
740 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
741 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
744 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
745 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
747 // Check input color property.
748 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
749 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
751 // Check the enable markup property.
752 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
753 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
754 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
756 // Check input font properties.
757 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
758 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
760 fontStyleMapSet.Clear();
761 fontStyleMapSet.Insert( "weight", "bold" );
762 fontStyleMapSet.Insert( "width", "condensed" );
763 fontStyleMapSet.Insert( "slant", "italic" );
765 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
766 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
767 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
768 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
770 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
771 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
773 // Reset input font style.
774 fontStyleMapSet.Clear();
775 fontStyleMapSet.Insert( "weight", "normal" );
776 fontStyleMapSet.Insert( "slant", "oblique" );
778 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
779 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
780 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
781 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
783 fontStyleMapSet.Clear();
784 fontStyleMapSet.Insert( "slant", "roman" );
786 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
787 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
789 // Replace 'roman' for 'normal'.
790 slantValue = fontStyleMapGet.Find( "slant" );
791 if( NULL != slantValue )
793 if( "normal" == slantValue->Get<std::string>() )
795 fontStyleMapGet["slant"] = "roman";
798 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
799 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
801 fontStyleMapSet.Clear();
803 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
804 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
805 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
806 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
808 Property::Map underlineMapSet;
809 Property::Map underlineMapGet;
811 underlineMapSet.Insert( "enable", true );
812 underlineMapSet.Insert( "color", Color::RED );
813 underlineMapSet.Insert( "height", 1 );
815 // Check the underline property
816 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
818 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
819 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
820 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
822 // Check the input underline property
823 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
824 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
826 // Check the shadow property
827 Property::Map shadowMapSet;
828 Property::Map shadowMapGet;
830 shadowMapSet.Insert( "color", Color::GREEN );
831 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
832 shadowMapSet.Insert( "blurRadius", 3.0f );
834 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
836 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
837 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
838 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
840 // Check the input shadow property
841 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
842 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
844 // Check the emboss property
845 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
846 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
848 // Check the input emboss property
849 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
850 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
852 // Check the outline property
854 // Test string type first
855 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
856 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
857 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
859 // Then test the property map type
860 Property::Map outlineMapSet;
861 Property::Map outlineMapGet;
863 outlineMapSet["color"] = Color::RED;
864 outlineMapSet["width"] = 2.0f;
866 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
868 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
869 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
870 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
872 // Check the input outline property
873 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
874 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
876 // Check the hidden input settings property
877 Property::Map hiddenMapSet;
878 Property::Map hiddenMapGet;
879 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
880 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
881 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
882 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
883 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
885 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
886 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
887 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
889 // Check the pixel size of font
890 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
891 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
893 // Check the enable selection property
894 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
895 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
897 // Check the placeholder property with pixel size
898 Property::Map placeholderPixelSizeMapSet;
899 Property::Map placeholderPixelSizeMapGet;
900 Property::Map placeholderFontstyleMap;
901 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
902 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
903 placeholderPixelSizeMapSet["color"] = Color::BLUE;
904 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
905 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
906 placeholderPixelSizeMapSet["ellipsis"] = true;
908 placeholderFontstyleMap.Insert( "weight", "bold" );
909 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
910 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
912 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
913 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
915 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
916 Property::Map placeholderConversionMap;
917 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
918 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
919 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
920 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
921 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
922 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
924 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
926 // Check the placeholder property with point size
927 Property::Map placeholderMapSet;
928 Property::Map placeholderMapGet;
929 placeholderMapSet["text"] = "Setting Placeholder Text";
930 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
931 placeholderMapSet["color"] = Color::RED;
932 placeholderMapSet["fontFamily"] = "Arial";
933 placeholderMapSet["pointSize"] = 12.0f;
934 placeholderMapSet["ellipsis"] = false;
936 // Check the placeholder font style property
937 placeholderFontstyleMap.Clear();
939 placeholderFontstyleMap.Insert( "weight", "bold" );
940 placeholderFontstyleMap.Insert( "width", "condensed" );
941 placeholderFontstyleMap.Insert( "slant", "italic" );
942 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
943 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
945 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
946 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
948 placeholderConversionMap.Clear();
949 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
950 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
951 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
952 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
953 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
954 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
956 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
959 placeholderFontstyleMap.Clear();
960 placeholderFontstyleMap.Insert( "weight", "normal" );
961 placeholderFontstyleMap.Insert( "slant", "oblique" );
962 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
963 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
965 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
966 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
968 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
969 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
971 placeholderFontstyleMap.Clear();
972 placeholderFontstyleMap.Insert( "slant", "roman" );
973 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
974 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
976 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
978 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
980 placeholderFontstyleMap.Clear();
981 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
982 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
984 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
985 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
986 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
988 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
990 // Check the ellipsis property
991 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
992 field.SetProperty( TextField::Property::ELLIPSIS, true );
993 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
995 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
996 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
998 // Test the ENABLE_GRAB_HANDLE_POPUP property
999 DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1000 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false );
1001 DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1003 application.SendNotification();
1004 application.Render();
1009 // Positive Atlas Text Renderer test
1010 int utcDaliTextFieldAtlasRenderP(void)
1012 ToolkitTestApplication application;
1013 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1014 StyleManager styleManager = StyleManager::Get();
1015 styleManager.ApplyDefaultTheme();
1016 TextField field = TextField::New();
1017 DALI_TEST_CHECK( field );
1019 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1021 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1023 Stage::GetCurrent().Add( field );
1027 // Render some text with the shared atlas backend
1028 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
1029 application.SendNotification();
1030 application.Render();
1034 tet_result(TET_FAIL);
1039 // Positive test for the textChanged signal.
1040 int utcDaliTextFieldTextChangedP(void)
1042 ToolkitTestApplication application;
1043 tet_infoline(" utcDaliTextFieldTextChangedP");
1044 TextField field = TextField::New();
1045 DALI_TEST_CHECK( field );
1047 Stage::GetCurrent().Add( field );
1049 // connect to the text changed signal.
1050 ConnectionTracker* testTracker = new ConnectionTracker();
1051 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1052 bool textChangedSignal = false;
1053 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1055 gTextChangedCallBackCalled = false;
1056 field.SetProperty( TextField::Property::TEXT, "ABC" );
1057 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1058 DALI_TEST_CHECK( textChangedSignal );
1060 application.SendNotification();
1062 field.SetKeyInputFocus();
1064 gTextChangedCallBackCalled = false;
1065 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1066 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1071 // Negative test for the textChanged signal.
1072 int utcDaliTextFieldTextChangedN(void)
1074 ToolkitTestApplication application;
1075 tet_infoline(" utcDaliTextFieldTextChangedN");
1076 TextField field = TextField::New();
1077 DALI_TEST_CHECK( field );
1079 Stage::GetCurrent().Add( field );
1081 // connect to the text changed signal.
1082 ConnectionTracker* testTracker = new ConnectionTracker();
1083 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1084 bool textChangedSignal = false;
1085 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1087 gTextChangedCallBackCalled = false;
1088 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1089 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1090 DALI_TEST_CHECK( !textChangedSignal );
1095 // Positive test for Max Characters reached signal.
1096 int utcDaliTextFieldMaxCharactersReachedP(void)
1098 ToolkitTestApplication application;
1099 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1100 TextField field = TextField::New();
1101 DALI_TEST_CHECK( field );
1103 Stage::GetCurrent().Add( field );
1105 const int maxNumberOfCharacters = 1;
1106 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1108 field.SetKeyInputFocus();
1110 // connect to the text changed signal.
1111 ConnectionTracker* testTracker = new ConnectionTracker();
1112 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1113 bool maxLengthReachedSignal = false;
1114 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1116 gMaxCharactersCallBackCalled = false;
1118 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1119 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1121 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1122 DALI_TEST_CHECK( maxLengthReachedSignal );
1127 // Negative test for Max Characters reached signal.
1128 int utcDaliTextFieldMaxCharactersReachedN(void)
1130 ToolkitTestApplication application;
1131 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1132 TextField field = TextField::New();
1133 DALI_TEST_CHECK( field );
1135 Stage::GetCurrent().Add( field );
1137 const int maxNumberOfCharacters = 3;
1138 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1140 field.SetKeyInputFocus();
1142 // connect to the text changed signal.
1143 ConnectionTracker* testTracker = new ConnectionTracker();
1144 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1145 bool maxLengthReachedSignal = false;
1146 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1148 gMaxCharactersCallBackCalled = false;
1150 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1151 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1153 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1154 DALI_TEST_CHECK( !maxLengthReachedSignal );
1156 application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::Down, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1158 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1159 DALI_TEST_CHECK( !maxLengthReachedSignal );
1164 int utcDaliTextFieldInputStyleChanged01(void)
1166 ToolkitTestApplication application;
1167 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1169 // The text-field emits signals when the input style changes. These changes of style are
1170 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1171 // can't be emitted during the size negotiation as the callbacks may update the UI.
1172 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1173 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1174 application.CreateAdaptor();
1178 char* pathNamePtr = get_current_dir_name();
1179 const std::string pathName( pathNamePtr );
1180 free( pathNamePtr );
1182 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1183 fontClient.SetDpi( 93u, 93u );
1185 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1186 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1188 TextField field = TextField::New();
1189 DALI_TEST_CHECK( field );
1192 field.SetSize( 300.f, 50.f );
1193 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1194 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1196 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1197 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1199 // connect to the text changed signal.
1200 ConnectionTracker* testTracker = new ConnectionTracker();
1201 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1202 bool inputStyleChangedSignal = false;
1203 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1205 Stage::GetCurrent().Add( field );
1207 // Render and notify
1208 application.SendNotification();
1209 application.Render();
1211 // Executes the idle callbacks added by the text control on the change of input style.
1212 application.RunIdles();
1214 gInputStyleChangedCallbackCalled = false;
1215 gInputStyleMask = TextField::InputStyle::NONE;
1216 inputStyleChangedSignal = false;
1218 // Create a tap event to touch the text field.
1219 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1220 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1222 // Render and notify
1223 application.SendNotification();
1224 application.Render();
1226 // Executes the idle callbacks added by the text control on the change of input style.
1227 application.RunIdles();
1229 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1230 if( gInputStyleChangedCallbackCalled )
1232 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1234 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1235 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1237 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1238 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1240 DALI_TEST_CHECK( inputStyleChangedSignal );
1242 gInputStyleChangedCallbackCalled = false;
1243 gInputStyleMask = TextField::InputStyle::NONE;
1244 inputStyleChangedSignal = false;
1246 // Create a tap event to touch the text field.
1247 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1248 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1250 // Render and notify
1251 application.SendNotification();
1252 application.Render();
1254 // Executes the idle callbacks added by the text control on the change of input style.
1255 application.RunIdles();
1257 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1258 DALI_TEST_CHECK( !inputStyleChangedSignal );
1260 gInputStyleChangedCallbackCalled = false;
1261 gInputStyleMask = TextField::InputStyle::NONE;
1262 inputStyleChangedSignal = false;
1264 // Create a tap event to touch the text field.
1265 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1266 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1268 // Render and notify
1269 application.SendNotification();
1270 application.Render();
1272 // Executes the idle callbacks added by the text control on the change of input style.
1273 application.RunIdles();
1275 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1276 if( gInputStyleChangedCallbackCalled )
1278 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1280 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1281 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1283 DALI_TEST_CHECK( inputStyleChangedSignal );
1285 gInputStyleChangedCallbackCalled = false;
1286 gInputStyleMask = TextField::InputStyle::NONE;
1287 inputStyleChangedSignal = false;
1289 // Create a tap event to touch the text field.
1290 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1291 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1293 // Render and notify
1294 application.SendNotification();
1295 application.Render();
1297 // Executes the idle callbacks added by the text control on the change of input style.
1298 application.RunIdles();
1300 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1301 if( gInputStyleChangedCallbackCalled )
1303 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1305 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1306 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1308 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1310 Property::Map fontStyleMapSet;
1311 fontStyleMapSet.Insert( "weight", "bold" );
1313 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1314 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1316 DALI_TEST_CHECK( inputStyleChangedSignal );
1318 gInputStyleChangedCallbackCalled = false;
1319 gInputStyleMask = TextField::InputStyle::NONE;
1320 inputStyleChangedSignal = false;
1322 // Create a tap event to touch the text field.
1323 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1324 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1326 // Render and notify
1327 application.SendNotification();
1328 application.Render();
1330 // Executes the idle callbacks added by the text control on the change of input style.
1331 application.RunIdles();
1333 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1334 DALI_TEST_CHECK( !inputStyleChangedSignal );
1336 gInputStyleChangedCallbackCalled = false;
1337 gInputStyleMask = TextField::InputStyle::NONE;
1338 inputStyleChangedSignal = false;
1340 // Create a tap event to touch the text field.
1341 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1342 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1344 // Render and notify
1345 application.SendNotification();
1346 application.Render();
1348 // Executes the idle callbacks added by the text control on the change of input style.
1349 application.RunIdles();
1351 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1352 if( gInputStyleChangedCallbackCalled )
1354 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1356 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1357 DALI_TEST_CHECK( style.empty() );
1359 DALI_TEST_CHECK( inputStyleChangedSignal );
1361 gInputStyleChangedCallbackCalled = false;
1362 gInputStyleMask = TextField::InputStyle::NONE;
1363 inputStyleChangedSignal = false;
1365 // Create a tap event to touch the text field.
1366 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1367 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1369 // Render and notify
1370 application.SendNotification();
1371 application.Render();
1373 // Executes the idle callbacks added by the text control on the change of input style.
1374 application.RunIdles();
1376 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1377 DALI_TEST_CHECK( !inputStyleChangedSignal );
1382 int utcDaliTextFieldInputStyleChanged02(void)
1384 ToolkitTestApplication application;
1385 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1387 // The text-field emits signals when the input style changes. These changes of style are
1388 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1389 // can't be emitted during the size negotiation as the callbacks may update the UI.
1390 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1391 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1392 application.CreateAdaptor();
1396 char* pathNamePtr = get_current_dir_name();
1397 const std::string pathName( pathNamePtr );
1398 free( pathNamePtr );
1400 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1401 fontClient.SetDpi( 93u, 93u );
1403 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1404 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1406 TextField field = TextField::New();
1407 DALI_TEST_CHECK( field );
1410 field.SetSize( 300.f, 50.f );
1411 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1412 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1414 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1415 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>" );
1417 // connect to the text changed signal.
1418 ConnectionTracker* testTracker = new ConnectionTracker();
1419 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1420 bool inputStyleChangedSignal = false;
1421 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1423 Stage::GetCurrent().Add( field );
1425 // Render and notify
1426 application.SendNotification();
1427 application.Render();
1429 // Executes the idle callbacks added by the text control on the change of input style.
1430 application.RunIdles();
1432 gInputStyleChangedCallbackCalled = false;
1433 gInputStyleMask = TextField::InputStyle::NONE;
1434 inputStyleChangedSignal = false;
1436 // Create a tap event to touch the text field.
1437 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1438 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1439 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1440 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1442 // Render and notify
1443 application.SendNotification();
1444 application.Render();
1446 // Executes the idle callbacks added by the text control on the change of input style.
1447 application.RunIdles();
1449 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1450 if( gInputStyleChangedCallbackCalled )
1452 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1453 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1454 TextField::InputStyle::POINT_SIZE |
1455 TextField::InputStyle::COLOR ),
1458 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1459 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1461 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1462 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1464 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1465 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1467 DALI_TEST_CHECK( inputStyleChangedSignal );
1469 gInputStyleChangedCallbackCalled = false;
1470 gInputStyleMask = TextField::InputStyle::NONE;
1471 inputStyleChangedSignal = false;
1473 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1475 // Render and notify
1476 application.SendNotification();
1477 application.Render();
1479 // Executes the idle callbacks added by the text control on the change of input style.
1480 application.RunIdles();
1482 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1483 if( gInputStyleChangedCallbackCalled )
1485 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1486 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1489 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1490 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1492 DALI_TEST_CHECK( inputStyleChangedSignal );
1494 gInputStyleChangedCallbackCalled = false;
1495 gInputStyleMask = TextField::InputStyle::NONE;
1496 inputStyleChangedSignal = false;
1498 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1500 // Render and notify
1501 application.SendNotification();
1502 application.Render();
1504 // Executes the idle callbacks added by the text control on the change of input style.
1505 application.RunIdles();
1507 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1508 DALI_TEST_CHECK( !inputStyleChangedSignal );
1510 gInputStyleChangedCallbackCalled = false;
1511 gInputStyleMask = TextField::InputStyle::NONE;
1512 inputStyleChangedSignal = false;
1514 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1516 // Render and notify
1517 application.SendNotification();
1518 application.Render();
1520 // Executes the idle callbacks added by the text control on the change of input style.
1521 application.RunIdles();
1523 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1524 if( gInputStyleChangedCallbackCalled )
1526 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1527 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1530 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1531 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1533 DALI_TEST_CHECK( inputStyleChangedSignal );
1535 gInputStyleChangedCallbackCalled = false;
1536 gInputStyleMask = TextField::InputStyle::NONE;
1537 inputStyleChangedSignal = false;
1539 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1541 Property::Map fontStyleMapSet;
1542 fontStyleMapSet.Insert( "weight", "thin" );
1543 fontStyleMapSet.Insert( "width", "condensed" );
1544 fontStyleMapSet.Insert( "slant", "italic" );
1546 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1547 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1549 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1550 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1551 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1552 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1554 // Render and notify
1555 application.SendNotification();
1556 application.Render();
1558 // Executes the idle callbacks added by the text control on the change of input style.
1559 application.RunIdles();
1561 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1562 DALI_TEST_CHECK( !inputStyleChangedSignal );
1564 // Create a tap event to touch the text field.
1565 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1566 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1568 // Render and notify
1569 application.SendNotification();
1570 application.Render();
1572 // Executes the idle callbacks added by the text control on the change of input style.
1573 application.RunIdles();
1575 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1576 if( gInputStyleChangedCallbackCalled )
1578 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1579 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1580 TextField::InputStyle::POINT_SIZE |
1581 TextField::InputStyle::FONT_STYLE |
1582 TextField::InputStyle::UNDERLINE |
1583 TextField::InputStyle::SHADOW |
1584 TextField::InputStyle::EMBOSS |
1585 TextField::InputStyle::OUTLINE ),
1588 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1589 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1591 DALI_TEST_CHECK( inputStyleChangedSignal );
1596 int utcDaliTextFieldEvent01(void)
1598 ToolkitTestApplication application;
1599 tet_infoline(" utcDaliTextFieldEvent01");
1601 // Creates a tap event. After creating a tap event the text field should
1602 // have the focus and add text with key events should be possible.
1604 TextField field = TextField::New();
1605 DALI_TEST_CHECK( field );
1607 Stage::GetCurrent().Add( field );
1609 field.SetSize( 300.f, 50.f );
1610 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1611 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1613 // Avoid a crash when core load gl resources.
1614 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1616 // Render and notify
1617 application.SendNotification();
1618 application.Render();
1620 // Add a key event but as the text field has not the focus it should do nothing.
1621 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1623 // Render and notify
1624 application.SendNotification();
1625 application.Render();
1627 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1629 // Create a tap event to touch the text field.
1630 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1631 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1633 // Render and notify
1634 application.SendNotification();
1635 application.Render();
1637 // Pressing delete key should be fine even if there is no text in TextField.
1638 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 ) );
1639 // Render and notify
1640 application.SendNotification();
1641 application.Render();
1643 // Now the text field has the focus, so it can handle the key events.
1644 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1645 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1647 // Render and notify
1648 application.SendNotification();
1649 application.Render();
1651 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1653 // Create a second text field and send key events to it.
1654 TextField field2 = TextField::New();
1656 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1657 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1658 field2.SetSize( 100.f, 100.f );
1659 field2.SetPosition( 100.f, 100.f );
1661 Stage::GetCurrent().Add( field2 );
1663 // Render and notify
1664 application.SendNotification();
1665 application.Render();
1667 // Create a tap event on the second text field.
1668 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1669 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1671 // Render and notify
1672 application.SendNotification();
1673 application.Render();
1675 // The second text field has the focus. It should handle the key events.
1676 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1677 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1679 // Render and notify
1680 application.SendNotification();
1681 application.Render();
1683 // Check the text has been added to the second text field.
1684 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1689 int utcDaliTextFieldEvent02(void)
1691 ToolkitTestApplication application;
1692 tet_infoline(" utcDaliTextFieldEvent02");
1694 // Checks if the right number of actors are created.
1696 TextField field = TextField::New();
1697 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1698 DALI_TEST_CHECK( field );
1699 LoadMarkerImages(application, field);
1701 Stage::GetCurrent().Add( field );
1703 field.SetSize( 300.f, 50.f );
1704 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1705 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1707 // Avoid a crash when core load gl resources.
1708 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1710 // Render and notify
1711 application.SendNotification();
1712 application.Render();
1714 // Check there are the expected number of children ( stencil ).
1715 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1717 Actor stencil = field.GetChildAt( 0u );
1718 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1720 // Create a tap event to touch the text field.
1721 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1722 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1724 // Render and notify
1725 application.SendNotification();
1726 application.Render();
1728 Actor layer = field.GetChildAt( 1u );
1729 DALI_TEST_CHECK( layer.IsLayer() );
1731 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1732 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1734 // Now the text field has the focus, so it can handle the key events.
1735 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1736 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1738 // Render and notify
1739 application.SendNotification();
1740 application.Render();
1742 // Checks the cursor and the renderer have been created.
1743 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1744 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1746 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1747 DALI_TEST_CHECK( cursor );
1749 // The offscreen root actor has a container with all the actors which contain the text renderers.
1750 Actor container = stencil.GetChildAt( 0u );
1751 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1753 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1754 DALI_TEST_CHECK( renderer );
1757 // Move the cursor and check the position changes.
1758 Vector3 position1 = cursor.GetCurrentPosition();
1759 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1761 // Render and notify
1762 application.SendNotification();
1763 application.Render();
1765 Vector3 position2 = cursor.GetCurrentPosition();
1766 DALI_TEST_CHECK( position2.x < position1.x );
1768 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1770 // Render and notify
1771 application.SendNotification();
1772 application.Render();
1774 Vector3 position3 = cursor.GetCurrentPosition();
1775 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1778 // Move the cursor to the first position.
1779 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1780 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1782 // Render and notify
1783 application.SendNotification();
1784 application.Render();
1786 Vector3 position4 = cursor.GetCurrentPosition();
1788 // Send some taps and check the cursor positions.
1790 // Try to tap at the beginning.
1791 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1792 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1794 // Render and notify
1795 application.SendNotification();
1796 application.Render();
1798 // Cursor position should be the same than position1.
1799 Vector3 position5 = cursor.GetCurrentPosition();
1801 DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
1803 // Tap away from the start position.
1804 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1805 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1807 // Render and notify
1808 application.SendNotification();
1809 application.Render();
1811 Vector3 position6 = cursor.GetCurrentPosition();
1813 DALI_TEST_CHECK( position6.x > position5.x );
1815 // Remove all the text.
1816 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1817 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1818 field.SetProperty( TextField::Property::TEXT, "" );
1820 // Render and notify
1821 application.SendNotification();
1822 application.Render();
1824 // Cursor position should be the same than position2.
1825 Vector3 position7 = cursor.GetCurrentPosition();
1827 DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
1829 // Should not be a renderer.
1830 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1832 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1833 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1834 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1836 application.SendNotification();
1837 application.Render();
1839 // There are renderer and decorator layer
1840 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1845 int utcDaliTextFieldEvent03(void)
1847 ToolkitTestApplication application;
1848 tet_infoline(" utcDaliTextFieldEvent03");
1850 // Checks if the highlight actor is created.
1852 TextField field = TextField::New();
1853 DALI_TEST_CHECK( field );
1855 Stage::GetCurrent().Add( field );
1857 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1858 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1859 field.SetSize( 30.f, 50.f );
1860 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1861 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1863 // Avoid a crash when core load gl resources.
1864 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1865 LoadMarkerImages(application, field);
1867 // Render and notify
1868 application.SendNotification();
1869 application.Render();
1871 // Tap first to get the focus.
1872 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1873 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1875 // Render and notify
1876 application.SendNotification();
1877 application.Render();
1879 // Double tap to select a word.
1880 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1881 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1883 // Render and notify
1884 application.SendNotification();
1885 application.Render();
1887 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1888 Actor stencil = field.GetChildAt( 0u );
1890 // The highlight actor is drawn first, so is the first actor in the list
1891 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1892 DALI_TEST_CHECK( highlight );
1894 // The offscreen root actor has a container with all the actors which contain the text renderers.
1895 Actor container = stencil.GetChildAt( 1u );
1896 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1898 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1899 DALI_TEST_CHECK( renderer );
1905 int utcDaliTextFieldEvent04(void)
1907 ToolkitTestApplication application;
1908 tet_infoline(" utcDaliTextFieldEvent04");
1910 // Checks if the highlight actor is created.
1912 TextField field = TextField::New();
1913 DALI_TEST_CHECK( field );
1914 Stage::GetCurrent().Add( field );
1915 LoadMarkerImages(application, field);
1916 // Render and notify
1917 application.SendNotification();
1918 application.Render();
1920 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1921 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1922 field.SetSize( 300.f, 50.f );
1923 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1924 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1926 // Avoid a crash when core load gl resources.
1927 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1928 // Render and notify
1929 application.SendNotification();
1930 application.Render();
1932 // Create a tap event to touch the text field.
1933 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1934 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1935 // Render and notify
1936 application.SendNotification();
1937 application.Render();
1940 // Tap first to get the focus.
1941 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1942 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1944 // Render and notify
1945 application.SendNotification();
1946 application.Render();
1948 // Double tap to select a word.
1949 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1950 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1952 // Render and notify
1953 application.SendNotification();
1954 application.Render();
1957 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1958 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1962 int utcDaliTextFieldEvent05(void)
1964 ToolkitTestApplication application;
1965 tet_infoline(" utcDaliTextFieldEvent05");
1967 // Checks dragging of cursor/grab handle
1969 TextField field = TextField::New();
1970 DALI_TEST_CHECK( field );
1971 Stage::GetCurrent().Add( field );
1972 LoadMarkerImages(application, field);
1973 // Render and notify
1974 application.SendNotification();
1975 application.Render();
1977 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1978 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1979 field.SetSize( 300.f, 50.f );
1980 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1981 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1983 // Avoid a crash when core load gl resources.
1984 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1985 // Render and notify
1986 application.SendNotification();
1987 application.Render();
1989 // Create a tap event to touch the text field.
1990 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1991 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1992 // Render and notify
1993 application.SendNotification();
1994 application.Render();
1996 // Tap first to get the focus.
1997 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1998 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2000 // Render and notify
2001 application.SendNotification();
2002 application.Render();
2004 // Double tap to select a word.
2005 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2006 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2008 // Render and notify
2009 application.SendNotification();
2010 application.Render();
2012 // drag grab handle right
2013 Vector2 pos(0.0f, 40.0f);
2014 SendPan(application, Gesture::Possible, pos);
2015 SendPan(application, Gesture::Started, pos);
2017 Wait(application, 100);
2019 for(int i = 0;i<20;i++)
2021 SendPan(application, Gesture::Continuing, pos);
2026 SendPan(application, Gesture::Finished, pos);
2027 Wait(application, RENDER_FRAME_INTERVAL);
2029 Actor stencil = field.GetChildAt( 1u );
2033 int utcDaliTextFieldEvent06(void)
2035 ToolkitTestApplication application;
2036 tet_infoline(" utcDaliTextFieldEvent06");
2038 // Checks Longpress when in edit mode
2040 TextField field = TextField::New();
2041 DALI_TEST_CHECK( field );
2042 Stage::GetCurrent().Add( field );
2043 LoadMarkerImages(application, field);
2044 // Render and notify
2045 application.SendNotification();
2046 application.Render();
2048 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2049 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2050 field.SetSize( 300.f, 50.f );
2051 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2052 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2054 // Avoid a crash when core load gl resources.
2055 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2056 // Render and notify
2057 application.SendNotification();
2058 application.Render();
2060 // Create a tap event to touch the text field.
2061 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2062 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2063 // Render and notify
2064 application.SendNotification();
2065 application.Render();
2068 // Tap first to get the focus.
2069 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2070 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2072 // Render and notify
2073 application.SendNotification();
2074 application.Render();
2077 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2078 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2080 // Render and notify
2081 application.SendNotification();
2082 application.Render();
2087 int utcDaliTextFieldEvent07(void)
2089 ToolkitTestApplication application;
2090 tet_infoline(" utcDaliTextFieldEvent07");
2092 // Checks Longpress to start edit mode
2094 TextField field = TextField::New();
2095 DALI_TEST_CHECK( field );
2096 Stage::GetCurrent().Add( field );
2097 LoadMarkerImages(application, field);
2098 // Render and notify
2099 application.SendNotification();
2100 application.Render();
2102 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2103 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2104 field.SetSize( 300.f, 50.f );
2105 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2106 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2107 Property::Map propertyMap;
2108 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2109 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2111 // Avoid a crash when core load gl resources.
2112 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2113 // Render and notify
2114 application.SendNotification();
2115 application.Render();
2118 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2119 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2121 // Render and notify
2122 application.SendNotification();
2123 application.Render();
2128 int utcDaliTextFieldEvent08(void)
2130 ToolkitTestApplication application;
2131 tet_infoline(" utcDaliTextFieldEvent08");
2133 Dali::Clipboard clipboard = Clipboard::Get();
2134 clipboard.SetItem("testTextFieldEvent");
2136 // Checks Longpress when only place holder text
2138 TextField field = TextField::New();
2139 DALI_TEST_CHECK( field );
2140 Stage::GetCurrent().Add( field );
2141 LoadMarkerImages(application, field);
2142 // Render and notify
2143 application.SendNotification();
2144 application.Render();
2146 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2147 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2148 field.SetSize( 300.f, 50.f );
2149 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2150 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2152 // Avoid a crash when core load gl resources.
2153 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2154 // Render and notify
2155 application.SendNotification();
2156 application.Render();
2159 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2160 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2162 // Render and notify
2163 application.SendNotification();
2164 application.Render();
2166 Wait(application, 500);
2169 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2170 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2172 // Render and notify
2173 application.SendNotification();
2174 application.Render();
2176 Wait(application, 500);
2178 Stage stage = Stage::GetCurrent();
2179 Layer layer = stage.GetRootLayer();
2180 Actor actor = layer.FindChildByName("optionPaste");
2184 Vector3 worldPosition = actor.GetCurrentWorldPosition();
2185 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2186 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2188 Dali::Integration::TouchEvent event;
2189 event = Dali::Integration::TouchEvent();
2190 event.AddPoint( GetPointDownInside( position ) );
2191 application.ProcessEvent( event );
2193 event = Dali::Integration::TouchEvent();
2194 event.AddPoint( GetPointUpInside( position ) );
2195 application.ProcessEvent( event );
2197 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2202 int utcDaliTextFieldEvent09(void)
2204 ToolkitTestApplication application;
2205 tet_infoline(" utcDaliTextFieldEvent09");
2207 TextField field = TextField::New();
2208 DALI_TEST_CHECK( field );
2209 Stage::GetCurrent().Add( field );
2210 LoadMarkerImages(application, field);
2211 // Render and notify
2212 application.SendNotification();
2213 application.Render();
2215 field.SetProperty( TextField::Property::TEXT, "Hello" );
2216 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2217 field.SetSize( 300.f, 50.f );
2218 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2219 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2221 // Avoid a crash when core load gl resources.
2222 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2224 // Create a tap event to touch the text field.
2225 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2226 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2227 application.SendNotification();
2228 application.Render();
2231 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2232 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2233 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2234 application.SendNotification();
2235 application.Render();
2237 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2238 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2239 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2240 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2241 application.SendNotification();
2242 application.Render();
2244 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2245 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2246 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2247 for( unsigned int index = 0u; index < 5u; ++index )
2249 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2250 application.SendNotification();
2251 application.Render();
2254 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2255 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2256 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2257 for( unsigned int index = 0u; index < 5u; ++index )
2259 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2260 application.SendNotification();
2261 application.Render();
2264 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2265 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2266 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2267 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2268 application.SendNotification();
2269 application.Render();
2270 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2271 application.SendNotification();
2272 application.Render();
2274 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2275 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2276 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2277 application.SendNotification();
2278 application.Render();
2280 Property::Map mapGet;
2281 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2282 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2283 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2288 int utcDaliTextFieldStyleWhilstSelected(void)
2290 ToolkitTestApplication application;
2291 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2293 // Change font and styles whilst text is selected whilst word selected
2295 TextField field = TextField::New();
2296 DALI_TEST_CHECK( field );
2297 Stage::GetCurrent().Add( field );
2298 LoadMarkerImages(application, field);
2299 // Render and notify
2300 application.SendNotification();
2301 application.Render();
2303 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2304 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2305 field.SetSize( 300.f, 50.f );
2306 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2307 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2309 // Avoid a crash when core load gl resources.
2310 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2311 // Render and notify
2312 application.SendNotification();
2313 application.Render();
2315 // Create a tap event to touch the text field.
2316 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2317 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2318 // Render and notify
2319 application.SendNotification();
2320 application.Render();
2323 // Tap first to get the focus.
2324 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2325 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2327 // Render and notify
2328 application.SendNotification();
2329 application.Render();
2331 // Double tap to select a word.
2332 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2333 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2335 // Render and notify
2336 application.SendNotification();
2337 application.Render();
2339 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2340 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2342 Property::Map fontStyleMapSet;
2343 Property::Map fontStyleMapGet;
2345 fontStyleMapSet.Insert( "weight", "bold" );
2346 fontStyleMapSet.Insert( "slant", "italic" );
2347 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2349 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2350 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2351 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2353 fontStyleMapSet.Clear();
2354 fontStyleMapSet.Insert( "width", "expanded" );
2355 fontStyleMapSet.Insert( "slant", "italic" );
2356 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2358 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2359 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2360 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2362 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2363 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2365 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2366 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2368 fontStyleMapSet.Clear();
2369 fontStyleMapSet.Insert( "weight", "bold" );
2370 fontStyleMapSet.Insert( "slant", "italic" );
2372 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2374 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2375 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2376 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2378 fontStyleMapSet.Clear();
2379 fontStyleMapSet.Insert( "width", "expanded" );
2381 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2383 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2384 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2385 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2387 // Press Escape to increase coverage
2388 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2389 application.SendNotification();
2390 application.Render();
2392 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2397 int utcDaliTextFieldEscKeyLoseFocus(void)
2399 ToolkitTestApplication application;
2400 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2402 // Creates a tap event. After creating a tap event the text field should
2403 // have the focus and add text with key events should be possible.
2405 TextField field = TextField::New();
2406 DALI_TEST_CHECK( field );
2408 Stage::GetCurrent().Add( field );
2410 field.SetSize( 300.f, 50.f );
2411 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2412 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2414 // Avoid a crash when core load gl resources.
2415 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2417 // Render and notify
2418 application.SendNotification();
2419 application.Render();
2421 // Add a key event but as the text field has not the focus it should do nothing.
2422 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2423 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2425 // Render and notify
2426 application.SendNotification();
2427 application.Render();
2429 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2431 // Create a tap event to touch the text field.
2432 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2433 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2435 // Render and notify
2436 application.SendNotification();
2437 application.Render();
2439 // Now the text field has the focus, so it can handle the key events.
2440 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2441 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2442 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2443 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2445 // Render and notify
2446 application.SendNotification();
2447 application.Render();
2449 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2451 // Generate a Esc key event. The text field should lose the focus.
2452 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2453 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2455 // Render and notify
2456 application.SendNotification();
2457 application.Render();
2459 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2461 // No more text should be introduced
2462 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2463 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2465 // Render and notify
2466 application.SendNotification();
2467 application.Render();
2469 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2474 int utcDaliTextFieldSomeSpecialKeys(void)
2476 ToolkitTestApplication application;
2477 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2479 // Checks some special keys when the text is selected.
2481 TextField field = TextField::New();
2482 DALI_TEST_CHECK( field );
2483 Stage::GetCurrent().Add( field );
2484 LoadMarkerImages(application, field);
2485 // Render and notify
2486 application.SendNotification();
2487 application.Render();
2489 const std::string longText( "This is a long text for the size of the text-field." );
2491 field.SetProperty( TextField::Property::TEXT, longText );
2492 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2493 field.SetSize( 300.f, 50.f );
2494 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2495 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2497 // Avoid a crash when core load gl resources.
2498 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2499 // Render and notify
2500 application.SendNotification();
2501 application.Render();
2503 // Create a tap event to touch the text field.
2504 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2505 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2507 // Render and notify
2508 application.SendNotification();
2509 application.Render();
2511 // Tap first to get the focus.
2512 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2513 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2515 // Render and notify
2516 application.SendNotification();
2517 application.Render();
2519 // Double tap to select a word.
2520 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2521 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2523 // Render and notify
2524 application.SendNotification();
2525 application.Render();
2527 // Generate a Esc key event. The text field should lose the focus.
2528 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2529 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2531 // Render and notify
2532 application.SendNotification();
2533 application.Render();
2535 // Generate a Esc key event. The text field should lose the focus.
2536 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2537 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2539 // Render and notify
2540 application.SendNotification();
2541 application.Render();
2543 // Generate a Esc key event. The text field should lose the focus.
2544 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2545 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2547 // Render and notify
2548 application.SendNotification();
2549 application.Render();
2551 // The text shouldn't be deleted.
2552 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2557 int utcDaliTextFieldSizeUpdate(void)
2559 ToolkitTestApplication application;
2560 tet_infoline("utcDaliTextFieldSizeUpdate");
2562 // Checks some special keys when the text is selected.
2563 TextField field = TextField::New();
2564 DALI_TEST_CHECK( field );
2565 Stage::GetCurrent().Add( field );
2567 float previousHeight = 0.0f;
2568 float currentHeight = 0.0f;
2569 const float fieldWidth = 1920.0f;
2572 // "ㅁ" is bigger then "ኢ"
2573 field.SetSize( Vector2( fieldWidth ,10.0f ) );
2574 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2575 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2577 field.SetProperty( TextField::Property::TEXT, "ኢ");
2578 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2579 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2581 field.SetKeyboardFocusable(true);
2582 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2584 application.SendNotification();
2585 application.Render();
2587 previousHeight = field.GetHeightForWidth( fieldWidth );
2588 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2590 // Add another script characters ( glyph height is defferent )
2591 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2592 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2594 application.SendNotification();
2595 application.Render();
2597 currentHeight = field.GetHeightForWidth( fieldWidth );
2598 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2599 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2604 int utcDaliTextFieldExtremlyLargePointSize(void)
2606 ToolkitTestApplication application;
2607 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2609 TextField field = TextField::New();
2611 field.SetProperty( TextField::Property::TEXT, "Text" );
2612 field.SetSize( 300.f, 50.f );
2613 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2614 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2615 Stage::GetCurrent().Add( field );
2619 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2620 application.SendNotification();
2621 DALI_TEST_CHECK( field );
2625 tet_result(TET_FAIL);
2630 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2632 ToolkitTestApplication application;
2633 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2634 TextField field = TextField::New();
2635 DALI_TEST_CHECK( field );
2636 Stage::GetCurrent().Add( field );
2638 Property::Map fontStyleMapGet;
2640 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2642 Property::Value* weightValue = NULL;
2643 Property::Value* widthValue = NULL;
2644 Property::Value* slantValue = NULL;
2645 weightValue = fontStyleMapGet.Find( "weight" );
2646 widthValue = fontStyleMapGet.Find( "width" );
2647 slantValue = fontStyleMapGet.Find( "slant" );
2648 DALI_TEST_CHECK( !weightValue );
2649 DALI_TEST_CHECK( !widthValue );
2650 DALI_TEST_CHECK( !slantValue );
2655 int UtcDaliTextFieldSettingPlaceholder(void)
2657 ToolkitTestApplication application;
2658 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
2660 TextField field = TextField::New();
2661 DALI_TEST_CHECK( field );
2662 Stage::GetCurrent().Add( field );
2664 // Check the placeholder property with pixel size
2665 Property::Map placeholderPixelSizeMapSet;
2666 Property::Map placeholderPixelSizeMapGet;
2667 Property::Map placeholderFontstyleMap;
2668 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2669 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2670 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
2671 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2672 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
2673 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
2675 placeholderFontstyleMap.Insert( "weight", "bold" );
2676 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2677 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
2679 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2680 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
2681 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
2683 // Check the placeholder property with point size
2684 Property::Map placeholderMapSet;
2685 Property::Map placeholderMapGet;
2686 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2687 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2688 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
2689 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2690 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
2691 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
2693 // Check the placeholder font style property
2694 placeholderFontstyleMap.Clear();
2696 placeholderFontstyleMap.Insert( "weight", "bold" );
2697 placeholderFontstyleMap.Insert( "width", "condensed" );
2698 placeholderFontstyleMap.Insert( "slant", "italic" );
2699 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2700 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2702 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2703 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2704 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2706 // Reset font style.
2707 placeholderFontstyleMap.Clear();
2708 placeholderFontstyleMap.Insert( "weight", "normal" );
2709 placeholderFontstyleMap.Insert( "slant", "oblique" );
2710 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2711 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2713 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2714 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2715 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2717 placeholderFontstyleMap.Clear();
2718 placeholderFontstyleMap.Insert( "slant", "roman" );
2719 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2720 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2722 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2724 placeholderFontstyleMap.Clear();
2725 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2727 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2728 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2729 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2730 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2735 int UtcDaliTextFieldSetPaddingProperty(void)
2737 ToolkitTestApplication application;
2738 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
2740 TextField field = TextField::New();
2741 DALI_TEST_CHECK( field );
2742 field.SetSize( 300.f, 50.f );
2743 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2744 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2745 Stage::GetCurrent().Add( field );
2747 application.SendNotification();
2748 application.Render();
2750 Vector3 originalSize = field.GetNaturalSize();
2752 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2754 application.SendNotification();
2755 application.Render();
2757 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2759 Vector3 paddingAddedSize = field.GetNaturalSize();
2761 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2763 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2768 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
2770 ToolkitTestApplication application;
2771 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
2773 TextField field = TextField::New();
2774 DALI_TEST_CHECK( field );
2775 field.SetSize( 300.f, 50.f );
2776 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2777 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2778 Stage::GetCurrent().Add( field );
2780 application.SendNotification();
2781 application.Render();
2783 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2784 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2786 // Check the enable shift selection property
2787 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
2788 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2790 application.SendNotification();
2791 application.Render();
2796 int UtcDaliTextFieldEnableGrabHandleProperty(void)
2798 ToolkitTestApplication application;
2799 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
2801 TextField field = TextField::New();
2802 DALI_TEST_CHECK( field );
2803 field.SetSize( 300.f, 50.f );
2804 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2805 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2806 Stage::GetCurrent().Add( field );
2808 application.SendNotification();
2809 application.Render();
2811 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2812 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2814 // Check the enable grab handle property
2815 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
2816 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2818 application.SendNotification();
2819 application.Render();
2824 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
2826 ToolkitTestApplication application;
2827 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
2829 TextField field = TextField::New();
2830 DALI_TEST_CHECK( field );
2831 field.SetSize( 300.f, 50.f );
2832 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2833 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2834 Stage::GetCurrent().Add( field );
2836 application.SendNotification();
2837 application.Render();
2839 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2840 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2842 // Check the match system language direction property
2843 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2844 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2846 application.SendNotification();
2847 application.Render();
2852 int utcDaliTextFieldLayoutDirectionCoverage(void)
2854 ToolkitTestApplication application;
2855 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
2857 // Creates a tap event. After creating a tap event the text field should
2858 // have the focus and add text with key events should be possible.
2859 TextField field = TextField::New();
2860 DALI_TEST_CHECK( field );
2862 Stage::GetCurrent().Add( field );
2864 field.SetSize( 300.f, 50.f );
2865 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2866 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2868 // Avoid a crash when core load gl resources.
2869 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2871 // Render and notify
2872 application.SendNotification();
2873 application.Render();
2875 // init direction for coverage
2876 // Set horizontal alignment END
2877 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2879 // Create a tap event to touch the text field.
2880 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2881 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2883 // Render and notify
2884 application.SendNotification();
2885 application.Render();
2887 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
2888 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2889 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
2891 // Set horizontal alignment BEGIN
2892 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
2894 // Create a tap event to touch the text field.
2895 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2896 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2898 // Render and notify
2899 application.SendNotification();
2900 application.Render();
2902 // Set horizontal alignment CENTER
2903 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
2905 // Create a tap event to touch the text field.
2906 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2907 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2909 // Render and notify
2910 application.SendNotification();
2911 application.Render();
2913 // Set horizontal alignment END
2914 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2916 // Create a tap event to touch the text field.
2917 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2918 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2920 // Render and notify
2921 application.SendNotification();
2922 application.Render();
2924 // Generate a Esc key event. The text field should lose the focus.
2925 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2926 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2928 // Render and notify
2929 application.SendNotification();
2930 application.Render();
2932 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2937 int UtcDaliTextFieldGetInputMethodContext(void)
2939 ToolkitTestApplication application;
2940 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
2942 TextField field = TextField::New();
2943 DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );
2948 int UtcDaliTextFieldSelectWholeText(void)
2950 ToolkitTestApplication application;
2951 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
2953 TextField textField = TextField::New();
2955 Stage::GetCurrent().Add( textField );
2957 textField.SetSize( 300.f, 50.f );
2958 textField.SetParentOrigin( ParentOrigin::TOP_LEFT );
2959 textField.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2961 // Avoid a crash when core load gl resources.
2962 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2964 application.SendNotification();
2965 application.Render();
2967 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2969 DevelTextField::SelectWholeText( textField );
2971 application.SendNotification();
2972 application.Render();
2974 // Nothing should have been selected. The number of children is still 1
2975 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
2977 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
2979 application.SendNotification();
2980 application.Render();
2982 DevelTextField::SelectWholeText( textField );
2984 application.SendNotification();
2985 application.Render();
2987 // Should be 2 children, the stencil and the layer
2988 DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
2990 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2991 Actor stencil = textField.GetChildAt( 0u );
2993 // The highlight actor is drawn first, so is the first actor in the list
2994 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2995 DALI_TEST_CHECK( highlight );