2 * Copyright (c) 2017 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-toolkit-test-suite-utils.h>
29 #include <dali-toolkit/dali-toolkit.h>
30 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
31 #include "toolkit-clipboard.h"
34 using namespace Toolkit;
36 void dali_textfield_startup(void)
38 test_return_value = TET_UNDEF;
41 void dali_textfield_cleanup(void)
43 test_return_value = TET_PASS;
49 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
50 const char* const PROPERTY_NAME_TEXT = "text";
51 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
52 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
53 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
54 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
55 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
56 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
57 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
58 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
59 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
60 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
61 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
62 const char* const PROPERTY_NAME_SHADOW_OFFSET = "shadowOffset";
63 const char* const PROPERTY_NAME_SHADOW_COLOR = "shadowColor";
64 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
65 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
66 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
67 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
68 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
69 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
70 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
71 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
72 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
73 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
79 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
80 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
81 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
82 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
83 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
84 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
85 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
86 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
87 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
89 const char* const PROPERTY_NAME_UNDERLINE = "underline";
90 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
91 const char* const PROPERTY_NAME_SHADOW = "shadow";
92 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
93 const char* const PROPERTY_NAME_EMBOSS = "emboss";
94 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
95 const char* const PROPERTY_NAME_OUTLINE = "outline";
96 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
98 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
99 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
100 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
101 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
102 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
103 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
105 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
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 unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
111 const float RENDER_FRAME_INTERVAL = 16.66f;
113 const float TO_MILLISECONDS = 1000.f;
114 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
116 const float SCROLL_THRESHOLD = 10.f;
117 const float SCROLL_SPEED = 300.f;
119 const unsigned int DEFAULT_FONT_SIZE = 1152u;
120 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
122 const int KEY_A_CODE = 38;
123 const int KEY_D_CODE = 40;
125 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
127 static bool gTextChangedCallBackCalled;
128 static bool gMaxCharactersCallBackCalled;
129 static bool gInputStyleChangedCallbackCalled;
130 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
132 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
134 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
135 Integration::ResourcePointer resource(bitmap);
136 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
139 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
143 LoadBitmapResource( app.GetPlatform(), width, height );
145 Property::Map propertyMap;
146 propertyMap["filename"] = "image.png";
147 propertyMap["width"] = width;
148 propertyMap["height"] = height;
149 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
150 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
151 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
152 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
153 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
154 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
155 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
156 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
159 // Generate a PanGestureEvent to send to Core
160 static Integration::PanGestureEvent GeneratePan(
161 Gesture::State state,
162 const Vector2& previousPosition,
163 const Vector2& currentPosition,
164 unsigned long timeDelta,
165 unsigned int numberOfTouches = 1)
167 Integration::PanGestureEvent pan(state);
169 pan.previousPosition = previousPosition;
170 pan.currentPosition = currentPosition;
171 pan.timeDelta = timeDelta;
172 pan.numberOfTouches = numberOfTouches;
178 * Helper to generate PanGestureEvent
180 * @param[in] application Application instance
181 * @param[in] state The Gesture State
182 * @param[in] pos The current position of touch.
184 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
188 if( (state == Gesture::Started) ||
189 (state == Gesture::Possible) )
195 application.ProcessEvent(GeneratePan(state, last, pos, 16));
202 * Simulate time passed by.
204 * @note this will always process at least 1 frame (1/60 sec)
206 * @param application Test application instance
207 * @param duration Time to pass in milliseconds.
208 * @return The actual time passed in milliseconds
210 static int Wait(ToolkitTestApplication& application, int duration = 0)
214 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
216 application.SendNotification();
217 application.Render(RENDER_FRAME_INTERVAL);
218 time += RENDER_FRAME_INTERVAL;
224 Dali::Integration::Point GetPointDownInside( Vector2& pos )
226 Dali::Integration::Point point;
227 point.SetState( PointState::DOWN );
228 point.SetScreenPosition( pos );
232 Dali::Integration::Point GetPointUpInside( Vector2& pos )
234 Dali::Integration::Point point;
235 point.SetState( PointState::UP );
236 point.SetScreenPosition( pos );
240 struct CallbackFunctor
242 CallbackFunctor(bool* callbackFlag)
243 : mCallbackFlag( callbackFlag )
249 *mCallbackFlag = true;
254 static void TestTextChangedCallback( TextField control )
256 tet_infoline(" TestTextChangedCallback");
258 gTextChangedCallBackCalled = true;
261 static void TestMaxLengthReachedCallback( TextField control )
263 tet_infoline(" TestMaxLengthReachedCallback");
265 gMaxCharactersCallBackCalled = true;
268 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
270 tet_infoline(" TestInputStyleChangedCallback");
272 gInputStyleChangedCallbackCalled = true;
273 gInputStyleMask = mask;
276 // Generate a TapGestureEvent to send to Core.
277 Integration::TapGestureEvent GenerateTap(
278 Gesture::State state,
279 unsigned int numberOfTaps,
280 unsigned int numberOfTouches,
283 Integration::TapGestureEvent tap( state );
285 tap.numberOfTaps = numberOfTaps;
286 tap.numberOfTouches = numberOfTouches;
292 Integration::LongPressGestureEvent GenerateLongPress(
293 Gesture::State state,
294 unsigned int numberOfTouches,
297 Integration::LongPressGestureEvent longPress( state );
299 longPress.numberOfTouches = numberOfTouches;
300 longPress.point = point;
304 // Generate a KeyEvent to send to Core.
305 Integration::KeyEvent GenerateKey( const std::string& keyName,
306 const std::string& keyString,
309 unsigned long timeStamp,
310 const Integration::KeyEvent::State& keyState,
311 const std::string& deviceName = DEFAULT_DEVICE_NAME,
312 const Device::Class::Type& deviceClass = Device::Class::NONE,
313 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
315 return Integration::KeyEvent( keyName,
326 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
328 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
330 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
332 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
334 if( valueGet.first.type == Property::Key::STRING )
336 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
337 if( NULL != valueSet )
339 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
341 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
347 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
353 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
354 if( NULL != valueSet )
356 if( valueGet.second.Get<int>() != valueSet->Get<int>() )
358 tet_printf( " Integer Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
364 tet_printf( " The Int key %d doesn't exist.", valueGet.first.indexKey );
376 int UtcDaliToolkitTextFieldConstructorP(void)
378 ToolkitTestApplication application;
379 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
381 DALI_TEST_CHECK( !textField );
385 int UtcDaliToolkitTextFieldNewP(void)
387 ToolkitTestApplication application;
388 tet_infoline(" UtcDaliToolkitTextFieldNewP");
389 TextField textField = TextField::New();
390 DALI_TEST_CHECK( textField );
394 int UtcDaliToolkitTextFieldDownCastP(void)
396 ToolkitTestApplication application;
397 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
398 TextField textField1 = TextField::New();
399 BaseHandle object( textField1 );
401 TextField textField2 = TextField::DownCast( object );
402 DALI_TEST_CHECK( textField2 );
404 TextField textField3 = DownCast< TextField >( object );
405 DALI_TEST_CHECK( textField3 );
409 int UtcDaliToolkitTextFieldDownCastN(void)
411 ToolkitTestApplication application;
412 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
413 BaseHandle uninitializedObject;
414 TextField textField1 = TextField::DownCast( uninitializedObject );
415 DALI_TEST_CHECK( !textField1 );
417 TextField textField2 = DownCast< TextField >( uninitializedObject );
418 DALI_TEST_CHECK( !textField2 );
422 int UtcDaliToolkitTextFieldCopyConstructorP(void)
424 ToolkitTestApplication application;
425 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
426 TextField textField = TextField::New();
427 textField.SetProperty( TextField::Property::TEXT, "Test" );
429 TextField copy( textField );
430 DALI_TEST_CHECK( copy );
431 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
435 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
437 ToolkitTestApplication application;
438 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
439 TextField textField = TextField::New();
440 textField.SetProperty( TextField::Property::TEXT, "Test" );
442 TextField copy = textField;
443 DALI_TEST_CHECK( copy );
444 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
448 int UtcDaliTextFieldNewP(void)
450 ToolkitTestApplication application;
451 tet_infoline(" UtcDaliToolkitTextFieldNewP");
452 TextField textField = TextField::New();
453 DALI_TEST_CHECK( textField );
457 // Positive test case for a method
458 int UtcDaliTextFieldGetPropertyP(void)
460 ToolkitTestApplication application;
461 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
462 TextField field = TextField::New();
463 DALI_TEST_CHECK( field );
465 // Check Property Indices are correct
466 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
467 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
468 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
469 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
470 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
471 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
472 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
473 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
474 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
475 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
476 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
477 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
478 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
479 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextField::Property::SHADOW_OFFSET );
480 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextField::Property::SHADOW_COLOR );
481 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
482 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
483 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
484 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
485 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
486 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
487 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
488 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
489 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
490 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
491 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
492 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
493 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
494 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
495 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
496 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
497 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
498 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
499 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
500 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
501 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
502 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
503 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
504 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
505 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
506 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
507 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
508 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
509 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
510 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
511 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
512 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
513 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
514 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
515 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
516 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
517 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
518 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
523 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
526 Property::Map imageMap;
527 imageMap[mapKey] =mapValue;
529 field.SetProperty( property , imageMap );
530 Property::Value propValue = field.GetProperty( property );
531 Property::Map* resultMap = propValue.GetMap();
533 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
541 // Positive test case for a method
542 int UtcDaliTextFieldSetPropertyP(void)
544 ToolkitTestApplication application;
545 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
546 TextField field = TextField::New();
547 DALI_TEST_CHECK( field );
548 Stage::GetCurrent().Add( field );
550 // Note - we can't check the defaults since the stylesheets are platform-specific
552 // Check the render backend property.
553 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
554 DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
556 // Check text property.
557 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
558 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
560 // Check placeholder text properties.
561 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
562 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
564 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
565 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
567 // Check font properties.
568 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
569 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
571 Property::Map fontStyleMapSet;
572 Property::Map fontStyleMapGet;
573 Property::Value* slantValue = NULL;
575 fontStyleMapSet.Insert( "weight", "bold" );
576 fontStyleMapSet.Insert( "width", "condensed" );
577 fontStyleMapSet.Insert( "slant", "italic" );
578 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
580 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
581 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
582 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
584 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
585 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
588 fontStyleMapSet.Clear();
589 fontStyleMapSet.Insert( "weight", "normal" );
590 fontStyleMapSet.Insert( "slant", "oblique" );
591 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
593 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
594 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
595 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
597 fontStyleMapSet.Clear();
598 fontStyleMapSet.Insert( "slant", "roman" );
599 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
600 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
602 // Replace 'roman' for 'normal'.
603 slantValue = fontStyleMapGet.Find( "slant" );
604 if( NULL != slantValue )
606 if( "normal" == slantValue->Get<std::string>() )
608 fontStyleMapGet["slant"] = "roman";
611 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
612 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
614 fontStyleMapSet.Clear();
616 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
617 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
618 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
619 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
621 // Check that the MAX_LENGTH property can be correctly set
622 const int maxNumberOfCharacters = 20;
623 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
624 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
626 // Check exceed policy
627 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
628 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
629 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
630 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
632 // Check that the Alignment properties can be correctly set
633 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
634 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
635 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
636 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
638 // Check text's color property
639 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
640 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
642 // Check placeholder text's color property.
643 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
644 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
646 // Check shadow properties.
647 field.SetProperty( TextField::Property::SHADOW_OFFSET, Vector2( 1.f, 1.f ) );
648 DALI_TEST_EQUALS( field.GetProperty<Vector2>( TextField::Property::SHADOW_OFFSET ), Vector2( 1.f, 1.f ), TEST_LOCATION );
649 field.SetProperty( TextField::Property::SHADOW_COLOR, Color::GREEN );
650 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SHADOW_COLOR ), Color::GREEN, TEST_LOCATION );
652 // Check cursor properties
653 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
654 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
655 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
656 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
658 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
659 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
660 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
661 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
662 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
663 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
664 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
665 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
667 // Check scroll properties.
668 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
669 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
670 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
671 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
673 // Check handle images
674 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
675 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
676 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
677 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
678 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
680 // Check handle images
681 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
682 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
683 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
684 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
685 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
686 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
688 // Check the highlight color
689 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
690 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
692 // Decoration bounding box
693 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
694 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
696 // Check the input method setting
697 Property::Map propertyMap;
698 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
699 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
700 InputMethod::ActionButtonTitle::Type actionButton = InputMethod::ActionButtonTitle::GO;
701 int inputVariation = 1;
702 propertyMap["PANEL_LAYOUT"] = panelLayout;
703 propertyMap["AUTO_CAPITALISE"] = autoCapital;
704 propertyMap["ACTION_BUTTON"] = actionButton;
705 propertyMap["VARIATION"] = inputVariation;
706 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
708 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
710 DALI_TEST_CHECK( value.Get( map ) );
713 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
714 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
717 DALI_TEST_CHECK( map[ "AUTO_CAPITALISE" ].Get( capital ) );
718 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
721 DALI_TEST_CHECK( map[ "ACTION_BUTTON" ].Get( action ) );
722 DALI_TEST_EQUALS( static_cast<int>(actionButton), action, TEST_LOCATION );
725 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
726 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
728 // Check input color property.
729 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
730 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
732 // Check the enable markup property.
733 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
734 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
735 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
737 // Check input font properties.
738 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
739 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
741 fontStyleMapSet.Clear();
742 fontStyleMapSet.Insert( "weight", "bold" );
743 fontStyleMapSet.Insert( "width", "condensed" );
744 fontStyleMapSet.Insert( "slant", "italic" );
746 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
747 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
748 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
749 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
751 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
752 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
754 // Reset input font style.
755 fontStyleMapSet.Clear();
756 fontStyleMapSet.Insert( "weight", "normal" );
757 fontStyleMapSet.Insert( "slant", "oblique" );
759 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
760 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
761 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
762 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
764 fontStyleMapSet.Clear();
765 fontStyleMapSet.Insert( "slant", "roman" );
767 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
768 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
770 // Replace 'roman' for 'normal'.
771 slantValue = fontStyleMapGet.Find( "slant" );
772 if( NULL != slantValue )
774 if( "normal" == slantValue->Get<std::string>() )
776 fontStyleMapGet["slant"] = "roman";
779 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
780 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
782 fontStyleMapSet.Clear();
784 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
785 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
786 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
787 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
789 Property::Map underlineMapSet;
790 Property::Map underlineMapGet;
792 underlineMapSet.Insert( "enable", "true" );
793 underlineMapSet.Insert( "color", "red" );
794 underlineMapSet.Insert( "height", "1" );
796 // Check the underline property
797 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
799 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
800 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
801 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
803 // Check the input underline property
804 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
805 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
807 // Check the shadow property
808 Property::Map shadowMapSet;
809 Property::Map shadowMapGet;
811 shadowMapSet.Insert( "color", Color::GREEN );
812 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
813 shadowMapSet.Insert( "blurRadius", 3.0f );
815 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
817 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
818 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
819 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
821 // Check the input shadow property
822 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
823 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
825 // Check the emboss property
826 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
827 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
829 // Check the input emboss property
830 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
831 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
833 // Check the outline property
835 // Test string type first
836 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
837 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
838 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
840 // Then test the property map type
841 Property::Map outlineMapSet;
842 Property::Map outlineMapGet;
844 outlineMapSet["color"] = Color::RED;
845 outlineMapSet["width"] = 2.0f;
847 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
849 outlineMapSet["color"] = "red";
850 outlineMapSet["width"] = "2";
851 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
852 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
853 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
855 // Check the input outline property
856 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
857 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
859 // Check the hidden input settings property
860 Property::Map hiddenMapSet;
861 Property::Map hiddenMapGet;
862 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
863 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
864 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
865 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
866 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
868 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
869 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
870 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
872 // Check the pixel size of font
873 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
874 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
876 // Check the enable selection property
877 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
878 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
880 // Check the placeholder property with pixel size
881 Property::Map placeholderPixelSizeMapSet;
882 Property::Map placeholderPixelSizeMapGet;
883 Property::Map placeholderFontstyleMap;
884 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
885 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
886 placeholderPixelSizeMapSet["color"] = Color::BLUE;
887 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
888 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
889 placeholderPixelSizeMapSet["ellipsis"] = true;
891 placeholderFontstyleMap.Insert( "weight", "bold" );
892 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
893 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
895 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
896 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
898 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
899 Property::Map placeholderConversionMap;
900 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
901 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
902 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
903 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
904 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
905 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
907 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
909 // Check the placeholder property with point size
910 Property::Map placeholderMapSet;
911 Property::Map placeholderMapGet;
912 placeholderMapSet["text"] = "Setting Placeholder Text";
913 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
914 placeholderMapSet["color"] = Color::RED;
915 placeholderMapSet["fontFamily"] = "Arial";
916 placeholderMapSet["pointSize"] = 12.0f;
917 placeholderMapSet["ellipsis"] = false;
919 // Check the placeholder font style property
920 placeholderFontstyleMap.Clear();
922 placeholderFontstyleMap.Insert( "weight", "bold" );
923 placeholderFontstyleMap.Insert( "width", "condensed" );
924 placeholderFontstyleMap.Insert( "slant", "italic" );
925 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
926 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
928 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
929 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
931 placeholderConversionMap.Clear();
932 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
933 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
934 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
935 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
936 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
937 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
939 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
942 placeholderFontstyleMap.Clear();
943 placeholderFontstyleMap.Insert( "weight", "normal" );
944 placeholderFontstyleMap.Insert( "slant", "oblique" );
945 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
946 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
948 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
949 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
951 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
952 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
954 placeholderFontstyleMap.Clear();
955 placeholderFontstyleMap.Insert( "slant", "roman" );
956 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
957 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
959 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
961 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
963 placeholderFontstyleMap.Clear();
964 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
965 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
967 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
968 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
969 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
971 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
973 // Check the ellipsis property
974 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
975 field.SetProperty( TextField::Property::ELLIPSIS, true );
976 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
978 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
979 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
981 application.SendNotification();
982 application.Render();
987 // Positive Atlas Text Renderer test
988 int utcDaliTextFieldAtlasRenderP(void)
990 ToolkitTestApplication application;
991 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
992 StyleManager styleManager = StyleManager::Get();
993 styleManager.ApplyDefaultTheme();
994 TextField field = TextField::New();
995 DALI_TEST_CHECK( field );
997 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
999 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1001 Stage::GetCurrent().Add( field );
1005 // Render some text with the shared atlas backend
1006 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
1007 application.SendNotification();
1008 application.Render();
1012 tet_result(TET_FAIL);
1017 // Positive test for the textChanged signal.
1018 int utcDaliTextFieldTextChangedP(void)
1020 ToolkitTestApplication application;
1021 tet_infoline(" utcDaliTextFieldTextChangedP");
1022 TextField field = TextField::New();
1023 DALI_TEST_CHECK( field );
1025 Stage::GetCurrent().Add( field );
1027 // connect to the text changed signal.
1028 ConnectionTracker* testTracker = new ConnectionTracker();
1029 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1030 bool textChangedSignal = false;
1031 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1033 gTextChangedCallBackCalled = false;
1034 field.SetProperty( TextField::Property::TEXT, "ABC" );
1035 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1036 DALI_TEST_CHECK( textChangedSignal );
1038 application.SendNotification();
1040 field.SetKeyInputFocus();
1042 gTextChangedCallBackCalled = false;
1043 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1044 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1049 // Negative test for the textChanged signal.
1050 int utcDaliTextFieldTextChangedN(void)
1052 ToolkitTestApplication application;
1053 tet_infoline(" utcDaliTextFieldTextChangedN");
1054 TextField field = TextField::New();
1055 DALI_TEST_CHECK( field );
1057 Stage::GetCurrent().Add( field );
1059 // connect to the text changed signal.
1060 ConnectionTracker* testTracker = new ConnectionTracker();
1061 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1062 bool textChangedSignal = false;
1063 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1065 gTextChangedCallBackCalled = false;
1066 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1067 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1068 DALI_TEST_CHECK( !textChangedSignal );
1073 // Positive test for Max Characters reached signal.
1074 int utcDaliTextFieldMaxCharactersReachedP(void)
1076 ToolkitTestApplication application;
1077 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1078 TextField field = TextField::New();
1079 DALI_TEST_CHECK( field );
1081 Stage::GetCurrent().Add( field );
1083 const int maxNumberOfCharacters = 1;
1084 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1086 field.SetKeyInputFocus();
1088 // connect to the text changed signal.
1089 ConnectionTracker* testTracker = new ConnectionTracker();
1090 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1091 bool maxLengthReachedSignal = false;
1092 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1094 gMaxCharactersCallBackCalled = false;
1096 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1097 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1099 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1100 DALI_TEST_CHECK( maxLengthReachedSignal );
1105 // Negative test for Max Characters reached signal.
1106 int utcDaliTextFieldMaxCharactersReachedN(void)
1108 ToolkitTestApplication application;
1109 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1110 TextField field = TextField::New();
1111 DALI_TEST_CHECK( field );
1113 Stage::GetCurrent().Add( field );
1115 const int maxNumberOfCharacters = 3;
1116 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1118 field.SetKeyInputFocus();
1120 // connect to the text changed signal.
1121 ConnectionTracker* testTracker = new ConnectionTracker();
1122 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1123 bool maxLengthReachedSignal = false;
1124 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1126 gMaxCharactersCallBackCalled = false;
1128 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1129 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1131 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1132 DALI_TEST_CHECK( !maxLengthReachedSignal );
1137 int utcDaliTextFieldInputStyleChanged01(void)
1139 ToolkitTestApplication application;
1140 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1142 // The text-field emits signals when the input style changes. These changes of style are
1143 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1144 // can't be emitted during the size negotiation as the callbacks may update the UI.
1145 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1146 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1147 application.CreateAdaptor();
1151 char* pathNamePtr = get_current_dir_name();
1152 const std::string pathName( pathNamePtr );
1153 free( pathNamePtr );
1155 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1156 fontClient.SetDpi( 93u, 93u );
1158 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1159 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1161 TextField field = TextField::New();
1162 DALI_TEST_CHECK( field );
1165 field.SetSize( 300.f, 50.f );
1166 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1167 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1169 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1170 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1172 // connect to the text changed signal.
1173 ConnectionTracker* testTracker = new ConnectionTracker();
1174 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1175 bool inputStyleChangedSignal = false;
1176 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1178 Stage::GetCurrent().Add( field );
1180 // Render and notify
1181 application.SendNotification();
1182 application.Render();
1184 // Executes the idle callbacks added by the text control on the change of input style.
1185 application.RunIdles();
1187 gInputStyleChangedCallbackCalled = false;
1188 gInputStyleMask = TextField::InputStyle::NONE;
1189 inputStyleChangedSignal = false;
1191 // Create a tap event to touch the text field.
1192 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1193 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1195 // Render and notify
1196 application.SendNotification();
1197 application.Render();
1199 // Executes the idle callbacks added by the text control on the change of input style.
1200 application.RunIdles();
1202 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1203 if( gInputStyleChangedCallbackCalled )
1205 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1207 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1208 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1210 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1211 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1213 DALI_TEST_CHECK( inputStyleChangedSignal );
1215 gInputStyleChangedCallbackCalled = false;
1216 gInputStyleMask = TextField::InputStyle::NONE;
1217 inputStyleChangedSignal = false;
1219 // Create a tap event to touch the text field.
1220 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1221 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1223 // Render and notify
1224 application.SendNotification();
1225 application.Render();
1227 // Executes the idle callbacks added by the text control on the change of input style.
1228 application.RunIdles();
1230 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1231 DALI_TEST_CHECK( !inputStyleChangedSignal );
1233 gInputStyleChangedCallbackCalled = false;
1234 gInputStyleMask = TextField::InputStyle::NONE;
1235 inputStyleChangedSignal = false;
1237 // Create a tap event to touch the text field.
1238 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1239 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1241 // Render and notify
1242 application.SendNotification();
1243 application.Render();
1245 // Executes the idle callbacks added by the text control on the change of input style.
1246 application.RunIdles();
1248 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1249 if( gInputStyleChangedCallbackCalled )
1251 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1253 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1254 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1256 DALI_TEST_CHECK( inputStyleChangedSignal );
1258 gInputStyleChangedCallbackCalled = false;
1259 gInputStyleMask = TextField::InputStyle::NONE;
1260 inputStyleChangedSignal = false;
1262 // Create a tap event to touch the text field.
1263 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1264 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1266 // Render and notify
1267 application.SendNotification();
1268 application.Render();
1270 // Executes the idle callbacks added by the text control on the change of input style.
1271 application.RunIdles();
1273 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1274 if( gInputStyleChangedCallbackCalled )
1276 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1278 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1279 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1281 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1283 Property::Map fontStyleMapSet;
1284 fontStyleMapSet.Insert( "weight", "bold" );
1286 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1287 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1289 DALI_TEST_CHECK( inputStyleChangedSignal );
1291 gInputStyleChangedCallbackCalled = false;
1292 gInputStyleMask = TextField::InputStyle::NONE;
1293 inputStyleChangedSignal = false;
1295 // Create a tap event to touch the text field.
1296 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1297 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1299 // Render and notify
1300 application.SendNotification();
1301 application.Render();
1303 // Executes the idle callbacks added by the text control on the change of input style.
1304 application.RunIdles();
1306 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1307 DALI_TEST_CHECK( !inputStyleChangedSignal );
1309 gInputStyleChangedCallbackCalled = false;
1310 gInputStyleMask = TextField::InputStyle::NONE;
1311 inputStyleChangedSignal = false;
1313 // Create a tap event to touch the text field.
1314 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1315 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1317 // Render and notify
1318 application.SendNotification();
1319 application.Render();
1321 // Executes the idle callbacks added by the text control on the change of input style.
1322 application.RunIdles();
1324 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1325 if( gInputStyleChangedCallbackCalled )
1327 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1329 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1330 DALI_TEST_CHECK( style.empty() );
1332 DALI_TEST_CHECK( inputStyleChangedSignal );
1334 gInputStyleChangedCallbackCalled = false;
1335 gInputStyleMask = TextField::InputStyle::NONE;
1336 inputStyleChangedSignal = false;
1338 // Create a tap event to touch the text field.
1339 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1340 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1342 // Render and notify
1343 application.SendNotification();
1344 application.Render();
1346 // Executes the idle callbacks added by the text control on the change of input style.
1347 application.RunIdles();
1349 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1350 DALI_TEST_CHECK( !inputStyleChangedSignal );
1355 int utcDaliTextFieldInputStyleChanged02(void)
1357 ToolkitTestApplication application;
1358 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1360 // The text-field emits signals when the input style changes. These changes of style are
1361 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1362 // can't be emitted during the size negotiation as the callbacks may update the UI.
1363 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1364 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1365 application.CreateAdaptor();
1369 char* pathNamePtr = get_current_dir_name();
1370 const std::string pathName( pathNamePtr );
1371 free( pathNamePtr );
1373 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1374 fontClient.SetDpi( 93u, 93u );
1376 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1377 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1379 TextField field = TextField::New();
1380 DALI_TEST_CHECK( field );
1383 field.SetSize( 300.f, 50.f );
1384 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1385 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1387 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1388 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>" );
1390 // connect to the text changed signal.
1391 ConnectionTracker* testTracker = new ConnectionTracker();
1392 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1393 bool inputStyleChangedSignal = false;
1394 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1396 Stage::GetCurrent().Add( field );
1398 // Render and notify
1399 application.SendNotification();
1400 application.Render();
1402 // Executes the idle callbacks added by the text control on the change of input style.
1403 application.RunIdles();
1405 gInputStyleChangedCallbackCalled = false;
1406 gInputStyleMask = TextField::InputStyle::NONE;
1407 inputStyleChangedSignal = false;
1409 // Create a tap event to touch the text field.
1410 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1411 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1412 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1413 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1415 // Render and notify
1416 application.SendNotification();
1417 application.Render();
1419 // Executes the idle callbacks added by the text control on the change of input style.
1420 application.RunIdles();
1422 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1423 if( gInputStyleChangedCallbackCalled )
1425 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1426 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1427 TextField::InputStyle::POINT_SIZE |
1428 TextField::InputStyle::COLOR ),
1431 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1432 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1434 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1435 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1437 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1438 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1440 DALI_TEST_CHECK( inputStyleChangedSignal );
1442 gInputStyleChangedCallbackCalled = false;
1443 gInputStyleMask = TextField::InputStyle::NONE;
1444 inputStyleChangedSignal = false;
1446 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1448 // Render and notify
1449 application.SendNotification();
1450 application.Render();
1452 // Executes the idle callbacks added by the text control on the change of input style.
1453 application.RunIdles();
1455 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1456 if( gInputStyleChangedCallbackCalled )
1458 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1459 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1462 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1463 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1465 DALI_TEST_CHECK( inputStyleChangedSignal );
1467 gInputStyleChangedCallbackCalled = false;
1468 gInputStyleMask = TextField::InputStyle::NONE;
1469 inputStyleChangedSignal = false;
1471 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1473 // Render and notify
1474 application.SendNotification();
1475 application.Render();
1477 // Executes the idle callbacks added by the text control on the change of input style.
1478 application.RunIdles();
1480 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1481 DALI_TEST_CHECK( !inputStyleChangedSignal );
1483 gInputStyleChangedCallbackCalled = false;
1484 gInputStyleMask = TextField::InputStyle::NONE;
1485 inputStyleChangedSignal = false;
1487 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1489 // Render and notify
1490 application.SendNotification();
1491 application.Render();
1493 // Executes the idle callbacks added by the text control on the change of input style.
1494 application.RunIdles();
1496 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1497 if( gInputStyleChangedCallbackCalled )
1499 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1500 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1503 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1504 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1506 DALI_TEST_CHECK( inputStyleChangedSignal );
1508 gInputStyleChangedCallbackCalled = false;
1509 gInputStyleMask = TextField::InputStyle::NONE;
1510 inputStyleChangedSignal = false;
1512 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1514 Property::Map fontStyleMapSet;
1515 fontStyleMapSet.Insert( "weight", "thin" );
1516 fontStyleMapSet.Insert( "width", "condensed" );
1517 fontStyleMapSet.Insert( "slant", "italic" );
1519 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1520 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1522 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1523 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1524 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1525 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1527 // Render and notify
1528 application.SendNotification();
1529 application.Render();
1531 // Executes the idle callbacks added by the text control on the change of input style.
1532 application.RunIdles();
1534 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1535 DALI_TEST_CHECK( !inputStyleChangedSignal );
1537 // Create a tap event to touch the text field.
1538 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1539 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1541 // Render and notify
1542 application.SendNotification();
1543 application.Render();
1545 // Executes the idle callbacks added by the text control on the change of input style.
1546 application.RunIdles();
1548 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1549 if( gInputStyleChangedCallbackCalled )
1551 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1552 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1553 TextField::InputStyle::POINT_SIZE |
1554 TextField::InputStyle::FONT_STYLE |
1555 TextField::InputStyle::UNDERLINE |
1556 TextField::InputStyle::SHADOW |
1557 TextField::InputStyle::EMBOSS |
1558 TextField::InputStyle::OUTLINE ),
1561 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1562 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1564 DALI_TEST_CHECK( inputStyleChangedSignal );
1569 int utcDaliTextFieldEvent01(void)
1571 ToolkitTestApplication application;
1572 tet_infoline(" utcDaliTextFieldEvent01");
1574 // Creates a tap event. After creating a tap event the text field should
1575 // have the focus and add text with key events should be possible.
1577 TextField field = TextField::New();
1578 DALI_TEST_CHECK( field );
1580 Stage::GetCurrent().Add( field );
1582 field.SetSize( 300.f, 50.f );
1583 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1584 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1586 // Avoid a crash when core load gl resources.
1587 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1589 // Render and notify
1590 application.SendNotification();
1591 application.Render();
1593 // Add a key event but as the text field has not the focus it should do nothing.
1594 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1596 // Render and notify
1597 application.SendNotification();
1598 application.Render();
1600 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1602 // Create a tap event to touch the text field.
1603 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1604 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1606 // Render and notify
1607 application.SendNotification();
1608 application.Render();
1610 // Now the text field has the focus, so it can handle the key events.
1611 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1612 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1614 // Render and notify
1615 application.SendNotification();
1616 application.Render();
1618 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1620 // Create a second text field and send key events to it.
1621 TextField field2 = TextField::New();
1623 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1624 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1625 field2.SetSize( 100.f, 100.f );
1626 field2.SetPosition( 100.f, 100.f );
1628 Stage::GetCurrent().Add( field2 );
1630 // Render and notify
1631 application.SendNotification();
1632 application.Render();
1634 // Create a tap event on the second text field.
1635 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1636 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1638 // Render and notify
1639 application.SendNotification();
1640 application.Render();
1642 // The second text field has the focus. It should handle the key events.
1643 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1644 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1646 // Render and notify
1647 application.SendNotification();
1648 application.Render();
1650 // Check the text has been added to the second text field.
1651 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1656 int utcDaliTextFieldEvent02(void)
1658 ToolkitTestApplication application;
1659 tet_infoline(" utcDaliTextFieldEvent02");
1661 // Checks if the right number of actors are created.
1663 TextField field = TextField::New();
1664 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1665 DALI_TEST_CHECK( field );
1666 LoadMarkerImages(application, field);
1668 Stage::GetCurrent().Add( field );
1670 field.SetSize( 300.f, 50.f );
1671 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1672 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1674 // Avoid a crash when core load gl resources.
1675 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1677 // Render and notify
1678 application.SendNotification();
1679 application.Render();
1681 // Check there are the expected number of children ( stencil ).
1682 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1684 Actor stencil = field.GetChildAt( 0u );
1685 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1687 // Create a tap event to touch the text field.
1688 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1689 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1691 // Render and notify
1692 application.SendNotification();
1693 application.Render();
1695 Actor layer = field.GetChildAt( 1u );
1696 DALI_TEST_CHECK( layer.IsLayer() );
1698 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1699 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1701 // Now the text field has the focus, so it can handle the key events.
1702 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1703 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1705 // Render and notify
1706 application.SendNotification();
1707 application.Render();
1709 // Checks the cursor and the renderer have been created.
1710 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1711 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1713 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1714 DALI_TEST_CHECK( cursor );
1716 // The offscreen root actor has a container with all the actors which contain the text renderers.
1717 Actor container = stencil.GetChildAt( 0u );
1718 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1720 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1721 DALI_TEST_CHECK( renderer );
1724 // Move the cursor and check the position changes.
1725 Vector3 position1 = cursor.GetCurrentPosition();
1727 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1728 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1730 // Render and notify
1731 application.SendNotification();
1732 application.Render();
1734 Vector3 position2 = cursor.GetCurrentPosition();
1736 DALI_TEST_CHECK( position2.x < position1.x );
1738 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1739 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1741 // Render and notify
1742 application.SendNotification();
1743 application.Render();
1745 Vector3 position3 = cursor.GetCurrentPosition();
1747 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1749 // Send some taps and check the cursor positions.
1751 // Try to tap at the beginning.
1752 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1753 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1755 // Render and notify
1756 application.SendNotification();
1757 application.Render();
1759 // Cursor position should be the same than position1.
1760 Vector3 position4 = cursor.GetCurrentPosition();
1762 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1764 // Tap away from the start position.
1765 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1766 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1768 // Render and notify
1769 application.SendNotification();
1770 application.Render();
1772 Vector3 position5 = cursor.GetCurrentPosition();
1774 DALI_TEST_CHECK( position5.x > position4.x );
1776 // Remove all the text.
1777 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1778 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1779 field.SetProperty( TextField::Property::TEXT, "" );
1781 // Render and notify
1782 application.SendNotification();
1783 application.Render();
1785 // Cursor position should be the same than position2.
1786 Vector3 position6 = cursor.GetCurrentPosition();
1788 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1790 // Should not be a renderer.
1791 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1793 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1794 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1795 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1797 application.SendNotification();
1798 application.Render();
1800 // There are renderer and decorator layer
1801 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1806 int utcDaliTextFieldEvent03(void)
1808 ToolkitTestApplication application;
1809 tet_infoline(" utcDaliTextFieldEvent03");
1811 // Checks if the highlight actor is created.
1813 TextField field = TextField::New();
1814 DALI_TEST_CHECK( field );
1816 Stage::GetCurrent().Add( field );
1818 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1819 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1820 field.SetSize( 30.f, 50.f );
1821 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1822 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1824 // Avoid a crash when core load gl resources.
1825 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1826 LoadMarkerImages(application, field);
1828 // Render and notify
1829 application.SendNotification();
1830 application.Render();
1832 // Tap first to get the focus.
1833 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1834 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1836 // Render and notify
1837 application.SendNotification();
1838 application.Render();
1840 // Double tap to select a word.
1841 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1842 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1844 // Render and notify
1845 application.SendNotification();
1846 application.Render();
1848 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1849 Actor stencil = field.GetChildAt( 0u );
1851 // The highlight actor is drawn first, so is the first actor in the list
1852 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1853 DALI_TEST_CHECK( highlight );
1855 // The offscreen root actor has a container with all the actors which contain the text renderers.
1856 Actor container = stencil.GetChildAt( 1u );
1857 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1859 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1860 DALI_TEST_CHECK( renderer );
1866 int utcDaliTextFieldEvent04(void)
1868 ToolkitTestApplication application;
1869 tet_infoline(" utcDaliTextFieldEvent04");
1871 // Checks if the highlight actor is created.
1873 TextField field = TextField::New();
1874 DALI_TEST_CHECK( field );
1875 Stage::GetCurrent().Add( field );
1876 LoadMarkerImages(application, field);
1877 // Render and notify
1878 application.SendNotification();
1879 application.Render();
1881 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1882 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1883 field.SetSize( 300.f, 50.f );
1884 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1885 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1887 // Avoid a crash when core load gl resources.
1888 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1889 // Render and notify
1890 application.SendNotification();
1891 application.Render();
1893 // Create a tap event to touch the text field.
1894 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1895 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1896 // Render and notify
1897 application.SendNotification();
1898 application.Render();
1901 // Tap first to get the focus.
1902 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1903 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1905 // Render and notify
1906 application.SendNotification();
1907 application.Render();
1909 // Double tap to select a word.
1910 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1911 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1913 // Render and notify
1914 application.SendNotification();
1915 application.Render();
1918 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1919 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1923 int utcDaliTextFieldEvent05(void)
1925 ToolkitTestApplication application;
1926 tet_infoline(" utcDaliTextFieldEvent05");
1928 // Checks dragging of cursor/grab handle
1930 TextField field = TextField::New();
1931 DALI_TEST_CHECK( field );
1932 Stage::GetCurrent().Add( field );
1933 LoadMarkerImages(application, field);
1934 // Render and notify
1935 application.SendNotification();
1936 application.Render();
1938 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1939 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1940 field.SetSize( 300.f, 50.f );
1941 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1942 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1944 // Avoid a crash when core load gl resources.
1945 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1946 // Render and notify
1947 application.SendNotification();
1948 application.Render();
1950 // Create a tap event to touch the text field.
1951 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1952 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1953 // Render and notify
1954 application.SendNotification();
1955 application.Render();
1958 // Tap first to get the focus.
1959 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1960 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1962 // Render and notify
1963 application.SendNotification();
1964 application.Render();
1966 // Double tap to select a word.
1967 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1968 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1970 // Render and notify
1971 application.SendNotification();
1972 application.Render();
1974 // drag grab handle right
1975 Vector2 pos(0.0f, 40.0f);
1976 SendPan(application, Gesture::Possible, pos);
1977 SendPan(application, Gesture::Started, pos);
1979 Wait(application, 100);
1981 for(int i = 0;i<20;i++)
1983 SendPan(application, Gesture::Continuing, pos);
1988 SendPan(application, Gesture::Finished, pos);
1989 Wait(application, RENDER_FRAME_INTERVAL);
1991 Actor stencil = field.GetChildAt( 1u );
1995 int utcDaliTextFieldEvent06(void)
1997 ToolkitTestApplication application;
1998 tet_infoline(" utcDaliTextFieldEvent06");
2000 // Checks Longpress when in edit mode
2002 TextField field = TextField::New();
2003 DALI_TEST_CHECK( field );
2004 Stage::GetCurrent().Add( field );
2005 LoadMarkerImages(application, field);
2006 // Render and notify
2007 application.SendNotification();
2008 application.Render();
2010 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2011 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2012 field.SetSize( 300.f, 50.f );
2013 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2014 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2016 // Avoid a crash when core load gl resources.
2017 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2018 // Render and notify
2019 application.SendNotification();
2020 application.Render();
2022 // Create a tap event to touch the text field.
2023 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2024 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2025 // Render and notify
2026 application.SendNotification();
2027 application.Render();
2030 // Tap first to get the focus.
2031 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2032 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2034 // Render and notify
2035 application.SendNotification();
2036 application.Render();
2039 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2040 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2042 // Render and notify
2043 application.SendNotification();
2044 application.Render();
2049 int utcDaliTextFieldEvent07(void)
2051 ToolkitTestApplication application;
2052 tet_infoline(" utcDaliTextFieldEvent07");
2054 // Checks Longpress to start edit mode
2056 TextField field = TextField::New();
2057 DALI_TEST_CHECK( field );
2058 Stage::GetCurrent().Add( field );
2059 LoadMarkerImages(application, field);
2060 // Render and notify
2061 application.SendNotification();
2062 application.Render();
2064 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2065 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2066 field.SetSize( 300.f, 50.f );
2067 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2068 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2069 Property::Map propertyMap;
2070 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2071 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2073 // Avoid a crash when core load gl resources.
2074 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2075 // Render and notify
2076 application.SendNotification();
2077 application.Render();
2080 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2081 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2083 // Render and notify
2084 application.SendNotification();
2085 application.Render();
2090 int utcDaliTextFieldEvent08(void)
2092 ToolkitTestApplication application;
2093 tet_infoline(" utcDaliTextFieldEvent08");
2095 Dali::Clipboard clipboard = Clipboard::Get();
2096 clipboard.SetItem("testTextFieldEvent");
2098 // Checks Longpress when only place holder text
2100 TextField field = TextField::New();
2101 DALI_TEST_CHECK( field );
2102 Stage::GetCurrent().Add( field );
2103 LoadMarkerImages(application, field);
2104 // Render and notify
2105 application.SendNotification();
2106 application.Render();
2108 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2109 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2110 field.SetSize( 300.f, 50.f );
2111 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2112 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2114 // Avoid a crash when core load gl resources.
2115 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2116 // Render and notify
2117 application.SendNotification();
2118 application.Render();
2121 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2122 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2124 // Render and notify
2125 application.SendNotification();
2126 application.Render();
2128 Wait(application, 500);
2131 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2132 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2134 // Render and notify
2135 application.SendNotification();
2136 application.Render();
2138 Wait(application, 500);
2140 Stage stage = Stage::GetCurrent();
2141 Layer layer = stage.GetRootLayer();
2142 Actor actor = layer.FindChildByName("optionPaste");
2146 Vector3 worldPosition = actor.GetCurrentWorldPosition();
2147 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2148 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2150 Dali::Integration::TouchEvent event;
2151 event = Dali::Integration::TouchEvent();
2152 event.AddPoint( GetPointDownInside( position ) );
2153 application.ProcessEvent( event );
2155 event = Dali::Integration::TouchEvent();
2156 event.AddPoint( GetPointUpInside( position ) );
2157 application.ProcessEvent( event );
2159 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2164 int utcDaliTextFieldEvent09(void)
2166 ToolkitTestApplication application;
2167 tet_infoline(" utcDaliTextFieldEvent09");
2169 TextField field = TextField::New();
2170 DALI_TEST_CHECK( field );
2171 Stage::GetCurrent().Add( field );
2172 LoadMarkerImages(application, field);
2173 // Render and notify
2174 application.SendNotification();
2175 application.Render();
2177 field.SetProperty( TextField::Property::TEXT, "Hello" );
2178 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2179 field.SetSize( 300.f, 50.f );
2180 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2181 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2183 // Avoid a crash when core load gl resources.
2184 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2186 // Create a tap event to touch the text field.
2187 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2188 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2189 application.SendNotification();
2190 application.Render();
2193 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2194 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2195 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2196 application.SendNotification();
2197 application.Render();
2199 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2200 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2201 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2202 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2203 application.SendNotification();
2204 application.Render();
2206 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2207 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2208 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2209 for( unsigned int index = 0u; index < 5u; ++index )
2211 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2212 application.SendNotification();
2213 application.Render();
2216 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2217 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2218 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2219 for( unsigned int index = 0u; index < 5u; ++index )
2221 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2222 application.SendNotification();
2223 application.Render();
2226 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2227 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2228 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2229 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2230 application.SendNotification();
2231 application.Render();
2232 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2233 application.SendNotification();
2234 application.Render();
2236 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2237 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2238 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2239 application.SendNotification();
2240 application.Render();
2242 Property::Map mapGet;
2243 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2244 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2245 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2250 int utcDaliTextFieldStyleWhilstSelected(void)
2252 ToolkitTestApplication application;
2253 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2255 // Change font and styles whilst text is selected whilst word selected
2257 TextField field = TextField::New();
2258 DALI_TEST_CHECK( field );
2259 Stage::GetCurrent().Add( field );
2260 LoadMarkerImages(application, field);
2261 // Render and notify
2262 application.SendNotification();
2263 application.Render();
2265 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2266 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2267 field.SetSize( 300.f, 50.f );
2268 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2269 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2271 // Avoid a crash when core load gl resources.
2272 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2273 // Render and notify
2274 application.SendNotification();
2275 application.Render();
2277 // Create a tap event to touch the text field.
2278 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2279 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2280 // Render and notify
2281 application.SendNotification();
2282 application.Render();
2285 // Tap first to get the focus.
2286 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2287 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2289 // Render and notify
2290 application.SendNotification();
2291 application.Render();
2293 // Double tap to select a word.
2294 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2295 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2297 // Render and notify
2298 application.SendNotification();
2299 application.Render();
2301 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2302 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2304 Property::Map fontStyleMapSet;
2305 Property::Map fontStyleMapGet;
2307 fontStyleMapSet.Insert( "weight", "bold" );
2308 fontStyleMapSet.Insert( "slant", "italic" );
2309 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2311 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2312 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2313 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2315 fontStyleMapSet.Clear();
2316 fontStyleMapSet.Insert( "width", "expanded" );
2317 fontStyleMapSet.Insert( "slant", "italic" );
2318 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2320 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2321 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2322 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2324 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2325 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2327 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2328 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2330 fontStyleMapSet.Clear();
2331 fontStyleMapSet.Insert( "weight", "bold" );
2332 fontStyleMapSet.Insert( "slant", "italic" );
2334 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2336 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2337 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2338 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2340 fontStyleMapSet.Clear();
2341 fontStyleMapSet.Insert( "width", "expanded" );
2343 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2345 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2346 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2347 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2349 // Press Escape to increase coverage
2350 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2351 application.SendNotification();
2352 application.Render();
2354 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2359 int utcDaliTextFieldEscKeyLoseFocus(void)
2361 ToolkitTestApplication application;
2362 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2364 // Creates a tap event. After creating a tap event the text field should
2365 // have the focus and add text with key events should be possible.
2367 TextField field = TextField::New();
2368 DALI_TEST_CHECK( field );
2370 Stage::GetCurrent().Add( field );
2372 field.SetSize( 300.f, 50.f );
2373 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2374 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2376 // Avoid a crash when core load gl resources.
2377 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2379 // Render and notify
2380 application.SendNotification();
2381 application.Render();
2383 // Add a key event but as the text field has not the focus it should do nothing.
2384 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2385 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2387 // Render and notify
2388 application.SendNotification();
2389 application.Render();
2391 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2393 // Create a tap event to touch the text field.
2394 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2395 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2397 // Render and notify
2398 application.SendNotification();
2399 application.Render();
2401 // Now the text field has the focus, so it can handle the key events.
2402 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2403 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2404 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2405 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2407 // Render and notify
2408 application.SendNotification();
2409 application.Render();
2411 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2413 // Generate a Esc key event. The text field should lose the focus.
2414 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2415 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2417 // Render and notify
2418 application.SendNotification();
2419 application.Render();
2421 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2423 // No more text should be introduced
2424 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2425 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2427 // Render and notify
2428 application.SendNotification();
2429 application.Render();
2431 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2436 int utcDaliTextFieldSomeSpecialKeys(void)
2438 ToolkitTestApplication application;
2439 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2441 // Checks some special keys when the text is selected.
2443 TextField field = TextField::New();
2444 DALI_TEST_CHECK( field );
2445 Stage::GetCurrent().Add( field );
2446 LoadMarkerImages(application, field);
2447 // Render and notify
2448 application.SendNotification();
2449 application.Render();
2451 const std::string longText( "This is a long text for the size of the text-field." );
2453 field.SetProperty( TextField::Property::TEXT, longText );
2454 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2455 field.SetSize( 300.f, 50.f );
2456 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2457 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2459 // Avoid a crash when core load gl resources.
2460 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2461 // Render and notify
2462 application.SendNotification();
2463 application.Render();
2465 // Create a tap event to touch the text field.
2466 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2467 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2469 // Render and notify
2470 application.SendNotification();
2471 application.Render();
2473 // Tap first to get the focus.
2474 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2475 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2477 // Render and notify
2478 application.SendNotification();
2479 application.Render();
2481 // Double tap to select a word.
2482 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2483 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2485 // Render and notify
2486 application.SendNotification();
2487 application.Render();
2489 // Generate a Esc key event. The text field should lose the focus.
2490 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2491 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2493 // Render and notify
2494 application.SendNotification();
2495 application.Render();
2497 // Generate a Esc key event. The text field should lose the focus.
2498 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2499 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2501 // Render and notify
2502 application.SendNotification();
2503 application.Render();
2505 // Generate a Esc key event. The text field should lose the focus.
2506 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2507 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2509 // Render and notify
2510 application.SendNotification();
2511 application.Render();
2513 // The text shouldn't be deleted.
2514 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2519 int utcDaliTextFieldSizeUpdate(void)
2521 ToolkitTestApplication application;
2522 tet_infoline("utcDaliTextFieldSizeUpdate");
2524 // Checks some special keys when the text is selected.
2525 TextField field = TextField::New();
2526 DALI_TEST_CHECK( field );
2527 Stage::GetCurrent().Add( field );
2529 float previousHeight = 0.0f;
2530 float currentHeight = 0.0f;
2531 const float fieldWidth = 1920.0f;
2534 // "ㅁ" is bigger then "ኢ"
2535 field.SetSize( Vector2( fieldWidth ,10.0f ) );
2536 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2537 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2539 field.SetProperty( TextField::Property::TEXT, "ኢ");
2540 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2541 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2543 field.SetKeyboardFocusable(true);
2544 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2546 application.SendNotification();
2547 application.Render();
2549 previousHeight = field.GetHeightForWidth( fieldWidth );
2550 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2552 // Add another script characters ( glyph height is defferent )
2553 application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2554 application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2556 application.SendNotification();
2557 application.Render();
2559 currentHeight = field.GetHeightForWidth( fieldWidth );
2560 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2561 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2566 int utcDaliTextFieldExtremlyLargePointSize(void)
2568 ToolkitTestApplication application;
2569 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2571 TextField field = TextField::New();
2573 field.SetProperty( TextField::Property::TEXT, "Text" );
2574 field.SetSize( 300.f, 50.f );
2575 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2576 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2577 Stage::GetCurrent().Add( field );
2581 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2582 application.SendNotification();
2583 DALI_TEST_CHECK( field );
2587 tet_result(TET_FAIL);
2592 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2594 ToolkitTestApplication application;
2595 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2596 TextField field = TextField::New();
2597 DALI_TEST_CHECK( field );
2598 Stage::GetCurrent().Add( field );
2600 Property::Map fontStyleMapGet;
2602 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2604 Property::Value* weightValue = NULL;
2605 Property::Value* widthValue = NULL;
2606 Property::Value* slantValue = NULL;
2607 weightValue = fontStyleMapGet.Find( "weight" );
2608 widthValue = fontStyleMapGet.Find( "width" );
2609 slantValue = fontStyleMapGet.Find( "slant" );
2610 DALI_TEST_CHECK( !weightValue );
2611 DALI_TEST_CHECK( !widthValue );
2612 DALI_TEST_CHECK( !slantValue );
2617 int UtcDaliTextFieldSettingPlaceholder(void)
2619 ToolkitTestApplication application;
2620 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
2622 TextField field = TextField::New();
2623 DALI_TEST_CHECK( field );
2624 Stage::GetCurrent().Add( field );
2626 // Check the placeholder property with pixel size
2627 Property::Map placeholderPixelSizeMapSet;
2628 Property::Map placeholderPixelSizeMapGet;
2629 Property::Map placeholderFontstyleMap;
2630 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2631 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2632 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
2633 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2634 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
2635 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
2637 placeholderFontstyleMap.Insert( "weight", "bold" );
2638 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2639 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
2641 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2642 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
2643 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
2645 // Check the placeholder property with point size
2646 Property::Map placeholderMapSet;
2647 Property::Map placeholderMapGet;
2648 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2649 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2650 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
2651 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2652 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
2653 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
2655 // Check the placeholder font style property
2656 placeholderFontstyleMap.Clear();
2658 placeholderFontstyleMap.Insert( "weight", "bold" );
2659 placeholderFontstyleMap.Insert( "width", "condensed" );
2660 placeholderFontstyleMap.Insert( "slant", "italic" );
2661 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2662 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2664 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2665 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2666 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2668 // Reset font style.
2669 placeholderFontstyleMap.Clear();
2670 placeholderFontstyleMap.Insert( "weight", "normal" );
2671 placeholderFontstyleMap.Insert( "slant", "oblique" );
2672 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2673 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2675 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2676 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2677 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2679 placeholderFontstyleMap.Clear();
2680 placeholderFontstyleMap.Insert( "slant", "roman" );
2681 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2682 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2684 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2686 placeholderFontstyleMap.Clear();
2687 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2689 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2690 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2691 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2692 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2697 int UtcDaliTextFieldSetPaddingProperty(void)
2699 ToolkitTestApplication application;
2700 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
2702 TextField field = TextField::New();
2703 DALI_TEST_CHECK( field );
2704 field.SetSize( 300.f, 50.f );
2705 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2706 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2707 Stage::GetCurrent().Add( field );
2709 application.SendNotification();
2710 application.Render();
2712 Vector3 originalSize = field.GetNaturalSize();
2714 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2716 application.SendNotification();
2717 application.Render();
2719 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2721 Vector3 paddingAddedSize = field.GetNaturalSize();
2723 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2725 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2730 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
2732 ToolkitTestApplication application;
2733 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
2735 TextField field = TextField::New();
2736 DALI_TEST_CHECK( field );
2737 field.SetSize( 300.f, 50.f );
2738 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2739 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2740 Stage::GetCurrent().Add( field );
2742 application.SendNotification();
2743 application.Render();
2745 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2746 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2748 // Check the enable shift selection property
2749 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
2750 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2752 application.SendNotification();
2753 application.Render();