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 Property::Value* valueSet = NULL;
335 if ( valueGet.first.type == Property::Key::INDEX )
337 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
341 // Get Key is a string so searching Set Map for a string key
342 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
345 if( NULL != valueSet )
347 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
349 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
352 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
354 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
357 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
359 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
362 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
364 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
367 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
369 Vector2 vector2Get = valueGet.second.Get<Vector2>();
370 Vector2 vector2Set = valueSet->Get<Vector2>();
371 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
374 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
376 Vector4 vector4Get = valueGet.second.Get<Vector4>();
377 Vector4 vector4Set = valueSet->Get<Vector4>();
378 tet_printf( "Value got : [%f, %f, %f, %f], expected : [%f, %f, %f, %f]", vector4Get.r, vector4Get.g, vector4Get.b, vector4Get.a, vector4Set.r, vector4Set.g, vector4Set.b, vector4Set.a );
384 if ( valueGet.first.type == Property::Key::INDEX )
386 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
390 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
402 int UtcDaliToolkitTextFieldConstructorP(void)
404 ToolkitTestApplication application;
405 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
407 DALI_TEST_CHECK( !textField );
411 int UtcDaliToolkitTextFieldNewP(void)
413 ToolkitTestApplication application;
414 tet_infoline(" UtcDaliToolkitTextFieldNewP");
415 TextField textField = TextField::New();
416 DALI_TEST_CHECK( textField );
420 int UtcDaliToolkitTextFieldDownCastP(void)
422 ToolkitTestApplication application;
423 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
424 TextField textField1 = TextField::New();
425 BaseHandle object( textField1 );
427 TextField textField2 = TextField::DownCast( object );
428 DALI_TEST_CHECK( textField2 );
430 TextField textField3 = DownCast< TextField >( object );
431 DALI_TEST_CHECK( textField3 );
435 int UtcDaliToolkitTextFieldDownCastN(void)
437 ToolkitTestApplication application;
438 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
439 BaseHandle uninitializedObject;
440 TextField textField1 = TextField::DownCast( uninitializedObject );
441 DALI_TEST_CHECK( !textField1 );
443 TextField textField2 = DownCast< TextField >( uninitializedObject );
444 DALI_TEST_CHECK( !textField2 );
448 int UtcDaliToolkitTextFieldCopyConstructorP(void)
450 ToolkitTestApplication application;
451 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
452 TextField textField = TextField::New();
453 textField.SetProperty( TextField::Property::TEXT, "Test" );
455 TextField copy( textField );
456 DALI_TEST_CHECK( copy );
457 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
461 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
463 ToolkitTestApplication application;
464 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
465 TextField textField = TextField::New();
466 textField.SetProperty( TextField::Property::TEXT, "Test" );
468 TextField copy = textField;
469 DALI_TEST_CHECK( copy );
470 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
474 int UtcDaliTextFieldNewP(void)
476 ToolkitTestApplication application;
477 tet_infoline(" UtcDaliToolkitTextFieldNewP");
478 TextField textField = TextField::New();
479 DALI_TEST_CHECK( textField );
483 // Positive test case for a method
484 int UtcDaliTextFieldGetPropertyP(void)
486 ToolkitTestApplication application;
487 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
488 TextField field = TextField::New();
489 DALI_TEST_CHECK( field );
491 // Check Property Indices are correct
492 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
493 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
494 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
495 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
496 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
497 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
498 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
499 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
500 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
501 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
502 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
503 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
504 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
505 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextField::Property::SHADOW_OFFSET );
506 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextField::Property::SHADOW_COLOR );
507 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
508 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
509 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
510 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
511 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
512 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
513 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
514 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
515 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
516 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
517 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
518 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
519 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
520 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
521 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
522 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
523 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
524 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
525 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
526 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
527 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
528 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
529 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
530 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
531 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
532 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
533 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
534 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
535 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
536 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
537 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
538 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
539 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
540 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
541 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
542 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
543 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
544 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
549 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
552 Property::Map imageMap;
553 imageMap[mapKey] =mapValue;
555 field.SetProperty( property , imageMap );
556 Property::Value propValue = field.GetProperty( property );
557 Property::Map* resultMap = propValue.GetMap();
559 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
567 // Positive test case for a method
568 int UtcDaliTextFieldSetPropertyP(void)
570 ToolkitTestApplication application;
571 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
572 TextField field = TextField::New();
573 DALI_TEST_CHECK( field );
574 Stage::GetCurrent().Add( field );
576 // Note - we can't check the defaults since the stylesheets are platform-specific
578 // Check the render backend property.
579 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
580 DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
582 // Check text property.
583 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
584 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
586 // Check placeholder text properties.
587 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
588 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
590 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
591 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
593 // Check font properties.
594 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
595 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
597 Property::Map fontStyleMapSet;
598 Property::Map fontStyleMapGet;
599 Property::Value* slantValue = NULL;
601 fontStyleMapSet.Insert( "weight", "bold" );
602 fontStyleMapSet.Insert( "width", "condensed" );
603 fontStyleMapSet.Insert( "slant", "italic" );
604 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
606 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
607 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
608 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
610 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
611 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
614 fontStyleMapSet.Clear();
615 fontStyleMapSet.Insert( "weight", "normal" );
616 fontStyleMapSet.Insert( "slant", "oblique" );
617 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
619 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
620 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
621 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
623 fontStyleMapSet.Clear();
624 fontStyleMapSet.Insert( "slant", "roman" );
625 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
626 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
628 // Replace 'roman' for 'normal'.
629 slantValue = fontStyleMapGet.Find( "slant" );
630 if( NULL != slantValue )
632 if( "normal" == slantValue->Get<std::string>() )
634 fontStyleMapGet["slant"] = "roman";
637 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
638 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
640 fontStyleMapSet.Clear();
642 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
643 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
644 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
645 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
647 // Check that the MAX_LENGTH property can be correctly set
648 const int maxNumberOfCharacters = 20;
649 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
650 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
652 // Check exceed policy
653 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
654 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
655 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
656 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
658 // Check that the Alignment properties can be correctly set
659 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
660 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
661 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
662 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
664 // Check text's color property
665 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
666 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
668 // Check placeholder text's color property.
669 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
670 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
672 // Check shadow properties.
673 field.SetProperty( TextField::Property::SHADOW_OFFSET, Vector2( 1.f, 1.f ) );
674 DALI_TEST_EQUALS( field.GetProperty<Vector2>( TextField::Property::SHADOW_OFFSET ), Vector2( 1.f, 1.f ), TEST_LOCATION );
675 field.SetProperty( TextField::Property::SHADOW_COLOR, Color::GREEN );
676 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SHADOW_COLOR ), Color::GREEN, TEST_LOCATION );
678 // Check cursor properties
679 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
680 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
681 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
682 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
684 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
685 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
686 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
687 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
688 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
689 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
690 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
691 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
693 // Check scroll properties.
694 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
695 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
696 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
697 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
699 // Check handle images
700 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
701 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
702 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
703 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
704 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
706 // Check handle images
707 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
708 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
709 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
710 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
711 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
712 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
714 // Check the highlight color
715 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
716 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
718 // Decoration bounding box
719 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
720 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
722 // Check the input method setting
723 Property::Map propertyMap;
724 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
725 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
726 InputMethod::ActionButtonTitle::Type actionButton = InputMethod::ActionButtonTitle::GO;
727 int inputVariation = 1;
728 propertyMap["PANEL_LAYOUT"] = panelLayout;
729 propertyMap["AUTO_CAPITALISE"] = autoCapital;
730 propertyMap["ACTION_BUTTON"] = actionButton;
731 propertyMap["VARIATION"] = inputVariation;
732 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
734 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
736 DALI_TEST_CHECK( value.Get( map ) );
739 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
740 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
743 DALI_TEST_CHECK( map[ "AUTO_CAPITALISE" ].Get( capital ) );
744 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
747 DALI_TEST_CHECK( map[ "ACTION_BUTTON" ].Get( action ) );
748 DALI_TEST_EQUALS( static_cast<int>(actionButton), action, TEST_LOCATION );
751 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
752 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
754 // Check input color property.
755 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
756 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
758 // Check the enable markup property.
759 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
760 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
761 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
763 // Check input font properties.
764 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
765 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
767 fontStyleMapSet.Clear();
768 fontStyleMapSet.Insert( "weight", "bold" );
769 fontStyleMapSet.Insert( "width", "condensed" );
770 fontStyleMapSet.Insert( "slant", "italic" );
772 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
773 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
774 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
775 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
777 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
778 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
780 // Reset input font style.
781 fontStyleMapSet.Clear();
782 fontStyleMapSet.Insert( "weight", "normal" );
783 fontStyleMapSet.Insert( "slant", "oblique" );
785 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
786 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
787 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
788 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
790 fontStyleMapSet.Clear();
791 fontStyleMapSet.Insert( "slant", "roman" );
793 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
794 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
796 // Replace 'roman' for 'normal'.
797 slantValue = fontStyleMapGet.Find( "slant" );
798 if( NULL != slantValue )
800 if( "normal" == slantValue->Get<std::string>() )
802 fontStyleMapGet["slant"] = "roman";
805 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
806 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
808 fontStyleMapSet.Clear();
810 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
811 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
812 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
813 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
815 Property::Map underlineMapSet;
816 Property::Map underlineMapGet;
818 underlineMapSet.Insert( "enable", "true" );
819 underlineMapSet.Insert( "color", "red" );
820 underlineMapSet.Insert( "height", "1" );
822 // Check the underline property
823 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
825 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
826 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
827 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
829 // Check the input underline property
830 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
831 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
833 // Check the shadow property
834 Property::Map shadowMapSet;
835 Property::Map shadowMapGet;
837 shadowMapSet.Insert( "color", Color::GREEN );
838 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
839 shadowMapSet.Insert( "blurRadius", 3.0f );
841 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
843 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
844 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
845 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
847 // Check the input shadow property
848 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
849 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
851 // Check the emboss property
852 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
853 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
855 // Check the input emboss property
856 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
857 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
859 // Check the outline property
861 // Test string type first
862 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
863 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
864 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
866 // Then test the property map type
867 Property::Map outlineMapSet;
868 Property::Map outlineMapGet;
870 outlineMapSet["color"] = Color::RED;
871 outlineMapSet["width"] = 2.0f;
873 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
875 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
876 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
877 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
879 // Check the input outline property
880 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
881 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
883 // Check the hidden input settings property
884 Property::Map hiddenMapSet;
885 Property::Map hiddenMapGet;
886 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
887 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
888 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
889 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
890 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
892 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
893 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
894 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
896 // Check the pixel size of font
897 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
898 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
900 // Check the enable selection property
901 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
902 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
904 // Check the placeholder property with pixel size
905 Property::Map placeholderPixelSizeMapSet;
906 Property::Map placeholderPixelSizeMapGet;
907 Property::Map placeholderFontstyleMap;
908 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
909 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
910 placeholderPixelSizeMapSet["color"] = Color::BLUE;
911 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
912 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
913 placeholderPixelSizeMapSet["ellipsis"] = true;
915 placeholderFontstyleMap.Insert( "weight", "bold" );
916 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
917 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
919 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
920 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
922 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
923 Property::Map placeholderConversionMap;
924 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
925 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
926 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
927 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
928 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
929 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
931 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
933 // Check the placeholder property with point size
934 Property::Map placeholderMapSet;
935 Property::Map placeholderMapGet;
936 placeholderMapSet["text"] = "Setting Placeholder Text";
937 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
938 placeholderMapSet["color"] = Color::RED;
939 placeholderMapSet["fontFamily"] = "Arial";
940 placeholderMapSet["pointSize"] = 12.0f;
941 placeholderMapSet["ellipsis"] = false;
943 // Check the placeholder font style property
944 placeholderFontstyleMap.Clear();
946 placeholderFontstyleMap.Insert( "weight", "bold" );
947 placeholderFontstyleMap.Insert( "width", "condensed" );
948 placeholderFontstyleMap.Insert( "slant", "italic" );
949 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
950 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
952 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
953 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
955 placeholderConversionMap.Clear();
956 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
957 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
958 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
959 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
960 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
961 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
963 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
966 placeholderFontstyleMap.Clear();
967 placeholderFontstyleMap.Insert( "weight", "normal" );
968 placeholderFontstyleMap.Insert( "slant", "oblique" );
969 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
970 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
972 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
973 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
975 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
976 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
978 placeholderFontstyleMap.Clear();
979 placeholderFontstyleMap.Insert( "slant", "roman" );
980 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
981 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
983 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
985 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
987 placeholderFontstyleMap.Clear();
988 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
989 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
991 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
992 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
993 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
995 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
997 // Check the ellipsis property
998 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
999 field.SetProperty( TextField::Property::ELLIPSIS, true );
1000 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1002 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
1003 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1005 application.SendNotification();
1006 application.Render();
1011 // Positive Atlas Text Renderer test
1012 int utcDaliTextFieldAtlasRenderP(void)
1014 ToolkitTestApplication application;
1015 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1016 StyleManager styleManager = StyleManager::Get();
1017 styleManager.ApplyDefaultTheme();
1018 TextField field = TextField::New();
1019 DALI_TEST_CHECK( field );
1021 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1023 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1025 Stage::GetCurrent().Add( field );
1029 // Render some text with the shared atlas backend
1030 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
1031 application.SendNotification();
1032 application.Render();
1036 tet_result(TET_FAIL);
1041 // Positive test for the textChanged signal.
1042 int utcDaliTextFieldTextChangedP(void)
1044 ToolkitTestApplication application;
1045 tet_infoline(" utcDaliTextFieldTextChangedP");
1046 TextField field = TextField::New();
1047 DALI_TEST_CHECK( field );
1049 Stage::GetCurrent().Add( field );
1051 // connect to the text changed signal.
1052 ConnectionTracker* testTracker = new ConnectionTracker();
1053 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1054 bool textChangedSignal = false;
1055 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1057 gTextChangedCallBackCalled = false;
1058 field.SetProperty( TextField::Property::TEXT, "ABC" );
1059 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1060 DALI_TEST_CHECK( textChangedSignal );
1062 application.SendNotification();
1064 field.SetKeyInputFocus();
1066 gTextChangedCallBackCalled = false;
1067 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1068 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1073 // Negative test for the textChanged signal.
1074 int utcDaliTextFieldTextChangedN(void)
1076 ToolkitTestApplication application;
1077 tet_infoline(" utcDaliTextFieldTextChangedN");
1078 TextField field = TextField::New();
1079 DALI_TEST_CHECK( field );
1081 Stage::GetCurrent().Add( field );
1083 // connect to the text changed signal.
1084 ConnectionTracker* testTracker = new ConnectionTracker();
1085 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1086 bool textChangedSignal = false;
1087 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1089 gTextChangedCallBackCalled = false;
1090 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1091 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1092 DALI_TEST_CHECK( !textChangedSignal );
1097 // Positive test for Max Characters reached signal.
1098 int utcDaliTextFieldMaxCharactersReachedP(void)
1100 ToolkitTestApplication application;
1101 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1102 TextField field = TextField::New();
1103 DALI_TEST_CHECK( field );
1105 Stage::GetCurrent().Add( field );
1107 const int maxNumberOfCharacters = 1;
1108 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1110 field.SetKeyInputFocus();
1112 // connect to the text changed signal.
1113 ConnectionTracker* testTracker = new ConnectionTracker();
1114 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1115 bool maxLengthReachedSignal = false;
1116 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1118 gMaxCharactersCallBackCalled = false;
1120 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1121 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1123 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1124 DALI_TEST_CHECK( maxLengthReachedSignal );
1129 // Negative test for Max Characters reached signal.
1130 int utcDaliTextFieldMaxCharactersReachedN(void)
1132 ToolkitTestApplication application;
1133 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1134 TextField field = TextField::New();
1135 DALI_TEST_CHECK( field );
1137 Stage::GetCurrent().Add( field );
1139 const int maxNumberOfCharacters = 3;
1140 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1142 field.SetKeyInputFocus();
1144 // connect to the text changed signal.
1145 ConnectionTracker* testTracker = new ConnectionTracker();
1146 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1147 bool maxLengthReachedSignal = false;
1148 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1150 gMaxCharactersCallBackCalled = false;
1152 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1153 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1155 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1156 DALI_TEST_CHECK( !maxLengthReachedSignal );
1161 int utcDaliTextFieldInputStyleChanged01(void)
1163 ToolkitTestApplication application;
1164 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1166 // The text-field emits signals when the input style changes. These changes of style are
1167 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1168 // can't be emitted during the size negotiation as the callbacks may update the UI.
1169 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1170 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1171 application.CreateAdaptor();
1175 char* pathNamePtr = get_current_dir_name();
1176 const std::string pathName( pathNamePtr );
1177 free( pathNamePtr );
1179 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1180 fontClient.SetDpi( 93u, 93u );
1182 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1183 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1185 TextField field = TextField::New();
1186 DALI_TEST_CHECK( field );
1189 field.SetSize( 300.f, 50.f );
1190 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1191 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1193 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1194 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1196 // connect to the text changed signal.
1197 ConnectionTracker* testTracker = new ConnectionTracker();
1198 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1199 bool inputStyleChangedSignal = false;
1200 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1202 Stage::GetCurrent().Add( field );
1204 // Render and notify
1205 application.SendNotification();
1206 application.Render();
1208 // Executes the idle callbacks added by the text control on the change of input style.
1209 application.RunIdles();
1211 gInputStyleChangedCallbackCalled = false;
1212 gInputStyleMask = TextField::InputStyle::NONE;
1213 inputStyleChangedSignal = false;
1215 // Create a tap event to touch the text field.
1216 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1217 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1219 // Render and notify
1220 application.SendNotification();
1221 application.Render();
1223 // Executes the idle callbacks added by the text control on the change of input style.
1224 application.RunIdles();
1226 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1227 if( gInputStyleChangedCallbackCalled )
1229 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1231 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1232 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1234 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1235 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1237 DALI_TEST_CHECK( inputStyleChangedSignal );
1239 gInputStyleChangedCallbackCalled = false;
1240 gInputStyleMask = TextField::InputStyle::NONE;
1241 inputStyleChangedSignal = false;
1243 // Create a tap event to touch the text field.
1244 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1245 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1247 // Render and notify
1248 application.SendNotification();
1249 application.Render();
1251 // Executes the idle callbacks added by the text control on the change of input style.
1252 application.RunIdles();
1254 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1255 DALI_TEST_CHECK( !inputStyleChangedSignal );
1257 gInputStyleChangedCallbackCalled = false;
1258 gInputStyleMask = TextField::InputStyle::NONE;
1259 inputStyleChangedSignal = false;
1261 // Create a tap event to touch the text field.
1262 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1263 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1265 // Render and notify
1266 application.SendNotification();
1267 application.Render();
1269 // Executes the idle callbacks added by the text control on the change of input style.
1270 application.RunIdles();
1272 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1273 if( gInputStyleChangedCallbackCalled )
1275 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1277 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1278 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1280 DALI_TEST_CHECK( inputStyleChangedSignal );
1282 gInputStyleChangedCallbackCalled = false;
1283 gInputStyleMask = TextField::InputStyle::NONE;
1284 inputStyleChangedSignal = false;
1286 // Create a tap event to touch the text field.
1287 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1288 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1290 // Render and notify
1291 application.SendNotification();
1292 application.Render();
1294 // Executes the idle callbacks added by the text control on the change of input style.
1295 application.RunIdles();
1297 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1298 if( gInputStyleChangedCallbackCalled )
1300 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1302 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1303 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1305 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1307 Property::Map fontStyleMapSet;
1308 fontStyleMapSet.Insert( "weight", "bold" );
1310 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1311 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1313 DALI_TEST_CHECK( inputStyleChangedSignal );
1315 gInputStyleChangedCallbackCalled = false;
1316 gInputStyleMask = TextField::InputStyle::NONE;
1317 inputStyleChangedSignal = false;
1319 // Create a tap event to touch the text field.
1320 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1321 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1323 // Render and notify
1324 application.SendNotification();
1325 application.Render();
1327 // Executes the idle callbacks added by the text control on the change of input style.
1328 application.RunIdles();
1330 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1331 DALI_TEST_CHECK( !inputStyleChangedSignal );
1333 gInputStyleChangedCallbackCalled = false;
1334 gInputStyleMask = TextField::InputStyle::NONE;
1335 inputStyleChangedSignal = false;
1337 // Create a tap event to touch the text field.
1338 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1339 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1341 // Render and notify
1342 application.SendNotification();
1343 application.Render();
1345 // Executes the idle callbacks added by the text control on the change of input style.
1346 application.RunIdles();
1348 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1349 if( gInputStyleChangedCallbackCalled )
1351 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1353 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1354 DALI_TEST_CHECK( style.empty() );
1356 DALI_TEST_CHECK( inputStyleChangedSignal );
1358 gInputStyleChangedCallbackCalled = false;
1359 gInputStyleMask = TextField::InputStyle::NONE;
1360 inputStyleChangedSignal = false;
1362 // Create a tap event to touch the text field.
1363 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1364 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1366 // Render and notify
1367 application.SendNotification();
1368 application.Render();
1370 // Executes the idle callbacks added by the text control on the change of input style.
1371 application.RunIdles();
1373 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1374 DALI_TEST_CHECK( !inputStyleChangedSignal );
1379 int utcDaliTextFieldInputStyleChanged02(void)
1381 ToolkitTestApplication application;
1382 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1384 // The text-field emits signals when the input style changes. These changes of style are
1385 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1386 // can't be emitted during the size negotiation as the callbacks may update the UI.
1387 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1388 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1389 application.CreateAdaptor();
1393 char* pathNamePtr = get_current_dir_name();
1394 const std::string pathName( pathNamePtr );
1395 free( pathNamePtr );
1397 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1398 fontClient.SetDpi( 93u, 93u );
1400 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1401 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1403 TextField field = TextField::New();
1404 DALI_TEST_CHECK( field );
1407 field.SetSize( 300.f, 50.f );
1408 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1409 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1411 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1412 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>" );
1414 // connect to the text changed signal.
1415 ConnectionTracker* testTracker = new ConnectionTracker();
1416 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1417 bool inputStyleChangedSignal = false;
1418 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1420 Stage::GetCurrent().Add( field );
1422 // Render and notify
1423 application.SendNotification();
1424 application.Render();
1426 // Executes the idle callbacks added by the text control on the change of input style.
1427 application.RunIdles();
1429 gInputStyleChangedCallbackCalled = false;
1430 gInputStyleMask = TextField::InputStyle::NONE;
1431 inputStyleChangedSignal = false;
1433 // Create a tap event to touch the text field.
1434 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1435 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1436 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1437 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1439 // Render and notify
1440 application.SendNotification();
1441 application.Render();
1443 // Executes the idle callbacks added by the text control on the change of input style.
1444 application.RunIdles();
1446 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1447 if( gInputStyleChangedCallbackCalled )
1449 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1450 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1451 TextField::InputStyle::POINT_SIZE |
1452 TextField::InputStyle::COLOR ),
1455 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1456 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1458 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1459 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1461 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1462 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1464 DALI_TEST_CHECK( inputStyleChangedSignal );
1466 gInputStyleChangedCallbackCalled = false;
1467 gInputStyleMask = TextField::InputStyle::NONE;
1468 inputStyleChangedSignal = false;
1470 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1472 // Render and notify
1473 application.SendNotification();
1474 application.Render();
1476 // Executes the idle callbacks added by the text control on the change of input style.
1477 application.RunIdles();
1479 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1480 if( gInputStyleChangedCallbackCalled )
1482 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1483 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1486 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1487 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1489 DALI_TEST_CHECK( inputStyleChangedSignal );
1491 gInputStyleChangedCallbackCalled = false;
1492 gInputStyleMask = TextField::InputStyle::NONE;
1493 inputStyleChangedSignal = false;
1495 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1497 // Render and notify
1498 application.SendNotification();
1499 application.Render();
1501 // Executes the idle callbacks added by the text control on the change of input style.
1502 application.RunIdles();
1504 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1505 DALI_TEST_CHECK( !inputStyleChangedSignal );
1507 gInputStyleChangedCallbackCalled = false;
1508 gInputStyleMask = TextField::InputStyle::NONE;
1509 inputStyleChangedSignal = false;
1511 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1513 // Render and notify
1514 application.SendNotification();
1515 application.Render();
1517 // Executes the idle callbacks added by the text control on the change of input style.
1518 application.RunIdles();
1520 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1521 if( gInputStyleChangedCallbackCalled )
1523 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1524 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1527 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1528 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1530 DALI_TEST_CHECK( inputStyleChangedSignal );
1532 gInputStyleChangedCallbackCalled = false;
1533 gInputStyleMask = TextField::InputStyle::NONE;
1534 inputStyleChangedSignal = false;
1536 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1538 Property::Map fontStyleMapSet;
1539 fontStyleMapSet.Insert( "weight", "thin" );
1540 fontStyleMapSet.Insert( "width", "condensed" );
1541 fontStyleMapSet.Insert( "slant", "italic" );
1543 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1544 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1546 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1547 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1548 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1549 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1551 // Render and notify
1552 application.SendNotification();
1553 application.Render();
1555 // Executes the idle callbacks added by the text control on the change of input style.
1556 application.RunIdles();
1558 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1559 DALI_TEST_CHECK( !inputStyleChangedSignal );
1561 // Create a tap event to touch the text field.
1562 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1563 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1565 // Render and notify
1566 application.SendNotification();
1567 application.Render();
1569 // Executes the idle callbacks added by the text control on the change of input style.
1570 application.RunIdles();
1572 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1573 if( gInputStyleChangedCallbackCalled )
1575 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1576 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1577 TextField::InputStyle::POINT_SIZE |
1578 TextField::InputStyle::FONT_STYLE |
1579 TextField::InputStyle::UNDERLINE |
1580 TextField::InputStyle::SHADOW |
1581 TextField::InputStyle::EMBOSS |
1582 TextField::InputStyle::OUTLINE ),
1585 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1586 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1588 DALI_TEST_CHECK( inputStyleChangedSignal );
1593 int utcDaliTextFieldEvent01(void)
1595 ToolkitTestApplication application;
1596 tet_infoline(" utcDaliTextFieldEvent01");
1598 // Creates a tap event. After creating a tap event the text field should
1599 // have the focus and add text with key events should be possible.
1601 TextField field = TextField::New();
1602 DALI_TEST_CHECK( field );
1604 Stage::GetCurrent().Add( field );
1606 field.SetSize( 300.f, 50.f );
1607 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1608 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1610 // Avoid a crash when core load gl resources.
1611 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1613 // Render and notify
1614 application.SendNotification();
1615 application.Render();
1617 // Add a key event but as the text field has not the focus it should do nothing.
1618 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1620 // Render and notify
1621 application.SendNotification();
1622 application.Render();
1624 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1626 // Create a tap event to touch the text field.
1627 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1628 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1630 // Render and notify
1631 application.SendNotification();
1632 application.Render();
1634 // Now the text field has the focus, so it can handle the key events.
1635 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1636 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1638 // Render and notify
1639 application.SendNotification();
1640 application.Render();
1642 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1644 // Create a second text field and send key events to it.
1645 TextField field2 = TextField::New();
1647 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1648 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1649 field2.SetSize( 100.f, 100.f );
1650 field2.SetPosition( 100.f, 100.f );
1652 Stage::GetCurrent().Add( field2 );
1654 // Render and notify
1655 application.SendNotification();
1656 application.Render();
1658 // Create a tap event on the second text field.
1659 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1660 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1662 // Render and notify
1663 application.SendNotification();
1664 application.Render();
1666 // The second text field has the focus. It should handle the key events.
1667 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1668 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1670 // Render and notify
1671 application.SendNotification();
1672 application.Render();
1674 // Check the text has been added to the second text field.
1675 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1680 int utcDaliTextFieldEvent02(void)
1682 ToolkitTestApplication application;
1683 tet_infoline(" utcDaliTextFieldEvent02");
1685 // Checks if the right number of actors are created.
1687 TextField field = TextField::New();
1688 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1689 DALI_TEST_CHECK( field );
1690 LoadMarkerImages(application, field);
1692 Stage::GetCurrent().Add( field );
1694 field.SetSize( 300.f, 50.f );
1695 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1696 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1698 // Avoid a crash when core load gl resources.
1699 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1701 // Render and notify
1702 application.SendNotification();
1703 application.Render();
1705 // Check there are the expected number of children ( stencil ).
1706 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1708 Actor stencil = field.GetChildAt( 0u );
1709 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1711 // Create a tap event to touch the text field.
1712 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1713 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1715 // Render and notify
1716 application.SendNotification();
1717 application.Render();
1719 Actor layer = field.GetChildAt( 1u );
1720 DALI_TEST_CHECK( layer.IsLayer() );
1722 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1723 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1725 // Now the text field has the focus, so it can handle the key events.
1726 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1727 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1729 // Render and notify
1730 application.SendNotification();
1731 application.Render();
1733 // Checks the cursor and the renderer have been created.
1734 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1735 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1737 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1738 DALI_TEST_CHECK( cursor );
1740 // The offscreen root actor has a container with all the actors which contain the text renderers.
1741 Actor container = stencil.GetChildAt( 0u );
1742 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1744 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1745 DALI_TEST_CHECK( renderer );
1748 // Move the cursor and check the position changes.
1749 Vector3 position1 = cursor.GetCurrentPosition();
1751 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1752 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1754 // Render and notify
1755 application.SendNotification();
1756 application.Render();
1758 Vector3 position2 = cursor.GetCurrentPosition();
1760 DALI_TEST_CHECK( position2.x < position1.x );
1762 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1763 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1765 // Render and notify
1766 application.SendNotification();
1767 application.Render();
1769 Vector3 position3 = cursor.GetCurrentPosition();
1771 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1773 // Send some taps and check the cursor positions.
1775 // Try to tap at the beginning.
1776 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1777 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1779 // Render and notify
1780 application.SendNotification();
1781 application.Render();
1783 // Cursor position should be the same than position1.
1784 Vector3 position4 = cursor.GetCurrentPosition();
1786 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1788 // Tap away from the start position.
1789 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1790 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1792 // Render and notify
1793 application.SendNotification();
1794 application.Render();
1796 Vector3 position5 = cursor.GetCurrentPosition();
1798 DALI_TEST_CHECK( position5.x > position4.x );
1800 // Remove all the text.
1801 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1802 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1803 field.SetProperty( TextField::Property::TEXT, "" );
1805 // Render and notify
1806 application.SendNotification();
1807 application.Render();
1809 // Cursor position should be the same than position2.
1810 Vector3 position6 = cursor.GetCurrentPosition();
1812 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1814 // Should not be a renderer.
1815 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1817 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1818 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1819 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1821 application.SendNotification();
1822 application.Render();
1824 // There are renderer and decorator layer
1825 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1830 int utcDaliTextFieldEvent03(void)
1832 ToolkitTestApplication application;
1833 tet_infoline(" utcDaliTextFieldEvent03");
1835 // Checks if the highlight actor is created.
1837 TextField field = TextField::New();
1838 DALI_TEST_CHECK( field );
1840 Stage::GetCurrent().Add( field );
1842 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1843 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1844 field.SetSize( 30.f, 50.f );
1845 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1846 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1848 // Avoid a crash when core load gl resources.
1849 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1850 LoadMarkerImages(application, field);
1852 // Render and notify
1853 application.SendNotification();
1854 application.Render();
1856 // Tap first to get the focus.
1857 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1858 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1860 // Render and notify
1861 application.SendNotification();
1862 application.Render();
1864 // Double tap to select a word.
1865 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1866 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1868 // Render and notify
1869 application.SendNotification();
1870 application.Render();
1872 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1873 Actor stencil = field.GetChildAt( 0u );
1875 // The highlight actor is drawn first, so is the first actor in the list
1876 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1877 DALI_TEST_CHECK( highlight );
1879 // The offscreen root actor has a container with all the actors which contain the text renderers.
1880 Actor container = stencil.GetChildAt( 1u );
1881 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1883 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1884 DALI_TEST_CHECK( renderer );
1890 int utcDaliTextFieldEvent04(void)
1892 ToolkitTestApplication application;
1893 tet_infoline(" utcDaliTextFieldEvent04");
1895 // Checks if the highlight actor is created.
1897 TextField field = TextField::New();
1898 DALI_TEST_CHECK( field );
1899 Stage::GetCurrent().Add( field );
1900 LoadMarkerImages(application, field);
1901 // Render and notify
1902 application.SendNotification();
1903 application.Render();
1905 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1906 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1907 field.SetSize( 300.f, 50.f );
1908 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1909 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1911 // Avoid a crash when core load gl resources.
1912 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1913 // Render and notify
1914 application.SendNotification();
1915 application.Render();
1917 // Create a tap event to touch the text field.
1918 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1919 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1920 // Render and notify
1921 application.SendNotification();
1922 application.Render();
1925 // Tap first to get the focus.
1926 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1927 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1929 // Render and notify
1930 application.SendNotification();
1931 application.Render();
1933 // Double tap to select a word.
1934 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1935 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1937 // Render and notify
1938 application.SendNotification();
1939 application.Render();
1942 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1943 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1947 int utcDaliTextFieldEvent05(void)
1949 ToolkitTestApplication application;
1950 tet_infoline(" utcDaliTextFieldEvent05");
1952 // Checks dragging of cursor/grab handle
1954 TextField field = TextField::New();
1955 DALI_TEST_CHECK( field );
1956 Stage::GetCurrent().Add( field );
1957 LoadMarkerImages(application, field);
1958 // Render and notify
1959 application.SendNotification();
1960 application.Render();
1962 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1963 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1964 field.SetSize( 300.f, 50.f );
1965 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1966 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1968 // Avoid a crash when core load gl resources.
1969 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1970 // Render and notify
1971 application.SendNotification();
1972 application.Render();
1974 // Create a tap event to touch the text field.
1975 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1976 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1977 // Render and notify
1978 application.SendNotification();
1979 application.Render();
1982 // Tap first to get the focus.
1983 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1984 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1986 // Render and notify
1987 application.SendNotification();
1988 application.Render();
1990 // Double tap to select a word.
1991 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1992 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1994 // Render and notify
1995 application.SendNotification();
1996 application.Render();
1998 // drag grab handle right
1999 Vector2 pos(0.0f, 40.0f);
2000 SendPan(application, Gesture::Possible, pos);
2001 SendPan(application, Gesture::Started, pos);
2003 Wait(application, 100);
2005 for(int i = 0;i<20;i++)
2007 SendPan(application, Gesture::Continuing, pos);
2012 SendPan(application, Gesture::Finished, pos);
2013 Wait(application, RENDER_FRAME_INTERVAL);
2015 Actor stencil = field.GetChildAt( 1u );
2019 int utcDaliTextFieldEvent06(void)
2021 ToolkitTestApplication application;
2022 tet_infoline(" utcDaliTextFieldEvent06");
2024 // Checks Longpress when in edit mode
2026 TextField field = TextField::New();
2027 DALI_TEST_CHECK( field );
2028 Stage::GetCurrent().Add( field );
2029 LoadMarkerImages(application, field);
2030 // Render and notify
2031 application.SendNotification();
2032 application.Render();
2034 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2035 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2036 field.SetSize( 300.f, 50.f );
2037 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2038 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2040 // Avoid a crash when core load gl resources.
2041 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2042 // Render and notify
2043 application.SendNotification();
2044 application.Render();
2046 // Create a tap event to touch the text field.
2047 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2048 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2049 // Render and notify
2050 application.SendNotification();
2051 application.Render();
2054 // Tap first to get the focus.
2055 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2056 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2058 // Render and notify
2059 application.SendNotification();
2060 application.Render();
2063 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2064 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2066 // Render and notify
2067 application.SendNotification();
2068 application.Render();
2073 int utcDaliTextFieldEvent07(void)
2075 ToolkitTestApplication application;
2076 tet_infoline(" utcDaliTextFieldEvent07");
2078 // Checks Longpress to start edit mode
2080 TextField field = TextField::New();
2081 DALI_TEST_CHECK( field );
2082 Stage::GetCurrent().Add( field );
2083 LoadMarkerImages(application, field);
2084 // Render and notify
2085 application.SendNotification();
2086 application.Render();
2088 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2089 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2090 field.SetSize( 300.f, 50.f );
2091 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2092 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2093 Property::Map propertyMap;
2094 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2095 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2097 // Avoid a crash when core load gl resources.
2098 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2099 // Render and notify
2100 application.SendNotification();
2101 application.Render();
2104 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2105 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2107 // Render and notify
2108 application.SendNotification();
2109 application.Render();
2114 int utcDaliTextFieldEvent08(void)
2116 ToolkitTestApplication application;
2117 tet_infoline(" utcDaliTextFieldEvent08");
2119 Dali::Clipboard clipboard = Clipboard::Get();
2120 clipboard.SetItem("testTextFieldEvent");
2122 // Checks Longpress when only place holder text
2124 TextField field = TextField::New();
2125 DALI_TEST_CHECK( field );
2126 Stage::GetCurrent().Add( field );
2127 LoadMarkerImages(application, field);
2128 // Render and notify
2129 application.SendNotification();
2130 application.Render();
2132 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2133 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2134 field.SetSize( 300.f, 50.f );
2135 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2136 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2138 // Avoid a crash when core load gl resources.
2139 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2140 // Render and notify
2141 application.SendNotification();
2142 application.Render();
2145 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2146 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2148 // Render and notify
2149 application.SendNotification();
2150 application.Render();
2152 Wait(application, 500);
2155 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2156 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2158 // Render and notify
2159 application.SendNotification();
2160 application.Render();
2162 Wait(application, 500);
2164 Stage stage = Stage::GetCurrent();
2165 Layer layer = stage.GetRootLayer();
2166 Actor actor = layer.FindChildByName("optionPaste");
2170 Vector3 worldPosition = actor.GetCurrentWorldPosition();
2171 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2172 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2174 Dali::Integration::TouchEvent event;
2175 event = Dali::Integration::TouchEvent();
2176 event.AddPoint( GetPointDownInside( position ) );
2177 application.ProcessEvent( event );
2179 event = Dali::Integration::TouchEvent();
2180 event.AddPoint( GetPointUpInside( position ) );
2181 application.ProcessEvent( event );
2183 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2188 int utcDaliTextFieldEvent09(void)
2190 ToolkitTestApplication application;
2191 tet_infoline(" utcDaliTextFieldEvent09");
2193 TextField field = TextField::New();
2194 DALI_TEST_CHECK( field );
2195 Stage::GetCurrent().Add( field );
2196 LoadMarkerImages(application, field);
2197 // Render and notify
2198 application.SendNotification();
2199 application.Render();
2201 field.SetProperty( TextField::Property::TEXT, "Hello" );
2202 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2203 field.SetSize( 300.f, 50.f );
2204 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2205 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2207 // Avoid a crash when core load gl resources.
2208 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2210 // Create a tap event to touch the text field.
2211 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2212 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2213 application.SendNotification();
2214 application.Render();
2217 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2218 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2219 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2220 application.SendNotification();
2221 application.Render();
2223 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2224 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2225 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2226 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2227 application.SendNotification();
2228 application.Render();
2230 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2231 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2232 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2233 for( unsigned int index = 0u; index < 5u; ++index )
2235 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2236 application.SendNotification();
2237 application.Render();
2240 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2241 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2242 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2243 for( unsigned int index = 0u; index < 5u; ++index )
2245 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2246 application.SendNotification();
2247 application.Render();
2250 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2251 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2252 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2253 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2254 application.SendNotification();
2255 application.Render();
2256 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2257 application.SendNotification();
2258 application.Render();
2260 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2261 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2262 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2263 application.SendNotification();
2264 application.Render();
2266 Property::Map mapGet;
2267 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2268 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2269 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2274 int utcDaliTextFieldStyleWhilstSelected(void)
2276 ToolkitTestApplication application;
2277 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2279 // Change font and styles whilst text is selected whilst word selected
2281 TextField field = TextField::New();
2282 DALI_TEST_CHECK( field );
2283 Stage::GetCurrent().Add( field );
2284 LoadMarkerImages(application, field);
2285 // Render and notify
2286 application.SendNotification();
2287 application.Render();
2289 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2290 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2291 field.SetSize( 300.f, 50.f );
2292 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2293 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2295 // Avoid a crash when core load gl resources.
2296 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2297 // Render and notify
2298 application.SendNotification();
2299 application.Render();
2301 // Create a tap event to touch the text field.
2302 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2303 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2304 // Render and notify
2305 application.SendNotification();
2306 application.Render();
2309 // Tap first to get the focus.
2310 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2311 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2313 // Render and notify
2314 application.SendNotification();
2315 application.Render();
2317 // Double tap to select a word.
2318 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2319 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2321 // Render and notify
2322 application.SendNotification();
2323 application.Render();
2325 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2326 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2328 Property::Map fontStyleMapSet;
2329 Property::Map fontStyleMapGet;
2331 fontStyleMapSet.Insert( "weight", "bold" );
2332 fontStyleMapSet.Insert( "slant", "italic" );
2333 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2335 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2336 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2337 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2339 fontStyleMapSet.Clear();
2340 fontStyleMapSet.Insert( "width", "expanded" );
2341 fontStyleMapSet.Insert( "slant", "italic" );
2342 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2344 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2345 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2346 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2348 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2349 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2351 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2352 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2354 fontStyleMapSet.Clear();
2355 fontStyleMapSet.Insert( "weight", "bold" );
2356 fontStyleMapSet.Insert( "slant", "italic" );
2358 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2360 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2361 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2362 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2364 fontStyleMapSet.Clear();
2365 fontStyleMapSet.Insert( "width", "expanded" );
2367 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2369 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2370 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2371 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2373 // Press Escape to increase coverage
2374 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2375 application.SendNotification();
2376 application.Render();
2378 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2383 int utcDaliTextFieldEscKeyLoseFocus(void)
2385 ToolkitTestApplication application;
2386 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2388 // Creates a tap event. After creating a tap event the text field should
2389 // have the focus and add text with key events should be possible.
2391 TextField field = TextField::New();
2392 DALI_TEST_CHECK( field );
2394 Stage::GetCurrent().Add( field );
2396 field.SetSize( 300.f, 50.f );
2397 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2398 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2400 // Avoid a crash when core load gl resources.
2401 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2403 // Render and notify
2404 application.SendNotification();
2405 application.Render();
2407 // Add a key event but as the text field has not the focus it should do nothing.
2408 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2409 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2411 // Render and notify
2412 application.SendNotification();
2413 application.Render();
2415 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2417 // Create a tap event to touch the text field.
2418 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2419 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2421 // Render and notify
2422 application.SendNotification();
2423 application.Render();
2425 // Now the text field has the focus, so it can handle the key events.
2426 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2427 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2428 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2429 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2431 // Render and notify
2432 application.SendNotification();
2433 application.Render();
2435 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2437 // Generate a Esc key event. The text field should lose the focus.
2438 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2439 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2441 // Render and notify
2442 application.SendNotification();
2443 application.Render();
2445 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2447 // No more text should be introduced
2448 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2449 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2451 // Render and notify
2452 application.SendNotification();
2453 application.Render();
2455 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2460 int utcDaliTextFieldSomeSpecialKeys(void)
2462 ToolkitTestApplication application;
2463 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2465 // Checks some special keys when the text is selected.
2467 TextField field = TextField::New();
2468 DALI_TEST_CHECK( field );
2469 Stage::GetCurrent().Add( field );
2470 LoadMarkerImages(application, field);
2471 // Render and notify
2472 application.SendNotification();
2473 application.Render();
2475 const std::string longText( "This is a long text for the size of the text-field." );
2477 field.SetProperty( TextField::Property::TEXT, longText );
2478 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2479 field.SetSize( 300.f, 50.f );
2480 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2481 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2483 // Avoid a crash when core load gl resources.
2484 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2485 // Render and notify
2486 application.SendNotification();
2487 application.Render();
2489 // Create a tap event to touch the text field.
2490 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2491 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2493 // Render and notify
2494 application.SendNotification();
2495 application.Render();
2497 // Tap first to get the focus.
2498 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2499 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2501 // Render and notify
2502 application.SendNotification();
2503 application.Render();
2505 // Double tap to select a word.
2506 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2507 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2509 // Render and notify
2510 application.SendNotification();
2511 application.Render();
2513 // Generate a Esc key event. The text field should lose the focus.
2514 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2515 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2517 // Render and notify
2518 application.SendNotification();
2519 application.Render();
2521 // Generate a Esc key event. The text field should lose the focus.
2522 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2523 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2525 // Render and notify
2526 application.SendNotification();
2527 application.Render();
2529 // Generate a Esc key event. The text field should lose the focus.
2530 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2531 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2533 // Render and notify
2534 application.SendNotification();
2535 application.Render();
2537 // The text shouldn't be deleted.
2538 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2543 int utcDaliTextFieldSizeUpdate(void)
2545 ToolkitTestApplication application;
2546 tet_infoline("utcDaliTextFieldSizeUpdate");
2548 // Checks some special keys when the text is selected.
2549 TextField field = TextField::New();
2550 DALI_TEST_CHECK( field );
2551 Stage::GetCurrent().Add( field );
2553 float previousHeight = 0.0f;
2554 float currentHeight = 0.0f;
2555 const float fieldWidth = 1920.0f;
2558 // "ㅁ" is bigger then "ኢ"
2559 field.SetSize( Vector2( fieldWidth ,10.0f ) );
2560 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2561 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2563 field.SetProperty( TextField::Property::TEXT, "ኢ");
2564 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2565 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2567 field.SetKeyboardFocusable(true);
2568 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2570 application.SendNotification();
2571 application.Render();
2573 previousHeight = field.GetHeightForWidth( fieldWidth );
2574 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2576 // Add another script characters ( glyph height is defferent )
2577 application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2578 application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2580 application.SendNotification();
2581 application.Render();
2583 currentHeight = field.GetHeightForWidth( fieldWidth );
2584 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2585 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2590 int utcDaliTextFieldExtremlyLargePointSize(void)
2592 ToolkitTestApplication application;
2593 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2595 TextField field = TextField::New();
2597 field.SetProperty( TextField::Property::TEXT, "Text" );
2598 field.SetSize( 300.f, 50.f );
2599 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2600 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2601 Stage::GetCurrent().Add( field );
2605 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2606 application.SendNotification();
2607 DALI_TEST_CHECK( field );
2611 tet_result(TET_FAIL);
2616 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2618 ToolkitTestApplication application;
2619 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2620 TextField field = TextField::New();
2621 DALI_TEST_CHECK( field );
2622 Stage::GetCurrent().Add( field );
2624 Property::Map fontStyleMapGet;
2626 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2628 Property::Value* weightValue = NULL;
2629 Property::Value* widthValue = NULL;
2630 Property::Value* slantValue = NULL;
2631 weightValue = fontStyleMapGet.Find( "weight" );
2632 widthValue = fontStyleMapGet.Find( "width" );
2633 slantValue = fontStyleMapGet.Find( "slant" );
2634 DALI_TEST_CHECK( !weightValue );
2635 DALI_TEST_CHECK( !widthValue );
2636 DALI_TEST_CHECK( !slantValue );
2641 int UtcDaliTextFieldSettingPlaceholder(void)
2643 ToolkitTestApplication application;
2644 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
2646 TextField field = TextField::New();
2647 DALI_TEST_CHECK( field );
2648 Stage::GetCurrent().Add( field );
2650 // Check the placeholder property with pixel size
2651 Property::Map placeholderPixelSizeMapSet;
2652 Property::Map placeholderPixelSizeMapGet;
2653 Property::Map placeholderFontstyleMap;
2654 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2655 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2656 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
2657 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2658 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
2659 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
2661 placeholderFontstyleMap.Insert( "weight", "bold" );
2662 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2663 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
2665 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2666 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
2667 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
2669 // Check the placeholder property with point size
2670 Property::Map placeholderMapSet;
2671 Property::Map placeholderMapGet;
2672 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2673 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2674 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
2675 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2676 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
2677 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
2679 // Check the placeholder font style property
2680 placeholderFontstyleMap.Clear();
2682 placeholderFontstyleMap.Insert( "weight", "bold" );
2683 placeholderFontstyleMap.Insert( "width", "condensed" );
2684 placeholderFontstyleMap.Insert( "slant", "italic" );
2685 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2686 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2688 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2689 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2690 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2692 // Reset font style.
2693 placeholderFontstyleMap.Clear();
2694 placeholderFontstyleMap.Insert( "weight", "normal" );
2695 placeholderFontstyleMap.Insert( "slant", "oblique" );
2696 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2697 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2699 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2700 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2701 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2703 placeholderFontstyleMap.Clear();
2704 placeholderFontstyleMap.Insert( "slant", "roman" );
2705 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2706 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2708 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2710 placeholderFontstyleMap.Clear();
2711 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2713 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2714 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2715 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2716 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2721 int UtcDaliTextFieldSetPaddingProperty(void)
2723 ToolkitTestApplication application;
2724 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
2726 TextField field = TextField::New();
2727 DALI_TEST_CHECK( field );
2728 field.SetSize( 300.f, 50.f );
2729 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2730 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2731 Stage::GetCurrent().Add( field );
2733 application.SendNotification();
2734 application.Render();
2736 Vector3 originalSize = field.GetNaturalSize();
2738 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2740 application.SendNotification();
2741 application.Render();
2743 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2745 Vector3 paddingAddedSize = field.GetNaturalSize();
2747 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2749 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2754 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
2756 ToolkitTestApplication application;
2757 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
2759 TextField field = TextField::New();
2760 DALI_TEST_CHECK( field );
2761 field.SetSize( 300.f, 50.f );
2762 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2763 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2764 Stage::GetCurrent().Add( field );
2766 application.SendNotification();
2767 application.Render();
2769 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2770 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2772 // Check the enable shift selection property
2773 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
2774 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2776 application.SendNotification();
2777 application.Render();