2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali/public-api/rendering/renderer.h>
23 #include <dali/integration-api/events/key-event-integ.h>
24 #include <dali/integration-api/events/tap-gesture-event.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/integration-api/events/pan-gesture-event.h>
27 #include <dali/integration-api/events/long-press-gesture-event.h>
28 #include <dali/devel-api/adaptor-framework/key-devel.h>
29 #include <dali-toolkit-test-suite-utils.h>
30 #include <dali-toolkit/dali-toolkit.h>
31 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
32 #include "toolkit-clipboard.h"
35 using namespace Toolkit;
37 void dali_textfield_startup(void)
39 test_return_value = TET_UNDEF;
42 void dali_textfield_cleanup(void)
44 test_return_value = TET_PASS;
50 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
51 const char* const PROPERTY_NAME_TEXT = "text";
52 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
53 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
54 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
55 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
56 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
57 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
58 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
59 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
60 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
61 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
62 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
63 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
64 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
65 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
66 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
67 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
68 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
69 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
70 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
71 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
72 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
73 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
80 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
81 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
82 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
83 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
84 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
85 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
86 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
88 const char* const PROPERTY_NAME_UNDERLINE = "underline";
89 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
90 const char* const PROPERTY_NAME_SHADOW = "shadow";
91 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
92 const char* const PROPERTY_NAME_EMBOSS = "emboss";
93 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
94 const char* const PROPERTY_NAME_OUTLINE = "outline";
95 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
97 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
98 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
99 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
100 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
101 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
102 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
103 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
104 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
106 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
108 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
109 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
111 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
112 const float RENDER_FRAME_INTERVAL = 16.66f;
114 const float TO_MILLISECONDS = 1000.f;
115 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
117 const float SCROLL_THRESHOLD = 10.f;
118 const float SCROLL_SPEED = 300.f;
120 const unsigned int DEFAULT_FONT_SIZE = 1152u;
121 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
123 const int KEY_RETURN_CODE = 36;
124 const int KEY_A_CODE = 38;
125 const int KEY_D_CODE = 40;
127 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
129 static bool gTextChangedCallBackCalled;
130 static bool gMaxCharactersCallBackCalled;
131 static bool gInputStyleChangedCallbackCalled;
132 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
134 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
136 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
137 Integration::ResourcePointer resource(bitmap);
138 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
141 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
145 LoadBitmapResource( app.GetPlatform(), width, height );
147 Property::Map propertyMap;
148 propertyMap["filename"] = "image.png";
149 propertyMap["width"] = width;
150 propertyMap["height"] = height;
151 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
152 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
153 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
154 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
155 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
156 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
157 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
158 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
161 // Generate a PanGestureEvent to send to Core
162 static Integration::PanGestureEvent GeneratePan(
163 Gesture::State state,
164 const Vector2& previousPosition,
165 const Vector2& currentPosition,
166 unsigned long timeDelta,
167 unsigned int numberOfTouches = 1)
169 Integration::PanGestureEvent pan(state);
171 pan.previousPosition = previousPosition;
172 pan.currentPosition = currentPosition;
173 pan.timeDelta = timeDelta;
174 pan.numberOfTouches = numberOfTouches;
180 * Helper to generate PanGestureEvent
182 * @param[in] application Application instance
183 * @param[in] state The Gesture State
184 * @param[in] pos The current position of touch.
186 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
190 if( (state == Gesture::Started) ||
191 (state == Gesture::Possible) )
197 application.ProcessEvent(GeneratePan(state, last, pos, 16));
204 * Simulate time passed by.
206 * @note this will always process at least 1 frame (1/60 sec)
208 * @param application Test application instance
209 * @param duration Time to pass in milliseconds.
210 * @return The actual time passed in milliseconds
212 static int Wait(ToolkitTestApplication& application, int duration = 0)
216 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
218 application.SendNotification();
219 application.Render(RENDER_FRAME_INTERVAL);
220 time += RENDER_FRAME_INTERVAL;
226 Dali::Integration::Point GetPointDownInside( Vector2& pos )
228 Dali::Integration::Point point;
229 point.SetState( PointState::DOWN );
230 point.SetScreenPosition( pos );
234 Dali::Integration::Point GetPointUpInside( Vector2& pos )
236 Dali::Integration::Point point;
237 point.SetState( PointState::UP );
238 point.SetScreenPosition( pos );
242 struct CallbackFunctor
244 CallbackFunctor(bool* callbackFlag)
245 : mCallbackFlag( callbackFlag )
251 *mCallbackFlag = true;
256 static void TestTextChangedCallback( TextField control )
258 tet_infoline(" TestTextChangedCallback");
260 gTextChangedCallBackCalled = true;
263 static void TestMaxLengthReachedCallback( TextField control )
265 tet_infoline(" TestMaxLengthReachedCallback");
267 gMaxCharactersCallBackCalled = true;
270 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
272 tet_infoline(" TestInputStyleChangedCallback");
274 gInputStyleChangedCallbackCalled = true;
275 gInputStyleMask = mask;
278 // Generate a TapGestureEvent to send to Core.
279 Integration::TapGestureEvent GenerateTap(
280 Gesture::State state,
281 unsigned int numberOfTaps,
282 unsigned int numberOfTouches,
285 Integration::TapGestureEvent tap( state );
287 tap.numberOfTaps = numberOfTaps;
288 tap.numberOfTouches = numberOfTouches;
294 Integration::LongPressGestureEvent GenerateLongPress(
295 Gesture::State state,
296 unsigned int numberOfTouches,
299 Integration::LongPressGestureEvent longPress( state );
301 longPress.numberOfTouches = numberOfTouches;
302 longPress.point = point;
306 // Generate a KeyEvent to send to Core.
307 Integration::KeyEvent GenerateKey( const std::string& keyName,
308 const std::string& keyString,
311 unsigned long timeStamp,
312 const Integration::KeyEvent::State& keyState,
313 const std::string& compose = "",
314 const std::string& deviceName = DEFAULT_DEVICE_NAME,
315 const Device::Class::Type& deviceClass = Device::Class::NONE,
316 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
318 return Integration::KeyEvent( keyName,
330 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
332 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
334 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
336 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
338 Property::Value* valueSet = NULL;
339 if ( valueGet.first.type == Property::Key::INDEX )
341 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
345 // Get Key is a string so searching Set Map for a string key
346 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
349 if( NULL != valueSet )
351 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
353 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
356 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
358 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
361 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
363 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
366 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
368 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
371 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
373 Vector2 vector2Get = valueGet.second.Get<Vector2>();
374 Vector2 vector2Set = valueSet->Get<Vector2>();
375 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
378 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
380 Vector4 vector4Get = valueGet.second.Get<Vector4>();
381 Vector4 vector4Set = valueSet->Get<Vector4>();
382 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 );
388 if ( valueGet.first.type == Property::Key::INDEX )
390 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
394 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
406 int UtcDaliToolkitTextFieldConstructorP(void)
408 ToolkitTestApplication application;
409 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
411 DALI_TEST_CHECK( !textField );
415 int UtcDaliToolkitTextFieldNewP(void)
417 ToolkitTestApplication application;
418 tet_infoline(" UtcDaliToolkitTextFieldNewP");
419 TextField textField = TextField::New();
420 DALI_TEST_CHECK( textField );
424 int UtcDaliToolkitTextFieldDownCastP(void)
426 ToolkitTestApplication application;
427 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
428 TextField textField1 = TextField::New();
429 BaseHandle object( textField1 );
431 TextField textField2 = TextField::DownCast( object );
432 DALI_TEST_CHECK( textField2 );
434 TextField textField3 = DownCast< TextField >( object );
435 DALI_TEST_CHECK( textField3 );
439 int UtcDaliToolkitTextFieldDownCastN(void)
441 ToolkitTestApplication application;
442 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
443 BaseHandle uninitializedObject;
444 TextField textField1 = TextField::DownCast( uninitializedObject );
445 DALI_TEST_CHECK( !textField1 );
447 TextField textField2 = DownCast< TextField >( uninitializedObject );
448 DALI_TEST_CHECK( !textField2 );
452 int UtcDaliToolkitTextFieldCopyConstructorP(void)
454 ToolkitTestApplication application;
455 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
456 TextField textField = TextField::New();
457 textField.SetProperty( TextField::Property::TEXT, "Test" );
459 TextField copy( textField );
460 DALI_TEST_CHECK( copy );
461 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
465 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
467 ToolkitTestApplication application;
468 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
469 TextField textField = TextField::New();
470 textField.SetProperty( TextField::Property::TEXT, "Test" );
472 TextField copy = textField;
473 DALI_TEST_CHECK( copy );
474 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
478 int UtcDaliTextFieldNewP(void)
480 ToolkitTestApplication application;
481 tet_infoline(" UtcDaliToolkitTextFieldNewP");
482 TextField textField = TextField::New();
483 DALI_TEST_CHECK( textField );
487 // Positive test case for a method
488 int UtcDaliTextFieldGetPropertyP(void)
490 ToolkitTestApplication application;
491 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
492 TextField field = TextField::New();
493 DALI_TEST_CHECK( field );
495 // Check Property Indices are correct
496 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
497 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
498 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
499 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
500 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
501 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
502 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
503 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
504 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
505 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
506 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
507 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
508 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
509 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
510 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
511 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
512 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
513 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
514 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
515 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
516 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
517 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
518 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
519 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
520 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
521 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
522 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
523 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
524 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
525 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
526 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
527 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
528 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
529 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
530 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
531 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
532 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
533 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
534 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
535 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
536 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
537 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
538 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
539 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
540 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
541 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
542 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
543 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
544 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
545 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
546 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
547 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
548 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
553 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
556 Property::Map imageMap;
557 imageMap[mapKey] =mapValue;
559 field.SetProperty( property , imageMap );
560 Property::Value propValue = field.GetProperty( property );
561 Property::Map* resultMap = propValue.GetMap();
563 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
571 // Positive test case for a method
572 int UtcDaliTextFieldSetPropertyP(void)
574 ToolkitTestApplication application;
575 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
576 TextField field = TextField::New();
577 DALI_TEST_CHECK( field );
578 Stage::GetCurrent().Add( field );
580 // Note - we can't check the defaults since the stylesheets are platform-specific
582 // Check the render backend property.
583 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
584 DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
586 // Check text property.
587 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
588 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
590 // Check placeholder text properties.
591 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
592 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
594 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
595 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
597 // Check font properties.
598 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
599 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
601 Property::Map fontStyleMapSet;
602 Property::Map fontStyleMapGet;
603 Property::Value* slantValue = NULL;
605 fontStyleMapSet.Insert( "weight", "bold" );
606 fontStyleMapSet.Insert( "width", "condensed" );
607 fontStyleMapSet.Insert( "slant", "italic" );
608 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
610 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
611 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
612 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
614 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
615 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
618 fontStyleMapSet.Clear();
619 fontStyleMapSet.Insert( "weight", "normal" );
620 fontStyleMapSet.Insert( "slant", "oblique" );
621 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
623 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
624 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
625 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
627 fontStyleMapSet.Clear();
628 fontStyleMapSet.Insert( "slant", "roman" );
629 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
630 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
632 // Replace 'roman' for 'normal'.
633 slantValue = fontStyleMapGet.Find( "slant" );
634 if( NULL != slantValue )
636 if( "normal" == slantValue->Get<std::string>() )
638 fontStyleMapGet["slant"] = "roman";
641 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
642 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
644 fontStyleMapSet.Clear();
646 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
647 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
648 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
649 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
651 // Check that the MAX_LENGTH property can be correctly set
652 const int maxNumberOfCharacters = 20;
653 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
654 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
656 // Check exceed policy
657 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
658 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
659 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
660 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
662 // Check that the Alignment properties can be correctly set
663 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
664 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
665 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
666 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
668 // Check text's color property
669 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
670 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
672 // Check placeholder text's color property.
673 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
674 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
676 // Check cursor properties
677 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
678 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
679 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
680 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
682 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
683 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
684 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
685 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
686 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
687 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
688 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
689 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
691 // Check scroll properties.
692 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
693 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
694 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
695 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
697 // Check handle images
698 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
699 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
700 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
701 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
702 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
704 // Check handle images
705 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
706 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
707 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
708 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
709 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
710 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
712 // Check the highlight color
713 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
714 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
716 // Decoration bounding box
717 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
718 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
720 // Check the input method setting
721 Property::Map propertyMap;
722 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
723 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
724 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
725 int inputVariation = 1;
726 propertyMap["PANEL_LAYOUT"] = panelLayout;
727 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
728 propertyMap["BUTTON_ACTION"] = buttonAction;
729 propertyMap["VARIATION"] = inputVariation;
730 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
732 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
734 DALI_TEST_CHECK( value.Get( map ) );
737 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
738 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
741 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
742 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
745 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
746 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
749 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
750 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
752 // Check input color property.
753 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
754 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
756 // Check the enable markup property.
757 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
758 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
759 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
761 // Check input font properties.
762 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
763 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
765 fontStyleMapSet.Clear();
766 fontStyleMapSet.Insert( "weight", "bold" );
767 fontStyleMapSet.Insert( "width", "condensed" );
768 fontStyleMapSet.Insert( "slant", "italic" );
770 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
771 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
772 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
773 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
775 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
776 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
778 // Reset input font style.
779 fontStyleMapSet.Clear();
780 fontStyleMapSet.Insert( "weight", "normal" );
781 fontStyleMapSet.Insert( "slant", "oblique" );
783 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
784 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
785 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
786 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
788 fontStyleMapSet.Clear();
789 fontStyleMapSet.Insert( "slant", "roman" );
791 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
792 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
794 // Replace 'roman' for 'normal'.
795 slantValue = fontStyleMapGet.Find( "slant" );
796 if( NULL != slantValue )
798 if( "normal" == slantValue->Get<std::string>() )
800 fontStyleMapGet["slant"] = "roman";
803 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
804 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
806 fontStyleMapSet.Clear();
808 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
809 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
810 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
811 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
813 Property::Map underlineMapSet;
814 Property::Map underlineMapGet;
816 underlineMapSet.Insert( "enable", "true" );
817 underlineMapSet.Insert( "color", "red" );
818 underlineMapSet.Insert( "height", "1" );
820 // Check the underline property
821 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
823 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
824 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
825 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
827 // Check the input underline property
828 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
829 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
831 // Check the shadow property
832 Property::Map shadowMapSet;
833 Property::Map shadowMapGet;
835 shadowMapSet.Insert( "color", Color::GREEN );
836 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
837 shadowMapSet.Insert( "blurRadius", 3.0f );
839 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
841 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
842 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
843 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
845 // Check the input shadow property
846 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
847 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
849 // Check the emboss property
850 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
851 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
853 // Check the input emboss property
854 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
855 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
857 // Check the outline property
859 // Test string type first
860 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
861 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
862 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
864 // Then test the property map type
865 Property::Map outlineMapSet;
866 Property::Map outlineMapGet;
868 outlineMapSet["color"] = Color::RED;
869 outlineMapSet["width"] = 2.0f;
871 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
873 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
874 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
875 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
877 // Check the input outline property
878 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
879 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
881 // Check the hidden input settings property
882 Property::Map hiddenMapSet;
883 Property::Map hiddenMapGet;
884 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
885 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
886 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
887 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
888 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
890 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
891 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
892 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
894 // Check the pixel size of font
895 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
896 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
898 // Check the enable selection property
899 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
900 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
902 // Check the placeholder property with pixel size
903 Property::Map placeholderPixelSizeMapSet;
904 Property::Map placeholderPixelSizeMapGet;
905 Property::Map placeholderFontstyleMap;
906 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
907 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
908 placeholderPixelSizeMapSet["color"] = Color::BLUE;
909 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
910 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
911 placeholderPixelSizeMapSet["ellipsis"] = true;
913 placeholderFontstyleMap.Insert( "weight", "bold" );
914 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
915 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
917 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
918 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
920 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
921 Property::Map placeholderConversionMap;
922 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
923 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
924 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
925 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
926 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
927 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
929 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
931 // Check the placeholder property with point size
932 Property::Map placeholderMapSet;
933 Property::Map placeholderMapGet;
934 placeholderMapSet["text"] = "Setting Placeholder Text";
935 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
936 placeholderMapSet["color"] = Color::RED;
937 placeholderMapSet["fontFamily"] = "Arial";
938 placeholderMapSet["pointSize"] = 12.0f;
939 placeholderMapSet["ellipsis"] = false;
941 // Check the placeholder font style property
942 placeholderFontstyleMap.Clear();
944 placeholderFontstyleMap.Insert( "weight", "bold" );
945 placeholderFontstyleMap.Insert( "width", "condensed" );
946 placeholderFontstyleMap.Insert( "slant", "italic" );
947 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
948 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
950 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
951 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
953 placeholderConversionMap.Clear();
954 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
955 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
956 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
957 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
958 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
959 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
961 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
964 placeholderFontstyleMap.Clear();
965 placeholderFontstyleMap.Insert( "weight", "normal" );
966 placeholderFontstyleMap.Insert( "slant", "oblique" );
967 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
968 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
970 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
971 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
973 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
974 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
976 placeholderFontstyleMap.Clear();
977 placeholderFontstyleMap.Insert( "slant", "roman" );
978 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
979 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
981 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
983 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
985 placeholderFontstyleMap.Clear();
986 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
987 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
989 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
990 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
991 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
993 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
995 // Check the ellipsis property
996 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
997 field.SetProperty( TextField::Property::ELLIPSIS, true );
998 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1000 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
1001 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1003 application.SendNotification();
1004 application.Render();
1009 // Positive Atlas Text Renderer test
1010 int utcDaliTextFieldAtlasRenderP(void)
1012 ToolkitTestApplication application;
1013 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1014 StyleManager styleManager = StyleManager::Get();
1015 styleManager.ApplyDefaultTheme();
1016 TextField field = TextField::New();
1017 DALI_TEST_CHECK( field );
1019 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1021 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1023 Stage::GetCurrent().Add( field );
1027 // Render some text with the shared atlas backend
1028 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
1029 application.SendNotification();
1030 application.Render();
1034 tet_result(TET_FAIL);
1039 // Positive test for the textChanged signal.
1040 int utcDaliTextFieldTextChangedP(void)
1042 ToolkitTestApplication application;
1043 tet_infoline(" utcDaliTextFieldTextChangedP");
1044 TextField field = TextField::New();
1045 DALI_TEST_CHECK( field );
1047 Stage::GetCurrent().Add( field );
1049 // connect to the text changed signal.
1050 ConnectionTracker* testTracker = new ConnectionTracker();
1051 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1052 bool textChangedSignal = false;
1053 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1055 gTextChangedCallBackCalled = false;
1056 field.SetProperty( TextField::Property::TEXT, "ABC" );
1057 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1058 DALI_TEST_CHECK( textChangedSignal );
1060 application.SendNotification();
1062 field.SetKeyInputFocus();
1064 gTextChangedCallBackCalled = false;
1065 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1066 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1071 // Negative test for the textChanged signal.
1072 int utcDaliTextFieldTextChangedN(void)
1074 ToolkitTestApplication application;
1075 tet_infoline(" utcDaliTextFieldTextChangedN");
1076 TextField field = TextField::New();
1077 DALI_TEST_CHECK( field );
1079 Stage::GetCurrent().Add( field );
1081 // connect to the text changed signal.
1082 ConnectionTracker* testTracker = new ConnectionTracker();
1083 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1084 bool textChangedSignal = false;
1085 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1087 gTextChangedCallBackCalled = false;
1088 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1089 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1090 DALI_TEST_CHECK( !textChangedSignal );
1095 // Positive test for Max Characters reached signal.
1096 int utcDaliTextFieldMaxCharactersReachedP(void)
1098 ToolkitTestApplication application;
1099 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1100 TextField field = TextField::New();
1101 DALI_TEST_CHECK( field );
1103 Stage::GetCurrent().Add( field );
1105 const int maxNumberOfCharacters = 1;
1106 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1108 field.SetKeyInputFocus();
1110 // connect to the text changed signal.
1111 ConnectionTracker* testTracker = new ConnectionTracker();
1112 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1113 bool maxLengthReachedSignal = false;
1114 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1116 gMaxCharactersCallBackCalled = false;
1118 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1119 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1121 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1122 DALI_TEST_CHECK( maxLengthReachedSignal );
1127 // Negative test for Max Characters reached signal.
1128 int utcDaliTextFieldMaxCharactersReachedN(void)
1130 ToolkitTestApplication application;
1131 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1132 TextField field = TextField::New();
1133 DALI_TEST_CHECK( field );
1135 Stage::GetCurrent().Add( field );
1137 const int maxNumberOfCharacters = 3;
1138 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1140 field.SetKeyInputFocus();
1142 // connect to the text changed signal.
1143 ConnectionTracker* testTracker = new ConnectionTracker();
1144 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1145 bool maxLengthReachedSignal = false;
1146 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1148 gMaxCharactersCallBackCalled = false;
1150 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1151 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1153 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1154 DALI_TEST_CHECK( !maxLengthReachedSignal );
1156 application.ProcessEvent( GenerateKey( "Return", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::Down, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1158 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1159 DALI_TEST_CHECK( !maxLengthReachedSignal );
1164 int utcDaliTextFieldInputStyleChanged01(void)
1166 ToolkitTestApplication application;
1167 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1169 // The text-field emits signals when the input style changes. These changes of style are
1170 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1171 // can't be emitted during the size negotiation as the callbacks may update the UI.
1172 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1173 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1174 application.CreateAdaptor();
1178 char* pathNamePtr = get_current_dir_name();
1179 const std::string pathName( pathNamePtr );
1180 free( pathNamePtr );
1182 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1183 fontClient.SetDpi( 93u, 93u );
1185 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1186 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1188 TextField field = TextField::New();
1189 DALI_TEST_CHECK( field );
1192 field.SetSize( 300.f, 50.f );
1193 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1194 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1196 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1197 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1199 // connect to the text changed signal.
1200 ConnectionTracker* testTracker = new ConnectionTracker();
1201 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1202 bool inputStyleChangedSignal = false;
1203 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1205 Stage::GetCurrent().Add( field );
1207 // Render and notify
1208 application.SendNotification();
1209 application.Render();
1211 // Executes the idle callbacks added by the text control on the change of input style.
1212 application.RunIdles();
1214 gInputStyleChangedCallbackCalled = false;
1215 gInputStyleMask = TextField::InputStyle::NONE;
1216 inputStyleChangedSignal = false;
1218 // Create a tap event to touch the text field.
1219 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1220 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1222 // Render and notify
1223 application.SendNotification();
1224 application.Render();
1226 // Executes the idle callbacks added by the text control on the change of input style.
1227 application.RunIdles();
1229 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1230 if( gInputStyleChangedCallbackCalled )
1232 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1234 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1235 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1237 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1238 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1240 DALI_TEST_CHECK( inputStyleChangedSignal );
1242 gInputStyleChangedCallbackCalled = false;
1243 gInputStyleMask = TextField::InputStyle::NONE;
1244 inputStyleChangedSignal = false;
1246 // Create a tap event to touch the text field.
1247 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1248 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1250 // Render and notify
1251 application.SendNotification();
1252 application.Render();
1254 // Executes the idle callbacks added by the text control on the change of input style.
1255 application.RunIdles();
1257 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1258 DALI_TEST_CHECK( !inputStyleChangedSignal );
1260 gInputStyleChangedCallbackCalled = false;
1261 gInputStyleMask = TextField::InputStyle::NONE;
1262 inputStyleChangedSignal = false;
1264 // Create a tap event to touch the text field.
1265 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1266 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1268 // Render and notify
1269 application.SendNotification();
1270 application.Render();
1272 // Executes the idle callbacks added by the text control on the change of input style.
1273 application.RunIdles();
1275 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1276 if( gInputStyleChangedCallbackCalled )
1278 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1280 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1281 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1283 DALI_TEST_CHECK( inputStyleChangedSignal );
1285 gInputStyleChangedCallbackCalled = false;
1286 gInputStyleMask = TextField::InputStyle::NONE;
1287 inputStyleChangedSignal = false;
1289 // Create a tap event to touch the text field.
1290 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1291 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1293 // Render and notify
1294 application.SendNotification();
1295 application.Render();
1297 // Executes the idle callbacks added by the text control on the change of input style.
1298 application.RunIdles();
1300 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1301 if( gInputStyleChangedCallbackCalled )
1303 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1305 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1306 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1308 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1310 Property::Map fontStyleMapSet;
1311 fontStyleMapSet.Insert( "weight", "bold" );
1313 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1314 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1316 DALI_TEST_CHECK( inputStyleChangedSignal );
1318 gInputStyleChangedCallbackCalled = false;
1319 gInputStyleMask = TextField::InputStyle::NONE;
1320 inputStyleChangedSignal = false;
1322 // Create a tap event to touch the text field.
1323 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1324 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1326 // Render and notify
1327 application.SendNotification();
1328 application.Render();
1330 // Executes the idle callbacks added by the text control on the change of input style.
1331 application.RunIdles();
1333 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1334 DALI_TEST_CHECK( !inputStyleChangedSignal );
1336 gInputStyleChangedCallbackCalled = false;
1337 gInputStyleMask = TextField::InputStyle::NONE;
1338 inputStyleChangedSignal = false;
1340 // Create a tap event to touch the text field.
1341 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1342 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1344 // Render and notify
1345 application.SendNotification();
1346 application.Render();
1348 // Executes the idle callbacks added by the text control on the change of input style.
1349 application.RunIdles();
1351 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1352 if( gInputStyleChangedCallbackCalled )
1354 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1356 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1357 DALI_TEST_CHECK( style.empty() );
1359 DALI_TEST_CHECK( inputStyleChangedSignal );
1361 gInputStyleChangedCallbackCalled = false;
1362 gInputStyleMask = TextField::InputStyle::NONE;
1363 inputStyleChangedSignal = false;
1365 // Create a tap event to touch the text field.
1366 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1367 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1369 // Render and notify
1370 application.SendNotification();
1371 application.Render();
1373 // Executes the idle callbacks added by the text control on the change of input style.
1374 application.RunIdles();
1376 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1377 DALI_TEST_CHECK( !inputStyleChangedSignal );
1382 int utcDaliTextFieldInputStyleChanged02(void)
1384 ToolkitTestApplication application;
1385 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1387 // The text-field emits signals when the input style changes. These changes of style are
1388 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1389 // can't be emitted during the size negotiation as the callbacks may update the UI.
1390 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1391 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1392 application.CreateAdaptor();
1396 char* pathNamePtr = get_current_dir_name();
1397 const std::string pathName( pathNamePtr );
1398 free( pathNamePtr );
1400 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1401 fontClient.SetDpi( 93u, 93u );
1403 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1404 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1406 TextField field = TextField::New();
1407 DALI_TEST_CHECK( field );
1410 field.SetSize( 300.f, 50.f );
1411 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1412 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1414 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1415 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='blue'> l</color><color value='green'>lo</color> <font weight='bold'>world</font> demo</font>" );
1417 // connect to the text changed signal.
1418 ConnectionTracker* testTracker = new ConnectionTracker();
1419 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1420 bool inputStyleChangedSignal = false;
1421 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1423 Stage::GetCurrent().Add( field );
1425 // Render and notify
1426 application.SendNotification();
1427 application.Render();
1429 // Executes the idle callbacks added by the text control on the change of input style.
1430 application.RunIdles();
1432 gInputStyleChangedCallbackCalled = false;
1433 gInputStyleMask = TextField::InputStyle::NONE;
1434 inputStyleChangedSignal = false;
1436 // Create a tap event to touch the text field.
1437 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1438 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1439 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1440 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1442 // Render and notify
1443 application.SendNotification();
1444 application.Render();
1446 // Executes the idle callbacks added by the text control on the change of input style.
1447 application.RunIdles();
1449 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1450 if( gInputStyleChangedCallbackCalled )
1452 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1453 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1454 TextField::InputStyle::POINT_SIZE |
1455 TextField::InputStyle::COLOR ),
1458 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1459 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1461 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1462 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1464 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1465 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1467 DALI_TEST_CHECK( inputStyleChangedSignal );
1469 gInputStyleChangedCallbackCalled = false;
1470 gInputStyleMask = TextField::InputStyle::NONE;
1471 inputStyleChangedSignal = false;
1473 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1475 // Render and notify
1476 application.SendNotification();
1477 application.Render();
1479 // Executes the idle callbacks added by the text control on the change of input style.
1480 application.RunIdles();
1482 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1483 if( gInputStyleChangedCallbackCalled )
1485 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1486 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1489 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1490 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1492 DALI_TEST_CHECK( inputStyleChangedSignal );
1494 gInputStyleChangedCallbackCalled = false;
1495 gInputStyleMask = TextField::InputStyle::NONE;
1496 inputStyleChangedSignal = false;
1498 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1500 // Render and notify
1501 application.SendNotification();
1502 application.Render();
1504 // Executes the idle callbacks added by the text control on the change of input style.
1505 application.RunIdles();
1507 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1508 DALI_TEST_CHECK( !inputStyleChangedSignal );
1510 gInputStyleChangedCallbackCalled = false;
1511 gInputStyleMask = TextField::InputStyle::NONE;
1512 inputStyleChangedSignal = false;
1514 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1516 // Render and notify
1517 application.SendNotification();
1518 application.Render();
1520 // Executes the idle callbacks added by the text control on the change of input style.
1521 application.RunIdles();
1523 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1524 if( gInputStyleChangedCallbackCalled )
1526 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1527 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1530 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1531 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1533 DALI_TEST_CHECK( inputStyleChangedSignal );
1535 gInputStyleChangedCallbackCalled = false;
1536 gInputStyleMask = TextField::InputStyle::NONE;
1537 inputStyleChangedSignal = false;
1539 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1541 Property::Map fontStyleMapSet;
1542 fontStyleMapSet.Insert( "weight", "thin" );
1543 fontStyleMapSet.Insert( "width", "condensed" );
1544 fontStyleMapSet.Insert( "slant", "italic" );
1546 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1547 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1549 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1550 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1551 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1552 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1554 // Render and notify
1555 application.SendNotification();
1556 application.Render();
1558 // Executes the idle callbacks added by the text control on the change of input style.
1559 application.RunIdles();
1561 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1562 DALI_TEST_CHECK( !inputStyleChangedSignal );
1564 // Create a tap event to touch the text field.
1565 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1566 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1568 // Render and notify
1569 application.SendNotification();
1570 application.Render();
1572 // Executes the idle callbacks added by the text control on the change of input style.
1573 application.RunIdles();
1575 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1576 if( gInputStyleChangedCallbackCalled )
1578 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1579 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1580 TextField::InputStyle::POINT_SIZE |
1581 TextField::InputStyle::FONT_STYLE |
1582 TextField::InputStyle::UNDERLINE |
1583 TextField::InputStyle::SHADOW |
1584 TextField::InputStyle::EMBOSS |
1585 TextField::InputStyle::OUTLINE ),
1588 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1589 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1591 DALI_TEST_CHECK( inputStyleChangedSignal );
1596 int utcDaliTextFieldEvent01(void)
1598 ToolkitTestApplication application;
1599 tet_infoline(" utcDaliTextFieldEvent01");
1601 // Creates a tap event. After creating a tap event the text field should
1602 // have the focus and add text with key events should be possible.
1604 TextField field = TextField::New();
1605 DALI_TEST_CHECK( field );
1607 Stage::GetCurrent().Add( field );
1609 field.SetSize( 300.f, 50.f );
1610 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1611 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1613 // Avoid a crash when core load gl resources.
1614 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1616 // Render and notify
1617 application.SendNotification();
1618 application.Render();
1620 // Add a key event but as the text field has not the focus it should do nothing.
1621 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1623 // Render and notify
1624 application.SendNotification();
1625 application.Render();
1627 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1629 // Create a tap event to touch the text field.
1630 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1631 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1633 // Render and notify
1634 application.SendNotification();
1635 application.Render();
1637 // Pressing delete key should be fine even if there is no text in TextField.
1638 application.ProcessEvent( GenerateKey( "Delete", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::Down, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1639 // Render and notify
1640 application.SendNotification();
1641 application.Render();
1643 // Now the text field has the focus, so it can handle the key events.
1644 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1645 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1647 // Render and notify
1648 application.SendNotification();
1649 application.Render();
1651 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1653 // Create a second text field and send key events to it.
1654 TextField field2 = TextField::New();
1656 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1657 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1658 field2.SetSize( 100.f, 100.f );
1659 field2.SetPosition( 100.f, 100.f );
1661 Stage::GetCurrent().Add( field2 );
1663 // Render and notify
1664 application.SendNotification();
1665 application.Render();
1667 // Create a tap event on the second text field.
1668 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1669 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1671 // Render and notify
1672 application.SendNotification();
1673 application.Render();
1675 // The second text field has the focus. It should handle the key events.
1676 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1677 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1679 // Render and notify
1680 application.SendNotification();
1681 application.Render();
1683 // Check the text has been added to the second text field.
1684 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1689 int utcDaliTextFieldEvent02(void)
1691 ToolkitTestApplication application;
1692 tet_infoline(" utcDaliTextFieldEvent02");
1694 // Checks if the right number of actors are created.
1696 TextField field = TextField::New();
1697 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1698 DALI_TEST_CHECK( field );
1699 LoadMarkerImages(application, field);
1701 Stage::GetCurrent().Add( field );
1703 field.SetSize( 300.f, 50.f );
1704 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1705 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1707 // Avoid a crash when core load gl resources.
1708 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1710 // Render and notify
1711 application.SendNotification();
1712 application.Render();
1714 // Check there are the expected number of children ( stencil ).
1715 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1717 Actor stencil = field.GetChildAt( 0u );
1718 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1720 // Create a tap event to touch the text field.
1721 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1722 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1724 // Render and notify
1725 application.SendNotification();
1726 application.Render();
1728 Actor layer = field.GetChildAt( 1u );
1729 DALI_TEST_CHECK( layer.IsLayer() );
1731 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1732 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1734 // Now the text field has the focus, so it can handle the key events.
1735 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1736 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1738 // Render and notify
1739 application.SendNotification();
1740 application.Render();
1742 // Checks the cursor and the renderer have been created.
1743 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1744 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1746 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1747 DALI_TEST_CHECK( cursor );
1749 // The offscreen root actor has a container with all the actors which contain the text renderers.
1750 Actor container = stencil.GetChildAt( 0u );
1751 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1753 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1754 DALI_TEST_CHECK( renderer );
1757 // Move the cursor and check the position changes.
1758 Vector3 position1 = cursor.GetCurrentPosition();
1760 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1761 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1763 // Render and notify
1764 application.SendNotification();
1765 application.Render();
1767 Vector3 position2 = cursor.GetCurrentPosition();
1769 DALI_TEST_CHECK( position2.x < position1.x );
1771 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1772 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1774 // Render and notify
1775 application.SendNotification();
1776 application.Render();
1778 Vector3 position3 = cursor.GetCurrentPosition();
1780 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1782 // Send some taps and check the cursor positions.
1784 // Try to tap at the beginning.
1785 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1786 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1788 // Render and notify
1789 application.SendNotification();
1790 application.Render();
1792 // Cursor position should be the same than position1.
1793 Vector3 position4 = cursor.GetCurrentPosition();
1795 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1797 // Tap away from the start position.
1798 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1799 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1801 // Render and notify
1802 application.SendNotification();
1803 application.Render();
1805 Vector3 position5 = cursor.GetCurrentPosition();
1807 DALI_TEST_CHECK( position5.x > position4.x );
1809 // Remove all the text.
1810 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1811 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1812 field.SetProperty( TextField::Property::TEXT, "" );
1814 // Render and notify
1815 application.SendNotification();
1816 application.Render();
1818 // Cursor position should be the same than position2.
1819 Vector3 position6 = cursor.GetCurrentPosition();
1821 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1823 // Should not be a renderer.
1824 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1826 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1827 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1828 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1830 application.SendNotification();
1831 application.Render();
1833 // There are renderer and decorator layer
1834 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1839 int utcDaliTextFieldEvent03(void)
1841 ToolkitTestApplication application;
1842 tet_infoline(" utcDaliTextFieldEvent03");
1844 // Checks if the highlight actor is created.
1846 TextField field = TextField::New();
1847 DALI_TEST_CHECK( field );
1849 Stage::GetCurrent().Add( field );
1851 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1852 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1853 field.SetSize( 30.f, 50.f );
1854 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1855 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1857 // Avoid a crash when core load gl resources.
1858 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1859 LoadMarkerImages(application, field);
1861 // Render and notify
1862 application.SendNotification();
1863 application.Render();
1865 // Tap first to get the focus.
1866 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1867 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1869 // Render and notify
1870 application.SendNotification();
1871 application.Render();
1873 // Double tap to select a word.
1874 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1875 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1877 // Render and notify
1878 application.SendNotification();
1879 application.Render();
1881 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1882 Actor stencil = field.GetChildAt( 0u );
1884 // The highlight actor is drawn first, so is the first actor in the list
1885 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1886 DALI_TEST_CHECK( highlight );
1888 // The offscreen root actor has a container with all the actors which contain the text renderers.
1889 Actor container = stencil.GetChildAt( 1u );
1890 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1892 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1893 DALI_TEST_CHECK( renderer );
1899 int utcDaliTextFieldEvent04(void)
1901 ToolkitTestApplication application;
1902 tet_infoline(" utcDaliTextFieldEvent04");
1904 // Checks if the highlight actor is created.
1906 TextField field = TextField::New();
1907 DALI_TEST_CHECK( field );
1908 Stage::GetCurrent().Add( field );
1909 LoadMarkerImages(application, field);
1910 // Render and notify
1911 application.SendNotification();
1912 application.Render();
1914 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1915 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1916 field.SetSize( 300.f, 50.f );
1917 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1918 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1920 // Avoid a crash when core load gl resources.
1921 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1922 // Render and notify
1923 application.SendNotification();
1924 application.Render();
1926 // Create a tap event to touch the text field.
1927 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1928 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1929 // Render and notify
1930 application.SendNotification();
1931 application.Render();
1934 // Tap first to get the focus.
1935 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1936 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1938 // Render and notify
1939 application.SendNotification();
1940 application.Render();
1942 // Double tap to select a word.
1943 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1944 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1946 // Render and notify
1947 application.SendNotification();
1948 application.Render();
1951 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1952 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1956 int utcDaliTextFieldEvent05(void)
1958 ToolkitTestApplication application;
1959 tet_infoline(" utcDaliTextFieldEvent05");
1961 // Checks dragging of cursor/grab handle
1963 TextField field = TextField::New();
1964 DALI_TEST_CHECK( field );
1965 Stage::GetCurrent().Add( field );
1966 LoadMarkerImages(application, field);
1967 // Render and notify
1968 application.SendNotification();
1969 application.Render();
1971 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1972 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1973 field.SetSize( 300.f, 50.f );
1974 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1975 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1977 // Avoid a crash when core load gl resources.
1978 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1979 // Render and notify
1980 application.SendNotification();
1981 application.Render();
1983 // Create a tap event to touch the text field.
1984 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1985 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1986 // Render and notify
1987 application.SendNotification();
1988 application.Render();
1990 // Tap first to get the focus.
1991 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1992 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1994 // Render and notify
1995 application.SendNotification();
1996 application.Render();
1998 // Double tap to select a word.
1999 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2000 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2002 // Render and notify
2003 application.SendNotification();
2004 application.Render();
2006 // drag grab handle right
2007 Vector2 pos(0.0f, 40.0f);
2008 SendPan(application, Gesture::Possible, pos);
2009 SendPan(application, Gesture::Started, pos);
2011 Wait(application, 100);
2013 for(int i = 0;i<20;i++)
2015 SendPan(application, Gesture::Continuing, pos);
2020 SendPan(application, Gesture::Finished, pos);
2021 Wait(application, RENDER_FRAME_INTERVAL);
2023 Actor stencil = field.GetChildAt( 1u );
2027 int utcDaliTextFieldEvent06(void)
2029 ToolkitTestApplication application;
2030 tet_infoline(" utcDaliTextFieldEvent06");
2032 // Checks Longpress when in edit mode
2034 TextField field = TextField::New();
2035 DALI_TEST_CHECK( field );
2036 Stage::GetCurrent().Add( field );
2037 LoadMarkerImages(application, field);
2038 // Render and notify
2039 application.SendNotification();
2040 application.Render();
2042 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2043 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2044 field.SetSize( 300.f, 50.f );
2045 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2046 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2048 // Avoid a crash when core load gl resources.
2049 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2050 // Render and notify
2051 application.SendNotification();
2052 application.Render();
2054 // Create a tap event to touch the text field.
2055 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2056 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2057 // Render and notify
2058 application.SendNotification();
2059 application.Render();
2062 // Tap first to get the focus.
2063 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2064 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2066 // Render and notify
2067 application.SendNotification();
2068 application.Render();
2071 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2072 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2074 // Render and notify
2075 application.SendNotification();
2076 application.Render();
2081 int utcDaliTextFieldEvent07(void)
2083 ToolkitTestApplication application;
2084 tet_infoline(" utcDaliTextFieldEvent07");
2086 // Checks Longpress to start edit mode
2088 TextField field = TextField::New();
2089 DALI_TEST_CHECK( field );
2090 Stage::GetCurrent().Add( field );
2091 LoadMarkerImages(application, field);
2092 // Render and notify
2093 application.SendNotification();
2094 application.Render();
2096 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2097 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2098 field.SetSize( 300.f, 50.f );
2099 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2100 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2101 Property::Map propertyMap;
2102 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2103 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2105 // Avoid a crash when core load gl resources.
2106 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2107 // Render and notify
2108 application.SendNotification();
2109 application.Render();
2112 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2113 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2115 // Render and notify
2116 application.SendNotification();
2117 application.Render();
2122 int utcDaliTextFieldEvent08(void)
2124 ToolkitTestApplication application;
2125 tet_infoline(" utcDaliTextFieldEvent08");
2127 Dali::Clipboard clipboard = Clipboard::Get();
2128 clipboard.SetItem("testTextFieldEvent");
2130 // Checks Longpress when only place holder text
2132 TextField field = TextField::New();
2133 DALI_TEST_CHECK( field );
2134 Stage::GetCurrent().Add( field );
2135 LoadMarkerImages(application, field);
2136 // Render and notify
2137 application.SendNotification();
2138 application.Render();
2140 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2141 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2142 field.SetSize( 300.f, 50.f );
2143 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2144 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2146 // Avoid a crash when core load gl resources.
2147 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2148 // Render and notify
2149 application.SendNotification();
2150 application.Render();
2153 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2154 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2156 // Render and notify
2157 application.SendNotification();
2158 application.Render();
2160 Wait(application, 500);
2163 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2164 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2166 // Render and notify
2167 application.SendNotification();
2168 application.Render();
2170 Wait(application, 500);
2172 Stage stage = Stage::GetCurrent();
2173 Layer layer = stage.GetRootLayer();
2174 Actor actor = layer.FindChildByName("optionPaste");
2178 Vector3 worldPosition = actor.GetCurrentWorldPosition();
2179 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2180 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2182 Dali::Integration::TouchEvent event;
2183 event = Dali::Integration::TouchEvent();
2184 event.AddPoint( GetPointDownInside( position ) );
2185 application.ProcessEvent( event );
2187 event = Dali::Integration::TouchEvent();
2188 event.AddPoint( GetPointUpInside( position ) );
2189 application.ProcessEvent( event );
2191 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2196 int utcDaliTextFieldEvent09(void)
2198 ToolkitTestApplication application;
2199 tet_infoline(" utcDaliTextFieldEvent09");
2201 TextField field = TextField::New();
2202 DALI_TEST_CHECK( field );
2203 Stage::GetCurrent().Add( field );
2204 LoadMarkerImages(application, field);
2205 // Render and notify
2206 application.SendNotification();
2207 application.Render();
2209 field.SetProperty( TextField::Property::TEXT, "Hello" );
2210 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2211 field.SetSize( 300.f, 50.f );
2212 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2213 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2215 // Avoid a crash when core load gl resources.
2216 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2218 // Create a tap event to touch the text field.
2219 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2220 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2221 application.SendNotification();
2222 application.Render();
2225 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2226 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2227 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2228 application.SendNotification();
2229 application.Render();
2231 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2232 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2233 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2234 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2235 application.SendNotification();
2236 application.Render();
2238 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2239 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2240 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2241 for( unsigned int index = 0u; index < 5u; ++index )
2243 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2244 application.SendNotification();
2245 application.Render();
2248 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2249 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2250 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2251 for( unsigned int index = 0u; index < 5u; ++index )
2253 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2254 application.SendNotification();
2255 application.Render();
2258 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2259 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2260 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2261 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2262 application.SendNotification();
2263 application.Render();
2264 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2265 application.SendNotification();
2266 application.Render();
2268 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2269 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2270 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2271 application.SendNotification();
2272 application.Render();
2274 Property::Map mapGet;
2275 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2276 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2277 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2282 int utcDaliTextFieldStyleWhilstSelected(void)
2284 ToolkitTestApplication application;
2285 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2287 // Change font and styles whilst text is selected whilst word selected
2289 TextField field = TextField::New();
2290 DALI_TEST_CHECK( field );
2291 Stage::GetCurrent().Add( field );
2292 LoadMarkerImages(application, field);
2293 // Render and notify
2294 application.SendNotification();
2295 application.Render();
2297 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2298 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2299 field.SetSize( 300.f, 50.f );
2300 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2301 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2303 // Avoid a crash when core load gl resources.
2304 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2305 // Render and notify
2306 application.SendNotification();
2307 application.Render();
2309 // Create a tap event to touch the text field.
2310 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2311 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2312 // Render and notify
2313 application.SendNotification();
2314 application.Render();
2317 // Tap first to get the focus.
2318 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2319 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2321 // Render and notify
2322 application.SendNotification();
2323 application.Render();
2325 // Double tap to select a word.
2326 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2327 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2329 // Render and notify
2330 application.SendNotification();
2331 application.Render();
2333 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2334 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2336 Property::Map fontStyleMapSet;
2337 Property::Map fontStyleMapGet;
2339 fontStyleMapSet.Insert( "weight", "bold" );
2340 fontStyleMapSet.Insert( "slant", "italic" );
2341 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2343 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2344 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2345 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2347 fontStyleMapSet.Clear();
2348 fontStyleMapSet.Insert( "width", "expanded" );
2349 fontStyleMapSet.Insert( "slant", "italic" );
2350 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2352 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2353 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2354 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2356 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2357 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2359 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2360 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2362 fontStyleMapSet.Clear();
2363 fontStyleMapSet.Insert( "weight", "bold" );
2364 fontStyleMapSet.Insert( "slant", "italic" );
2366 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2368 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2369 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2370 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2372 fontStyleMapSet.Clear();
2373 fontStyleMapSet.Insert( "width", "expanded" );
2375 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2377 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2378 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2379 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2381 // Press Escape to increase coverage
2382 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2383 application.SendNotification();
2384 application.Render();
2386 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2391 int utcDaliTextFieldEscKeyLoseFocus(void)
2393 ToolkitTestApplication application;
2394 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2396 // Creates a tap event. After creating a tap event the text field should
2397 // have the focus and add text with key events should be possible.
2399 TextField field = TextField::New();
2400 DALI_TEST_CHECK( field );
2402 Stage::GetCurrent().Add( field );
2404 field.SetSize( 300.f, 50.f );
2405 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2406 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2408 // Avoid a crash when core load gl resources.
2409 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2411 // Render and notify
2412 application.SendNotification();
2413 application.Render();
2415 // Add a key event but as the text field has not the focus it should do nothing.
2416 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2417 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2419 // Render and notify
2420 application.SendNotification();
2421 application.Render();
2423 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2425 // Create a tap event to touch the text field.
2426 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2427 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2429 // Render and notify
2430 application.SendNotification();
2431 application.Render();
2433 // Now the text field has the focus, so it can handle the key events.
2434 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2435 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2436 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2437 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2439 // Render and notify
2440 application.SendNotification();
2441 application.Render();
2443 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2445 // Generate a Esc key event. The text field should lose the focus.
2446 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2447 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2449 // Render and notify
2450 application.SendNotification();
2451 application.Render();
2453 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2455 // No more text should be introduced
2456 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2457 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2459 // Render and notify
2460 application.SendNotification();
2461 application.Render();
2463 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2468 int utcDaliTextFieldSomeSpecialKeys(void)
2470 ToolkitTestApplication application;
2471 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2473 // Checks some special keys when the text is selected.
2475 TextField field = TextField::New();
2476 DALI_TEST_CHECK( field );
2477 Stage::GetCurrent().Add( field );
2478 LoadMarkerImages(application, field);
2479 // Render and notify
2480 application.SendNotification();
2481 application.Render();
2483 const std::string longText( "This is a long text for the size of the text-field." );
2485 field.SetProperty( TextField::Property::TEXT, longText );
2486 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2487 field.SetSize( 300.f, 50.f );
2488 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2489 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2491 // Avoid a crash when core load gl resources.
2492 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2493 // Render and notify
2494 application.SendNotification();
2495 application.Render();
2497 // Create a tap event to touch the text field.
2498 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2499 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2501 // Render and notify
2502 application.SendNotification();
2503 application.Render();
2505 // Tap first to get the focus.
2506 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2507 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2509 // Render and notify
2510 application.SendNotification();
2511 application.Render();
2513 // Double tap to select a word.
2514 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2515 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
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( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2523 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, "XF86PowerOff", 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( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2531 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2533 // Render and notify
2534 application.SendNotification();
2535 application.Render();
2537 // Generate a Esc key event. The text field should lose the focus.
2538 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2539 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2541 // Render and notify
2542 application.SendNotification();
2543 application.Render();
2545 // The text shouldn't be deleted.
2546 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2551 int utcDaliTextFieldSizeUpdate(void)
2553 ToolkitTestApplication application;
2554 tet_infoline("utcDaliTextFieldSizeUpdate");
2556 // Checks some special keys when the text is selected.
2557 TextField field = TextField::New();
2558 DALI_TEST_CHECK( field );
2559 Stage::GetCurrent().Add( field );
2561 float previousHeight = 0.0f;
2562 float currentHeight = 0.0f;
2563 const float fieldWidth = 1920.0f;
2566 // "ㅁ" is bigger then "ኢ"
2567 field.SetSize( Vector2( fieldWidth ,10.0f ) );
2568 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2569 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2571 field.SetProperty( TextField::Property::TEXT, "ኢ");
2572 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2573 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2575 field.SetKeyboardFocusable(true);
2576 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2578 application.SendNotification();
2579 application.Render();
2581 previousHeight = field.GetHeightForWidth( fieldWidth );
2582 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2584 // Add another script characters ( glyph height is defferent )
2585 application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2586 application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2588 application.SendNotification();
2589 application.Render();
2591 currentHeight = field.GetHeightForWidth( fieldWidth );
2592 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2593 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2598 int utcDaliTextFieldExtremlyLargePointSize(void)
2600 ToolkitTestApplication application;
2601 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2603 TextField field = TextField::New();
2605 field.SetProperty( TextField::Property::TEXT, "Text" );
2606 field.SetSize( 300.f, 50.f );
2607 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2608 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2609 Stage::GetCurrent().Add( field );
2613 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2614 application.SendNotification();
2615 DALI_TEST_CHECK( field );
2619 tet_result(TET_FAIL);
2624 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2626 ToolkitTestApplication application;
2627 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2628 TextField field = TextField::New();
2629 DALI_TEST_CHECK( field );
2630 Stage::GetCurrent().Add( field );
2632 Property::Map fontStyleMapGet;
2634 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2636 Property::Value* weightValue = NULL;
2637 Property::Value* widthValue = NULL;
2638 Property::Value* slantValue = NULL;
2639 weightValue = fontStyleMapGet.Find( "weight" );
2640 widthValue = fontStyleMapGet.Find( "width" );
2641 slantValue = fontStyleMapGet.Find( "slant" );
2642 DALI_TEST_CHECK( !weightValue );
2643 DALI_TEST_CHECK( !widthValue );
2644 DALI_TEST_CHECK( !slantValue );
2649 int UtcDaliTextFieldSettingPlaceholder(void)
2651 ToolkitTestApplication application;
2652 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
2654 TextField field = TextField::New();
2655 DALI_TEST_CHECK( field );
2656 Stage::GetCurrent().Add( field );
2658 // Check the placeholder property with pixel size
2659 Property::Map placeholderPixelSizeMapSet;
2660 Property::Map placeholderPixelSizeMapGet;
2661 Property::Map placeholderFontstyleMap;
2662 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2663 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2664 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
2665 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2666 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
2667 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
2669 placeholderFontstyleMap.Insert( "weight", "bold" );
2670 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2671 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
2673 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2674 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
2675 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
2677 // Check the placeholder property with point size
2678 Property::Map placeholderMapSet;
2679 Property::Map placeholderMapGet;
2680 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2681 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2682 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
2683 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2684 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
2685 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
2687 // Check the placeholder font style property
2688 placeholderFontstyleMap.Clear();
2690 placeholderFontstyleMap.Insert( "weight", "bold" );
2691 placeholderFontstyleMap.Insert( "width", "condensed" );
2692 placeholderFontstyleMap.Insert( "slant", "italic" );
2693 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2694 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2696 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2697 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2698 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2700 // Reset font style.
2701 placeholderFontstyleMap.Clear();
2702 placeholderFontstyleMap.Insert( "weight", "normal" );
2703 placeholderFontstyleMap.Insert( "slant", "oblique" );
2704 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2705 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2707 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2708 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2709 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2711 placeholderFontstyleMap.Clear();
2712 placeholderFontstyleMap.Insert( "slant", "roman" );
2713 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2714 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2716 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2718 placeholderFontstyleMap.Clear();
2719 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2721 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2722 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2723 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2724 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2729 int UtcDaliTextFieldSetPaddingProperty(void)
2731 ToolkitTestApplication application;
2732 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
2734 TextField field = TextField::New();
2735 DALI_TEST_CHECK( field );
2736 field.SetSize( 300.f, 50.f );
2737 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2738 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2739 Stage::GetCurrent().Add( field );
2741 application.SendNotification();
2742 application.Render();
2744 Vector3 originalSize = field.GetNaturalSize();
2746 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2748 application.SendNotification();
2749 application.Render();
2751 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2753 Vector3 paddingAddedSize = field.GetNaturalSize();
2755 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2757 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2762 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
2764 ToolkitTestApplication application;
2765 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
2767 TextField field = TextField::New();
2768 DALI_TEST_CHECK( field );
2769 field.SetSize( 300.f, 50.f );
2770 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2771 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2772 Stage::GetCurrent().Add( field );
2774 application.SendNotification();
2775 application.Render();
2777 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2778 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2780 // Check the enable shift selection property
2781 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
2782 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2784 application.SendNotification();
2785 application.Render();
2790 int UtcDaliTextFieldEnableGrabHandleProperty(void)
2792 ToolkitTestApplication application;
2793 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
2795 TextField field = TextField::New();
2796 DALI_TEST_CHECK( field );
2797 field.SetSize( 300.f, 50.f );
2798 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2799 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2800 Stage::GetCurrent().Add( field );
2802 application.SendNotification();
2803 application.Render();
2805 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2806 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2808 // Check the enable grab handle property
2809 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
2810 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2812 application.SendNotification();
2813 application.Render();
2818 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
2820 ToolkitTestApplication application;
2821 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
2823 TextField field = TextField::New();
2824 DALI_TEST_CHECK( field );
2825 field.SetSize( 300.f, 50.f );
2826 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2827 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2828 Stage::GetCurrent().Add( field );
2830 application.SendNotification();
2831 application.Render();
2833 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2834 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2836 // Check the match system language direction property
2837 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2838 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2840 application.SendNotification();
2841 application.Render();
2846 int utcDaliTextFieldLayoutDirectionCoverage(void)
2848 ToolkitTestApplication application;
2849 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
2851 // Creates a tap event. After creating a tap event the text field should
2852 // have the focus and add text with key events should be possible.
2853 TextField field = TextField::New();
2854 DALI_TEST_CHECK( field );
2856 Stage::GetCurrent().Add( field );
2858 field.SetSize( 300.f, 50.f );
2859 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2860 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2862 // Avoid a crash when core load gl resources.
2863 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2865 // Render and notify
2866 application.SendNotification();
2867 application.Render();
2869 // init direction for coverage
2870 // Set horizontal alignment END
2871 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2873 // Create a tap event to touch the text field.
2874 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2875 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2877 // Render and notify
2878 application.SendNotification();
2879 application.Render();
2881 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
2882 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2883 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
2885 // Set horizontal alignment BEGIN
2886 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
2888 // Create a tap event to touch the text field.
2889 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2890 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2892 // Render and notify
2893 application.SendNotification();
2894 application.Render();
2896 // Set horizontal alignment CENTER
2897 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
2899 // Create a tap event to touch the text field.
2900 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2901 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2903 // Render and notify
2904 application.SendNotification();
2905 application.Render();
2907 // Set horizontal alignment END
2908 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2910 // Create a tap event to touch the text field.
2911 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2912 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2914 // Render and notify
2915 application.SendNotification();
2916 application.Render();
2918 // Generate a Esc key event. The text field should lose the focus.
2919 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2920 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2922 // Render and notify
2923 application.SendNotification();
2924 application.Render();
2926 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2932 int UtcDaliTextFieldGetInputMethodContext(void)
2934 ToolkitTestApplication application;
2935 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
2937 TextField field = TextField::New();
2938 DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );