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& logicalKey,
309 const std::string& keyString,
312 unsigned long timeStamp,
313 const Integration::KeyEvent::State& keyState,
314 const std::string& compose = "",
315 const std::string& deviceName = DEFAULT_DEVICE_NAME,
316 const Device::Class::Type& deviceClass = Device::Class::NONE,
317 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
319 return Integration::KeyEvent( keyName,
332 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
334 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
336 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
338 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
340 Property::Value* valueSet = NULL;
341 if ( valueGet.first.type == Property::Key::INDEX )
343 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
347 // Get Key is a string so searching Set Map for a string key
348 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
351 if( NULL != valueSet )
353 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
355 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
358 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
360 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
363 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
365 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
368 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
370 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
373 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
375 Vector2 vector2Get = valueGet.second.Get<Vector2>();
376 Vector2 vector2Set = valueSet->Get<Vector2>();
377 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
380 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
382 Vector4 vector4Get = valueGet.second.Get<Vector4>();
383 Vector4 vector4Set = valueSet->Get<Vector4>();
384 tet_printf( "Value got : [%f, %f, %f, %f], expected : [%f, %f, %f, %f]", vector4Get.r, vector4Get.g, vector4Get.b, vector4Get.a, vector4Set.r, vector4Set.g, vector4Set.b, vector4Set.a );
390 if ( valueGet.first.type == Property::Key::INDEX )
392 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
396 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
408 int UtcDaliToolkitTextFieldConstructorP(void)
410 ToolkitTestApplication application;
411 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
413 DALI_TEST_CHECK( !textField );
417 int UtcDaliToolkitTextFieldNewP(void)
419 ToolkitTestApplication application;
420 tet_infoline(" UtcDaliToolkitTextFieldNewP");
421 TextField textField = TextField::New();
422 DALI_TEST_CHECK( textField );
426 int UtcDaliToolkitTextFieldDownCastP(void)
428 ToolkitTestApplication application;
429 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
430 TextField textField1 = TextField::New();
431 BaseHandle object( textField1 );
433 TextField textField2 = TextField::DownCast( object );
434 DALI_TEST_CHECK( textField2 );
436 TextField textField3 = DownCast< TextField >( object );
437 DALI_TEST_CHECK( textField3 );
441 int UtcDaliToolkitTextFieldDownCastN(void)
443 ToolkitTestApplication application;
444 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
445 BaseHandle uninitializedObject;
446 TextField textField1 = TextField::DownCast( uninitializedObject );
447 DALI_TEST_CHECK( !textField1 );
449 TextField textField2 = DownCast< TextField >( uninitializedObject );
450 DALI_TEST_CHECK( !textField2 );
454 int UtcDaliToolkitTextFieldCopyConstructorP(void)
456 ToolkitTestApplication application;
457 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
458 TextField textField = TextField::New();
459 textField.SetProperty( TextField::Property::TEXT, "Test" );
461 TextField copy( textField );
462 DALI_TEST_CHECK( copy );
463 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
467 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
469 ToolkitTestApplication application;
470 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
471 TextField textField = TextField::New();
472 textField.SetProperty( TextField::Property::TEXT, "Test" );
474 TextField copy = textField;
475 DALI_TEST_CHECK( copy );
476 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
480 int UtcDaliTextFieldNewP(void)
482 ToolkitTestApplication application;
483 tet_infoline(" UtcDaliToolkitTextFieldNewP");
484 TextField textField = TextField::New();
485 DALI_TEST_CHECK( textField );
489 // Positive test case for a method
490 int UtcDaliTextFieldGetPropertyP(void)
492 ToolkitTestApplication application;
493 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
494 TextField field = TextField::New();
495 DALI_TEST_CHECK( field );
497 // Check Property Indices are correct
498 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
499 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
500 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
501 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
502 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
503 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
504 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
505 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
506 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
507 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
508 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
509 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
510 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
511 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
512 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
513 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
514 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
515 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
516 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
517 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
518 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
519 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
520 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
521 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
522 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
523 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
524 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
525 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
526 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
527 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
528 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
529 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
530 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
531 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
532 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
533 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
534 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
535 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
536 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
537 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
538 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
539 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
540 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
541 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
542 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
543 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
544 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
545 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
546 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
547 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
548 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
549 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
550 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
555 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
558 Property::Map imageMap;
559 imageMap[mapKey] =mapValue;
561 field.SetProperty( property , imageMap );
562 Property::Value propValue = field.GetProperty( property );
563 Property::Map* resultMap = propValue.GetMap();
565 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
573 // Positive test case for a method
574 int UtcDaliTextFieldSetPropertyP(void)
576 ToolkitTestApplication application;
577 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
578 TextField field = TextField::New();
579 DALI_TEST_CHECK( field );
580 Stage::GetCurrent().Add( field );
582 // Note - we can't check the defaults since the stylesheets are platform-specific
584 // Check the render backend property.
585 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
586 DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
588 // Check text property.
589 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
590 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
592 // Check placeholder text properties.
593 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
594 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
596 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
597 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
599 // Check font properties.
600 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
601 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
603 Property::Map fontStyleMapSet;
604 Property::Map fontStyleMapGet;
605 Property::Value* slantValue = NULL;
607 fontStyleMapSet.Insert( "weight", "bold" );
608 fontStyleMapSet.Insert( "width", "condensed" );
609 fontStyleMapSet.Insert( "slant", "italic" );
610 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
612 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
613 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
614 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
616 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
617 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
620 fontStyleMapSet.Clear();
621 fontStyleMapSet.Insert( "weight", "normal" );
622 fontStyleMapSet.Insert( "slant", "oblique" );
623 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
625 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
626 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
627 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
629 fontStyleMapSet.Clear();
630 fontStyleMapSet.Insert( "slant", "roman" );
631 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
632 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
634 // Replace 'roman' for 'normal'.
635 slantValue = fontStyleMapGet.Find( "slant" );
636 if( NULL != slantValue )
638 if( "normal" == slantValue->Get<std::string>() )
640 fontStyleMapGet["slant"] = "roman";
643 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
644 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
646 fontStyleMapSet.Clear();
648 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
649 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
650 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
651 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
653 // Check that the MAX_LENGTH property can be correctly set
654 const int maxNumberOfCharacters = 20;
655 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
656 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
658 // Check exceed policy
659 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
660 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
661 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
662 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
664 // Check that the Alignment properties can be correctly set
665 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
666 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
667 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
668 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
670 // Check text's color property
671 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
672 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
674 // Check placeholder text's color property.
675 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
676 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
678 // Check cursor properties
679 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
680 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
681 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
682 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
684 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
685 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
686 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
687 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
688 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
689 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
690 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
691 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
693 // Check scroll properties.
694 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
695 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
696 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
697 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
699 // Check handle images
700 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
701 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
702 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
703 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
704 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
706 // Check handle images
707 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
708 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
709 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
710 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
711 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
712 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
714 // Check the highlight color
715 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
716 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
718 // Decoration bounding box
719 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
720 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
722 // Check the input method setting
723 Property::Map propertyMap;
724 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
725 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
726 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
727 int inputVariation = 1;
728 propertyMap["PANEL_LAYOUT"] = panelLayout;
729 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
730 propertyMap["BUTTON_ACTION"] = buttonAction;
731 propertyMap["VARIATION"] = inputVariation;
732 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
734 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
736 DALI_TEST_CHECK( value.Get( map ) );
739 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
740 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
743 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
744 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
747 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
748 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
751 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
752 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
754 // Check input color property.
755 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
756 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
758 // Check the enable markup property.
759 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
760 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
761 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
763 // Check input font properties.
764 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
765 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
767 fontStyleMapSet.Clear();
768 fontStyleMapSet.Insert( "weight", "bold" );
769 fontStyleMapSet.Insert( "width", "condensed" );
770 fontStyleMapSet.Insert( "slant", "italic" );
772 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
773 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
774 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
775 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
777 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
778 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
780 // Reset input font style.
781 fontStyleMapSet.Clear();
782 fontStyleMapSet.Insert( "weight", "normal" );
783 fontStyleMapSet.Insert( "slant", "oblique" );
785 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
786 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
787 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
788 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
790 fontStyleMapSet.Clear();
791 fontStyleMapSet.Insert( "slant", "roman" );
793 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
794 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
796 // Replace 'roman' for 'normal'.
797 slantValue = fontStyleMapGet.Find( "slant" );
798 if( NULL != slantValue )
800 if( "normal" == slantValue->Get<std::string>() )
802 fontStyleMapGet["slant"] = "roman";
805 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
806 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
808 fontStyleMapSet.Clear();
810 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
811 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
812 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
813 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
815 Property::Map underlineMapSet;
816 Property::Map underlineMapGet;
818 underlineMapSet.Insert( "enable", "true" );
819 underlineMapSet.Insert( "color", "red" );
820 underlineMapSet.Insert( "height", "1" );
822 // Check the underline property
823 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
825 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
826 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
827 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
829 // Check the input underline property
830 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
831 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
833 // Check the shadow property
834 Property::Map shadowMapSet;
835 Property::Map shadowMapGet;
837 shadowMapSet.Insert( "color", Color::GREEN );
838 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
839 shadowMapSet.Insert( "blurRadius", 3.0f );
841 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
843 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
844 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
845 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
847 // Check the input shadow property
848 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
849 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
851 // Check the emboss property
852 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
853 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
855 // Check the input emboss property
856 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
857 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
859 // Check the outline property
861 // Test string type first
862 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
863 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
864 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
866 // Then test the property map type
867 Property::Map outlineMapSet;
868 Property::Map outlineMapGet;
870 outlineMapSet["color"] = Color::RED;
871 outlineMapSet["width"] = 2.0f;
873 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
875 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
876 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
877 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
879 // Check the input outline property
880 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
881 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
883 // Check the hidden input settings property
884 Property::Map hiddenMapSet;
885 Property::Map hiddenMapGet;
886 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
887 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
888 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
889 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
890 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
892 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
893 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
894 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
896 // Check the pixel size of font
897 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
898 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
900 // Check the enable selection property
901 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
902 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
904 // Check the placeholder property with pixel size
905 Property::Map placeholderPixelSizeMapSet;
906 Property::Map placeholderPixelSizeMapGet;
907 Property::Map placeholderFontstyleMap;
908 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
909 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
910 placeholderPixelSizeMapSet["color"] = Color::BLUE;
911 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
912 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
913 placeholderPixelSizeMapSet["ellipsis"] = true;
915 placeholderFontstyleMap.Insert( "weight", "bold" );
916 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
917 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
919 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
920 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
922 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
923 Property::Map placeholderConversionMap;
924 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
925 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
926 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
927 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
928 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
929 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
931 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
933 // Check the placeholder property with point size
934 Property::Map placeholderMapSet;
935 Property::Map placeholderMapGet;
936 placeholderMapSet["text"] = "Setting Placeholder Text";
937 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
938 placeholderMapSet["color"] = Color::RED;
939 placeholderMapSet["fontFamily"] = "Arial";
940 placeholderMapSet["pointSize"] = 12.0f;
941 placeholderMapSet["ellipsis"] = false;
943 // Check the placeholder font style property
944 placeholderFontstyleMap.Clear();
946 placeholderFontstyleMap.Insert( "weight", "bold" );
947 placeholderFontstyleMap.Insert( "width", "condensed" );
948 placeholderFontstyleMap.Insert( "slant", "italic" );
949 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
950 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
952 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
953 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
955 placeholderConversionMap.Clear();
956 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
957 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
958 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
959 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
960 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
961 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
963 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
966 placeholderFontstyleMap.Clear();
967 placeholderFontstyleMap.Insert( "weight", "normal" );
968 placeholderFontstyleMap.Insert( "slant", "oblique" );
969 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
970 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
972 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
973 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
975 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
976 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
978 placeholderFontstyleMap.Clear();
979 placeholderFontstyleMap.Insert( "slant", "roman" );
980 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
981 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
983 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
985 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
987 placeholderFontstyleMap.Clear();
988 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
989 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
991 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
992 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
993 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
995 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
997 // Check the ellipsis property
998 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
999 field.SetProperty( TextField::Property::ELLIPSIS, true );
1000 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1002 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
1003 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1005 application.SendNotification();
1006 application.Render();
1011 // Positive Atlas Text Renderer test
1012 int utcDaliTextFieldAtlasRenderP(void)
1014 ToolkitTestApplication application;
1015 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1016 StyleManager styleManager = StyleManager::Get();
1017 styleManager.ApplyDefaultTheme();
1018 TextField field = TextField::New();
1019 DALI_TEST_CHECK( field );
1021 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1023 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1025 Stage::GetCurrent().Add( field );
1029 // Render some text with the shared atlas backend
1030 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
1031 application.SendNotification();
1032 application.Render();
1036 tet_result(TET_FAIL);
1041 // Positive test for the textChanged signal.
1042 int utcDaliTextFieldTextChangedP(void)
1044 ToolkitTestApplication application;
1045 tet_infoline(" utcDaliTextFieldTextChangedP");
1046 TextField field = TextField::New();
1047 DALI_TEST_CHECK( field );
1049 Stage::GetCurrent().Add( field );
1051 // connect to the text changed signal.
1052 ConnectionTracker* testTracker = new ConnectionTracker();
1053 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1054 bool textChangedSignal = false;
1055 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1057 gTextChangedCallBackCalled = false;
1058 field.SetProperty( TextField::Property::TEXT, "ABC" );
1059 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1060 DALI_TEST_CHECK( textChangedSignal );
1062 application.SendNotification();
1064 field.SetKeyInputFocus();
1066 gTextChangedCallBackCalled = false;
1067 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1068 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1073 // Negative test for the textChanged signal.
1074 int utcDaliTextFieldTextChangedN(void)
1076 ToolkitTestApplication application;
1077 tet_infoline(" utcDaliTextFieldTextChangedN");
1078 TextField field = TextField::New();
1079 DALI_TEST_CHECK( field );
1081 Stage::GetCurrent().Add( field );
1083 // connect to the text changed signal.
1084 ConnectionTracker* testTracker = new ConnectionTracker();
1085 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1086 bool textChangedSignal = false;
1087 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1089 gTextChangedCallBackCalled = false;
1090 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1091 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1092 DALI_TEST_CHECK( !textChangedSignal );
1097 // Positive test for Max Characters reached signal.
1098 int utcDaliTextFieldMaxCharactersReachedP(void)
1100 ToolkitTestApplication application;
1101 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1102 TextField field = TextField::New();
1103 DALI_TEST_CHECK( field );
1105 Stage::GetCurrent().Add( field );
1107 const int maxNumberOfCharacters = 1;
1108 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1110 field.SetKeyInputFocus();
1112 // connect to the text changed signal.
1113 ConnectionTracker* testTracker = new ConnectionTracker();
1114 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1115 bool maxLengthReachedSignal = false;
1116 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1118 gMaxCharactersCallBackCalled = false;
1120 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1121 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1123 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1124 DALI_TEST_CHECK( maxLengthReachedSignal );
1129 // Negative test for Max Characters reached signal.
1130 int utcDaliTextFieldMaxCharactersReachedN(void)
1132 ToolkitTestApplication application;
1133 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1134 TextField field = TextField::New();
1135 DALI_TEST_CHECK( field );
1137 Stage::GetCurrent().Add( field );
1139 const int maxNumberOfCharacters = 3;
1140 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1142 field.SetKeyInputFocus();
1144 // connect to the text changed signal.
1145 ConnectionTracker* testTracker = new ConnectionTracker();
1146 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1147 bool maxLengthReachedSignal = false;
1148 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1150 gMaxCharactersCallBackCalled = false;
1152 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1153 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1155 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1156 DALI_TEST_CHECK( !maxLengthReachedSignal );
1158 application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::Down, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1160 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1161 DALI_TEST_CHECK( !maxLengthReachedSignal );
1166 int utcDaliTextFieldInputStyleChanged01(void)
1168 ToolkitTestApplication application;
1169 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1171 // The text-field emits signals when the input style changes. These changes of style are
1172 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1173 // can't be emitted during the size negotiation as the callbacks may update the UI.
1174 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1175 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1176 application.CreateAdaptor();
1180 char* pathNamePtr = get_current_dir_name();
1181 const std::string pathName( pathNamePtr );
1182 free( pathNamePtr );
1184 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1185 fontClient.SetDpi( 93u, 93u );
1187 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1188 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1190 TextField field = TextField::New();
1191 DALI_TEST_CHECK( field );
1194 field.SetSize( 300.f, 50.f );
1195 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1196 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1198 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1199 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1201 // connect to the text changed signal.
1202 ConnectionTracker* testTracker = new ConnectionTracker();
1203 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1204 bool inputStyleChangedSignal = false;
1205 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1207 Stage::GetCurrent().Add( field );
1209 // Render and notify
1210 application.SendNotification();
1211 application.Render();
1213 // Executes the idle callbacks added by the text control on the change of input style.
1214 application.RunIdles();
1216 gInputStyleChangedCallbackCalled = false;
1217 gInputStyleMask = TextField::InputStyle::NONE;
1218 inputStyleChangedSignal = false;
1220 // Create a tap event to touch the text field.
1221 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1222 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1224 // Render and notify
1225 application.SendNotification();
1226 application.Render();
1228 // Executes the idle callbacks added by the text control on the change of input style.
1229 application.RunIdles();
1231 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1232 if( gInputStyleChangedCallbackCalled )
1234 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1236 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1237 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1239 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1240 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1242 DALI_TEST_CHECK( inputStyleChangedSignal );
1244 gInputStyleChangedCallbackCalled = false;
1245 gInputStyleMask = TextField::InputStyle::NONE;
1246 inputStyleChangedSignal = false;
1248 // Create a tap event to touch the text field.
1249 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1250 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1252 // Render and notify
1253 application.SendNotification();
1254 application.Render();
1256 // Executes the idle callbacks added by the text control on the change of input style.
1257 application.RunIdles();
1259 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1260 DALI_TEST_CHECK( !inputStyleChangedSignal );
1262 gInputStyleChangedCallbackCalled = false;
1263 gInputStyleMask = TextField::InputStyle::NONE;
1264 inputStyleChangedSignal = false;
1266 // Create a tap event to touch the text field.
1267 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1268 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1270 // Render and notify
1271 application.SendNotification();
1272 application.Render();
1274 // Executes the idle callbacks added by the text control on the change of input style.
1275 application.RunIdles();
1277 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1278 if( gInputStyleChangedCallbackCalled )
1280 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1282 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1283 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1285 DALI_TEST_CHECK( inputStyleChangedSignal );
1287 gInputStyleChangedCallbackCalled = false;
1288 gInputStyleMask = TextField::InputStyle::NONE;
1289 inputStyleChangedSignal = false;
1291 // Create a tap event to touch the text field.
1292 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1293 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1295 // Render and notify
1296 application.SendNotification();
1297 application.Render();
1299 // Executes the idle callbacks added by the text control on the change of input style.
1300 application.RunIdles();
1302 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1303 if( gInputStyleChangedCallbackCalled )
1305 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1307 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1308 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1310 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1312 Property::Map fontStyleMapSet;
1313 fontStyleMapSet.Insert( "weight", "bold" );
1315 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1316 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1318 DALI_TEST_CHECK( inputStyleChangedSignal );
1320 gInputStyleChangedCallbackCalled = false;
1321 gInputStyleMask = TextField::InputStyle::NONE;
1322 inputStyleChangedSignal = false;
1324 // Create a tap event to touch the text field.
1325 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1326 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1328 // Render and notify
1329 application.SendNotification();
1330 application.Render();
1332 // Executes the idle callbacks added by the text control on the change of input style.
1333 application.RunIdles();
1335 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1336 DALI_TEST_CHECK( !inputStyleChangedSignal );
1338 gInputStyleChangedCallbackCalled = false;
1339 gInputStyleMask = TextField::InputStyle::NONE;
1340 inputStyleChangedSignal = false;
1342 // Create a tap event to touch the text field.
1343 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1344 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1346 // Render and notify
1347 application.SendNotification();
1348 application.Render();
1350 // Executes the idle callbacks added by the text control on the change of input style.
1351 application.RunIdles();
1353 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1354 if( gInputStyleChangedCallbackCalled )
1356 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1358 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1359 DALI_TEST_CHECK( style.empty() );
1361 DALI_TEST_CHECK( inputStyleChangedSignal );
1363 gInputStyleChangedCallbackCalled = false;
1364 gInputStyleMask = TextField::InputStyle::NONE;
1365 inputStyleChangedSignal = false;
1367 // Create a tap event to touch the text field.
1368 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1369 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1371 // Render and notify
1372 application.SendNotification();
1373 application.Render();
1375 // Executes the idle callbacks added by the text control on the change of input style.
1376 application.RunIdles();
1378 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1379 DALI_TEST_CHECK( !inputStyleChangedSignal );
1384 int utcDaliTextFieldInputStyleChanged02(void)
1386 ToolkitTestApplication application;
1387 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1389 // The text-field emits signals when the input style changes. These changes of style are
1390 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1391 // can't be emitted during the size negotiation as the callbacks may update the UI.
1392 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1393 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1394 application.CreateAdaptor();
1398 char* pathNamePtr = get_current_dir_name();
1399 const std::string pathName( pathNamePtr );
1400 free( pathNamePtr );
1402 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1403 fontClient.SetDpi( 93u, 93u );
1405 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1406 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1408 TextField field = TextField::New();
1409 DALI_TEST_CHECK( field );
1412 field.SetSize( 300.f, 50.f );
1413 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1414 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1416 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1417 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>" );
1419 // connect to the text changed signal.
1420 ConnectionTracker* testTracker = new ConnectionTracker();
1421 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1422 bool inputStyleChangedSignal = false;
1423 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1425 Stage::GetCurrent().Add( field );
1427 // Render and notify
1428 application.SendNotification();
1429 application.Render();
1431 // Executes the idle callbacks added by the text control on the change of input style.
1432 application.RunIdles();
1434 gInputStyleChangedCallbackCalled = false;
1435 gInputStyleMask = TextField::InputStyle::NONE;
1436 inputStyleChangedSignal = false;
1438 // Create a tap event to touch the text field.
1439 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1440 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1441 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1442 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1444 // Render and notify
1445 application.SendNotification();
1446 application.Render();
1448 // Executes the idle callbacks added by the text control on the change of input style.
1449 application.RunIdles();
1451 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1452 if( gInputStyleChangedCallbackCalled )
1454 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1455 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1456 TextField::InputStyle::POINT_SIZE |
1457 TextField::InputStyle::COLOR ),
1460 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1461 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1463 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1464 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1466 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1467 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1469 DALI_TEST_CHECK( inputStyleChangedSignal );
1471 gInputStyleChangedCallbackCalled = false;
1472 gInputStyleMask = TextField::InputStyle::NONE;
1473 inputStyleChangedSignal = false;
1475 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1477 // Render and notify
1478 application.SendNotification();
1479 application.Render();
1481 // Executes the idle callbacks added by the text control on the change of input style.
1482 application.RunIdles();
1484 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1485 if( gInputStyleChangedCallbackCalled )
1487 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1488 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1491 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1492 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1494 DALI_TEST_CHECK( inputStyleChangedSignal );
1496 gInputStyleChangedCallbackCalled = false;
1497 gInputStyleMask = TextField::InputStyle::NONE;
1498 inputStyleChangedSignal = false;
1500 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1502 // Render and notify
1503 application.SendNotification();
1504 application.Render();
1506 // Executes the idle callbacks added by the text control on the change of input style.
1507 application.RunIdles();
1509 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1510 DALI_TEST_CHECK( !inputStyleChangedSignal );
1512 gInputStyleChangedCallbackCalled = false;
1513 gInputStyleMask = TextField::InputStyle::NONE;
1514 inputStyleChangedSignal = false;
1516 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1518 // Render and notify
1519 application.SendNotification();
1520 application.Render();
1522 // Executes the idle callbacks added by the text control on the change of input style.
1523 application.RunIdles();
1525 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1526 if( gInputStyleChangedCallbackCalled )
1528 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1529 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1532 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1533 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1535 DALI_TEST_CHECK( inputStyleChangedSignal );
1537 gInputStyleChangedCallbackCalled = false;
1538 gInputStyleMask = TextField::InputStyle::NONE;
1539 inputStyleChangedSignal = false;
1541 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1543 Property::Map fontStyleMapSet;
1544 fontStyleMapSet.Insert( "weight", "thin" );
1545 fontStyleMapSet.Insert( "width", "condensed" );
1546 fontStyleMapSet.Insert( "slant", "italic" );
1548 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1549 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1551 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1552 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1553 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1554 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1556 // Render and notify
1557 application.SendNotification();
1558 application.Render();
1560 // Executes the idle callbacks added by the text control on the change of input style.
1561 application.RunIdles();
1563 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1564 DALI_TEST_CHECK( !inputStyleChangedSignal );
1566 // Create a tap event to touch the text field.
1567 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1568 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1570 // Render and notify
1571 application.SendNotification();
1572 application.Render();
1574 // Executes the idle callbacks added by the text control on the change of input style.
1575 application.RunIdles();
1577 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1578 if( gInputStyleChangedCallbackCalled )
1580 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1581 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1582 TextField::InputStyle::POINT_SIZE |
1583 TextField::InputStyle::FONT_STYLE |
1584 TextField::InputStyle::UNDERLINE |
1585 TextField::InputStyle::SHADOW |
1586 TextField::InputStyle::EMBOSS |
1587 TextField::InputStyle::OUTLINE ),
1590 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1591 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1593 DALI_TEST_CHECK( inputStyleChangedSignal );
1598 int utcDaliTextFieldEvent01(void)
1600 ToolkitTestApplication application;
1601 tet_infoline(" utcDaliTextFieldEvent01");
1603 // Creates a tap event. After creating a tap event the text field should
1604 // have the focus and add text with key events should be possible.
1606 TextField field = TextField::New();
1607 DALI_TEST_CHECK( field );
1609 Stage::GetCurrent().Add( field );
1611 field.SetSize( 300.f, 50.f );
1612 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1613 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1615 // Avoid a crash when core load gl resources.
1616 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1618 // Render and notify
1619 application.SendNotification();
1620 application.Render();
1622 // Add a key event but as the text field has not the focus it should do nothing.
1623 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1625 // Render and notify
1626 application.SendNotification();
1627 application.Render();
1629 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1631 // Create a tap event to touch the text field.
1632 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1633 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1635 // Render and notify
1636 application.SendNotification();
1637 application.Render();
1639 // Pressing delete key should be fine even if there is no text in TextField.
1640 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 ) );
1641 // Render and notify
1642 application.SendNotification();
1643 application.Render();
1645 // Now the text field has the focus, so it can handle the key events.
1646 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1647 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1649 // Render and notify
1650 application.SendNotification();
1651 application.Render();
1653 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1655 // Create a second text field and send key events to it.
1656 TextField field2 = TextField::New();
1658 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1659 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1660 field2.SetSize( 100.f, 100.f );
1661 field2.SetPosition( 100.f, 100.f );
1663 Stage::GetCurrent().Add( field2 );
1665 // Render and notify
1666 application.SendNotification();
1667 application.Render();
1669 // Create a tap event on the second text field.
1670 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1671 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1673 // Render and notify
1674 application.SendNotification();
1675 application.Render();
1677 // The second text field has the focus. It should handle the key events.
1678 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1679 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1681 // Render and notify
1682 application.SendNotification();
1683 application.Render();
1685 // Check the text has been added to the second text field.
1686 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1691 int utcDaliTextFieldEvent02(void)
1693 ToolkitTestApplication application;
1694 tet_infoline(" utcDaliTextFieldEvent02");
1696 // Checks if the right number of actors are created.
1698 TextField field = TextField::New();
1699 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1700 DALI_TEST_CHECK( field );
1701 LoadMarkerImages(application, field);
1703 Stage::GetCurrent().Add( field );
1705 field.SetSize( 300.f, 50.f );
1706 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1707 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1709 // Avoid a crash when core load gl resources.
1710 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1712 // Render and notify
1713 application.SendNotification();
1714 application.Render();
1716 // Check there are the expected number of children ( stencil ).
1717 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1719 Actor stencil = field.GetChildAt( 0u );
1720 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1722 // Create a tap event to touch the text field.
1723 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1724 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1726 // Render and notify
1727 application.SendNotification();
1728 application.Render();
1730 Actor layer = field.GetChildAt( 1u );
1731 DALI_TEST_CHECK( layer.IsLayer() );
1733 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1734 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1736 // Now the text field has the focus, so it can handle the key events.
1737 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1738 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1740 // Render and notify
1741 application.SendNotification();
1742 application.Render();
1744 // Checks the cursor and the renderer have been created.
1745 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1746 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1748 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1749 DALI_TEST_CHECK( cursor );
1751 // The offscreen root actor has a container with all the actors which contain the text renderers.
1752 Actor container = stencil.GetChildAt( 0u );
1753 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1755 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1756 DALI_TEST_CHECK( renderer );
1759 // Move the cursor and check the position changes.
1760 Vector3 position1 = cursor.GetCurrentPosition();
1762 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1763 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1765 // Render and notify
1766 application.SendNotification();
1767 application.Render();
1769 Vector3 position2 = cursor.GetCurrentPosition();
1771 DALI_TEST_CHECK( position2.x < position1.x );
1773 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1774 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1776 // Render and notify
1777 application.SendNotification();
1778 application.Render();
1780 Vector3 position3 = cursor.GetCurrentPosition();
1782 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1784 // Send some taps and check the cursor positions.
1786 // Try to tap at the beginning.
1787 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1788 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1790 // Render and notify
1791 application.SendNotification();
1792 application.Render();
1794 // Cursor position should be the same than position1.
1795 Vector3 position4 = cursor.GetCurrentPosition();
1797 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1799 // Tap away from the start position.
1800 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1801 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1803 // Render and notify
1804 application.SendNotification();
1805 application.Render();
1807 Vector3 position5 = cursor.GetCurrentPosition();
1809 DALI_TEST_CHECK( position5.x > position4.x );
1811 // Remove all the text.
1812 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1813 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1814 field.SetProperty( TextField::Property::TEXT, "" );
1816 // Render and notify
1817 application.SendNotification();
1818 application.Render();
1820 // Cursor position should be the same than position2.
1821 Vector3 position6 = cursor.GetCurrentPosition();
1823 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1825 // Should not be a renderer.
1826 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1828 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1829 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1830 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1832 application.SendNotification();
1833 application.Render();
1835 // There are renderer and decorator layer
1836 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1841 int utcDaliTextFieldEvent03(void)
1843 ToolkitTestApplication application;
1844 tet_infoline(" utcDaliTextFieldEvent03");
1846 // Checks if the highlight actor is created.
1848 TextField field = TextField::New();
1849 DALI_TEST_CHECK( field );
1851 Stage::GetCurrent().Add( field );
1853 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1854 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1855 field.SetSize( 30.f, 50.f );
1856 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1857 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1859 // Avoid a crash when core load gl resources.
1860 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1861 LoadMarkerImages(application, field);
1863 // Render and notify
1864 application.SendNotification();
1865 application.Render();
1867 // Tap first to get the focus.
1868 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1869 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1871 // Render and notify
1872 application.SendNotification();
1873 application.Render();
1875 // Double tap to select a word.
1876 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1877 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1879 // Render and notify
1880 application.SendNotification();
1881 application.Render();
1883 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1884 Actor stencil = field.GetChildAt( 0u );
1886 // The highlight actor is drawn first, so is the first actor in the list
1887 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1888 DALI_TEST_CHECK( highlight );
1890 // The offscreen root actor has a container with all the actors which contain the text renderers.
1891 Actor container = stencil.GetChildAt( 1u );
1892 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1894 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1895 DALI_TEST_CHECK( renderer );
1901 int utcDaliTextFieldEvent04(void)
1903 ToolkitTestApplication application;
1904 tet_infoline(" utcDaliTextFieldEvent04");
1906 // Checks if the highlight actor is created.
1908 TextField field = TextField::New();
1909 DALI_TEST_CHECK( field );
1910 Stage::GetCurrent().Add( field );
1911 LoadMarkerImages(application, field);
1912 // Render and notify
1913 application.SendNotification();
1914 application.Render();
1916 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1917 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1918 field.SetSize( 300.f, 50.f );
1919 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1920 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1922 // Avoid a crash when core load gl resources.
1923 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1924 // Render and notify
1925 application.SendNotification();
1926 application.Render();
1928 // Create a tap event to touch the text field.
1929 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1930 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1931 // Render and notify
1932 application.SendNotification();
1933 application.Render();
1936 // Tap first to get the focus.
1937 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1938 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1940 // Render and notify
1941 application.SendNotification();
1942 application.Render();
1944 // Double tap to select a word.
1945 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1946 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1948 // Render and notify
1949 application.SendNotification();
1950 application.Render();
1953 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1954 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1958 int utcDaliTextFieldEvent05(void)
1960 ToolkitTestApplication application;
1961 tet_infoline(" utcDaliTextFieldEvent05");
1963 // Checks dragging of cursor/grab handle
1965 TextField field = TextField::New();
1966 DALI_TEST_CHECK( field );
1967 Stage::GetCurrent().Add( field );
1968 LoadMarkerImages(application, field);
1969 // Render and notify
1970 application.SendNotification();
1971 application.Render();
1973 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1974 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1975 field.SetSize( 300.f, 50.f );
1976 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1977 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1979 // Avoid a crash when core load gl resources.
1980 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1981 // Render and notify
1982 application.SendNotification();
1983 application.Render();
1985 // Create a tap event to touch the text field.
1986 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1987 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1988 // Render and notify
1989 application.SendNotification();
1990 application.Render();
1992 // Tap first to get the focus.
1993 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1994 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1996 // Render and notify
1997 application.SendNotification();
1998 application.Render();
2000 // Double tap to select a word.
2001 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2002 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2004 // Render and notify
2005 application.SendNotification();
2006 application.Render();
2008 // drag grab handle right
2009 Vector2 pos(0.0f, 40.0f);
2010 SendPan(application, Gesture::Possible, pos);
2011 SendPan(application, Gesture::Started, pos);
2013 Wait(application, 100);
2015 for(int i = 0;i<20;i++)
2017 SendPan(application, Gesture::Continuing, pos);
2022 SendPan(application, Gesture::Finished, pos);
2023 Wait(application, RENDER_FRAME_INTERVAL);
2025 Actor stencil = field.GetChildAt( 1u );
2029 int utcDaliTextFieldEvent06(void)
2031 ToolkitTestApplication application;
2032 tet_infoline(" utcDaliTextFieldEvent06");
2034 // Checks Longpress when in edit mode
2036 TextField field = TextField::New();
2037 DALI_TEST_CHECK( field );
2038 Stage::GetCurrent().Add( field );
2039 LoadMarkerImages(application, field);
2040 // Render and notify
2041 application.SendNotification();
2042 application.Render();
2044 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2045 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2046 field.SetSize( 300.f, 50.f );
2047 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2048 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2050 // Avoid a crash when core load gl resources.
2051 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2052 // Render and notify
2053 application.SendNotification();
2054 application.Render();
2056 // Create a tap event to touch the text field.
2057 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2058 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2059 // Render and notify
2060 application.SendNotification();
2061 application.Render();
2064 // Tap first to get the focus.
2065 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2066 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2068 // Render and notify
2069 application.SendNotification();
2070 application.Render();
2073 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2074 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2076 // Render and notify
2077 application.SendNotification();
2078 application.Render();
2083 int utcDaliTextFieldEvent07(void)
2085 ToolkitTestApplication application;
2086 tet_infoline(" utcDaliTextFieldEvent07");
2088 // Checks Longpress to start edit mode
2090 TextField field = TextField::New();
2091 DALI_TEST_CHECK( field );
2092 Stage::GetCurrent().Add( field );
2093 LoadMarkerImages(application, field);
2094 // Render and notify
2095 application.SendNotification();
2096 application.Render();
2098 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2099 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2100 field.SetSize( 300.f, 50.f );
2101 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2102 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2103 Property::Map propertyMap;
2104 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2105 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2107 // Avoid a crash when core load gl resources.
2108 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2109 // Render and notify
2110 application.SendNotification();
2111 application.Render();
2114 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2115 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2117 // Render and notify
2118 application.SendNotification();
2119 application.Render();
2124 int utcDaliTextFieldEvent08(void)
2126 ToolkitTestApplication application;
2127 tet_infoline(" utcDaliTextFieldEvent08");
2129 Dali::Clipboard clipboard = Clipboard::Get();
2130 clipboard.SetItem("testTextFieldEvent");
2132 // Checks Longpress when only place holder text
2134 TextField field = TextField::New();
2135 DALI_TEST_CHECK( field );
2136 Stage::GetCurrent().Add( field );
2137 LoadMarkerImages(application, field);
2138 // Render and notify
2139 application.SendNotification();
2140 application.Render();
2142 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2143 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2144 field.SetSize( 300.f, 50.f );
2145 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2146 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2148 // Avoid a crash when core load gl resources.
2149 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2150 // Render and notify
2151 application.SendNotification();
2152 application.Render();
2155 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2156 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2158 // Render and notify
2159 application.SendNotification();
2160 application.Render();
2162 Wait(application, 500);
2165 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2166 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2168 // Render and notify
2169 application.SendNotification();
2170 application.Render();
2172 Wait(application, 500);
2174 Stage stage = Stage::GetCurrent();
2175 Layer layer = stage.GetRootLayer();
2176 Actor actor = layer.FindChildByName("optionPaste");
2180 Vector3 worldPosition = actor.GetCurrentWorldPosition();
2181 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2182 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2184 Dali::Integration::TouchEvent event;
2185 event = Dali::Integration::TouchEvent();
2186 event.AddPoint( GetPointDownInside( position ) );
2187 application.ProcessEvent( event );
2189 event = Dali::Integration::TouchEvent();
2190 event.AddPoint( GetPointUpInside( position ) );
2191 application.ProcessEvent( event );
2193 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2198 int utcDaliTextFieldEvent09(void)
2200 ToolkitTestApplication application;
2201 tet_infoline(" utcDaliTextFieldEvent09");
2203 TextField field = TextField::New();
2204 DALI_TEST_CHECK( field );
2205 Stage::GetCurrent().Add( field );
2206 LoadMarkerImages(application, field);
2207 // Render and notify
2208 application.SendNotification();
2209 application.Render();
2211 field.SetProperty( TextField::Property::TEXT, "Hello" );
2212 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2213 field.SetSize( 300.f, 50.f );
2214 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2215 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2217 // Avoid a crash when core load gl resources.
2218 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2220 // Create a tap event to touch the text field.
2221 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2222 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2223 application.SendNotification();
2224 application.Render();
2227 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2228 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2229 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2230 application.SendNotification();
2231 application.Render();
2233 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2234 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2235 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2236 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2237 application.SendNotification();
2238 application.Render();
2240 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2241 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2242 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2243 for( unsigned int index = 0u; index < 5u; ++index )
2245 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2246 application.SendNotification();
2247 application.Render();
2250 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2251 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2252 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2253 for( unsigned int index = 0u; index < 5u; ++index )
2255 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2256 application.SendNotification();
2257 application.Render();
2260 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2261 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2262 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2263 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2264 application.SendNotification();
2265 application.Render();
2266 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2267 application.SendNotification();
2268 application.Render();
2270 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2271 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2272 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2273 application.SendNotification();
2274 application.Render();
2276 Property::Map mapGet;
2277 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2278 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2279 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2284 int utcDaliTextFieldStyleWhilstSelected(void)
2286 ToolkitTestApplication application;
2287 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2289 // Change font and styles whilst text is selected whilst word selected
2291 TextField field = TextField::New();
2292 DALI_TEST_CHECK( field );
2293 Stage::GetCurrent().Add( field );
2294 LoadMarkerImages(application, field);
2295 // Render and notify
2296 application.SendNotification();
2297 application.Render();
2299 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2300 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2301 field.SetSize( 300.f, 50.f );
2302 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2303 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2305 // Avoid a crash when core load gl resources.
2306 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2307 // Render and notify
2308 application.SendNotification();
2309 application.Render();
2311 // Create a tap event to touch the text field.
2312 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2313 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2314 // Render and notify
2315 application.SendNotification();
2316 application.Render();
2319 // Tap first to get the focus.
2320 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2321 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2323 // Render and notify
2324 application.SendNotification();
2325 application.Render();
2327 // Double tap to select a word.
2328 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2329 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2331 // Render and notify
2332 application.SendNotification();
2333 application.Render();
2335 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2336 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2338 Property::Map fontStyleMapSet;
2339 Property::Map fontStyleMapGet;
2341 fontStyleMapSet.Insert( "weight", "bold" );
2342 fontStyleMapSet.Insert( "slant", "italic" );
2343 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2345 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2346 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2347 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2349 fontStyleMapSet.Clear();
2350 fontStyleMapSet.Insert( "width", "expanded" );
2351 fontStyleMapSet.Insert( "slant", "italic" );
2352 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2354 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2355 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2356 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2358 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2359 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2361 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2362 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2364 fontStyleMapSet.Clear();
2365 fontStyleMapSet.Insert( "weight", "bold" );
2366 fontStyleMapSet.Insert( "slant", "italic" );
2368 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2370 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2371 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2372 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2374 fontStyleMapSet.Clear();
2375 fontStyleMapSet.Insert( "width", "expanded" );
2377 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2379 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2380 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2381 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2383 // Press Escape to increase coverage
2384 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2385 application.SendNotification();
2386 application.Render();
2388 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2393 int utcDaliTextFieldEscKeyLoseFocus(void)
2395 ToolkitTestApplication application;
2396 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2398 // Creates a tap event. After creating a tap event the text field should
2399 // have the focus and add text with key events should be possible.
2401 TextField field = TextField::New();
2402 DALI_TEST_CHECK( field );
2404 Stage::GetCurrent().Add( field );
2406 field.SetSize( 300.f, 50.f );
2407 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2408 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2410 // Avoid a crash when core load gl resources.
2411 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2413 // Render and notify
2414 application.SendNotification();
2415 application.Render();
2417 // Add a key event but as the text field has not the focus it should do nothing.
2418 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2419 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2421 // Render and notify
2422 application.SendNotification();
2423 application.Render();
2425 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2427 // Create a tap event to touch the text field.
2428 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2429 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2431 // Render and notify
2432 application.SendNotification();
2433 application.Render();
2435 // Now the text field has the focus, so it can handle the key events.
2436 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2437 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2438 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2439 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2441 // Render and notify
2442 application.SendNotification();
2443 application.Render();
2445 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2447 // Generate a Esc key event. The text field should lose the focus.
2448 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2449 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2451 // Render and notify
2452 application.SendNotification();
2453 application.Render();
2455 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2457 // No more text should be introduced
2458 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2459 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2461 // Render and notify
2462 application.SendNotification();
2463 application.Render();
2465 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2470 int utcDaliTextFieldSomeSpecialKeys(void)
2472 ToolkitTestApplication application;
2473 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2475 // Checks some special keys when the text is selected.
2477 TextField field = TextField::New();
2478 DALI_TEST_CHECK( field );
2479 Stage::GetCurrent().Add( field );
2480 LoadMarkerImages(application, field);
2481 // Render and notify
2482 application.SendNotification();
2483 application.Render();
2485 const std::string longText( "This is a long text for the size of the text-field." );
2487 field.SetProperty( TextField::Property::TEXT, longText );
2488 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2489 field.SetSize( 300.f, 50.f );
2490 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2491 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2493 // Avoid a crash when core load gl resources.
2494 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2495 // Render and notify
2496 application.SendNotification();
2497 application.Render();
2499 // Create a tap event to touch the text field.
2500 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2501 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2503 // Render and notify
2504 application.SendNotification();
2505 application.Render();
2507 // Tap first to get the focus.
2508 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2509 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2511 // Render and notify
2512 application.SendNotification();
2513 application.Render();
2515 // Double tap to select a word.
2516 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2517 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2519 // Render and notify
2520 application.SendNotification();
2521 application.Render();
2523 // Generate a Esc key event. The text field should lose the focus.
2524 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2525 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2527 // Render and notify
2528 application.SendNotification();
2529 application.Render();
2531 // Generate a Esc key event. The text field should lose the focus.
2532 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2533 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2535 // Render and notify
2536 application.SendNotification();
2537 application.Render();
2539 // Generate a Esc key event. The text field should lose the focus.
2540 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2541 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2543 // Render and notify
2544 application.SendNotification();
2545 application.Render();
2547 // The text shouldn't be deleted.
2548 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2553 int utcDaliTextFieldSizeUpdate(void)
2555 ToolkitTestApplication application;
2556 tet_infoline("utcDaliTextFieldSizeUpdate");
2558 // Checks some special keys when the text is selected.
2559 TextField field = TextField::New();
2560 DALI_TEST_CHECK( field );
2561 Stage::GetCurrent().Add( field );
2563 float previousHeight = 0.0f;
2564 float currentHeight = 0.0f;
2565 const float fieldWidth = 1920.0f;
2568 // "ㅁ" is bigger then "ኢ"
2569 field.SetSize( Vector2( fieldWidth ,10.0f ) );
2570 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2571 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2573 field.SetProperty( TextField::Property::TEXT, "ኢ");
2574 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2575 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2577 field.SetKeyboardFocusable(true);
2578 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2580 application.SendNotification();
2581 application.Render();
2583 previousHeight = field.GetHeightForWidth( fieldWidth );
2584 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2586 // Add another script characters ( glyph height is defferent )
2587 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2588 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2590 application.SendNotification();
2591 application.Render();
2593 currentHeight = field.GetHeightForWidth( fieldWidth );
2594 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2595 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2600 int utcDaliTextFieldExtremlyLargePointSize(void)
2602 ToolkitTestApplication application;
2603 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2605 TextField field = TextField::New();
2607 field.SetProperty( TextField::Property::TEXT, "Text" );
2608 field.SetSize( 300.f, 50.f );
2609 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2610 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2611 Stage::GetCurrent().Add( field );
2615 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2616 application.SendNotification();
2617 DALI_TEST_CHECK( field );
2621 tet_result(TET_FAIL);
2626 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2628 ToolkitTestApplication application;
2629 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2630 TextField field = TextField::New();
2631 DALI_TEST_CHECK( field );
2632 Stage::GetCurrent().Add( field );
2634 Property::Map fontStyleMapGet;
2636 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2638 Property::Value* weightValue = NULL;
2639 Property::Value* widthValue = NULL;
2640 Property::Value* slantValue = NULL;
2641 weightValue = fontStyleMapGet.Find( "weight" );
2642 widthValue = fontStyleMapGet.Find( "width" );
2643 slantValue = fontStyleMapGet.Find( "slant" );
2644 DALI_TEST_CHECK( !weightValue );
2645 DALI_TEST_CHECK( !widthValue );
2646 DALI_TEST_CHECK( !slantValue );
2651 int UtcDaliTextFieldSettingPlaceholder(void)
2653 ToolkitTestApplication application;
2654 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
2656 TextField field = TextField::New();
2657 DALI_TEST_CHECK( field );
2658 Stage::GetCurrent().Add( field );
2660 // Check the placeholder property with pixel size
2661 Property::Map placeholderPixelSizeMapSet;
2662 Property::Map placeholderPixelSizeMapGet;
2663 Property::Map placeholderFontstyleMap;
2664 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2665 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2666 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
2667 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2668 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
2669 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
2671 placeholderFontstyleMap.Insert( "weight", "bold" );
2672 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2673 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
2675 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2676 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
2677 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
2679 // Check the placeholder property with point size
2680 Property::Map placeholderMapSet;
2681 Property::Map placeholderMapGet;
2682 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2683 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2684 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
2685 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2686 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
2687 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
2689 // Check the placeholder font style property
2690 placeholderFontstyleMap.Clear();
2692 placeholderFontstyleMap.Insert( "weight", "bold" );
2693 placeholderFontstyleMap.Insert( "width", "condensed" );
2694 placeholderFontstyleMap.Insert( "slant", "italic" );
2695 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2696 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2698 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2699 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2700 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2702 // Reset font style.
2703 placeholderFontstyleMap.Clear();
2704 placeholderFontstyleMap.Insert( "weight", "normal" );
2705 placeholderFontstyleMap.Insert( "slant", "oblique" );
2706 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2707 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2709 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2710 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2711 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2713 placeholderFontstyleMap.Clear();
2714 placeholderFontstyleMap.Insert( "slant", "roman" );
2715 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2716 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2718 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2720 placeholderFontstyleMap.Clear();
2721 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2723 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2724 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2725 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2726 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2731 int UtcDaliTextFieldSetPaddingProperty(void)
2733 ToolkitTestApplication application;
2734 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
2736 TextField field = TextField::New();
2737 DALI_TEST_CHECK( field );
2738 field.SetSize( 300.f, 50.f );
2739 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2740 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2741 Stage::GetCurrent().Add( field );
2743 application.SendNotification();
2744 application.Render();
2746 Vector3 originalSize = field.GetNaturalSize();
2748 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2750 application.SendNotification();
2751 application.Render();
2753 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2755 Vector3 paddingAddedSize = field.GetNaturalSize();
2757 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2759 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2764 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
2766 ToolkitTestApplication application;
2767 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
2769 TextField field = TextField::New();
2770 DALI_TEST_CHECK( field );
2771 field.SetSize( 300.f, 50.f );
2772 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2773 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2774 Stage::GetCurrent().Add( field );
2776 application.SendNotification();
2777 application.Render();
2779 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2780 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2782 // Check the enable shift selection property
2783 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
2784 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2786 application.SendNotification();
2787 application.Render();
2792 int UtcDaliTextFieldEnableGrabHandleProperty(void)
2794 ToolkitTestApplication application;
2795 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
2797 TextField field = TextField::New();
2798 DALI_TEST_CHECK( field );
2799 field.SetSize( 300.f, 50.f );
2800 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2801 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2802 Stage::GetCurrent().Add( field );
2804 application.SendNotification();
2805 application.Render();
2807 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2808 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2810 // Check the enable grab handle property
2811 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
2812 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2814 application.SendNotification();
2815 application.Render();
2820 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
2822 ToolkitTestApplication application;
2823 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
2825 TextField field = TextField::New();
2826 DALI_TEST_CHECK( field );
2827 field.SetSize( 300.f, 50.f );
2828 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2829 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2830 Stage::GetCurrent().Add( field );
2832 application.SendNotification();
2833 application.Render();
2835 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2836 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2838 // Check the match system language direction property
2839 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2840 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2842 application.SendNotification();
2843 application.Render();
2848 int utcDaliTextFieldLayoutDirectionCoverage(void)
2850 ToolkitTestApplication application;
2851 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
2853 // Creates a tap event. After creating a tap event the text field should
2854 // have the focus and add text with key events should be possible.
2855 TextField field = TextField::New();
2856 DALI_TEST_CHECK( field );
2858 Stage::GetCurrent().Add( field );
2860 field.SetSize( 300.f, 50.f );
2861 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2862 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2864 // Avoid a crash when core load gl resources.
2865 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2867 // Render and notify
2868 application.SendNotification();
2869 application.Render();
2871 // init direction for coverage
2872 // Set horizontal alignment END
2873 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2875 // Create a tap event to touch the text field.
2876 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2877 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2879 // Render and notify
2880 application.SendNotification();
2881 application.Render();
2883 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
2884 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2885 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
2887 // Set horizontal alignment BEGIN
2888 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
2890 // Create a tap event to touch the text field.
2891 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2892 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2894 // Render and notify
2895 application.SendNotification();
2896 application.Render();
2898 // Set horizontal alignment CENTER
2899 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
2901 // Create a tap event to touch the text field.
2902 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2903 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2905 // Render and notify
2906 application.SendNotification();
2907 application.Render();
2909 // Set horizontal alignment END
2910 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2912 // Create a tap event to touch the text field.
2913 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2914 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2916 // Render and notify
2917 application.SendNotification();
2918 application.Render();
2920 // Generate a Esc key event. The text field should lose the focus.
2921 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2922 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2924 // Render and notify
2925 application.SendNotification();
2926 application.Render();
2928 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2934 int UtcDaliTextFieldGetInputMethodContext(void)
2936 ToolkitTestApplication application;
2937 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
2939 TextField field = TextField::New();
2940 DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );