2 * Copyright (c) 2021 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/touch-event-integ.h>
26 #include <dali/devel-api/adaptor-framework/key-devel.h>
27 #include <dali/devel-api/text-abstraction/font-client.h>
28 #include <dali-toolkit-test-suite-utils.h>
29 #include <dali-toolkit/dali-toolkit.h>
30 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
31 #include <dali-toolkit/devel-api/text/rendering-backend.h>
32 #include "toolkit-clipboard.h"
33 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
36 using namespace Toolkit;
38 void dali_textfield_startup(void)
40 test_return_value = TET_UNDEF;
43 void dali_textfield_cleanup(void)
45 test_return_value = TET_PASS;
51 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
52 const char* const PROPERTY_NAME_TEXT = "text";
53 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
54 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
55 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
56 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
57 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
58 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
59 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
60 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
61 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
62 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
63 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
64 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
65 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
66 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
67 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
68 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
69 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
70 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
71 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
72 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
73 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
79 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
80 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
81 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
82 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
83 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
84 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
85 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
86 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
87 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
89 const char* const PROPERTY_NAME_UNDERLINE = "underline";
90 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
91 const char* const PROPERTY_NAME_SHADOW = "shadow";
92 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
93 const char* const PROPERTY_NAME_EMBOSS = "emboss";
94 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
95 const char* const PROPERTY_NAME_OUTLINE = "outline";
96 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
98 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
99 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
100 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
101 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
102 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
103 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
104 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
105 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
106 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
107 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
108 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
109 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
110 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
112 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
113 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
115 const float RENDER_FRAME_INTERVAL = 16.66f;
117 const unsigned int DEFAULT_FONT_SIZE = 1152u;
118 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
120 const int KEY_RETURN_CODE = 36;
121 const int KEY_A_CODE = 38;
122 const int KEY_D_CODE = 40;
124 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
126 static bool gAnchorClickedCallBackCalled;
127 static bool gAnchorClickedCallBackNotCalled;
128 static bool gTextChangedCallBackCalled;
129 static bool gMaxCharactersCallBackCalled;
130 static bool gInputFilteredAcceptedCallbackCalled;
131 static bool gInputFilteredRejectedCallbackCalled;
132 static bool gInputStyleChangedCallbackCalled;
133 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
135 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
137 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
138 Integration::ResourcePointer resource(bitmap);
139 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
142 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
146 LoadBitmapResource( app.GetPlatform(), width, height );
148 Property::Map propertyMap;
149 propertyMap["filename"] = "image.png";
150 propertyMap["width"] = width;
151 propertyMap["height"] = height;
152 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
153 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
154 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
155 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
156 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
157 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
158 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
159 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
163 * Simulate time passed by.
165 * @note this will always process at least 1 frame (1/60 sec)
167 * @param application Test application instance
168 * @param duration Time to pass in milliseconds.
169 * @return The actual time passed in milliseconds
171 static int Wait(ToolkitTestApplication& application, int duration = 0)
175 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
177 application.SendNotification();
178 application.Render(RENDER_FRAME_INTERVAL);
179 time += RENDER_FRAME_INTERVAL;
185 Dali::Integration::Point GetPointDownInside( Vector2& pos )
187 Dali::Integration::Point point;
188 point.SetState( PointState::DOWN );
189 point.SetScreenPosition( pos );
193 Dali::Integration::Point GetPointUpInside( Vector2& pos )
195 Dali::Integration::Point point;
196 point.SetState( PointState::UP );
197 point.SetScreenPosition( pos );
201 struct CallbackFunctor
203 CallbackFunctor(bool* callbackFlag)
204 : mCallbackFlag( callbackFlag )
210 *mCallbackFlag = true;
215 static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength)
217 tet_infoline(" TestAnchorClickedCallback");
219 gAnchorClickedCallBackNotCalled = false;
221 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
223 gAnchorClickedCallBackCalled = true;
227 static void TestTextChangedCallback( TextField control )
229 tet_infoline(" TestTextChangedCallback");
231 gTextChangedCallBackCalled = true;
234 static void TestMaxLengthReachedCallback( TextField control )
236 tet_infoline(" TestMaxLengthReachedCallback");
238 gMaxCharactersCallBackCalled = true;
241 static void TestInputFilteredCallback(TextField control, Toolkit::InputFilter::Property::Type type)
243 tet_infoline(" TestInputFilteredCallback");
245 if(type == Toolkit::InputFilter::Property::ACCEPTED)
247 gInputFilteredAcceptedCallbackCalled = true;
249 else if(type == Toolkit::InputFilter::Property::REJECTED)
251 gInputFilteredRejectedCallbackCalled = true;
255 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
257 tet_infoline(" TestInputStyleChangedCallback");
259 gInputStyleChangedCallbackCalled = true;
260 gInputStyleMask = mask;
263 // Generate a KeyEvent to send to Core.
264 Integration::KeyEvent GenerateKey( const std::string& keyName,
265 const std::string& logicalKey,
266 const std::string& keyString,
269 unsigned long timeStamp,
270 const Integration::KeyEvent::State& keyState,
271 const std::string& compose = "",
272 const std::string& deviceName = DEFAULT_DEVICE_NAME,
273 const Device::Class::Type& deviceClass = Device::Class::NONE,
274 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
276 return Integration::KeyEvent( keyName,
289 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
291 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
293 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
295 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
297 Property::Value* valueSet = NULL;
298 if ( valueGet.first.type == Property::Key::INDEX )
300 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
304 // Get Key is a string so searching Set Map for a string key
305 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
308 if( NULL != valueSet )
310 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
312 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
315 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
317 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
320 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
322 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
325 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
327 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
330 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
332 Vector2 vector2Get = valueGet.second.Get<Vector2>();
333 Vector2 vector2Set = valueSet->Get<Vector2>();
334 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
337 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
339 Vector4 vector4Get = valueGet.second.Get<Vector4>();
340 Vector4 vector4Set = valueSet->Get<Vector4>();
341 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 );
347 if ( valueGet.first.type == Property::Key::INDEX )
349 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
353 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
365 int UtcDaliToolkitTextFieldConstructorP(void)
367 ToolkitTestApplication application;
368 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
370 DALI_TEST_CHECK( !textField );
374 int UtcDaliToolkitTextFieldNewP(void)
376 ToolkitTestApplication application;
377 tet_infoline(" UtcDaliToolkitTextFieldNewP");
378 TextField textField = TextField::New();
379 DALI_TEST_CHECK( textField );
383 int UtcDaliToolkitTextFieldDownCastP(void)
385 ToolkitTestApplication application;
386 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
387 TextField textField1 = TextField::New();
388 BaseHandle object( textField1 );
390 TextField textField2 = TextField::DownCast( object );
391 DALI_TEST_CHECK( textField2 );
393 TextField textField3 = DownCast< TextField >( object );
394 DALI_TEST_CHECK( textField3 );
398 int UtcDaliToolkitTextFieldDownCastN(void)
400 ToolkitTestApplication application;
401 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
402 BaseHandle uninitializedObject;
403 TextField textField1 = TextField::DownCast( uninitializedObject );
404 DALI_TEST_CHECK( !textField1 );
406 TextField textField2 = DownCast< TextField >( uninitializedObject );
407 DALI_TEST_CHECK( !textField2 );
411 int UtcDaliToolkitTextFieldCopyConstructorP(void)
413 ToolkitTestApplication application;
414 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
415 TextField textField = TextField::New();
416 textField.SetProperty( TextField::Property::TEXT, "Test" );
418 TextField copy( textField );
419 DALI_TEST_CHECK( copy );
420 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
424 int UtcDaliTextFieldMoveConstructor(void)
426 ToolkitTestApplication application;
428 TextField textField = TextField::New();
429 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
430 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
432 TextField moved = std::move( textField );
433 DALI_TEST_CHECK( moved );
434 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
435 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
436 DALI_TEST_CHECK( !textField );
441 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
443 ToolkitTestApplication application;
444 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
445 TextField textField = TextField::New();
446 textField.SetProperty( TextField::Property::TEXT, "Test" );
448 TextField copy = textField;
449 DALI_TEST_CHECK( copy );
450 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
454 int UtcDaliTextFieldMoveAssignment(void)
456 ToolkitTestApplication application;
458 TextField textField = TextField::New();
459 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
460 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
463 moved = std::move( textField );
464 DALI_TEST_CHECK( moved );
465 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
466 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
467 DALI_TEST_CHECK( !textField );
472 int UtcDaliTextFieldNewP(void)
474 ToolkitTestApplication application;
475 tet_infoline(" UtcDaliToolkitTextFieldNewP");
476 TextField textField = TextField::New();
477 DALI_TEST_CHECK( textField );
481 // Positive test case for a method
482 int UtcDaliTextFieldGetPropertyP(void)
484 ToolkitTestApplication application;
485 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
486 TextField field = TextField::New();
487 DALI_TEST_CHECK( field );
489 // Check Property Indices are correct
490 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextField::Property::RENDERING_BACKEND );
491 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
492 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
493 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
494 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
495 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
496 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
497 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
498 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
499 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
500 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
501 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
502 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
503 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
504 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
505 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
506 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
507 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
508 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
509 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
510 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
511 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
512 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
513 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
514 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
515 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
516 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
517 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
518 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
519 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
520 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
521 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
522 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
523 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
524 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
525 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
526 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
527 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
528 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
529 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
530 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
531 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
532 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
533 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
534 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
535 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
536 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
537 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
538 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
539 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
540 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextField::Property::FONT_SIZE_SCALE );
541 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
542 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
543 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
544 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP );
545 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextField::Property::BACKGROUND );
546 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextField::Property::GRAB_HANDLE_COLOR );
547 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FILTER ) == DevelTextField::Property::INPUT_FILTER );
552 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
555 Property::Map imageMap;
556 imageMap[mapKey] =mapValue;
558 field.SetProperty( property , imageMap );
559 Property::Value propValue = field.GetProperty( property );
560 Property::Map* resultMap = propValue.GetMap();
562 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
570 // Positive test case for a method
571 int UtcDaliTextFieldSetPropertyP(void)
573 ToolkitTestApplication application;
574 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
575 TextField field = TextField::New();
576 DALI_TEST_CHECK( field );
577 application.GetScene().Add( field );
579 // Note - we can't check the defaults since the stylesheets are platform-specific
581 // Check the render backend property.
582 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
583 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
585 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
586 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION );
588 // Check text property.
589 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
590 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
592 // Check placeholder text properties.
593 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
594 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
596 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
597 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
599 // Check font properties.
600 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
601 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
603 Property::Map fontStyleMapSet;
604 Property::Map fontStyleMapGet;
605 Property::Value* slantValue = NULL;
607 fontStyleMapSet.Insert( "weight", "bold" );
608 fontStyleMapSet.Insert( "width", "condensed" );
609 fontStyleMapSet.Insert( "slant", "italic" );
610 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
612 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
613 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
614 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
616 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
617 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
619 field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 2.5f );
620 DALI_TEST_EQUALS( field.GetProperty<float>( DevelTextField::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
621 field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 1.0f );
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 cursor properties
683 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
684 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
685 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
686 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
688 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
689 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
690 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
691 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
692 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
693 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
694 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
695 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
697 // Check scroll properties.
698 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
699 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
700 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
701 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
703 // Check handle images
704 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
705 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
706 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
707 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
708 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
710 // Check handle images
711 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
712 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
713 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
714 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
715 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
716 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
718 // Check the highlight color
719 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
720 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
722 // Decoration bounding box
723 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
724 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
726 // Check the input method setting
727 Property::Map propertyMap;
728 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
729 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
730 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
731 int inputVariation = 1;
732 propertyMap["PANEL_LAYOUT"] = panelLayout;
733 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
734 propertyMap["BUTTON_ACTION"] = buttonAction;
735 propertyMap["VARIATION"] = inputVariation;
736 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
738 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
740 DALI_TEST_CHECK( value.Get( map ) );
743 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
744 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
747 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
748 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
751 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
752 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
755 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
756 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
758 // Check input color property.
759 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
760 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
762 // Check the enable markup property.
763 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
764 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
765 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
767 // Check input font properties.
768 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
769 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
771 fontStyleMapSet.Clear();
772 fontStyleMapSet.Insert( "weight", "bold" );
773 fontStyleMapSet.Insert( "width", "condensed" );
774 fontStyleMapSet.Insert( "slant", "italic" );
776 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
777 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
778 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
779 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
781 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
782 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
784 // Reset input font style.
785 fontStyleMapSet.Clear();
786 fontStyleMapSet.Insert( "weight", "normal" );
787 fontStyleMapSet.Insert( "slant", "oblique" );
789 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
790 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
791 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
792 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
794 fontStyleMapSet.Clear();
795 fontStyleMapSet.Insert( "slant", "roman" );
797 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
798 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
800 // Replace 'roman' for 'normal'.
801 slantValue = fontStyleMapGet.Find( "slant" );
802 if( NULL != slantValue )
804 if( "normal" == slantValue->Get<std::string>() )
806 fontStyleMapGet["slant"] = "roman";
809 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
810 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
812 fontStyleMapSet.Clear();
814 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
815 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
816 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
817 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
819 Property::Map underlineMapSet;
820 Property::Map underlineMapGet;
822 underlineMapSet.Insert( "enable", true );
823 underlineMapSet.Insert( "color", Color::RED );
824 underlineMapSet.Insert( "height", 1 );
826 // Check the underline property
827 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
829 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
830 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
831 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
833 // Check the input underline property
834 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
835 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
837 // Check the shadow property
838 Property::Map shadowMapSet;
839 Property::Map shadowMapGet;
841 shadowMapSet.Insert( "color", Color::GREEN );
842 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
843 shadowMapSet.Insert( "blurRadius", 3.0f );
845 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
847 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
848 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
849 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
851 // Check the input shadow property
852 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
853 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
855 // Check the emboss property
856 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
857 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
859 // Check the input emboss property
860 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
861 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
863 // Check the outline property
865 // Test string type first
866 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
867 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
868 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
870 // Then test the property map type
871 Property::Map outlineMapSet;
872 Property::Map outlineMapGet;
874 outlineMapSet["color"] = Color::RED;
875 outlineMapSet["width"] = 2.0f;
877 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
879 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
880 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
881 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
883 // Check the input outline property
884 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
885 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
887 // Check the hidden input settings property
888 Property::Map hiddenMapSet;
889 Property::Map hiddenMapGet;
890 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
891 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
892 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
893 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
894 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
896 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
897 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
898 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
900 // Check the pixel size of font
901 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
902 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
904 // Check the enable selection property
905 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
906 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
908 // Check the placeholder property with pixel size
909 Property::Map placeholderPixelSizeMapSet;
910 Property::Map placeholderPixelSizeMapGet;
911 Property::Map placeholderFontstyleMap;
912 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
913 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
914 placeholderPixelSizeMapSet["color"] = Color::BLUE;
915 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
916 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
917 placeholderPixelSizeMapSet["ellipsis"] = true;
919 placeholderFontstyleMap.Insert( "weight", "bold" );
920 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
921 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
923 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
924 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
926 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
927 Property::Map placeholderConversionMap;
928 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
929 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
930 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
931 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
932 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
933 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
935 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
937 // Check the placeholder property with point size
938 Property::Map placeholderMapSet;
939 Property::Map placeholderMapGet;
940 placeholderMapSet["text"] = "Setting Placeholder Text";
941 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
942 placeholderMapSet["color"] = Color::RED;
943 placeholderMapSet["fontFamily"] = "Arial";
944 placeholderMapSet["pointSize"] = 12.0f;
945 placeholderMapSet["ellipsis"] = false;
947 // Check the placeholder font style property
948 placeholderFontstyleMap.Clear();
950 placeholderFontstyleMap.Insert( "weight", "bold" );
951 placeholderFontstyleMap.Insert( "width", "condensed" );
952 placeholderFontstyleMap.Insert( "slant", "italic" );
953 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
954 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
956 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
957 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
959 placeholderConversionMap.Clear();
960 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
961 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
962 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
963 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
964 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
965 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
967 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
970 placeholderFontstyleMap.Clear();
971 placeholderFontstyleMap.Insert( "weight", "normal" );
972 placeholderFontstyleMap.Insert( "slant", "oblique" );
973 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
974 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
976 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
977 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
979 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
980 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
982 placeholderFontstyleMap.Clear();
983 placeholderFontstyleMap.Insert( "slant", "roman" );
984 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
985 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
987 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
989 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
991 placeholderFontstyleMap.Clear();
992 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
993 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
995 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
996 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
997 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
999 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1001 // Check the ellipsis property
1002 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1003 field.SetProperty( TextField::Property::ELLIPSIS, true );
1004 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1006 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
1007 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1009 // Test the ENABLE_GRAB_HANDLE_POPUP property
1010 DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1011 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false );
1012 DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1014 // Check the background property
1015 field.SetProperty( DevelTextField::Property::BACKGROUND, Color::RED );
1016 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::BACKGROUND ), Color::RED, TEST_LOCATION );
1018 //Check handle color
1019 field.SetProperty( DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN );
1020 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
1022 // Check the input filter property
1023 Property::Map inputFilterMapSet;
1024 Property::Map inputFilterMapGet;
1025 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1026 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1028 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1030 inputFilterMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::INPUT_FILTER);
1031 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1034 inputFilterMapSet.Clear();
1035 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1037 application.SendNotification();
1038 application.Render();
1043 // Positive Atlas Text Renderer test
1044 int utcDaliTextFieldAtlasRenderP(void)
1046 ToolkitTestApplication application;
1047 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1048 StyleManager styleManager = StyleManager::Get();
1049 styleManager.ApplyDefaultTheme();
1050 TextField field = TextField::New();
1051 DALI_TEST_CHECK( field );
1053 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1055 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1057 application.GetScene().Add( field );
1061 // Render some text with the shared atlas backend
1062 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1063 application.SendNotification();
1064 application.Render();
1068 tet_result(TET_FAIL);
1073 // Positive test for the anchorClicked signal.
1074 int utcDaliTextFieldAnchorClicked01(void)
1076 ToolkitTestApplication application;
1077 tet_infoline(" utcDaliTextFieldAnchorClicked01");
1078 TextField field = TextField::New();
1079 DALI_TEST_CHECK(field);
1081 application.GetScene().Add(field);
1083 // connect to the anchor clicked signal.
1084 ConnectionTracker* testTracker = new ConnectionTracker();
1085 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1086 bool anchorClickedSignal = false;
1087 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1089 gAnchorClickedCallBackCalled = false;
1090 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1091 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1092 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1093 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1094 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1096 application.SendNotification();
1097 application.Render();
1098 field.SetKeyInputFocus();
1100 // Create a tap event to touch the text field.
1101 TestGenerateTap(application, 5.0f, 25.0f);
1102 application.SendNotification();
1103 application.Render();
1105 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1106 DALI_TEST_CHECK(anchorClickedSignal);
1108 gAnchorClickedCallBackNotCalled = true;
1109 // Tap the outside of anchor, callback should not be called.
1110 TestGenerateTap(application, 150.f, 100.f);
1111 application.SendNotification();
1112 application.Render();
1114 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1119 // Positive test for the anchorClicked signal.
1120 int utcDaliTextFieldAnchorClicked02(void)
1122 ToolkitTestApplication application;
1123 tet_infoline(" utcDaliTextFieldAnchorClicked02");
1124 TextField field = TextField::New();
1125 DALI_TEST_CHECK(field);
1127 application.GetScene().Add(field);
1129 // connect to the anchor clicked signal.
1130 ConnectionTracker* testTracker = new ConnectionTracker();
1131 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1132 bool anchorClickedSignal = false;
1133 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1135 gAnchorClickedCallBackCalled = false;
1136 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1137 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1138 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1139 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1140 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1142 application.SendNotification();
1143 application.Render();
1144 field.SetKeyInputFocus();
1146 // Avoid a crash when core load gl resources.
1147 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1149 // Create a tap event to touch the text field.
1150 TestGenerateTap(application, 30.0f, 25.0f, 100);
1151 application.SendNotification();
1152 application.Render();
1154 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1155 DALI_TEST_CHECK(anchorClickedSignal);
1158 // For coverage InsertTextAnchor, RemoveTextAnchor
1159 // first index insert
1160 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1161 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1162 application.SendNotification();
1163 application.Render();
1165 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1166 application.SendNotification();
1167 application.Render();
1169 gAnchorClickedCallBackCalled = false;
1170 // Create a tap event to touch the text field.
1171 TestGenerateTap(application, 30.0f, 25.0f, 700);
1172 application.SendNotification();
1173 field.SetKeyInputFocus();
1175 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1177 // last index insert
1178 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1179 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1180 application.SendNotification();
1181 application.Render();
1183 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1184 application.SendNotification();
1185 application.Render();
1187 gAnchorClickedCallBackCalled = false;
1188 // Create a tap event to touch the text field.
1189 TestGenerateTap(application, 30.0f, 25.0f, 1300);
1190 application.SendNotification();
1191 field.SetKeyInputFocus();
1193 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1196 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1197 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1198 application.SendNotification();
1199 application.Render();
1201 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1202 application.SendNotification();
1203 application.Render();
1205 gAnchorClickedCallBackCalled = false;
1206 // Create a tap event to touch the text field.
1207 TestGenerateTap(application, 30.0f, 25.0f, 1900);
1208 application.SendNotification();
1209 field.SetKeyInputFocus();
1211 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1213 // first index remove
1214 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1215 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1216 application.SendNotification();
1217 application.Render();
1219 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1220 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));
1221 application.SendNotification();
1222 application.Render();
1224 gAnchorClickedCallBackCalled = false;
1225 // Create a tap event to touch the text field.
1226 TestGenerateTap(application, 30.0f, 25.0f, 2500);
1227 application.SendNotification();
1228 field.SetKeyInputFocus();
1230 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1232 // last index remove
1233 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1234 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1235 application.SendNotification();
1236 application.Render();
1238 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1239 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));
1240 application.SendNotification();
1241 application.Render();
1243 gAnchorClickedCallBackCalled = false;
1244 // Create a tap event to touch the text field.
1245 TestGenerateTap(application, 30.0f, 25.0f, 3100);
1246 application.SendNotification();
1247 application.Render();
1249 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1252 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1253 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1254 application.SendNotification();
1255 application.Render();
1257 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1258 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));
1259 application.SendNotification();
1260 application.Render();
1262 gAnchorClickedCallBackCalled = false;
1263 // Create a tap event to touch the text field.
1264 TestGenerateTap(application, 30.0f, 25.0f, 3700);
1265 application.SendNotification();
1266 application.Render();
1268 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1270 // 0 ~ 1 index remove
1271 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1272 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 0);
1273 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 1);
1274 application.SendNotification();
1275 application.Render();
1277 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1278 application.SendNotification();
1279 application.Render();
1281 gAnchorClickedCallBackCalled = false;
1282 // Create a tap event to touch the text field.
1283 TestGenerateTap(application, 30.0f, 25.0f, 4300);
1284 application.SendNotification();
1285 application.Render();
1287 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1289 // 1 ~ 3 index remove
1290 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1291 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 1);
1292 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 3);
1293 application.SendNotification();
1294 application.Render();
1296 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1297 application.SendNotification();
1298 application.Render();
1300 gAnchorClickedCallBackCalled = false;
1301 // Create a tap event to touch the text field.
1302 TestGenerateTap(application, 30.0f, 25.0f, 4900);
1303 application.SendNotification();
1304 application.Render();
1306 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1308 // 3 ~ 4 index remove
1309 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1310 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 3);
1311 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 4);
1312 application.SendNotification();
1313 application.Render();
1315 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1316 application.SendNotification();
1317 application.Render();
1319 gAnchorClickedCallBackCalled = false;
1320 // Create a tap event to touch the text field.
1321 TestGenerateTap(application, 30.0f, 25.0f, 5500);
1322 application.SendNotification();
1323 application.Render();
1325 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1327 // Remove front of anchor
1328 field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
1329 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
1330 application.SendNotification();
1331 application.Render();
1333 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1334 application.SendNotification();
1335 application.Render();
1337 // Remove whole text
1338 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1339 DevelTextField::SelectWholeText(field);
1340 application.SendNotification();
1341 application.Render();
1343 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1344 application.SendNotification();
1345 application.Render();
1347 // Remove all with backspace
1348 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1349 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
1350 application.SendNotification();
1351 application.Render();
1353 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1354 application.SendNotification();
1355 application.Render();
1357 // Remove all with delete
1358 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1359 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1360 application.SendNotification();
1361 application.Render();
1363 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));
1364 application.SendNotification();
1365 application.Render();
1370 // Positive test for the textChanged signal.
1371 int utcDaliTextFieldTextChangedP(void)
1373 ToolkitTestApplication application;
1374 tet_infoline(" utcDaliTextFieldTextChangedP");
1375 TextField field = TextField::New();
1376 DALI_TEST_CHECK( field );
1378 application.GetScene().Add( field );
1380 // connect to the text changed signal.
1381 ConnectionTracker* testTracker = new ConnectionTracker();
1382 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1383 bool textChangedSignal = false;
1384 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1386 gTextChangedCallBackCalled = false;
1387 field.SetProperty( TextField::Property::TEXT, "ABC" );
1388 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1389 DALI_TEST_CHECK( textChangedSignal );
1391 application.SendNotification();
1392 field.SetKeyInputFocus();
1394 gTextChangedCallBackCalled = false;
1395 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1396 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1399 field.SetProperty( TextField::Property::TEXT, "" );
1401 // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1402 gTextChangedCallBackCalled = false;
1403 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1404 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1406 // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1407 gTextChangedCallBackCalled = false;
1408 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1409 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1414 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1416 ToolkitTestApplication application;
1417 tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1418 TextField field = TextField::New();
1419 DALI_TEST_CHECK( field );
1422 application.GetScene().Add( field );
1424 // connect to the text changed signal.
1425 ConnectionTracker* testTracker = new ConnectionTracker();
1426 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1427 bool textChangedSignal = false;
1428 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1431 // get InputMethodContext
1433 InputMethodContext::EventData imfEvent;
1434 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext( field );
1436 field.SetKeyInputFocus();
1437 field.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
1440 gTextChangedCallBackCalled = false;
1441 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1442 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1443 application.SendNotification();
1444 application.Render();
1445 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1446 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1448 gTextChangedCallBackCalled = false;
1449 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1450 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1451 application.SendNotification();
1452 application.Render();
1453 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1454 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호"), TEST_LOCATION );
1456 gTextChangedCallBackCalled = false;
1457 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1458 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1459 application.SendNotification();
1460 application.Render();
1461 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1462 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1464 gTextChangedCallBackCalled = false;
1465 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1466 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1467 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1469 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1470 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1471 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1473 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1474 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1475 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1477 application.SendNotification();
1478 application.Render();
1479 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1480 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1486 // Negative test for the textChanged signal.
1487 int utcDaliTextFieldTextChangedN(void)
1489 ToolkitTestApplication application;
1490 tet_infoline(" utcDaliTextFieldTextChangedN");
1491 TextField field = TextField::New();
1492 DALI_TEST_CHECK( field );
1494 application.GetScene().Add( field );
1496 // connect to the text changed signal.
1497 ConnectionTracker* testTracker = new ConnectionTracker();
1498 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1499 bool textChangedSignal = false;
1500 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1502 gTextChangedCallBackCalled = false;
1503 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1504 application.SendNotification();
1505 application.Render();
1506 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1507 DALI_TEST_CHECK( !textChangedSignal );
1512 // Positive test for Max Characters reached signal.
1513 int utcDaliTextFieldMaxCharactersReachedP(void)
1515 ToolkitTestApplication application;
1516 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1517 TextField field = TextField::New();
1518 DALI_TEST_CHECK( field );
1520 application.GetScene().Add( field );
1522 const int maxNumberOfCharacters = 1;
1523 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1525 field.SetKeyInputFocus();
1527 // connect to the text changed signal.
1528 ConnectionTracker* testTracker = new ConnectionTracker();
1529 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1530 bool maxLengthReachedSignal = false;
1531 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1533 gMaxCharactersCallBackCalled = false;
1535 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1536 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1538 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1539 DALI_TEST_CHECK( maxLengthReachedSignal );
1544 // Negative test for Max Characters reached signal.
1545 int utcDaliTextFieldMaxCharactersReachedN(void)
1547 ToolkitTestApplication application;
1548 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1549 TextField field = TextField::New();
1550 DALI_TEST_CHECK( field );
1552 application.GetScene().Add( field );
1554 const int maxNumberOfCharacters = 3;
1555 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1557 field.SetKeyInputFocus();
1559 // connect to the text changed signal.
1560 ConnectionTracker* testTracker = new ConnectionTracker();
1561 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1562 bool maxLengthReachedSignal = false;
1563 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1565 gMaxCharactersCallBackCalled = false;
1567 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1568 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1570 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1571 DALI_TEST_CHECK( !maxLengthReachedSignal );
1573 application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1575 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1576 DALI_TEST_CHECK( !maxLengthReachedSignal );
1581 // Positive test for Input Filtered signal.
1582 int utcDaliTextFieldInputFilteredP(void)
1584 ToolkitTestApplication application;
1585 tet_infoline(" utcDaliTextFieldInputFilteredP");
1586 TextField field = TextField::New();
1587 DALI_TEST_CHECK(field);
1589 application.GetScene().Add(field);
1591 Property::Map inputFilter;
1593 // Only digit is accepted.
1594 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1596 // Set input filter to TextField.
1597 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1599 field.SetKeyInputFocus();
1601 // connect to the input filtered signal.
1602 ConnectionTracker* testTracker = new ConnectionTracker();
1603 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1604 bool inputFilteredSignal = false;
1605 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1607 gInputFilteredAcceptedCallbackCalled = false;
1609 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ));
1611 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1612 DALI_TEST_CHECK(inputFilteredSignal);
1614 // Word is rejected.
1615 inputFilter[InputFilter::Property::ACCEPTED] = "";
1616 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1618 // Set input filter to TextField.
1619 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1621 field.SetKeyInputFocus();
1623 inputFilteredSignal = false;
1624 gInputFilteredRejectedCallbackCalled = false;
1626 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1628 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1629 DALI_TEST_CHECK(inputFilteredSignal);
1634 // Negative test for Input Filtered signal.
1635 int utcDaliTextFieldInputFilteredN(void)
1637 ToolkitTestApplication application;
1638 tet_infoline(" utcDaliTextFieldInputFilteredP");
1639 TextField field = TextField::New();
1640 DALI_TEST_CHECK(field);
1642 application.GetScene().Add(field);
1644 Property::Map inputFilter;
1646 // Only word is accepted.
1647 inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
1649 // Set input filter to TextField.
1650 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1652 field.SetKeyInputFocus();
1654 // connect to the input filtered signal.
1655 ConnectionTracker* testTracker = new ConnectionTracker();
1656 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1657 bool inputFilteredSignal = false;
1658 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1660 gInputFilteredAcceptedCallbackCalled = false;
1662 // Key a, d should not be filtered.
1663 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1664 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1665 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1666 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1668 // Backspace, Delete should not be filtered.
1669 application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1670 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));
1672 // Render and notify
1673 application.SendNotification();
1674 application.Render();
1676 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1677 DALI_TEST_CHECK(!inputFilteredSignal);
1679 // Digit is rejected.
1680 inputFilter[InputFilter::Property::ACCEPTED] = "";
1681 inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
1683 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1685 field.SetKeyInputFocus();
1687 inputFilteredSignal = false;
1688 gInputFilteredRejectedCallbackCalled = false;
1690 // Key a, d should not be filtered.
1691 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1692 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1693 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1694 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1696 // Backspace, Delete should not be filtered.
1697 application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1698 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));
1700 // Render and notify
1701 application.SendNotification();
1702 application.Render();
1704 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1705 DALI_TEST_CHECK(!inputFilteredSignal);
1710 int utcDaliTextFieldInputStyleChanged01(void)
1712 // The text-field emits signals when the input style changes. These changes of style are
1713 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1714 // can't be emitted during the size negotiation as the callbacks may update the UI.
1715 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1716 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1717 ToolkitTestApplication application;
1718 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1722 char* pathNamePtr = get_current_dir_name();
1723 const std::string pathName( pathNamePtr );
1724 free( pathNamePtr );
1726 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1727 fontClient.SetDpi( 93u, 93u );
1729 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1730 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1732 TextField field = TextField::New();
1733 DALI_TEST_CHECK( field );
1736 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1737 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1738 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1740 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1741 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1743 // connect to the text changed signal.
1744 ConnectionTracker* testTracker = new ConnectionTracker();
1745 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1746 bool inputStyleChangedSignal = false;
1747 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1749 application.GetScene().Add( field );
1751 // Render and notify
1752 application.SendNotification();
1753 application.Render();
1755 // Executes the idle callbacks added by the text control on the change of input style.
1756 application.RunIdles();
1758 gInputStyleChangedCallbackCalled = false;
1759 gInputStyleMask = TextField::InputStyle::NONE;
1760 inputStyleChangedSignal = false;
1762 // Create a tap event to touch the text field.
1763 TestGenerateTap( application, 18.0f, 25.0f );
1765 // Render and notify
1766 application.SendNotification();
1767 application.Render();
1769 // Executes the idle callbacks added by the text control on the change of input style.
1770 application.RunIdles();
1772 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1773 if( gInputStyleChangedCallbackCalled )
1775 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1777 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1778 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1780 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1781 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1783 DALI_TEST_CHECK( inputStyleChangedSignal );
1785 gInputStyleChangedCallbackCalled = false;
1786 gInputStyleMask = TextField::InputStyle::NONE;
1787 inputStyleChangedSignal = false;
1789 // Create a tap event to touch the text field.
1790 TestGenerateTap( application, 30.0f, 25.0f );
1792 // Render and notify
1793 application.SendNotification();
1794 application.Render();
1796 // Executes the idle callbacks added by the text control on the change of input style.
1797 application.RunIdles();
1799 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1800 DALI_TEST_CHECK( !inputStyleChangedSignal );
1802 gInputStyleChangedCallbackCalled = false;
1803 gInputStyleMask = TextField::InputStyle::NONE;
1804 inputStyleChangedSignal = false;
1806 // Create a tap event to touch the text field.
1807 TestGenerateTap( application, 43.0f, 25.0f );
1809 // Render and notify
1810 application.SendNotification();
1811 application.Render();
1813 // Executes the idle callbacks added by the text control on the change of input style.
1814 application.RunIdles();
1816 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1817 if( gInputStyleChangedCallbackCalled )
1819 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1821 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1822 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1824 DALI_TEST_CHECK( inputStyleChangedSignal );
1826 gInputStyleChangedCallbackCalled = false;
1827 gInputStyleMask = TextField::InputStyle::NONE;
1828 inputStyleChangedSignal = false;
1830 // Create a tap event to touch the text field.
1831 TestGenerateTap( application, 88.0f, 25.0f );
1833 // Render and notify
1834 application.SendNotification();
1835 application.Render();
1837 // Executes the idle callbacks added by the text control on the change of input style.
1838 application.RunIdles();
1840 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1841 if( gInputStyleChangedCallbackCalled )
1843 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1845 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1846 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1848 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1850 Property::Map fontStyleMapSet;
1851 fontStyleMapSet.Insert( "weight", "bold" );
1853 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1854 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1856 DALI_TEST_CHECK( inputStyleChangedSignal );
1858 gInputStyleChangedCallbackCalled = false;
1859 gInputStyleMask = TextField::InputStyle::NONE;
1860 inputStyleChangedSignal = false;
1862 // Create a tap event to touch the text field.
1863 TestGenerateTap( application, 115.0f, 25.0f );
1865 // Render and notify
1866 application.SendNotification();
1867 application.Render();
1869 // Executes the idle callbacks added by the text control on the change of input style.
1870 application.RunIdles();
1872 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1873 DALI_TEST_CHECK( !inputStyleChangedSignal );
1875 gInputStyleChangedCallbackCalled = false;
1876 gInputStyleMask = TextField::InputStyle::NONE;
1877 inputStyleChangedSignal = false;
1879 // Create a tap event to touch the text field.
1880 TestGenerateTap( application, 164.0f, 25.0f );
1882 // Render and notify
1883 application.SendNotification();
1884 application.Render();
1886 // Executes the idle callbacks added by the text control on the change of input style.
1887 application.RunIdles();
1889 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1890 if( gInputStyleChangedCallbackCalled )
1892 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1894 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1895 DALI_TEST_CHECK( style.empty() );
1897 DALI_TEST_CHECK( inputStyleChangedSignal );
1899 gInputStyleChangedCallbackCalled = false;
1900 gInputStyleMask = TextField::InputStyle::NONE;
1901 inputStyleChangedSignal = false;
1903 // Create a tap event to touch the text field.
1904 TestGenerateTap( application, 191.0f, 25.0f );
1906 // Render and notify
1907 application.SendNotification();
1908 application.Render();
1910 // Executes the idle callbacks added by the text control on the change of input style.
1911 application.RunIdles();
1913 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1914 DALI_TEST_CHECK( !inputStyleChangedSignal );
1919 int utcDaliTextFieldInputStyleChanged02(void)
1921 // The text-field emits signals when the input style changes. These changes of style are
1922 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1923 // can't be emitted during the size negotiation as the callbacks may update the UI.
1924 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1925 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1926 ToolkitTestApplication application;
1927 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1931 char* pathNamePtr = get_current_dir_name();
1932 const std::string pathName( pathNamePtr );
1933 free( pathNamePtr );
1935 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1936 fontClient.SetDpi( 93u, 93u );
1938 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1939 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1941 TextField field = TextField::New();
1942 DALI_TEST_CHECK( field );
1944 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1945 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1946 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1948 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1949 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>" );
1951 // connect to the text changed signal.
1952 ConnectionTracker* testTracker = new ConnectionTracker();
1953 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1954 bool inputStyleChangedSignal = false;
1955 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1957 application.GetScene().Add( field );
1959 // Render and notify
1960 application.SendNotification();
1961 application.Render();
1963 // Executes the idle callbacks added by the text control on the change of input style.
1964 application.RunIdles();
1966 gInputStyleChangedCallbackCalled = false;
1967 gInputStyleMask = TextField::InputStyle::NONE;
1968 inputStyleChangedSignal = false;
1970 // Create a tap event to touch the text field.
1971 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1972 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1974 // Render and notify
1975 application.SendNotification();
1976 application.Render();
1978 // Executes the idle callbacks added by the text control on the change of input style.
1979 application.RunIdles();
1981 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1982 if( gInputStyleChangedCallbackCalled )
1984 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1985 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1986 TextField::InputStyle::POINT_SIZE |
1987 TextField::InputStyle::COLOR ),
1990 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1991 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1993 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1994 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1996 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1997 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1999 DALI_TEST_CHECK( inputStyleChangedSignal );
2001 gInputStyleChangedCallbackCalled = false;
2002 gInputStyleMask = TextField::InputStyle::NONE;
2003 inputStyleChangedSignal = false;
2005 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2007 // Render and notify
2008 application.SendNotification();
2009 application.Render();
2011 // Executes the idle callbacks added by the text control on the change of input style.
2012 application.RunIdles();
2014 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2015 if( gInputStyleChangedCallbackCalled )
2017 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2018 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
2021 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2022 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
2024 DALI_TEST_CHECK( inputStyleChangedSignal );
2026 gInputStyleChangedCallbackCalled = false;
2027 gInputStyleMask = TextField::InputStyle::NONE;
2028 inputStyleChangedSignal = false;
2030 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2032 // Render and notify
2033 application.SendNotification();
2034 application.Render();
2036 // Executes the idle callbacks added by the text control on the change of input style.
2037 application.RunIdles();
2039 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
2040 DALI_TEST_CHECK( !inputStyleChangedSignal );
2042 gInputStyleChangedCallbackCalled = false;
2043 gInputStyleMask = TextField::InputStyle::NONE;
2044 inputStyleChangedSignal = false;
2046 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2048 // Render and notify
2049 application.SendNotification();
2050 application.Render();
2052 // Executes the idle callbacks added by the text control on the change of input style.
2053 application.RunIdles();
2055 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2056 if( gInputStyleChangedCallbackCalled )
2058 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2059 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
2062 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2063 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
2065 DALI_TEST_CHECK( inputStyleChangedSignal );
2067 gInputStyleChangedCallbackCalled = false;
2068 gInputStyleMask = TextField::InputStyle::NONE;
2069 inputStyleChangedSignal = false;
2071 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
2073 Property::Map fontStyleMapSet;
2074 fontStyleMapSet.Insert( "weight", "thin" );
2075 fontStyleMapSet.Insert( "width", "condensed" );
2076 fontStyleMapSet.Insert( "slant", "italic" );
2078 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2079 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
2081 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
2082 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
2083 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
2084 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
2086 // Render and notify
2087 application.SendNotification();
2088 application.Render();
2090 // Executes the idle callbacks added by the text control on the change of input style.
2091 application.RunIdles();
2093 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
2094 DALI_TEST_CHECK( !inputStyleChangedSignal );
2096 // Create a tap event to touch the text field.
2097 TestGenerateTap( application, 63.0f, 25.0f, 700 );
2099 // Render and notify
2100 application.SendNotification();
2101 application.Render();
2103 // Executes the idle callbacks added by the text control on the change of input style.
2104 application.RunIdles();
2106 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2107 if( gInputStyleChangedCallbackCalled )
2109 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2110 static_cast<unsigned int>( TextField::InputStyle::COLOR |
2111 TextField::InputStyle::POINT_SIZE |
2112 TextField::InputStyle::FONT_STYLE |
2113 TextField::InputStyle::UNDERLINE |
2114 TextField::InputStyle::SHADOW |
2115 TextField::InputStyle::EMBOSS |
2116 TextField::InputStyle::OUTLINE ),
2119 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2120 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
2122 DALI_TEST_CHECK( inputStyleChangedSignal );
2127 int utcDaliTextFieldEvent01(void)
2129 ToolkitTestApplication application;
2130 tet_infoline(" utcDaliTextFieldEvent01");
2132 // Creates a tap event. After creating a tap event the text field should
2133 // have the focus and add text with key events should be possible.
2135 TextField field = TextField::New();
2136 DALI_TEST_CHECK( field );
2138 application.GetScene().Add( field );
2140 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2141 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2142 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2144 // Render and notify
2145 application.SendNotification();
2146 application.Render();
2148 // Avoid a crash when core load gl resources.
2149 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2151 // Render and notify
2152 application.SendNotification();
2153 application.Render();
2155 // Add a key event but as the text field has not the focus it should do nothing.
2156 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2158 // Render and notify
2159 application.SendNotification();
2160 application.Render();
2162 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2164 // Create a tap event to touch the text field.
2165 TestGenerateTap( application, 150.0f, 25.0f );
2167 // Render and notify
2168 application.SendNotification();
2169 application.Render();
2171 // Pressing delete key should be fine even if there is no text in TextField.
2172 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 ) );
2173 // Render and notify
2174 application.SendNotification();
2175 application.Render();
2177 // Now the text field has the focus, so it can handle the key events.
2178 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2179 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2181 // Render and notify
2182 application.SendNotification();
2183 application.Render();
2185 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2187 // Create a second text field and send key events to it.
2188 TextField field2 = TextField::New();
2190 field2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2191 field2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2192 field2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2193 field2.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
2195 application.GetScene().Add( field2 );
2197 // Render and notify
2198 application.SendNotification();
2199 application.Render();
2201 // Create a tap event on the second text field.
2202 TestGenerateTap( application, 150.0f, 125.0f );
2204 // Render and notify
2205 application.SendNotification();
2206 application.Render();
2208 // The second text field has the focus. It should handle the key events.
2209 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2210 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2212 // Render and notify
2213 application.SendNotification();
2214 application.Render();
2216 // Check the text has been added to the second text field.
2217 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2222 int utcDaliTextFieldEvent02(void)
2224 ToolkitTestApplication application;
2225 tet_infoline(" utcDaliTextFieldEvent02");
2227 // Checks if the right number of actors are created.
2229 TextField field = TextField::New();
2230 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2231 DALI_TEST_CHECK( field );
2232 LoadMarkerImages(application, field);
2234 application.GetScene().Add( field );
2236 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2237 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2238 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2240 // Avoid a crash when core load gl resources.
2241 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2243 // Render and notify
2244 application.SendNotification();
2245 application.Render();
2247 // Check there are the expected number of children ( stencil ).
2248 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
2250 Actor stencil = field.GetChildAt( 0u );
2251 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2253 // Create a tap event to touch the text field.
2254 TestGenerateTap( application, 150.0f, 25.0f, 300 );
2256 // Render and notify
2257 application.SendNotification();
2258 application.Render();
2260 Actor layer = field.GetChildAt( 1u );
2261 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2262 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2264 // Now the text field has the focus, so it can handle the key events.
2265 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2266 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2268 // Render and notify
2269 application.SendNotification();
2270 application.Render();
2272 // Checks the cursor and the renderer have been created.
2273 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2274 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
2276 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
2277 DALI_TEST_CHECK( cursor );
2279 // The offscreen root actor has a container with all the actors which contain the text renderers.
2280 Actor container = stencil.GetChildAt( 0u );
2281 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2283 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2284 DALI_TEST_CHECK( renderer );
2287 // Move the cursor and check the position changes.
2288 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2289 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2291 // Render and notify
2292 application.SendNotification();
2293 application.Render();
2295 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2296 DALI_TEST_CHECK( position2.x < position1.x );
2298 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2300 // Render and notify
2301 application.SendNotification();
2302 application.Render();
2304 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2305 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
2308 // Move the cursor to the first position.
2309 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2310 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2312 // Render and notify
2313 application.SendNotification();
2314 application.Render();
2316 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2318 // Send some taps and check the cursor positions.
2320 // Try to tap at the beginning.
2321 TestGenerateTap( application, 1.0f, 25.0f, 900 );
2323 // Render and notify
2324 application.SendNotification();
2325 application.Render();
2327 // Cursor position should be the same than position1.
2328 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2330 DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
2332 // Tap away from the start position.
2333 TestGenerateTap( application, 16.0f, 25.0f, 1500 );
2335 // Render and notify
2336 application.SendNotification();
2337 application.Render();
2339 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2341 DALI_TEST_CHECK( position6.x > position5.x );
2343 // Remove all the text.
2344 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2345 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2346 field.SetProperty( TextField::Property::TEXT, "" );
2348 // Render and notify
2349 application.SendNotification();
2350 application.Render();
2352 // Cursor position should be the same than position2.
2353 Vector3 position7 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2355 DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
2357 // Should not be a renderer.
2358 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2360 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2361 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2362 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
2364 application.SendNotification();
2365 application.Render();
2367 // There are renderer and decorator layer
2368 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
2373 int utcDaliTextFieldEvent03(void)
2375 ToolkitTestApplication application;
2376 tet_infoline(" utcDaliTextFieldEvent03");
2378 // Checks if the highlight actor is created.
2380 TextField field = TextField::New();
2381 DALI_TEST_CHECK( field );
2383 application.GetScene().Add( field );
2385 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2386 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2387 field.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
2388 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2389 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2391 // Avoid a crash when core load gl resources.
2392 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2393 LoadMarkerImages(application, field);
2395 // Render and notify
2396 application.SendNotification();
2397 application.Render();
2399 // Tap first to get the focus.
2400 TestGenerateTap( application, 3.0f, 25.0f );
2402 // Render and notify
2403 application.SendNotification();
2404 application.Render();
2406 // Double tap to select a word.
2407 TestGenerateTap( application, 3.0f, 25.0f );
2409 // Render and notify
2410 application.SendNotification();
2411 application.Render();
2413 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2414 Actor stencil = field.GetChildAt( 0u );
2416 // The highlight actor is drawn first, so is the first actor in the list
2417 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2418 DALI_TEST_CHECK( highlight );
2420 // The offscreen root actor has a container with all the actors which contain the text renderers.
2421 Actor container = stencil.GetChildAt( 1u );
2422 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2424 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2425 DALI_TEST_CHECK( renderer );
2431 int utcDaliTextFieldEvent04(void)
2433 ToolkitTestApplication application;
2434 tet_infoline(" utcDaliTextFieldEvent04");
2436 // Checks if the highlight actor is created.
2438 TextField field = TextField::New();
2439 DALI_TEST_CHECK( field );
2440 application.GetScene().Add( field );
2441 LoadMarkerImages(application, field);
2442 // Render and notify
2443 application.SendNotification();
2444 application.Render();
2446 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2447 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2448 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2449 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2450 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2452 // Avoid a crash when core load gl resources.
2453 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2454 // Render and notify
2455 application.SendNotification();
2456 application.Render();
2458 // Create a tap event to touch the text field.
2459 TestGenerateTap( application, 150.0f, 25.0f );
2460 // Render and notify
2461 application.SendNotification();
2462 application.Render();
2465 // Tap first to get the focus.
2466 TestGenerateTap( application, 1.0f, 25.0f );
2468 // Render and notify
2469 application.SendNotification();
2470 application.Render();
2472 // Double tap to select a word.
2473 TestGenerateTap( application, 1.0f, 25.0f );
2475 // Render and notify
2476 application.SendNotification();
2477 application.Render();
2480 TestGenerateTap( application, 0.0f, 40.0f );
2484 int utcDaliTextFieldEvent05(void)
2486 ToolkitTestApplication application;
2487 tet_infoline(" utcDaliTextFieldEvent05");
2489 // Checks dragging of cursor/grab handle
2491 TextField field = TextField::New();
2492 DALI_TEST_CHECK( field );
2493 application.GetScene().Add( field );
2494 LoadMarkerImages(application, field);
2495 // Render and notify
2496 application.SendNotification();
2497 application.Render();
2499 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2500 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2501 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2502 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2503 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2505 // Avoid a crash when core load gl resources.
2506 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2507 // Render and notify
2508 application.SendNotification();
2509 application.Render();
2511 // Create a tap event to touch the text field.
2512 TestGenerateTap( application, 150.0f, 25.0f );
2513 // Render and notify
2514 application.SendNotification();
2515 application.Render();
2517 // Tap first to get the focus.
2518 TestGenerateTap( application, 1.0f, 25.0f );
2520 // Render and notify
2521 application.SendNotification();
2522 application.Render();
2524 // Double tap to select a word.
2525 TestGenerateTap( application, 1.0f, 25.0f );
2527 // Render and notify
2528 application.SendNotification();
2529 application.Render();
2531 Actor stencil = field.GetChildAt( 1u );
2535 int utcDaliTextFieldEvent06(void)
2537 ToolkitTestApplication application;
2538 tet_infoline(" utcDaliTextFieldEvent06");
2540 // Checks Longpress when in edit mode
2542 TextField field = TextField::New();
2543 DALI_TEST_CHECK( field );
2544 application.GetScene().Add( field );
2545 LoadMarkerImages(application, field);
2546 // Render and notify
2547 application.SendNotification();
2548 application.Render();
2550 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2551 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2552 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2553 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2554 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2556 // Avoid a crash when core load gl resources.
2557 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2558 // Render and notify
2559 application.SendNotification();
2560 application.Render();
2562 // Create a tap event to touch the text field.
2563 TestGenerateTap( application, 150.0f, 25.0f );
2564 // Render and notify
2565 application.SendNotification();
2566 application.Render();
2569 // Tap first to get the focus.
2570 TestGenerateTap( application, 1.0f, 25.0f );
2572 // Render and notify
2573 application.SendNotification();
2574 application.Render();
2577 TestGenerateLongPress(application, 1.0f, 25.0f);
2579 // Render and notify
2580 application.SendNotification();
2581 application.Render();
2586 int utcDaliTextFieldEvent07(void)
2588 ToolkitTestApplication application;
2589 tet_infoline(" utcDaliTextFieldEvent07");
2591 // Checks Longpress to start edit mode
2593 TextField field = TextField::New();
2594 DALI_TEST_CHECK( field );
2595 application.GetScene().Add( field );
2596 LoadMarkerImages(application, field);
2597 // Render and notify
2598 application.SendNotification();
2599 application.Render();
2601 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2602 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2603 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2604 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2605 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2606 Property::Map propertyMap;
2607 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2608 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2610 // Avoid a crash when core load gl resources.
2611 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2612 // Render and notify
2613 application.SendNotification();
2614 application.Render();
2617 TestGenerateLongPress(application, 1.0f, 25.0f);
2619 // Render and notify
2620 application.SendNotification();
2621 application.Render();
2626 int utcDaliTextFieldEvent08(void)
2628 ToolkitTestApplication application;
2629 tet_infoline(" utcDaliTextFieldEvent08");
2631 Dali::Clipboard clipboard = Clipboard::Get();
2632 clipboard.SetItem("testTextFieldEvent");
2634 // Checks Longpress when only place holder text
2636 TextField field = TextField::New();
2637 DALI_TEST_CHECK( field );
2638 application.GetScene().Add( field );
2639 LoadMarkerImages(application, field);
2640 // Render and notify
2641 application.SendNotification();
2642 application.Render();
2644 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2645 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2646 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2647 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2648 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2650 // Avoid a crash when core load gl resources.
2651 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2652 // Render and notify
2653 application.SendNotification();
2654 application.Render();
2657 TestGenerateLongPress( application, 1.0f, 25.0f, 20 );
2659 // Render and notify
2660 application.SendNotification();
2661 application.Render();
2663 Wait(application, 500);
2665 TestEndLongPress( application, 1.0f, 25.0f, 520 );
2668 TestGenerateLongPress( application, 1.0f, 25.0f, 600 );
2670 // Render and notify
2671 application.Render();
2673 Wait(application, 500);
2675 Integration::Scene stage = application.GetScene();
2676 Layer layer = stage.GetRootLayer();
2677 Actor actor = layer.FindChildByName("optionPaste");
2681 Vector3 worldPosition = actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION );
2682 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2683 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2685 Dali::Integration::TouchEvent event;
2686 event = Dali::Integration::TouchEvent();
2687 event.AddPoint( GetPointDownInside( position ) );
2688 application.ProcessEvent( event );
2690 event = Dali::Integration::TouchEvent();
2691 event.AddPoint( GetPointUpInside( position ) );
2692 application.ProcessEvent( event );
2694 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2699 int utcDaliTextFieldEvent09(void)
2701 ToolkitTestApplication application;
2702 tet_infoline(" utcDaliTextFieldEvent09");
2704 TextField field = TextField::New();
2705 DALI_TEST_CHECK( field );
2706 application.GetScene().Add( field );
2707 LoadMarkerImages(application, field);
2708 // Render and notify
2709 application.SendNotification();
2710 application.Render();
2712 field.SetProperty( TextField::Property::TEXT, "Hello" );
2713 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2714 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2715 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2716 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2718 // Avoid a crash when core load gl resources.
2719 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2721 // Create a tap event to touch the text field.
2722 TestGenerateTap( application, 150.0f, 25.0f );
2723 application.SendNotification();
2724 application.Render();
2727 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2728 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2729 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2730 application.SendNotification();
2731 application.Render();
2733 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2734 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2735 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2736 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2737 application.SendNotification();
2738 application.Render();
2740 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2741 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2742 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2743 for( unsigned int index = 0u; index < 5u; ++index )
2745 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2746 application.SendNotification();
2747 application.Render();
2750 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2751 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2752 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2753 for( unsigned int index = 0u; index < 5u; ++index )
2755 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2756 application.SendNotification();
2757 application.Render();
2760 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2761 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2762 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2763 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2764 application.SendNotification();
2765 application.Render();
2766 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2767 application.SendNotification();
2768 application.Render();
2770 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2771 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2772 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2773 application.SendNotification();
2774 application.Render();
2776 Property::Map mapGet;
2777 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2778 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2779 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2784 int utcDaliTextFieldStyleWhilstSelected(void)
2786 ToolkitTestApplication application;
2787 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2789 // Change font and styles whilst text is selected whilst word selected
2791 TextField field = TextField::New();
2792 DALI_TEST_CHECK( field );
2793 application.GetScene().Add( field );
2794 LoadMarkerImages(application, field);
2795 // Render and notify
2796 application.SendNotification();
2797 application.Render();
2799 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2800 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2801 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2802 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2803 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2805 // Avoid a crash when core load gl resources.
2806 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2807 // Render and notify
2808 application.SendNotification();
2809 application.Render();
2811 // Create a tap event to touch the text field.
2812 TestGenerateTap( application, 150.0f, 25.0f );
2813 // Render and notify
2814 application.SendNotification();
2815 application.Render();
2818 // Tap first to get the focus.
2819 TestGenerateTap( application, 1.0f, 25.0f );
2821 // Render and notify
2822 application.SendNotification();
2823 application.Render();
2825 // Double tap to select a word.
2826 TestGenerateTap( application, 1.0f, 25.0f );
2828 // Render and notify
2829 application.SendNotification();
2830 application.Render();
2832 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2833 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2835 Property::Map fontStyleMapSet;
2836 Property::Map fontStyleMapGet;
2838 fontStyleMapSet.Insert( "weight", "bold" );
2839 fontStyleMapSet.Insert( "slant", "italic" );
2840 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2842 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2843 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2844 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2846 fontStyleMapSet.Clear();
2847 fontStyleMapSet.Insert( "width", "expanded" );
2848 fontStyleMapSet.Insert( "slant", "italic" );
2849 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2851 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2852 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2853 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2855 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2856 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2858 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2859 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2861 fontStyleMapSet.Clear();
2862 fontStyleMapSet.Insert( "weight", "bold" );
2863 fontStyleMapSet.Insert( "slant", "italic" );
2865 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2867 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2868 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2869 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2871 fontStyleMapSet.Clear();
2872 fontStyleMapSet.Insert( "width", "expanded" );
2874 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2876 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2877 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2878 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2880 // Press Escape to increase coverage
2881 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2882 application.SendNotification();
2883 application.Render();
2885 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2890 int utcDaliTextFieldEscKeyLoseFocus(void)
2892 ToolkitTestApplication application;
2893 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2895 // Creates a tap event. After creating a tap event the text field should
2896 // have the focus and add text with key events should be possible.
2898 TextField field = TextField::New();
2899 DALI_TEST_CHECK( field );
2901 application.GetScene().Add( field );
2903 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2904 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2905 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2907 // Avoid a crash when core load gl resources.
2908 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2910 // Render and notify
2911 application.SendNotification();
2912 application.Render();
2914 // Add a key event but as the text field has not the focus it should do nothing.
2915 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2916 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2918 // Render and notify
2919 application.SendNotification();
2920 application.Render();
2922 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2924 // Create a tap event to touch the text field.
2925 TestGenerateTap( application, 150.0f, 25.0f );
2927 // Render and notify
2928 application.SendNotification();
2929 application.Render();
2931 // Now the text field has the focus, so it can handle the key events.
2932 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2933 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2934 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2935 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2937 // Render and notify
2938 application.SendNotification();
2939 application.Render();
2941 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2943 // Generate a Esc key event. The text field should lose the focus.
2944 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2945 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2947 // Render and notify
2948 application.SendNotification();
2949 application.Render();
2951 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2953 // No more text should be introduced
2954 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2955 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2957 // Render and notify
2958 application.SendNotification();
2959 application.Render();
2961 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2966 int utcDaliTextFieldSomeSpecialKeys(void)
2968 ToolkitTestApplication application;
2969 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2971 // Checks some special keys when the text is selected.
2973 TextField field = TextField::New();
2974 DALI_TEST_CHECK( field );
2975 application.GetScene().Add( field );
2976 LoadMarkerImages(application, field);
2977 // Render and notify
2978 application.SendNotification();
2979 application.Render();
2981 const std::string longText( "This is a long text for the size of the text-field." );
2983 field.SetProperty( TextField::Property::TEXT, longText );
2984 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2985 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2986 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2987 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2989 // Avoid a crash when core load gl resources.
2990 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2991 // Render and notify
2992 application.SendNotification();
2993 application.Render();
2995 // Create a tap event to touch the text field.
2996 TestGenerateTap( application, 150.0f, 25.0f );
2998 // Render and notify
2999 application.SendNotification();
3000 application.Render();
3002 // Tap first to get the focus.
3003 TestGenerateTap( application, 1.0f, 25.0f );
3005 // Render and notify
3006 application.SendNotification();
3007 application.Render();
3009 // Double tap to select a word.
3010 TestGenerateTap( application, 1.0f, 25.0f );
3012 // Render and notify
3013 application.SendNotification();
3014 application.Render();
3016 // Generate a Esc key event. The text field should lose the focus.
3017 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3018 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3020 // Render and notify
3021 application.SendNotification();
3022 application.Render();
3024 // Generate a Esc key event. The text field should lose the focus.
3025 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3026 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3028 // Render and notify
3029 application.SendNotification();
3030 application.Render();
3032 // Generate a Esc key event. The text field should lose the focus.
3033 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3034 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3036 // Render and notify
3037 application.SendNotification();
3038 application.Render();
3040 // The text shouldn't be deleted.
3041 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
3046 int utcDaliTextFieldSizeUpdate(void)
3048 ToolkitTestApplication application;
3049 tet_infoline("utcDaliTextFieldSizeUpdate");
3051 // Checks some special keys when the text is selected.
3052 TextField field = TextField::New();
3053 DALI_TEST_CHECK( field );
3054 application.GetScene().Add( field );
3056 float previousHeight = 0.0f;
3057 float currentHeight = 0.0f;
3058 const float fieldWidth = 19