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_SHADOW_OFFSET = "shadowOffset";
64 const char* const PROPERTY_NAME_SHADOW_COLOR = "shadowColor";
65 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
66 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
67 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
68 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
69 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
70 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
71 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
72 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
73 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
74 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
80 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
81 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
82 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
83 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
84 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
85 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
86 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
87 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
88 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
90 const char* const PROPERTY_NAME_UNDERLINE = "underline";
91 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
92 const char* const PROPERTY_NAME_SHADOW = "shadow";
93 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
94 const char* const PROPERTY_NAME_EMBOSS = "emboss";
95 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
96 const char* const PROPERTY_NAME_OUTLINE = "outline";
97 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
99 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
100 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
101 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
102 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
103 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
104 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
105 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
106 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
108 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
110 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
111 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
113 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
114 const float RENDER_FRAME_INTERVAL = 16.66f;
116 const float TO_MILLISECONDS = 1000.f;
117 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
119 const float SCROLL_THRESHOLD = 10.f;
120 const float SCROLL_SPEED = 300.f;
122 const unsigned int DEFAULT_FONT_SIZE = 1152u;
123 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
125 const int KEY_RETURN_CODE = 36;
126 const int KEY_A_CODE = 38;
127 const int KEY_D_CODE = 40;
129 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
131 static bool gTextChangedCallBackCalled;
132 static bool gMaxCharactersCallBackCalled;
133 static bool gInputStyleChangedCallbackCalled;
134 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
136 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
138 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
139 Integration::ResourcePointer resource(bitmap);
140 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
143 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
147 LoadBitmapResource( app.GetPlatform(), width, height );
149 Property::Map propertyMap;
150 propertyMap["filename"] = "image.png";
151 propertyMap["width"] = width;
152 propertyMap["height"] = height;
153 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
154 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
155 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
156 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
157 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
158 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
159 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
160 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
163 // Generate a PanGestureEvent to send to Core
164 static Integration::PanGestureEvent GeneratePan(
165 Gesture::State state,
166 const Vector2& previousPosition,
167 const Vector2& currentPosition,
168 unsigned long timeDelta,
169 unsigned int numberOfTouches = 1)
171 Integration::PanGestureEvent pan(state);
173 pan.previousPosition = previousPosition;
174 pan.currentPosition = currentPosition;
175 pan.timeDelta = timeDelta;
176 pan.numberOfTouches = numberOfTouches;
182 * Helper to generate PanGestureEvent
184 * @param[in] application Application instance
185 * @param[in] state The Gesture State
186 * @param[in] pos The current position of touch.
188 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
192 if( (state == Gesture::Started) ||
193 (state == Gesture::Possible) )
199 application.ProcessEvent(GeneratePan(state, last, pos, 16));
206 * Simulate time passed by.
208 * @note this will always process at least 1 frame (1/60 sec)
210 * @param application Test application instance
211 * @param duration Time to pass in milliseconds.
212 * @return The actual time passed in milliseconds
214 static int Wait(ToolkitTestApplication& application, int duration = 0)
218 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
220 application.SendNotification();
221 application.Render(RENDER_FRAME_INTERVAL);
222 time += RENDER_FRAME_INTERVAL;
228 Dali::Integration::Point GetPointDownInside( Vector2& pos )
230 Dali::Integration::Point point;
231 point.SetState( PointState::DOWN );
232 point.SetScreenPosition( pos );
236 Dali::Integration::Point GetPointUpInside( Vector2& pos )
238 Dali::Integration::Point point;
239 point.SetState( PointState::UP );
240 point.SetScreenPosition( pos );
244 struct CallbackFunctor
246 CallbackFunctor(bool* callbackFlag)
247 : mCallbackFlag( callbackFlag )
253 *mCallbackFlag = true;
258 static void TestTextChangedCallback( TextField control )
260 tet_infoline(" TestTextChangedCallback");
262 gTextChangedCallBackCalled = true;
265 static void TestMaxLengthReachedCallback( TextField control )
267 tet_infoline(" TestMaxLengthReachedCallback");
269 gMaxCharactersCallBackCalled = true;
272 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
274 tet_infoline(" TestInputStyleChangedCallback");
276 gInputStyleChangedCallbackCalled = true;
277 gInputStyleMask = mask;
280 // Generate a TapGestureEvent to send to Core.
281 Integration::TapGestureEvent GenerateTap(
282 Gesture::State state,
283 unsigned int numberOfTaps,
284 unsigned int numberOfTouches,
287 Integration::TapGestureEvent tap( state );
289 tap.numberOfTaps = numberOfTaps;
290 tap.numberOfTouches = numberOfTouches;
296 Integration::LongPressGestureEvent GenerateLongPress(
297 Gesture::State state,
298 unsigned int numberOfTouches,
301 Integration::LongPressGestureEvent longPress( state );
303 longPress.numberOfTouches = numberOfTouches;
304 longPress.point = point;
308 // Generate a KeyEvent to send to Core.
309 Integration::KeyEvent GenerateKey( const std::string& keyName,
310 const std::string& logicalKey,
311 const std::string& keyString,
314 unsigned long timeStamp,
315 const Integration::KeyEvent::State& keyState,
316 const std::string& compose = "",
317 const std::string& deviceName = DEFAULT_DEVICE_NAME,
318 const Device::Class::Type& deviceClass = Device::Class::NONE,
319 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
321 return Integration::KeyEvent( keyName,
334 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
336 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
338 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
340 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
342 Property::Value* valueSet = NULL;
343 if ( valueGet.first.type == Property::Key::INDEX )
345 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
349 // Get Key is a string so searching Set Map for a string key
350 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
353 if( NULL != valueSet )
355 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
357 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
360 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
362 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
365 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
367 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
370 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
372 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
375 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
377 Vector2 vector2Get = valueGet.second.Get<Vector2>();
378 Vector2 vector2Set = valueSet->Get<Vector2>();
379 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
382 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
384 Vector4 vector4Get = valueGet.second.Get<Vector4>();
385 Vector4 vector4Set = valueSet->Get<Vector4>();
386 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 );
392 if ( valueGet.first.type == Property::Key::INDEX )
394 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
398 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
410 int UtcDaliToolkitTextFieldConstructorP(void)
412 ToolkitTestApplication application;
413 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
415 DALI_TEST_CHECK( !textField );
419 int UtcDaliToolkitTextFieldNewP(void)
421 ToolkitTestApplication application;
422 tet_infoline(" UtcDaliToolkitTextFieldNewP");
423 TextField textField = TextField::New();
424 DALI_TEST_CHECK( textField );
428 int UtcDaliToolkitTextFieldDownCastP(void)
430 ToolkitTestApplication application;
431 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
432 TextField textField1 = TextField::New();
433 BaseHandle object( textField1 );
435 TextField textField2 = TextField::DownCast( object );
436 DALI_TEST_CHECK( textField2 );
438 TextField textField3 = DownCast< TextField >( object );
439 DALI_TEST_CHECK( textField3 );
443 int UtcDaliToolkitTextFieldDownCastN(void)
445 ToolkitTestApplication application;
446 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
447 BaseHandle uninitializedObject;
448 TextField textField1 = TextField::DownCast( uninitializedObject );
449 DALI_TEST_CHECK( !textField1 );
451 TextField textField2 = DownCast< TextField >( uninitializedObject );
452 DALI_TEST_CHECK( !textField2 );
456 int UtcDaliToolkitTextFieldCopyConstructorP(void)
458 ToolkitTestApplication application;
459 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
460 TextField textField = TextField::New();
461 textField.SetProperty( TextField::Property::TEXT, "Test" );
463 TextField copy( textField );
464 DALI_TEST_CHECK( copy );
465 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
469 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
471 ToolkitTestApplication application;
472 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
473 TextField textField = TextField::New();
474 textField.SetProperty( TextField::Property::TEXT, "Test" );
476 TextField copy = textField;
477 DALI_TEST_CHECK( copy );
478 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
482 int UtcDaliTextFieldNewP(void)
484 ToolkitTestApplication application;
485 tet_infoline(" UtcDaliToolkitTextFieldNewP");
486 TextField textField = TextField::New();
487 DALI_TEST_CHECK( textField );
491 // Positive test case for a method
492 int UtcDaliTextFieldGetPropertyP(void)
494 ToolkitTestApplication application;
495 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
496 TextField field = TextField::New();
497 DALI_TEST_CHECK( field );
499 // Check Property Indices are correct
500 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
501 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
502 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
503 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
504 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
505 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
506 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
507 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
508 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
509 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
510 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
511 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
512 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
513 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextField::Property::SHADOW_OFFSET );
514 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextField::Property::SHADOW_COLOR );
515 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
516 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
517 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
518 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
519 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
520 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
521 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
522 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
523 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
524 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
525 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
526 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
527 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
528 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
529 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
530 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
531 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
532 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
533 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
534 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
535 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
536 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
537 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
538 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
539 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
540 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
541 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
542 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
543 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
544 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
545 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
546 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
547 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
548 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
549 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
550 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
551 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
552 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
553 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
554 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
559 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
562 Property::Map imageMap;
563 imageMap[mapKey] =mapValue;
565 field.SetProperty( property , imageMap );
566 Property::Value propValue = field.GetProperty( property );
567 Property::Map* resultMap = propValue.GetMap();
569 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
577 // Positive test case for a method
578 int UtcDaliTextFieldSetPropertyP(void)
580 ToolkitTestApplication application;
581 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
582 TextField field = TextField::New();
583 DALI_TEST_CHECK( field );
584 Stage::GetCurrent().Add( field );
586 // Note - we can't check the defaults since the stylesheets are platform-specific
588 // Check the render backend property.
589 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
590 DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
592 // Check text property.
593 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
594 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
596 // Check placeholder text properties.
597 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
598 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
600 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
601 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
603 // Check font properties.
604 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
605 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
607 Property::Map fontStyleMapSet;
608 Property::Map fontStyleMapGet;
609 Property::Value* slantValue = NULL;
611 fontStyleMapSet.Insert( "weight", "bold" );
612 fontStyleMapSet.Insert( "width", "condensed" );
613 fontStyleMapSet.Insert( "slant", "italic" );
614 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
616 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
617 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
618 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
620 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
621 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
624 fontStyleMapSet.Clear();
625 fontStyleMapSet.Insert( "weight", "normal" );
626 fontStyleMapSet.Insert( "slant", "oblique" );
627 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
629 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
630 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
631 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
633 fontStyleMapSet.Clear();
634 fontStyleMapSet.Insert( "slant", "roman" );
635 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
636 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
638 // Replace 'roman' for 'normal'.
639 slantValue = fontStyleMapGet.Find( "slant" );
640 if( NULL != slantValue )
642 if( "normal" == slantValue->Get<std::string>() )
644 fontStyleMapGet["slant"] = "roman";
647 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
648 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
650 fontStyleMapSet.Clear();
652 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
653 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
654 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
655 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
657 // Check that the MAX_LENGTH property can be correctly set
658 const int maxNumberOfCharacters = 20;
659 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
660 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
662 // Check exceed policy
663 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
664 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
665 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
666 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
668 // Check that the Alignment properties can be correctly set
669 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
670 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
671 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
672 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
674 // Check text's color property
675 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
676 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
678 // Check placeholder text's color property.
679 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
680 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
682 // Check shadow properties.
683 field.SetProperty( TextField::Property::SHADOW_OFFSET, Vector2( 1.f, 1.f ) );
684 DALI_TEST_EQUALS( field.GetProperty<Vector2>( TextField::Property::SHADOW_OFFSET ), Vector2( 1.f, 1.f ), TEST_LOCATION );
685 field.SetProperty( TextField::Property::SHADOW_COLOR, Color::GREEN );
686 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SHADOW_COLOR ), Color::GREEN, TEST_LOCATION );
688 // Check cursor properties
689 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
690 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
691 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
692 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
694 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
695 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
696 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
697 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
698 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
699 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
700 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
701 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
703 // Check scroll properties.
704 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
705 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
706 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
707 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
709 // Check handle images
710 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
711 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
712 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
713 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
714 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
716 // Check handle images
717 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
718 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
719 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
720 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
721 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
722 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
724 // Check the highlight color
725 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
726 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
728 // Decoration bounding box
729 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
730 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
732 // Check the input method setting
733 Property::Map propertyMap;
734 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
735 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
736 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
737 int inputVariation = 1;
738 propertyMap["PANEL_LAYOUT"] = panelLayout;
739 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
740 propertyMap["BUTTON_ACTION"] = buttonAction;
741 propertyMap["VARIATION"] = inputVariation;
742 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
744 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
746 DALI_TEST_CHECK( value.Get( map ) );
749 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
750 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
753 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
754 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
757 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
758 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
761 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
762 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
764 // Check input color property.
765 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
766 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
768 // Check the enable markup property.
769 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
770 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
771 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
773 // Check input font properties.
774 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
775 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
777 fontStyleMapSet.Clear();
778 fontStyleMapSet.Insert( "weight", "bold" );
779 fontStyleMapSet.Insert( "width", "condensed" );
780 fontStyleMapSet.Insert( "slant", "italic" );
782 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
783 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
784 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
785 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
787 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
788 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
790 // Reset input font style.
791 fontStyleMapSet.Clear();
792 fontStyleMapSet.Insert( "weight", "normal" );
793 fontStyleMapSet.Insert( "slant", "oblique" );
795 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
796 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
797 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
798 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
800 fontStyleMapSet.Clear();
801 fontStyleMapSet.Insert( "slant", "roman" );
803 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
804 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
806 // Replace 'roman' for 'normal'.
807 slantValue = fontStyleMapGet.Find( "slant" );
808 if( NULL != slantValue )
810 if( "normal" == slantValue->Get<std::string>() )
812 fontStyleMapGet["slant"] = "roman";
815 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
816 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
818 fontStyleMapSet.Clear();
820 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
821 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
822 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
823 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
825 Property::Map underlineMapSet;
826 Property::Map underlineMapGet;
828 underlineMapSet.Insert( "enable", "true" );
829 underlineMapSet.Insert( "color", "red" );
830 underlineMapSet.Insert( "height", "1" );
832 // Check the underline property
833 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
835 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
836 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
837 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
839 // Check the input underline property
840 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
841 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
843 // Check the shadow property
844 Property::Map shadowMapSet;
845 Property::Map shadowMapGet;
847 shadowMapSet.Insert( "color", Color::GREEN );
848 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
849 shadowMapSet.Insert( "blurRadius", 3.0f );
851 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
853 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
854 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
855 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
857 // Check the input shadow property
858 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
859 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
861 // Check the emboss property
862 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
863 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
865 // Check the input emboss property
866 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
867 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
869 // Check the outline property
871 // Test string type first
872 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
873 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
874 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
876 // Then test the property map type
877 Property::Map outlineMapSet;
878 Property::Map outlineMapGet;
880 outlineMapSet["color"] = Color::RED;
881 outlineMapSet["width"] = 2.0f;
883 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
885 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
886 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
887 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
889 // Check the input outline property
890 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
891 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
893 // Check the hidden input settings property
894 Property::Map hiddenMapSet;
895 Property::Map hiddenMapGet;
896 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
897 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
898 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
899 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
900 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
902 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
903 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
904 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
906 // Check the pixel size of font
907 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
908 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
910 // Check the enable selection property
911 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
912 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
914 // Check the placeholder property with pixel size
915 Property::Map placeholderPixelSizeMapSet;
916 Property::Map placeholderPixelSizeMapGet;
917 Property::Map placeholderFontstyleMap;
918 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
919 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
920 placeholderPixelSizeMapSet["color"] = Color::BLUE;
921 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
922 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
923 placeholderPixelSizeMapSet["ellipsis"] = true;
925 placeholderFontstyleMap.Insert( "weight", "bold" );
926 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
927 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
929 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
930 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
932 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
933 Property::Map placeholderConversionMap;
934 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
935 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
936 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
937 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
938 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
939 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
941 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
943 // Check the placeholder property with point size
944 Property::Map placeholderMapSet;
945 Property::Map placeholderMapGet;
946 placeholderMapSet["text"] = "Setting Placeholder Text";
947 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
948 placeholderMapSet["color"] = Color::RED;
949 placeholderMapSet["fontFamily"] = "Arial";
950 placeholderMapSet["pointSize"] = 12.0f;
951 placeholderMapSet["ellipsis"] = false;
953 // Check the placeholder font style property
954 placeholderFontstyleMap.Clear();
956 placeholderFontstyleMap.Insert( "weight", "bold" );
957 placeholderFontstyleMap.Insert( "width", "condensed" );
958 placeholderFontstyleMap.Insert( "slant", "italic" );
959 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
960 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
962 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
963 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
965 placeholderConversionMap.Clear();
966 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
967 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
968 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
969 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
970 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
971 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
973 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
976 placeholderFontstyleMap.Clear();
977 placeholderFontstyleMap.Insert( "weight", "normal" );
978 placeholderFontstyleMap.Insert( "slant", "oblique" );
979 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
980 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
982 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
983 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
985 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
986 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
988 placeholderFontstyleMap.Clear();
989 placeholderFontstyleMap.Insert( "slant", "roman" );
990 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
991 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
993 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
995 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
997 placeholderFontstyleMap.Clear();
998 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
999 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1001 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1002 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1003 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1005 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1007 // Check the ellipsis property
1008 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1009 field.SetProperty( TextField::Property::ELLIPSIS, true );
1010 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1012 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
1013 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1015 application.SendNotification();
1016 application.Render();
1021 // Positive Atlas Text Renderer test
1022 int utcDaliTextFieldAtlasRenderP(void)
1024 ToolkitTestApplication application;
1025 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1026 StyleManager styleManager = StyleManager::Get();
1027 styleManager.ApplyDefaultTheme();
1028 TextField field = TextField::New();
1029 DALI_TEST_CHECK( field );
1031 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1033 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1035 Stage::GetCurrent().Add( field );
1039 // Render some text with the shared atlas backend
1040 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
1041 application.SendNotification();
1042 application.Render();
1046 tet_result(TET_FAIL);
1051 // Positive test for the textChanged signal.
1052 int utcDaliTextFieldTextChangedP(void)
1054 ToolkitTestApplication application;
1055 tet_infoline(" utcDaliTextFieldTextChangedP");
1056 TextField field = TextField::New();
1057 DALI_TEST_CHECK( field );
1059 Stage::GetCurrent().Add( field );
1061 // connect to the text changed signal.
1062 ConnectionTracker* testTracker = new ConnectionTracker();
1063 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1064 bool textChangedSignal = false;
1065 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1067 gTextChangedCallBackCalled = false;
1068 field.SetProperty( TextField::Property::TEXT, "ABC" );
1069 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1070 DALI_TEST_CHECK( textChangedSignal );
1072 application.SendNotification();
1074 field.SetKeyInputFocus();
1076 gTextChangedCallBackCalled = false;
1077 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1078 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1083 // Negative test for the textChanged signal.
1084 int utcDaliTextFieldTextChangedN(void)
1086 ToolkitTestApplication application;
1087 tet_infoline(" utcDaliTextFieldTextChangedN");
1088 TextField field = TextField::New();
1089 DALI_TEST_CHECK( field );
1091 Stage::GetCurrent().Add( field );
1093 // connect to the text changed signal.
1094 ConnectionTracker* testTracker = new ConnectionTracker();
1095 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1096 bool textChangedSignal = false;
1097 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1099 gTextChangedCallBackCalled = false;
1100 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1101 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1102 DALI_TEST_CHECK( !textChangedSignal );
1107 // Positive test for Max Characters reached signal.
1108 int utcDaliTextFieldMaxCharactersReachedP(void)
1110 ToolkitTestApplication application;
1111 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1112 TextField field = TextField::New();
1113 DALI_TEST_CHECK( field );
1115 Stage::GetCurrent().Add( field );
1117 const int maxNumberOfCharacters = 1;
1118 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1120 field.SetKeyInputFocus();
1122 // connect to the text changed signal.
1123 ConnectionTracker* testTracker = new ConnectionTracker();
1124 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1125 bool maxLengthReachedSignal = false;
1126 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1128 gMaxCharactersCallBackCalled = false;
1130 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1131 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1133 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1134 DALI_TEST_CHECK( maxLengthReachedSignal );
1139 // Negative test for Max Characters reached signal.
1140 int utcDaliTextFieldMaxCharactersReachedN(void)
1142 ToolkitTestApplication application;
1143 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1144 TextField field = TextField::New();
1145 DALI_TEST_CHECK( field );
1147 Stage::GetCurrent().Add( field );
1149 const int maxNumberOfCharacters = 3;
1150 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1152 field.SetKeyInputFocus();
1154 // connect to the text changed signal.
1155 ConnectionTracker* testTracker = new ConnectionTracker();
1156 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1157 bool maxLengthReachedSignal = false;
1158 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1160 gMaxCharactersCallBackCalled = false;
1162 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1163 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1165 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1166 DALI_TEST_CHECK( !maxLengthReachedSignal );
1168 application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::Down, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1170 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1171 DALI_TEST_CHECK( !maxLengthReachedSignal );
1176 int utcDaliTextFieldInputStyleChanged01(void)
1178 ToolkitTestApplication application;
1179 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1181 // The text-field emits signals when the input style changes. These changes of style are
1182 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1183 // can't be emitted during the size negotiation as the callbacks may update the UI.
1184 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1185 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1186 application.CreateAdaptor();
1190 char* pathNamePtr = get_current_dir_name();
1191 const std::string pathName( pathNamePtr );
1192 free( pathNamePtr );
1194 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1195 fontClient.SetDpi( 93u, 93u );
1197 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1198 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1200 TextField field = TextField::New();
1201 DALI_TEST_CHECK( field );
1204 field.SetSize( 300.f, 50.f );
1205 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1206 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1208 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1209 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1211 // connect to the text changed signal.
1212 ConnectionTracker* testTracker = new ConnectionTracker();
1213 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1214 bool inputStyleChangedSignal = false;
1215 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1217 Stage::GetCurrent().Add( field );
1219 // Render and notify
1220 application.SendNotification();
1221 application.Render();
1223 // Executes the idle callbacks added by the text control on the change of input style.
1224 application.RunIdles();
1226 gInputStyleChangedCallbackCalled = false;
1227 gInputStyleMask = TextField::InputStyle::NONE;
1228 inputStyleChangedSignal = false;
1230 // Create a tap event to touch the text field.
1231 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1232 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1234 // Render and notify
1235 application.SendNotification();
1236 application.Render();
1238 // Executes the idle callbacks added by the text control on the change of input style.
1239 application.RunIdles();
1241 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1242 if( gInputStyleChangedCallbackCalled )
1244 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1246 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1247 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1249 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1250 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1252 DALI_TEST_CHECK( inputStyleChangedSignal );
1254 gInputStyleChangedCallbackCalled = false;
1255 gInputStyleMask = TextField::InputStyle::NONE;
1256 inputStyleChangedSignal = false;
1258 // Create a tap event to touch the text field.
1259 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1260 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1262 // Render and notify
1263 application.SendNotification();
1264 application.Render();
1266 // Executes the idle callbacks added by the text control on the change of input style.
1267 application.RunIdles();
1269 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1270 DALI_TEST_CHECK( !inputStyleChangedSignal );
1272 gInputStyleChangedCallbackCalled = false;
1273 gInputStyleMask = TextField::InputStyle::NONE;
1274 inputStyleChangedSignal = false;
1276 // Create a tap event to touch the text field.
1277 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1278 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1280 // Render and notify
1281 application.SendNotification();
1282 application.Render();
1284 // Executes the idle callbacks added by the text control on the change of input style.
1285 application.RunIdles();
1287 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1288 if( gInputStyleChangedCallbackCalled )
1290 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1292 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1293 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1295 DALI_TEST_CHECK( inputStyleChangedSignal );
1297 gInputStyleChangedCallbackCalled = false;
1298 gInputStyleMask = TextField::InputStyle::NONE;
1299 inputStyleChangedSignal = false;
1301 // Create a tap event to touch the text field.
1302 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1303 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1305 // Render and notify
1306 application.SendNotification();
1307 application.Render();
1309 // Executes the idle callbacks added by the text control on the change of input style.
1310 application.RunIdles();
1312 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1313 if( gInputStyleChangedCallbackCalled )
1315 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1317 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1318 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1320 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1322 Property::Map fontStyleMapSet;
1323 fontStyleMapSet.Insert( "weight", "bold" );
1325 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1326 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1328 DALI_TEST_CHECK( inputStyleChangedSignal );
1330 gInputStyleChangedCallbackCalled = false;
1331 gInputStyleMask = TextField::InputStyle::NONE;
1332 inputStyleChangedSignal = false;
1334 // Create a tap event to touch the text field.
1335 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1336 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1338 // Render and notify
1339 application.SendNotification();
1340 application.Render();
1342 // Executes the idle callbacks added by the text control on the change of input style.
1343 application.RunIdles();
1345 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1346 DALI_TEST_CHECK( !inputStyleChangedSignal );
1348 gInputStyleChangedCallbackCalled = false;
1349 gInputStyleMask = TextField::InputStyle::NONE;
1350 inputStyleChangedSignal = false;
1352 // Create a tap event to touch the text field.
1353 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1354 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1356 // Render and notify
1357 application.SendNotification();
1358 application.Render();
1360 // Executes the idle callbacks added by the text control on the change of input style.
1361 application.RunIdles();
1363 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1364 if( gInputStyleChangedCallbackCalled )
1366 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1368 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1369 DALI_TEST_CHECK( style.empty() );
1371 DALI_TEST_CHECK( inputStyleChangedSignal );
1373 gInputStyleChangedCallbackCalled = false;
1374 gInputStyleMask = TextField::InputStyle::NONE;
1375 inputStyleChangedSignal = false;
1377 // Create a tap event to touch the text field.
1378 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1379 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1381 // Render and notify
1382 application.SendNotification();
1383 application.Render();
1385 // Executes the idle callbacks added by the text control on the change of input style.
1386 application.RunIdles();
1388 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1389 DALI_TEST_CHECK( !inputStyleChangedSignal );
1394 int utcDaliTextFieldInputStyleChanged02(void)
1396 ToolkitTestApplication application;
1397 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1399 // The text-field emits signals when the input style changes. These changes of style are
1400 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1401 // can't be emitted during the size negotiation as the callbacks may update the UI.
1402 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1403 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1404 application.CreateAdaptor();
1408 char* pathNamePtr = get_current_dir_name();
1409 const std::string pathName( pathNamePtr );
1410 free( pathNamePtr );
1412 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1413 fontClient.SetDpi( 93u, 93u );
1415 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1416 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1418 TextField field = TextField::New();
1419 DALI_TEST_CHECK( field );
1422 field.SetSize( 300.f, 50.f );
1423 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1424 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1426 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1427 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>" );
1429 // connect to the text changed signal.
1430 ConnectionTracker* testTracker = new ConnectionTracker();
1431 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1432 bool inputStyleChangedSignal = false;
1433 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1435 Stage::GetCurrent().Add( field );
1437 // Render and notify
1438 application.SendNotification();
1439 application.Render();
1441 // Executes the idle callbacks added by the text control on the change of input style.
1442 application.RunIdles();
1444 gInputStyleChangedCallbackCalled = false;
1445 gInputStyleMask = TextField::InputStyle::NONE;
1446 inputStyleChangedSignal = false;
1448 // Create a tap event to touch the text field.
1449 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1450 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1451 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1452 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1454 // Render and notify
1455 application.SendNotification();
1456 application.Render();
1458 // Executes the idle callbacks added by the text control on the change of input style.
1459 application.RunIdles();
1461 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1462 if( gInputStyleChangedCallbackCalled )
1464 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1465 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1466 TextField::InputStyle::POINT_SIZE |
1467 TextField::InputStyle::COLOR ),
1470 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1471 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1473 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1474 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1476 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1477 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1479 DALI_TEST_CHECK( inputStyleChangedSignal );
1481 gInputStyleChangedCallbackCalled = false;
1482 gInputStyleMask = TextField::InputStyle::NONE;
1483 inputStyleChangedSignal = false;
1485 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1487 // Render and notify
1488 application.SendNotification();
1489 application.Render();
1491 // Executes the idle callbacks added by the text control on the change of input style.
1492 application.RunIdles();
1494 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1495 if( gInputStyleChangedCallbackCalled )
1497 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1498 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1501 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1502 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1504 DALI_TEST_CHECK( inputStyleChangedSignal );
1506 gInputStyleChangedCallbackCalled = false;
1507 gInputStyleMask = TextField::InputStyle::NONE;
1508 inputStyleChangedSignal = false;
1510 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1512 // Render and notify
1513 application.SendNotification();
1514 application.Render();
1516 // Executes the idle callbacks added by the text control on the change of input style.
1517 application.RunIdles();
1519 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1520 DALI_TEST_CHECK( !inputStyleChangedSignal );
1522 gInputStyleChangedCallbackCalled = false;
1523 gInputStyleMask = TextField::InputStyle::NONE;
1524 inputStyleChangedSignal = false;
1526 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1528 // Render and notify
1529 application.SendNotification();
1530 application.Render();
1532 // Executes the idle callbacks added by the text control on the change of input style.
1533 application.RunIdles();
1535 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1536 if( gInputStyleChangedCallbackCalled )
1538 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1539 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1542 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1543 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1545 DALI_TEST_CHECK( inputStyleChangedSignal );
1547 gInputStyleChangedCallbackCalled = false;
1548 gInputStyleMask = TextField::InputStyle::NONE;
1549 inputStyleChangedSignal = false;
1551 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1553 Property::Map fontStyleMapSet;
1554 fontStyleMapSet.Insert( "weight", "thin" );
1555 fontStyleMapSet.Insert( "width", "condensed" );
1556 fontStyleMapSet.Insert( "slant", "italic" );
1558 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1559 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1561 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1562 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1563 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1564 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1566 // Render and notify
1567 application.SendNotification();
1568 application.Render();
1570 // Executes the idle callbacks added by the text control on the change of input style.
1571 application.RunIdles();
1573 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1574 DALI_TEST_CHECK( !inputStyleChangedSignal );
1576 // Create a tap event to touch the text field.
1577 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1578 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1580 // Render and notify
1581 application.SendNotification();
1582 application.Render();
1584 // Executes the idle callbacks added by the text control on the change of input style.
1585 application.RunIdles();
1587 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1588 if( gInputStyleChangedCallbackCalled )
1590 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1591 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1592 TextField::InputStyle::POINT_SIZE |
1593 TextField::InputStyle::FONT_STYLE |
1594 TextField::InputStyle::UNDERLINE |
1595 TextField::InputStyle::SHADOW |
1596 TextField::InputStyle::EMBOSS |
1597 TextField::InputStyle::OUTLINE ),
1600 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1601 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1603 DALI_TEST_CHECK( inputStyleChangedSignal );
1608 int utcDaliTextFieldEvent01(void)
1610 ToolkitTestApplication application;
1611 tet_infoline(" utcDaliTextFieldEvent01");
1613 // Creates a tap event. After creating a tap event the text field should
1614 // have the focus and add text with key events should be possible.
1616 TextField field = TextField::New();
1617 DALI_TEST_CHECK( field );
1619 Stage::GetCurrent().Add( field );
1621 field.SetSize( 300.f, 50.f );
1622 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1623 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1625 // Avoid a crash when core load gl resources.
1626 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1628 // Render and notify
1629 application.SendNotification();
1630 application.Render();
1632 // Add a key event but as the text field has not the focus it should do nothing.
1633 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1635 // Render and notify
1636 application.SendNotification();
1637 application.Render();
1639 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1641 // Create a tap event to touch the text field.
1642 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1643 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1645 // Render and notify
1646 application.SendNotification();
1647 application.Render();
1649 // Pressing delete key should be fine even if there is no text in TextField.
1650 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 ) );
1651 // Render and notify
1652 application.SendNotification();
1653 application.Render();
1655 // Now the text field has the focus, so it can handle the key events.
1656 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1657 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1659 // Render and notify
1660 application.SendNotification();
1661 application.Render();
1663 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1665 // Create a second text field and send key events to it.
1666 TextField field2 = TextField::New();
1668 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1669 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1670 field2.SetSize( 100.f, 100.f );
1671 field2.SetPosition( 100.f, 100.f );
1673 Stage::GetCurrent().Add( field2 );
1675 // Render and notify
1676 application.SendNotification();
1677 application.Render();
1679 // Create a tap event on the second text field.
1680 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1681 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1683 // Render and notify
1684 application.SendNotification();
1685 application.Render();
1687 // The second text field has the focus. It should handle the key events.
1688 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1689 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1691 // Render and notify
1692 application.SendNotification();
1693 application.Render();
1695 // Check the text has been added to the second text field.
1696 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1701 int utcDaliTextFieldEvent02(void)
1703 ToolkitTestApplication application;
1704 tet_infoline(" utcDaliTextFieldEvent02");
1706 // Checks if the right number of actors are created.
1708 TextField field = TextField::New();
1709 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1710 DALI_TEST_CHECK( field );
1711 LoadMarkerImages(application, field);
1713 Stage::GetCurrent().Add( field );
1715 field.SetSize( 300.f, 50.f );
1716 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1717 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1719 // Avoid a crash when core load gl resources.
1720 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1722 // Render and notify
1723 application.SendNotification();
1724 application.Render();
1726 // Check there are the expected number of children ( stencil ).
1727 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1729 Actor stencil = field.GetChildAt( 0u );
1730 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1732 // Create a tap event to touch the text field.
1733 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1734 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1736 // Render and notify
1737 application.SendNotification();
1738 application.Render();
1740 Actor layer = field.GetChildAt( 1u );
1741 DALI_TEST_CHECK( layer.IsLayer() );
1743 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1744 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1746 // Now the text field has the focus, so it can handle the key events.
1747 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1748 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1750 // Render and notify
1751 application.SendNotification();
1752 application.Render();
1754 // Checks the cursor and the renderer have been created.
1755 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1756 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1758 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1759 DALI_TEST_CHECK( cursor );
1761 // The offscreen root actor has a container with all the actors which contain the text renderers.
1762 Actor container = stencil.GetChildAt( 0u );
1763 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1765 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1766 DALI_TEST_CHECK( renderer );
1769 // Move the cursor and check the position changes.
1770 Vector3 position1 = cursor.GetCurrentPosition();
1772 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1773 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1775 // Render and notify
1776 application.SendNotification();
1777 application.Render();
1779 Vector3 position2 = cursor.GetCurrentPosition();
1781 DALI_TEST_CHECK( position2.x < position1.x );
1783 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1784 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1786 // Render and notify
1787 application.SendNotification();
1788 application.Render();
1790 Vector3 position3 = cursor.GetCurrentPosition();
1792 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1794 // Send some taps and check the cursor positions.
1796 // Try to tap at the beginning.
1797 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1798 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1800 // Render and notify
1801 application.SendNotification();
1802 application.Render();
1804 // Cursor position should be the same than position1.
1805 Vector3 position4 = cursor.GetCurrentPosition();
1807 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1809 // Tap away from the start position.
1810 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1811 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1813 // Render and notify
1814 application.SendNotification();
1815 application.Render();
1817 Vector3 position5 = cursor.GetCurrentPosition();
1819 DALI_TEST_CHECK( position5.x > position4.x );
1821 // Remove all the text.
1822 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1823 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1824 field.SetProperty( TextField::Property::TEXT, "" );
1826 // Render and notify
1827 application.SendNotification();
1828 application.Render();
1830 // Cursor position should be the same than position2.
1831 Vector3 position6 = cursor.GetCurrentPosition();
1833 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1835 // Should not be a renderer.
1836 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1838 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1839 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1840 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1842 application.SendNotification();
1843 application.Render();
1845 // There are renderer and decorator layer
1846 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1851 int utcDaliTextFieldEvent03(void)
1853 ToolkitTestApplication application;
1854 tet_infoline(" utcDaliTextFieldEvent03");
1856 // Checks if the highlight actor is created.
1858 TextField field = TextField::New();
1859 DALI_TEST_CHECK( field );
1861 Stage::GetCurrent().Add( field );
1863 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1864 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1865 field.SetSize( 30.f, 50.f );
1866 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1867 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1869 // Avoid a crash when core load gl resources.
1870 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1871 LoadMarkerImages(application, field);
1873 // Render and notify
1874 application.SendNotification();
1875 application.Render();
1877 // Tap first to get the focus.
1878 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1879 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1881 // Render and notify
1882 application.SendNotification();
1883 application.Render();
1885 // Double tap to select a word.
1886 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1887 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1889 // Render and notify
1890 application.SendNotification();
1891 application.Render();
1893 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1894 Actor stencil = field.GetChildAt( 0u );
1896 // The highlight actor is drawn first, so is the first actor in the list
1897 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1898 DALI_TEST_CHECK( highlight );
1900 // The offscreen root actor has a container with all the actors which contain the text renderers.
1901 Actor container = stencil.GetChildAt( 1u );
1902 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1904 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1905 DALI_TEST_CHECK( renderer );
1911 int utcDaliTextFieldEvent04(void)
1913 ToolkitTestApplication application;
1914 tet_infoline(" utcDaliTextFieldEvent04");
1916 // Checks if the highlight actor is created.
1918 TextField field = TextField::New();
1919 DALI_TEST_CHECK( field );
1920 Stage::GetCurrent().Add( field );
1921 LoadMarkerImages(application, field);
1922 // Render and notify
1923 application.SendNotification();
1924 application.Render();
1926 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1927 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1928 field.SetSize( 300.f, 50.f );
1929 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1930 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1932 // Avoid a crash when core load gl resources.
1933 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1934 // Render and notify
1935 application.SendNotification();
1936 application.Render();
1938 // Create a tap event to touch the text field.
1939 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1940 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1941 // Render and notify
1942 application.SendNotification();
1943 application.Render();
1946 // Tap first to get the focus.
1947 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1948 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1950 // Render and notify
1951 application.SendNotification();
1952 application.Render();
1954 // Double tap to select a word.
1955 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1956 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1958 // Render and notify
1959 application.SendNotification();
1960 application.Render();
1963 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1964 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1968 int utcDaliTextFieldEvent05(void)
1970 ToolkitTestApplication application;
1971 tet_infoline(" utcDaliTextFieldEvent05");
1973 // Checks dragging of cursor/grab handle
1975 TextField field = TextField::New();
1976 DALI_TEST_CHECK( field );
1977 Stage::GetCurrent().Add( field );
1978 LoadMarkerImages(application, field);
1979 // Render and notify
1980 application.SendNotification();
1981 application.Render();
1983 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1984 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1985 field.SetSize( 300.f, 50.f );
1986 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1987 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1989 // Avoid a crash when core load gl resources.
1990 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1991 // Render and notify
1992 application.SendNotification();
1993 application.Render();
1995 // Create a tap event to touch the text field.
1996 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1997 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1998 // Render and notify
1999 application.SendNotification();
2000 application.Render();
2002 // Tap first to get the focus.
2003 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2004 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2006 // Render and notify
2007 application.SendNotification();
2008 application.Render();
2010 // Double tap to select a word.
2011 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2012 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2014 // Render and notify
2015 application.SendNotification();
2016 application.Render();
2018 // drag grab handle right
2019 Vector2 pos(0.0f, 40.0f);
2020 SendPan(application, Gesture::Possible, pos);
2021 SendPan(application, Gesture::Started, pos);
2023 Wait(application, 100);
2025 for(int i = 0;i<20;i++)
2027 SendPan(application, Gesture::Continuing, pos);
2032 SendPan(application, Gesture::Finished, pos);
2033 Wait(application, RENDER_FRAME_INTERVAL);
2035 Actor stencil = field.GetChildAt( 1u );
2039 int utcDaliTextFieldEvent06(void)
2041 ToolkitTestApplication application;
2042 tet_infoline(" utcDaliTextFieldEvent06");
2044 // Checks Longpress when in edit mode
2046 TextField field = TextField::New();
2047 DALI_TEST_CHECK( field );
2048 Stage::GetCurrent().Add( field );
2049 LoadMarkerImages(application, field);
2050 // Render and notify
2051 application.SendNotification();
2052 application.Render();
2054 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2055 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2056 field.SetSize( 300.f, 50.f );
2057 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2058 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2060 // Avoid a crash when core load gl resources.
2061 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2062 // Render and notify
2063 application.SendNotification();
2064 application.Render();
2066 // Create a tap event to touch the text field.
2067 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2068 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2069 // Render and notify
2070 application.SendNotification();
2071 application.Render();
2074 // Tap first to get the focus.
2075 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2076 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2078 // Render and notify
2079 application.SendNotification();
2080 application.Render();
2083 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2084 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2086 // Render and notify
2087 application.SendNotification();
2088 application.Render();
2093 int utcDaliTextFieldEvent07(void)
2095 ToolkitTestApplication application;
2096 tet_infoline(" utcDaliTextFieldEvent07");
2098 // Checks Longpress to start edit mode
2100 TextField field = TextField::New();
2101 DALI_TEST_CHECK( field );
2102 Stage::GetCurrent().Add( field );
2103 LoadMarkerImages(application, field);
2104 // Render and notify
2105 application.SendNotification();
2106 application.Render();
2108 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2109 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2110 field.SetSize( 300.f, 50.f );
2111 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2112 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2113 Property::Map propertyMap;
2114 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2115 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2117 // Avoid a crash when core load gl resources.
2118 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2119 // Render and notify
2120 application.SendNotification();
2121 application.Render();
2124 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2125 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2127 // Render and notify
2128 application.SendNotification();
2129 application.Render();
2134 int utcDaliTextFieldEvent08(void)
2136 ToolkitTestApplication application;
2137 tet_infoline(" utcDaliTextFieldEvent08");
2139 Dali::Clipboard clipboard = Clipboard::Get();
2140 clipboard.SetItem("testTextFieldEvent");
2142 // Checks Longpress when only place holder text
2144 TextField field = TextField::New();
2145 DALI_TEST_CHECK( field );
2146 Stage::GetCurrent().Add( field );
2147 LoadMarkerImages(application, field);
2148 // Render and notify
2149 application.SendNotification();
2150 application.Render();
2152 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2153 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2154 field.SetSize( 300.f, 50.f );
2155 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2156 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2158 // Avoid a crash when core load gl resources.
2159 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2160 // Render and notify
2161 application.SendNotification();
2162 application.Render();
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);
2175 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2176 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2178 // Render and notify
2179 application.SendNotification();
2180 application.Render();
2182 Wait(application, 500);
2184 Stage stage = Stage::GetCurrent();
2185 Layer layer = stage.GetRootLayer();
2186 Actor actor = layer.FindChildByName("optionPaste");
2190 Vector3 worldPosition = actor.GetCurrentWorldPosition();
2191 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2192 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2194 Dali::Integration::TouchEvent event;
2195 event = Dali::Integration::TouchEvent();
2196 event.AddPoint( GetPointDownInside( position ) );
2197 application.ProcessEvent( event );
2199 event = Dali::Integration::TouchEvent();
2200 event.AddPoint( GetPointUpInside( position ) );
2201 application.ProcessEvent( event );
2203 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2208 int utcDaliTextFieldEvent09(void)
2210 ToolkitTestApplication application;
2211 tet_infoline(" utcDaliTextFieldEvent09");
2213 TextField field = TextField::New();
2214 DALI_TEST_CHECK( field );
2215 Stage::GetCurrent().Add( field );
2216 LoadMarkerImages(application, field);
2217 // Render and notify
2218 application.SendNotification();
2219 application.Render();
2221 field.SetProperty( TextField::Property::TEXT, "Hello" );
2222 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2223 field.SetSize( 300.f, 50.f );
2224 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2225 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2227 // Avoid a crash when core load gl resources.
2228 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2230 // Create a tap event to touch the text field.
2231 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2232 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2233 application.SendNotification();
2234 application.Render();
2237 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2238 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2239 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2240 application.SendNotification();
2241 application.Render();
2243 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2244 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2245 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2246 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2247 application.SendNotification();
2248 application.Render();
2250 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_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_COUNT;
2261 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2262 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2263 for( unsigned int index = 0u; index < 5u; ++index )
2265 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2266 application.SendNotification();
2267 application.Render();
2270 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2271 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2272 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2273 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2274 application.SendNotification();
2275 application.Render();
2276 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2277 application.SendNotification();
2278 application.Render();
2280 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2281 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2282 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2283 application.SendNotification();
2284 application.Render();
2286 Property::Map mapGet;
2287 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2288 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2289 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2294 int utcDaliTextFieldStyleWhilstSelected(void)
2296 ToolkitTestApplication application;
2297 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2299 // Change font and styles whilst text is selected whilst word selected
2301 TextField field = TextField::New();
2302 DALI_TEST_CHECK( field );
2303 Stage::GetCurrent().Add( field );
2304 LoadMarkerImages(application, field);
2305 // Render and notify
2306 application.SendNotification();
2307 application.Render();
2309 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2310 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2311 field.SetSize( 300.f, 50.f );
2312 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2313 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2315 // Avoid a crash when core load gl resources.
2316 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2317 // Render and notify
2318 application.SendNotification();
2319 application.Render();
2321 // Create a tap event to touch the text field.
2322 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2323 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2324 // Render and notify
2325 application.SendNotification();
2326 application.Render();
2329 // Tap first to get the focus.
2330 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2331 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2333 // Render and notify
2334 application.SendNotification();
2335 application.Render();
2337 // Double tap to select a word.
2338 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2339 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2341 // Render and notify
2342 application.SendNotification();
2343 application.Render();
2345 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2346 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2348 Property::Map fontStyleMapSet;
2349 Property::Map fontStyleMapGet;
2351 fontStyleMapSet.Insert( "weight", "bold" );
2352 fontStyleMapSet.Insert( "slant", "italic" );
2353 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2355 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2356 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2357 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2359 fontStyleMapSet.Clear();
2360 fontStyleMapSet.Insert( "width", "expanded" );
2361 fontStyleMapSet.Insert( "slant", "italic" );
2362 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2364 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2365 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2366 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2368 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2369 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2371 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2372 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2374 fontStyleMapSet.Clear();
2375 fontStyleMapSet.Insert( "weight", "bold" );
2376 fontStyleMapSet.Insert( "slant", "italic" );
2378 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2380 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2381 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2382 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2384 fontStyleMapSet.Clear();
2385 fontStyleMapSet.Insert( "width", "expanded" );
2387 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2389 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2390 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2391 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2393 // Press Escape to increase coverage
2394 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2395 application.SendNotification();
2396 application.Render();
2398 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2403 int utcDaliTextFieldEscKeyLoseFocus(void)
2405 ToolkitTestApplication application;
2406 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2408 // Creates a tap event. After creating a tap event the text field should
2409 // have the focus and add text with key events should be possible.
2411 TextField field = TextField::New();
2412 DALI_TEST_CHECK( field );
2414 Stage::GetCurrent().Add( field );
2416 field.SetSize( 300.f, 50.f );
2417 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2418 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2420 // Avoid a crash when core load gl resources.
2421 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2423 // Render and notify
2424 application.SendNotification();
2425 application.Render();
2427 // Add a key event but as the text field has not the focus it should do nothing.
2428 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2429 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2431 // Render and notify
2432 application.SendNotification();
2433 application.Render();
2435 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2437 // Create a tap event to touch the text field.
2438 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2439 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2441 // Render and notify
2442 application.SendNotification();
2443 application.Render();
2445 // Now the text field has the focus, so it can handle the key events.
2446 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2447 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2448 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2449 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2451 // Render and notify
2452 application.SendNotification();
2453 application.Render();
2455 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2457 // Generate a Esc key event. The text field should lose the focus.
2458 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2459 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2461 // Render and notify
2462 application.SendNotification();
2463 application.Render();
2465 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2467 // No more text should be introduced
2468 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2469 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2471 // Render and notify
2472 application.SendNotification();
2473 application.Render();
2475 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2480 int utcDaliTextFieldSomeSpecialKeys(void)
2482 ToolkitTestApplication application;
2483 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2485 // Checks some special keys when the text is selected.
2487 TextField field = TextField::New();
2488 DALI_TEST_CHECK( field );
2489 Stage::GetCurrent().Add( field );
2490 LoadMarkerImages(application, field);
2491 // Render and notify
2492 application.SendNotification();
2493 application.Render();
2495 const std::string longText( "This is a long text for the size of the text-field." );
2497 field.SetProperty( TextField::Property::TEXT, longText );
2498 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2499 field.SetSize( 300.f, 50.f );
2500 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2501 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2503 // Avoid a crash when core load gl resources.
2504 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2505 // Render and notify
2506 application.SendNotification();
2507 application.Render();
2509 // Create a tap event to touch the text field.
2510 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2511 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2513 // Render and notify
2514 application.SendNotification();
2515 application.Render();
2517 // Tap first to get the focus.
2518 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2519 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2521 // Render and notify
2522 application.SendNotification();
2523 application.Render();
2525 // Double tap to select a word.
2526 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2527 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2529 // Render and notify
2530 application.SendNotification();
2531 application.Render();
2533 // Generate a Esc key event. The text field should lose the focus.
2534 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2535 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2537 // Render and notify
2538 application.SendNotification();
2539 application.Render();
2541 // Generate a Esc key event. The text field should lose the focus.
2542 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2543 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2545 // Render and notify
2546 application.SendNotification();
2547 application.Render();
2549 // Generate a Esc key event. The text field should lose the focus.
2550 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2551 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2553 // Render and notify
2554 application.SendNotification();
2555 application.Render();
2557 // The text shouldn't be deleted.
2558 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2563 int utcDaliTextFieldSizeUpdate(void)
2565 ToolkitTestApplication application;
2566 tet_infoline("utcDaliTextFieldSizeUpdate");
2568 // Checks some special keys when the text is selected.
2569 TextField field = TextField::New();
2570 DALI_TEST_CHECK( field );
2571 Stage::GetCurrent().Add( field );
2573 float previousHeight = 0.0f;
2574 float currentHeight = 0.0f;
2575 const float fieldWidth = 1920.0f;
2578 // "ㅁ" is bigger then "ኢ"
2579 field.SetSize( Vector2( fieldWidth ,10.0f ) );
2580 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2581 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2583 field.SetProperty( TextField::Property::TEXT, "ኢ");
2584 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2585 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2587 field.SetKeyboardFocusable(true);
2588 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2590 application.SendNotification();
2591 application.Render();
2593 previousHeight = field.GetHeightForWidth( fieldWidth );
2594 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2596 // Add another script characters ( glyph height is defferent )
2597 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2598 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2600 application.SendNotification();
2601 application.Render();
2603 currentHeight = field.GetHeightForWidth( fieldWidth );
2604 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2605 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2610 int utcDaliTextFieldExtremlyLargePointSize(void)
2612 ToolkitTestApplication application;
2613 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2615 TextField field = TextField::New();
2617 field.SetProperty( TextField::Property::TEXT, "Text" );
2618 field.SetSize( 300.f, 50.f );
2619 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2620 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2621 Stage::GetCurrent().Add( field );
2625 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2626 application.SendNotification();
2627 DALI_TEST_CHECK( field );
2631 tet_result(TET_FAIL);
2636 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2638 ToolkitTestApplication application;
2639 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2640 TextField field = TextField::New();
2641 DALI_TEST_CHECK( field );
2642 Stage::GetCurrent().Add( field );
2644 Property::Map fontStyleMapGet;
2646 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2648 Property::Value* weightValue = NULL;
2649 Property::Value* widthValue = NULL;
2650 Property::Value* slantValue = NULL;
2651 weightValue = fontStyleMapGet.Find( "weight" );
2652 widthValue = fontStyleMapGet.Find( "width" );
2653 slantValue = fontStyleMapGet.Find( "slant" );
2654 DALI_TEST_CHECK( !weightValue );
2655 DALI_TEST_CHECK( !widthValue );
2656 DALI_TEST_CHECK( !slantValue );
2661 int UtcDaliTextFieldSettingPlaceholder(void)
2663 ToolkitTestApplication application;
2664 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
2666 TextField field = TextField::New();
2667 DALI_TEST_CHECK( field );
2668 Stage::GetCurrent().Add( field );
2670 // Check the placeholder property with pixel size
2671 Property::Map placeholderPixelSizeMapSet;
2672 Property::Map placeholderPixelSizeMapGet;
2673 Property::Map placeholderFontstyleMap;
2674 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2675 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2676 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
2677 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2678 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
2679 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
2681 placeholderFontstyleMap.Insert( "weight", "bold" );
2682 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2683 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
2685 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2686 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
2687 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
2689 // Check the placeholder property with point size
2690 Property::Map placeholderMapSet;
2691 Property::Map placeholderMapGet;
2692 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2693 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2694 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
2695 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2696 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
2697 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
2699 // Check the placeholder font style property
2700 placeholderFontstyleMap.Clear();
2702 placeholderFontstyleMap.Insert( "weight", "bold" );
2703 placeholderFontstyleMap.Insert( "width", "condensed" );
2704 placeholderFontstyleMap.Insert( "slant", "italic" );
2705 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2706 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2708 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2709 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2710 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2712 // Reset font style.
2713 placeholderFontstyleMap.Clear();
2714 placeholderFontstyleMap.Insert( "weight", "normal" );
2715 placeholderFontstyleMap.Insert( "slant", "oblique" );
2716 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2717 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2719 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2720 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2721 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2723 placeholderFontstyleMap.Clear();
2724 placeholderFontstyleMap.Insert( "slant", "roman" );
2725 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2726 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2728 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2730 placeholderFontstyleMap.Clear();
2731 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
2733 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
2734 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
2735 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
2736 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
2741 int UtcDaliTextFieldSetPaddingProperty(void)
2743 ToolkitTestApplication application;
2744 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
2746 TextField field = TextField::New();
2747 DALI_TEST_CHECK( field );
2748 field.SetSize( 300.f, 50.f );
2749 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2750 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2751 Stage::GetCurrent().Add( field );
2753 application.SendNotification();
2754 application.Render();
2756 Vector3 originalSize = field.GetNaturalSize();
2758 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2760 application.SendNotification();
2761 application.Render();
2763 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2765 Vector3 paddingAddedSize = field.GetNaturalSize();
2767 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2769 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2774 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
2776 ToolkitTestApplication application;
2777 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
2779 TextField field = TextField::New();
2780 DALI_TEST_CHECK( field );
2781 field.SetSize( 300.f, 50.f );
2782 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2783 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2784 Stage::GetCurrent().Add( field );
2786 application.SendNotification();
2787 application.Render();
2789 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2790 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2792 // Check the enable shift selection property
2793 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
2794 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2796 application.SendNotification();
2797 application.Render();
2802 int UtcDaliTextFieldEnableGrabHandleProperty(void)
2804 ToolkitTestApplication application;
2805 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
2807 TextField field = TextField::New();
2808 DALI_TEST_CHECK( field );
2809 field.SetSize( 300.f, 50.f );
2810 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2811 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2812 Stage::GetCurrent().Add( field );
2814 application.SendNotification();
2815 application.Render();
2817 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2818 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2820 // Check the enable grab handle property
2821 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
2822 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2824 application.SendNotification();
2825 application.Render();
2830 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
2832 ToolkitTestApplication application;
2833 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
2835 TextField field = TextField::New();
2836 DALI_TEST_CHECK( field );
2837 field.SetSize( 300.f, 50.f );
2838 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2839 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2840 Stage::GetCurrent().Add( field );
2842 application.SendNotification();
2843 application.Render();
2845 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2846 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2848 // Check the match system language direction property
2849 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2850 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2852 application.SendNotification();
2853 application.Render();
2858 int utcDaliTextFieldLayoutDirectionCoverage(void)
2860 ToolkitTestApplication application;
2861 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
2863 // Creates a tap event. After creating a tap event the text field should
2864 // have the focus and add text with key events should be possible.
2865 TextField field = TextField::New();
2866 DALI_TEST_CHECK( field );
2868 Stage::GetCurrent().Add( field );
2870 field.SetSize( 300.f, 50.f );
2871 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2872 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2874 // Avoid a crash when core load gl resources.
2875 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2877 // Render and notify
2878 application.SendNotification();
2879 application.Render();
2881 // init direction for coverage
2882 // Set horizontal alignment END
2883 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2885 // Create a tap event to touch the text field.
2886 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2887 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2889 // Render and notify
2890 application.SendNotification();
2891 application.Render();
2893 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
2894 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2895 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
2897 // Set horizontal alignment BEGIN
2898 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
2900 // Create a tap event to touch the text field.
2901 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2902 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2904 // Render and notify
2905 application.SendNotification();
2906 application.Render();
2908 // Set horizontal alignment CENTER
2909 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
2911 // Create a tap event to touch the text field.
2912 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2913 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2915 // Render and notify
2916 application.SendNotification();
2917 application.Render();
2919 // Set horizontal alignment END
2920 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
2922 // Create a tap event to touch the text field.
2923 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2924 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2926 // Render and notify
2927 application.SendNotification();
2928 application.Render();
2930 // Generate a Esc key event. The text field should lose the focus.
2931 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2932 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2934 // Render and notify
2935 application.SendNotification();
2936 application.Render();
2938 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2944 int UtcDaliTextFieldGetInputMethodContext(void)
2946 ToolkitTestApplication application;
2947 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
2949 TextField field = TextField::New();
2950 DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );