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 bool gCursorPositionChangedCallbackCalled;
134 static uint32_t oldCursorPos;
135 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
137 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
139 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
140 Integration::ResourcePointer resource(bitmap);
141 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
144 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
148 LoadBitmapResource( app.GetPlatform(), width, height );
150 Property::Map propertyMap;
151 propertyMap["filename"] = "image.png";
152 propertyMap["width"] = width;
153 propertyMap["height"] = height;
154 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
155 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
156 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
157 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
158 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
159 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
160 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
161 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
165 * Simulate time passed by.
167 * @note this will always process at least 1 frame (1/60 sec)
169 * @param application Test application instance
170 * @param duration Time to pass in milliseconds.
171 * @return The actual time passed in milliseconds
173 static int Wait(ToolkitTestApplication& application, int duration = 0)
177 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
179 application.SendNotification();
180 application.Render(RENDER_FRAME_INTERVAL);
181 time += RENDER_FRAME_INTERVAL;
187 Dali::Integration::Point GetPointDownInside( Vector2& pos )
189 Dali::Integration::Point point;
190 point.SetState( PointState::DOWN );
191 point.SetScreenPosition( pos );
195 Dali::Integration::Point GetPointUpInside( Vector2& pos )
197 Dali::Integration::Point point;
198 point.SetState( PointState::UP );
199 point.SetScreenPosition( pos );
203 struct CallbackFunctor
205 CallbackFunctor(bool* callbackFlag)
206 : mCallbackFlag( callbackFlag )
212 *mCallbackFlag = true;
217 static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength)
219 tet_infoline(" TestAnchorClickedCallback");
221 gAnchorClickedCallBackNotCalled = false;
223 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
225 gAnchorClickedCallBackCalled = true;
229 static void TestCursorPositionChangedCallback( TextField control, unsigned int oldPos )
231 tet_infoline(" TestCursorPositionChangedCallback");
233 gCursorPositionChangedCallbackCalled = true;
234 oldCursorPos = oldPos;
237 static void TestTextChangedCallback( TextField control )
239 tet_infoline(" TestTextChangedCallback");
241 gTextChangedCallBackCalled = true;
244 static void TestMaxLengthReachedCallback( TextField control )
246 tet_infoline(" TestMaxLengthReachedCallback");
248 gMaxCharactersCallBackCalled = true;
251 static void TestInputFilteredCallback(TextField control, Toolkit::InputFilter::Property::Type type)
253 tet_infoline(" TestInputFilteredCallback");
255 if(type == Toolkit::InputFilter::Property::ACCEPTED)
257 gInputFilteredAcceptedCallbackCalled = true;
259 else if(type == Toolkit::InputFilter::Property::REJECTED)
261 gInputFilteredRejectedCallbackCalled = true;
265 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
267 tet_infoline(" TestInputStyleChangedCallback");
269 gInputStyleChangedCallbackCalled = true;
270 gInputStyleMask = mask;
273 // Generate a KeyEvent to send to Core.
274 Integration::KeyEvent GenerateKey( const std::string& keyName,
275 const std::string& logicalKey,
276 const std::string& keyString,
279 unsigned long timeStamp,
280 const Integration::KeyEvent::State& keyState,
281 const std::string& compose = "",
282 const std::string& deviceName = DEFAULT_DEVICE_NAME,
283 const Device::Class::Type& deviceClass = Device::Class::NONE,
284 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
286 return Integration::KeyEvent( keyName,
299 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
301 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
303 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
305 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
307 Property::Value* valueSet = NULL;
308 if ( valueGet.first.type == Property::Key::INDEX )
310 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
314 // Get Key is a string so searching Set Map for a string key
315 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
318 if( NULL != valueSet )
320 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
322 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
325 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
327 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
330 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
332 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
335 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
337 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
340 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
342 Vector2 vector2Get = valueGet.second.Get<Vector2>();
343 Vector2 vector2Set = valueSet->Get<Vector2>();
344 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
347 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
349 Vector4 vector4Get = valueGet.second.Get<Vector4>();
350 Vector4 vector4Set = valueSet->Get<Vector4>();
351 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 );
357 if ( valueGet.first.type == Property::Key::INDEX )
359 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
363 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
375 int UtcDaliToolkitTextFieldConstructorP(void)
377 ToolkitTestApplication application;
378 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
380 DALI_TEST_CHECK( !textField );
384 int UtcDaliToolkitTextFieldNewP(void)
386 ToolkitTestApplication application;
387 tet_infoline(" UtcDaliToolkitTextFieldNewP");
388 TextField textField = TextField::New();
389 DALI_TEST_CHECK( textField );
393 int UtcDaliToolkitTextFieldDownCastP(void)
395 ToolkitTestApplication application;
396 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
397 TextField textField1 = TextField::New();
398 BaseHandle object( textField1 );
400 TextField textField2 = TextField::DownCast( object );
401 DALI_TEST_CHECK( textField2 );
403 TextField textField3 = DownCast< TextField >( object );
404 DALI_TEST_CHECK( textField3 );
408 int UtcDaliToolkitTextFieldDownCastN(void)
410 ToolkitTestApplication application;
411 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
412 BaseHandle uninitializedObject;
413 TextField textField1 = TextField::DownCast( uninitializedObject );
414 DALI_TEST_CHECK( !textField1 );
416 TextField textField2 = DownCast< TextField >( uninitializedObject );
417 DALI_TEST_CHECK( !textField2 );
421 int UtcDaliToolkitTextFieldCopyConstructorP(void)
423 ToolkitTestApplication application;
424 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
425 TextField textField = TextField::New();
426 textField.SetProperty( TextField::Property::TEXT, "Test" );
428 TextField copy( textField );
429 DALI_TEST_CHECK( copy );
430 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
434 int UtcDaliTextFieldMoveConstructor(void)
436 ToolkitTestApplication application;
438 TextField textField = TextField::New();
439 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
440 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
442 TextField moved = std::move( textField );
443 DALI_TEST_CHECK( moved );
444 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
445 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
446 DALI_TEST_CHECK( !textField );
451 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
453 ToolkitTestApplication application;
454 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
455 TextField textField = TextField::New();
456 textField.SetProperty( TextField::Property::TEXT, "Test" );
458 TextField copy = textField;
459 DALI_TEST_CHECK( copy );
460 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
464 int UtcDaliTextFieldMoveAssignment(void)
466 ToolkitTestApplication application;
468 TextField textField = TextField::New();
469 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
470 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
473 moved = std::move( textField );
474 DALI_TEST_CHECK( moved );
475 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
476 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
477 DALI_TEST_CHECK( !textField );
482 int UtcDaliTextFieldNewP(void)
484 ToolkitTestApplication application;
485 tet_infoline(" UtcDaliToolkitTextFieldNewP");
486 TextField textField = TextField::New();
487 DALI_TEST_CHECK( textField );
491 // Positive test case for a method
492 int UtcDaliTextFieldGetPropertyP(void)
494 ToolkitTestApplication application;
495 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
496 TextField field = TextField::New();
497 DALI_TEST_CHECK( field );
499 // Check Property Indices are correct
500 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextField::Property::RENDERING_BACKEND );
501 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
502 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
503 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
504 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
505 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
506 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
507 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
508 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
509 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
510 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
511 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
512 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
513 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
514 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
515 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
516 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
517 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
518 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
519 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
520 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
521 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
522 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
523 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
524 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
525 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
526 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
527 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
528 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
529 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
530 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
531 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
532 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
533 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
534 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
535 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
536 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
537 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
538 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
539 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
540 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
541 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
542 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
543 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
544 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
545 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
546 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
547 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
548 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
549 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
550 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextField::Property::FONT_SIZE_SCALE );
551 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
552 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
553 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
554 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP );
555 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextField::Property::BACKGROUND );
556 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextField::Property::GRAB_HANDLE_COLOR );
557 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FILTER ) == DevelTextField::Property::INPUT_FILTER );
562 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
565 Property::Map imageMap;
566 imageMap[mapKey] =mapValue;
568 field.SetProperty( property , imageMap );
569 Property::Value propValue = field.GetProperty( property );
570 Property::Map* resultMap = propValue.GetMap();
572 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
580 // Positive test case for a method
581 int UtcDaliTextFieldSetPropertyP(void)
583 ToolkitTestApplication application;
584 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
585 TextField field = TextField::New();
586 DALI_TEST_CHECK( field );
587 application.GetScene().Add( field );
589 // Note - we can't check the defaults since the stylesheets are platform-specific
591 // Check the render backend property.
592 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
593 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
595 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
596 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION );
598 // Check text property.
599 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
600 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
602 // Check placeholder text properties.
603 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
604 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
606 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
607 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
609 // Check font properties.
610 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
611 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
613 Property::Map fontStyleMapSet;
614 Property::Map fontStyleMapGet;
615 Property::Value* slantValue = NULL;
617 fontStyleMapSet.Insert( "weight", "bold" );
618 fontStyleMapSet.Insert( "width", "condensed" );
619 fontStyleMapSet.Insert( "slant", "italic" );
620 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
622 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
623 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
624 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
626 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
627 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
629 field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 2.5f );
630 DALI_TEST_EQUALS( field.GetProperty<float>( DevelTextField::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
631 field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 1.0f );
634 fontStyleMapSet.Clear();
635 fontStyleMapSet.Insert( "weight", "normal" );
636 fontStyleMapSet.Insert( "slant", "oblique" );
637 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
639 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
640 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
641 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
643 fontStyleMapSet.Clear();
644 fontStyleMapSet.Insert( "slant", "roman" );
645 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
646 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
648 // Replace 'roman' for 'normal'.
649 slantValue = fontStyleMapGet.Find( "slant" );
650 if( NULL != slantValue )
652 if( "normal" == slantValue->Get<std::string>() )
654 fontStyleMapGet["slant"] = "roman";
657 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
658 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
660 fontStyleMapSet.Clear();
662 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
663 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
664 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
665 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
667 // Check that the MAX_LENGTH property can be correctly set
668 const int maxNumberOfCharacters = 20;
669 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
670 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
672 // Check exceed policy
673 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
674 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
675 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
676 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
678 // Check that the Alignment properties can be correctly set
679 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
680 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
681 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
682 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
684 // Check text's color property
685 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
686 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
688 // Check placeholder text's color property.
689 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
690 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
692 // Check cursor properties
693 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
694 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
695 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
696 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
698 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
699 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
700 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
701 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
702 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
703 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
704 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
705 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
707 // Check scroll properties.
708 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
709 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
710 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
711 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
713 // Check handle images
714 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
715 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
716 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
717 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
718 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
720 // Check handle images
721 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
722 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
723 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
724 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
725 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
726 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
728 // Check the highlight color
729 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
730 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
732 // Decoration bounding box
733 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
734 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
736 // Check the input method setting
737 Property::Map propertyMap;
738 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
739 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
740 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
741 int inputVariation = 1;
742 propertyMap["PANEL_LAYOUT"] = panelLayout;
743 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
744 propertyMap["BUTTON_ACTION"] = buttonAction;
745 propertyMap["VARIATION"] = inputVariation;
746 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
748 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
750 DALI_TEST_CHECK( value.Get( map ) );
753 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
754 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
757 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
758 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
761 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
762 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
765 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
766 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
768 // Check input color property.
769 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
770 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
772 // Check the enable markup property.
773 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
774 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
775 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
777 // Check input font properties.
778 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
779 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
781 fontStyleMapSet.Clear();
782 fontStyleMapSet.Insert( "weight", "bold" );
783 fontStyleMapSet.Insert( "width", "condensed" );
784 fontStyleMapSet.Insert( "slant", "italic" );
786 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
787 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
788 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
789 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
791 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
792 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
794 // Reset input font style.
795 fontStyleMapSet.Clear();
796 fontStyleMapSet.Insert( "weight", "normal" );
797 fontStyleMapSet.Insert( "slant", "oblique" );
799 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
800 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
801 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
802 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
804 fontStyleMapSet.Clear();
805 fontStyleMapSet.Insert( "slant", "roman" );
807 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
808 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
810 // Replace 'roman' for 'normal'.
811 slantValue = fontStyleMapGet.Find( "slant" );
812 if( NULL != slantValue )
814 if( "normal" == slantValue->Get<std::string>() )
816 fontStyleMapGet["slant"] = "roman";
819 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
820 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
822 fontStyleMapSet.Clear();
824 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
825 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
826 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
827 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
829 Property::Map underlineMapSet;
830 Property::Map underlineMapGet;
832 underlineMapSet.Insert( "enable", true );
833 underlineMapSet.Insert( "color", Color::RED );
834 underlineMapSet.Insert( "height", 1 );
836 // Check the underline property
837 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
839 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
840 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
841 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
843 // Check the input underline property
844 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
845 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
847 // Check the shadow property
848 Property::Map shadowMapSet;
849 Property::Map shadowMapGet;
851 shadowMapSet.Insert( "color", Color::GREEN );
852 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
853 shadowMapSet.Insert( "blurRadius", 3.0f );
855 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
857 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
858 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
859 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
861 // Check the input shadow property
862 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
863 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
865 // Check the emboss property
866 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
867 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
869 // Check the input emboss property
870 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
871 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
873 // Check the outline property
875 // Test string type first
876 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
877 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
878 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
880 // Then test the property map type
881 Property::Map outlineMapSet;
882 Property::Map outlineMapGet;
884 outlineMapSet["color"] = Color::RED;
885 outlineMapSet["width"] = 2.0f;
887 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
889 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
890 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
891 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
893 // Check the input outline property
894 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
895 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
897 // Check the hidden input settings property
898 Property::Map hiddenMapSet;
899 Property::Map hiddenMapGet;
900 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
901 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
902 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
903 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
904 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
906 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
907 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
908 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
910 // Check the pixel size of font
911 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
912 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
914 // Check the enable selection property
915 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
916 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
918 // Check the placeholder property with pixel size
919 Property::Map placeholderPixelSizeMapSet;
920 Property::Map placeholderPixelSizeMapGet;
921 Property::Map placeholderFontstyleMap;
922 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
923 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
924 placeholderPixelSizeMapSet["color"] = Color::BLUE;
925 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
926 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
927 placeholderPixelSizeMapSet["ellipsis"] = true;
929 placeholderFontstyleMap.Insert( "weight", "bold" );
930 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
931 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
933 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
934 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
936 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
937 Property::Map placeholderConversionMap;
938 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
939 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
940 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
941 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
942 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
943 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
945 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
947 // Check the placeholder property with point size
948 Property::Map placeholderMapSet;
949 Property::Map placeholderMapGet;
950 placeholderMapSet["text"] = "Setting Placeholder Text";
951 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
952 placeholderMapSet["color"] = Color::RED;
953 placeholderMapSet["fontFamily"] = "Arial";
954 placeholderMapSet["pointSize"] = 12.0f;
955 placeholderMapSet["ellipsis"] = false;
957 // Check the placeholder font style property
958 placeholderFontstyleMap.Clear();
960 placeholderFontstyleMap.Insert( "weight", "bold" );
961 placeholderFontstyleMap.Insert( "width", "condensed" );
962 placeholderFontstyleMap.Insert( "slant", "italic" );
963 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
964 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
966 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
967 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
969 placeholderConversionMap.Clear();
970 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
971 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
972 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
973 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
974 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
975 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
977 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
980 placeholderFontstyleMap.Clear();
981 placeholderFontstyleMap.Insert( "weight", "normal" );
982 placeholderFontstyleMap.Insert( "slant", "oblique" );
983 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
984 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
986 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
987 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
989 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
990 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
992 placeholderFontstyleMap.Clear();
993 placeholderFontstyleMap.Insert( "slant", "roman" );
994 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
995 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
997 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
999 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1001 placeholderFontstyleMap.Clear();
1002 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1003 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1005 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1006 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1007 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1009 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1011 // Check the ellipsis property
1012 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1013 field.SetProperty( TextField::Property::ELLIPSIS, true );
1014 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1016 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
1017 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1019 // Test the ENABLE_GRAB_HANDLE_POPUP property
1020 DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1021 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false );
1022 DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1024 // Check the background property
1025 field.SetProperty( DevelTextField::Property::BACKGROUND, Color::RED );
1026 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::BACKGROUND ), Color::RED, TEST_LOCATION );
1028 //Check handle color
1029 field.SetProperty( DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN );
1030 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
1032 // Check the input filter property
1033 Property::Map inputFilterMapSet;
1034 Property::Map inputFilterMapGet;
1035 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1036 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1038 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1040 inputFilterMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::INPUT_FILTER);
1041 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1044 inputFilterMapSet.Clear();
1045 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1047 application.SendNotification();
1048 application.Render();
1053 // Positive Atlas Text Renderer test
1054 int utcDaliTextFieldAtlasRenderP(void)
1056 ToolkitTestApplication application;
1057 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1058 StyleManager styleManager = StyleManager::Get();
1059 styleManager.ApplyDefaultTheme();
1060 TextField field = TextField::New();
1061 DALI_TEST_CHECK( field );
1063 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1065 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1067 application.GetScene().Add( field );
1071 // Render some text with the shared atlas backend
1072 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1073 application.SendNotification();
1074 application.Render();
1078 tet_result(TET_FAIL);
1083 // Positive test for the anchorClicked signal.
1084 int utcDaliTextFieldAnchorClicked01(void)
1086 ToolkitTestApplication application;
1087 tet_infoline(" utcDaliTextFieldAnchorClicked01");
1088 TextField field = TextField::New();
1089 DALI_TEST_CHECK(field);
1091 application.GetScene().Add(field);
1093 // connect to the anchor clicked signal.
1094 ConnectionTracker* testTracker = new ConnectionTracker();
1095 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1096 bool anchorClickedSignal = false;
1097 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1099 gAnchorClickedCallBackCalled = false;
1100 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1101 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1102 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1103 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1104 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1106 application.SendNotification();
1107 application.Render();
1108 field.SetKeyInputFocus();
1110 // Create a tap event to touch the text field.
1111 TestGenerateTap(application, 5.0f, 25.0f);
1112 application.SendNotification();
1113 application.Render();
1115 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1116 DALI_TEST_CHECK(anchorClickedSignal);
1118 gAnchorClickedCallBackNotCalled = true;
1119 // Tap the outside of anchor, callback should not be called.
1120 TestGenerateTap(application, 150.f, 100.f);
1121 application.SendNotification();
1122 application.Render();
1124 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1129 // Positive test for the anchorClicked signal.
1130 int utcDaliTextFieldAnchorClicked02(void)
1132 ToolkitTestApplication application;
1133 tet_infoline(" utcDaliTextFieldAnchorClicked02");
1134 TextField field = TextField::New();
1135 DALI_TEST_CHECK(field);
1137 application.GetScene().Add(field);
1139 // connect to the anchor clicked signal.
1140 ConnectionTracker* testTracker = new ConnectionTracker();
1141 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1142 bool anchorClickedSignal = false;
1143 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1145 gAnchorClickedCallBackCalled = false;
1146 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1147 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1148 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1149 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1150 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1152 application.SendNotification();
1153 application.Render();
1154 field.SetKeyInputFocus();
1156 // Avoid a crash when core load gl resources.
1157 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1159 // Create a tap event to touch the text field.
1160 TestGenerateTap(application, 30.0f, 25.0f, 100);
1161 application.SendNotification();
1162 application.Render();
1164 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1165 DALI_TEST_CHECK(anchorClickedSignal);
1168 // For coverage InsertTextAnchor, RemoveTextAnchor
1169 // first index insert
1170 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1171 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1172 application.SendNotification();
1173 application.Render();
1175 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1176 application.SendNotification();
1177 application.Render();
1179 gAnchorClickedCallBackCalled = false;
1180 // Create a tap event to touch the text field.
1181 TestGenerateTap(application, 30.0f, 25.0f, 700);
1182 application.SendNotification();
1183 field.SetKeyInputFocus();
1185 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1187 // last index insert
1188 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1189 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1190 application.SendNotification();
1191 application.Render();
1193 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1194 application.SendNotification();
1195 application.Render();
1197 gAnchorClickedCallBackCalled = false;
1198 // Create a tap event to touch the text field.
1199 TestGenerateTap(application, 30.0f, 25.0f, 1300);
1200 application.SendNotification();
1201 field.SetKeyInputFocus();
1203 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1206 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1207 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1208 application.SendNotification();
1209 application.Render();
1211 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1212 application.SendNotification();
1213 application.Render();
1215 gAnchorClickedCallBackCalled = false;
1216 // Create a tap event to touch the text field.
1217 TestGenerateTap(application, 30.0f, 25.0f, 1900);
1218 application.SendNotification();
1219 field.SetKeyInputFocus();
1221 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1223 // first index remove
1224 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1225 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1226 application.SendNotification();
1227 application.Render();
1229 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1230 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));
1231 application.SendNotification();
1232 application.Render();
1234 gAnchorClickedCallBackCalled = false;
1235 // Create a tap event to touch the text field.
1236 TestGenerateTap(application, 30.0f, 25.0f, 2500);
1237 application.SendNotification();
1238 field.SetKeyInputFocus();
1240 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1242 // last index remove
1243 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1244 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1245 application.SendNotification();
1246 application.Render();
1248 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1249 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));
1250 application.SendNotification();
1251 application.Render();
1253 gAnchorClickedCallBackCalled = false;
1254 // Create a tap event to touch the text field.
1255 TestGenerateTap(application, 30.0f, 25.0f, 3100);
1256 application.SendNotification();
1257 application.Render();
1259 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1262 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1263 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1264 application.SendNotification();
1265 application.Render();
1267 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1268 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));
1269 application.SendNotification();
1270 application.Render();
1272 gAnchorClickedCallBackCalled = false;
1273 // Create a tap event to touch the text field.
1274 TestGenerateTap(application, 30.0f, 25.0f, 3700);
1275 application.SendNotification();
1276 application.Render();
1278 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1280 // 0 ~ 1 index remove
1281 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1282 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 0);
1283 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 1);
1284 application.SendNotification();
1285 application.Render();
1287 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1288 application.SendNotification();
1289 application.Render();
1291 gAnchorClickedCallBackCalled = false;
1292 // Create a tap event to touch the text field.
1293 TestGenerateTap(application, 30.0f, 25.0f, 4300);
1294 application.SendNotification();
1295 application.Render();
1297 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1299 // 1 ~ 3 index remove
1300 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1301 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 1);
1302 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 3);
1303 application.SendNotification();
1304 application.Render();
1306 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1307 application.SendNotification();
1308 application.Render();
1310 gAnchorClickedCallBackCalled = false;
1311 // Create a tap event to touch the text field.
1312 TestGenerateTap(application, 30.0f, 25.0f, 4900);
1313 application.SendNotification();
1314 application.Render();
1316 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1318 // 3 ~ 4 index remove
1319 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1320 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 3);
1321 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 4);
1322 application.SendNotification();
1323 application.Render();
1325 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1326 application.SendNotification();
1327 application.Render();
1329 gAnchorClickedCallBackCalled = false;
1330 // Create a tap event to touch the text field.
1331 TestGenerateTap(application, 30.0f, 25.0f, 5500);
1332 application.SendNotification();
1333 application.Render();
1335 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1337 // Remove front of anchor
1338 field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
1339 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
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 whole text
1348 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1349 DevelTextField::SelectWholeText(field);
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 backspace
1358 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1359 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
1360 application.SendNotification();
1361 application.Render();
1363 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1364 application.SendNotification();
1365 application.Render();
1367 // Remove all with delete
1368 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1369 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1370 application.SendNotification();
1371 application.Render();
1373 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));
1374 application.SendNotification();
1375 application.Render();
1380 // Positive test for the textChanged signal.
1381 int utcDaliTextFieldTextChangedP(void)
1383 ToolkitTestApplication application;
1384 tet_infoline(" utcDaliTextFieldTextChangedP");
1385 TextField field = TextField::New();
1386 DALI_TEST_CHECK( field );
1388 application.GetScene().Add( field );
1390 // connect to the text changed signal.
1391 ConnectionTracker* testTracker = new ConnectionTracker();
1392 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1393 bool textChangedSignal = false;
1394 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1396 gTextChangedCallBackCalled = false;
1397 field.SetProperty( TextField::Property::TEXT, "ABC" );
1398 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1399 DALI_TEST_CHECK( textChangedSignal );
1401 application.SendNotification();
1402 field.SetKeyInputFocus();
1404 gTextChangedCallBackCalled = false;
1405 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1406 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1409 field.SetProperty( TextField::Property::TEXT, "" );
1411 // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1412 gTextChangedCallBackCalled = false;
1413 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1414 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1416 // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1417 gTextChangedCallBackCalled = false;
1418 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1419 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1424 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1426 ToolkitTestApplication application;
1427 tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1428 TextField field = TextField::New();
1429 DALI_TEST_CHECK( field );
1432 application.GetScene().Add( field );
1434 // connect to the text changed signal.
1435 ConnectionTracker* testTracker = new ConnectionTracker();
1436 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1437 bool textChangedSignal = false;
1438 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1441 // get InputMethodContext
1443 InputMethodContext::EventData imfEvent;
1444 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext( field );
1446 field.SetKeyInputFocus();
1447 field.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
1450 gTextChangedCallBackCalled = false;
1451 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1452 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1453 application.SendNotification();
1454 application.Render();
1455 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1456 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1458 gTextChangedCallBackCalled = false;
1459 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1460 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1461 application.SendNotification();
1462 application.Render();
1463 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1464 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호"), TEST_LOCATION );
1466 gTextChangedCallBackCalled = false;
1467 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1468 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1469 application.SendNotification();
1470 application.Render();
1471 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1472 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1474 gTextChangedCallBackCalled = false;
1475 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1476 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1477 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1479 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1480 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1481 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1483 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1484 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1485 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1487 application.SendNotification();
1488 application.Render();
1489 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1490 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1496 // Negative test for the textChanged signal.
1497 int utcDaliTextFieldTextChangedN(void)
1499 ToolkitTestApplication application;
1500 tet_infoline(" utcDaliTextFieldTextChangedN");
1501 TextField field = TextField::New();
1502 DALI_TEST_CHECK( field );
1504 application.GetScene().Add( field );
1506 // connect to the text changed signal.
1507 ConnectionTracker* testTracker = new ConnectionTracker();
1508 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1509 bool textChangedSignal = false;
1510 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1512 gTextChangedCallBackCalled = false;
1513 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1514 application.SendNotification();
1515 application.Render();
1516 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1517 DALI_TEST_CHECK( !textChangedSignal );
1522 // Positive test for Max Characters reached signal.
1523 int utcDaliTextFieldMaxCharactersReachedP(void)
1525 ToolkitTestApplication application;
1526 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1527 TextField field = TextField::New();
1528 DALI_TEST_CHECK( field );
1530 application.GetScene().Add( field );
1532 const int maxNumberOfCharacters = 1;
1533 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1535 field.SetKeyInputFocus();
1537 // connect to the text changed signal.
1538 ConnectionTracker* testTracker = new ConnectionTracker();
1539 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1540 bool maxLengthReachedSignal = false;
1541 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1543 gMaxCharactersCallBackCalled = false;
1545 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1546 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1548 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1549 DALI_TEST_CHECK( maxLengthReachedSignal );
1554 // Negative test for Max Characters reached signal.
1555 int utcDaliTextFieldMaxCharactersReachedN(void)
1557 ToolkitTestApplication application;
1558 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1559 TextField field = TextField::New();
1560 DALI_TEST_CHECK( field );
1562 application.GetScene().Add( field );
1564 const int maxNumberOfCharacters = 3;
1565 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1567 field.SetKeyInputFocus();
1569 // connect to the text changed signal.
1570 ConnectionTracker* testTracker = new ConnectionTracker();
1571 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1572 bool maxLengthReachedSignal = false;
1573 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1575 gMaxCharactersCallBackCalled = false;
1577 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1578 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1580 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1581 DALI_TEST_CHECK( !maxLengthReachedSignal );
1583 application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1585 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1586 DALI_TEST_CHECK( !maxLengthReachedSignal );
1591 // Positive test for Input Filtered signal.
1592 int utcDaliTextFieldInputFilteredP(void)
1594 ToolkitTestApplication application;
1595 tet_infoline(" utcDaliTextFieldInputFilteredP");
1596 TextField field = TextField::New();
1597 DALI_TEST_CHECK(field);
1599 application.GetScene().Add(field);
1601 Property::Map inputFilter;
1603 // Only digit is accepted.
1604 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1606 // Set input filter to TextField.
1607 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1609 field.SetKeyInputFocus();
1611 // connect to the input filtered signal.
1612 ConnectionTracker* testTracker = new ConnectionTracker();
1613 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1614 bool inputFilteredSignal = false;
1615 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1617 gInputFilteredAcceptedCallbackCalled = false;
1619 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ));
1621 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1622 DALI_TEST_CHECK(inputFilteredSignal);
1624 // Word is rejected.
1625 inputFilter[InputFilter::Property::ACCEPTED] = "";
1626 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1628 // Set input filter to TextField.
1629 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1631 field.SetKeyInputFocus();
1633 inputFilteredSignal = false;
1634 gInputFilteredRejectedCallbackCalled = false;
1636 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1638 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1639 DALI_TEST_CHECK(inputFilteredSignal);
1644 // Negative test for Input Filtered signal.
1645 int utcDaliTextFieldInputFilteredN(void)
1647 ToolkitTestApplication application;
1648 tet_infoline(" utcDaliTextFieldInputFilteredP");
1649 TextField field = TextField::New();
1650 DALI_TEST_CHECK(field);
1652 application.GetScene().Add(field);
1654 Property::Map inputFilter;
1656 // Only word is accepted.
1657 inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
1659 // Set input filter to TextField.
1660 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1662 field.SetKeyInputFocus();
1664 // connect to the input filtered signal.
1665 ConnectionTracker* testTracker = new ConnectionTracker();
1666 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1667 bool inputFilteredSignal = false;
1668 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1670 gInputFilteredAcceptedCallbackCalled = false;
1672 // Key a, d should not be filtered.
1673 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1674 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1675 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1676 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1678 // Backspace, Delete should not be filtered.
1679 application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1680 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));
1682 // Render and notify
1683 application.SendNotification();
1684 application.Render();
1686 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1687 DALI_TEST_CHECK(!inputFilteredSignal);
1689 // Digit is rejected.
1690 inputFilter[InputFilter::Property::ACCEPTED] = "";
1691 inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
1693 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1695 field.SetKeyInputFocus();
1697 inputFilteredSignal = false;
1698 gInputFilteredRejectedCallbackCalled = false;
1700 // Key a, d should not be filtered.
1701 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1702 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1703 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1704 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1706 // Backspace, Delete should not be filtered.
1707 application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1708 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));
1710 // Render and notify
1711 application.SendNotification();
1712 application.Render();
1714 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1715 DALI_TEST_CHECK(!inputFilteredSignal);
1720 int utcDaliTextFieldInputStyleChanged01(void)
1722 // The text-field emits signals when the input style changes. These changes of style are
1723 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1724 // can't be emitted during the size negotiation as the callbacks may update the UI.
1725 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1726 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1727 ToolkitTestApplication application;
1728 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1732 char* pathNamePtr = get_current_dir_name();
1733 const std::string pathName( pathNamePtr );
1734 free( pathNamePtr );
1736 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1737 fontClient.SetDpi( 93u, 93u );
1739 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1740 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1742 TextField field = TextField::New();
1743 DALI_TEST_CHECK( field );
1746 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1747 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1748 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1750 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1751 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1753 // connect to the text changed signal.
1754 ConnectionTracker* testTracker = new ConnectionTracker();
1755 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1756 bool inputStyleChangedSignal = false;
1757 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1759 application.GetScene().Add( field );
1761 // Render and notify
1762 application.SendNotification();
1763 application.Render();
1765 // Executes the idle callbacks added by the text control on the change of input style.
1766 application.RunIdles();
1768 gInputStyleChangedCallbackCalled = false;
1769 gInputStyleMask = TextField::InputStyle::NONE;
1770 inputStyleChangedSignal = false;
1772 // Create a tap event to touch the text field.
1773 TestGenerateTap( application, 18.0f, 25.0f );
1775 // Render and notify
1776 application.SendNotification();
1777 application.Render();
1779 // Executes the idle callbacks added by the text control on the change of input style.
1780 application.RunIdles();
1782 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1783 if( gInputStyleChangedCallbackCalled )
1785 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1787 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1788 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1790 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1791 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1793 DALI_TEST_CHECK( inputStyleChangedSignal );
1795 gInputStyleChangedCallbackCalled = false;
1796 gInputStyleMask = TextField::InputStyle::NONE;
1797 inputStyleChangedSignal = false;
1799 // Create a tap event to touch the text field.
1800 TestGenerateTap( application, 30.0f, 25.0f );
1802 // Render and notify
1803 application.SendNotification();
1804 application.Render();
1806 // Executes the idle callbacks added by the text control on the change of input style.
1807 application.RunIdles();
1809 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1810 DALI_TEST_CHECK( !inputStyleChangedSignal );
1812 gInputStyleChangedCallbackCalled = false;
1813 gInputStyleMask = TextField::InputStyle::NONE;
1814 inputStyleChangedSignal = false;
1816 // Create a tap event to touch the text field.
1817 TestGenerateTap( application, 43.0f, 25.0f );
1819 // Render and notify
1820 application.SendNotification();
1821 application.Render();
1823 // Executes the idle callbacks added by the text control on the change of input style.
1824 application.RunIdles();
1826 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1827 if( gInputStyleChangedCallbackCalled )
1829 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1831 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1832 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1834 DALI_TEST_CHECK( inputStyleChangedSignal );
1836 gInputStyleChangedCallbackCalled = false;
1837 gInputStyleMask = TextField::InputStyle::NONE;
1838 inputStyleChangedSignal = false;
1840 // Create a tap event to touch the text field.
1841 TestGenerateTap( application, 88.0f, 25.0f );
1843 // Render and notify
1844 application.SendNotification();
1845 application.Render();
1847 // Executes the idle callbacks added by the text control on the change of input style.
1848 application.RunIdles();
1850 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1851 if( gInputStyleChangedCallbackCalled )
1853 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1855 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1856 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1858 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1860 Property::Map fontStyleMapSet;
1861 fontStyleMapSet.Insert( "weight", "bold" );
1863 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1864 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1866 DALI_TEST_CHECK( inputStyleChangedSignal );
1868 gInputStyleChangedCallbackCalled = false;
1869 gInputStyleMask = TextField::InputStyle::NONE;
1870 inputStyleChangedSignal = false;
1872 // Create a tap event to touch the text field.
1873 TestGenerateTap( application, 115.0f, 25.0f );
1875 // Render and notify
1876 application.SendNotification();
1877 application.Render();
1879 // Executes the idle callbacks added by the text control on the change of input style.
1880 application.RunIdles();
1882 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1883 DALI_TEST_CHECK( !inputStyleChangedSignal );
1885 gInputStyleChangedCallbackCalled = false;
1886 gInputStyleMask = TextField::InputStyle::NONE;
1887 inputStyleChangedSignal = false;
1889 // Create a tap event to touch the text field.
1890 TestGenerateTap( application, 164.0f, 25.0f );
1892 // Render and notify
1893 application.SendNotification();
1894 application.Render();
1896 // Executes the idle callbacks added by the text control on the change of input style.
1897 application.RunIdles();
1899 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1900 if( gInputStyleChangedCallbackCalled )
1902 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1904 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1905 DALI_TEST_CHECK( style.empty() );
1907 DALI_TEST_CHECK( inputStyleChangedSignal );
1909 gInputStyleChangedCallbackCalled = false;
1910 gInputStyleMask = TextField::InputStyle::NONE;
1911 inputStyleChangedSignal = false;
1913 // Create a tap event to touch the text field.
1914 TestGenerateTap( application, 191.0f, 25.0f );
1916 // Render and notify
1917 application.SendNotification();
1918 application.Render();
1920 // Executes the idle callbacks added by the text control on the change of input style.
1921 application.RunIdles();
1923 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1924 DALI_TEST_CHECK( !inputStyleChangedSignal );
1929 int utcDaliTextFieldInputStyleChanged02(void)
1931 // The text-field emits signals when the input style changes. These changes of style are
1932 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1933 // can't be emitted during the size negotiation as the callbacks may update the UI.
1934 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1935 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1936 ToolkitTestApplication application;
1937 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1941 char* pathNamePtr = get_current_dir_name();
1942 const std::string pathName( pathNamePtr );
1943 free( pathNamePtr );
1945 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1946 fontClient.SetDpi( 93u, 93u );
1948 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1949 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1951 TextField field = TextField::New();
1952 DALI_TEST_CHECK( field );
1954 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1955 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1956 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1958 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1959 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>" );
1961 // connect to the text changed signal.
1962 ConnectionTracker* testTracker = new ConnectionTracker();
1963 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1964 bool inputStyleChangedSignal = false;
1965 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1967 application.GetScene().Add( field );
1969 // Render and notify
1970 application.SendNotification();
1971 application.Render();
1973 // Executes the idle callbacks added by the text control on the change of input style.
1974 application.RunIdles();
1976 gInputStyleChangedCallbackCalled = false;
1977 gInputStyleMask = TextField::InputStyle::NONE;
1978 inputStyleChangedSignal = false;
1980 // Create a tap event to touch the text field.
1981 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1982 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1984 // Render and notify
1985 application.SendNotification();
1986 application.Render();
1988 // Executes the idle callbacks added by the text control on the change of input style.
1989 application.RunIdles();
1991 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1992 if( gInputStyleChangedCallbackCalled )
1994 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1995 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1996 TextField::InputStyle::POINT_SIZE |
1997 TextField::InputStyle::COLOR ),
2000 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2001 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
2003 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
2004 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
2006 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
2007 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2009 DALI_TEST_CHECK( inputStyleChangedSignal );
2011 gInputStyleChangedCallbackCalled = false;
2012 gInputStyleMask = TextField::InputStyle::NONE;
2013 inputStyleChangedSignal = false;
2015 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2017 // Render and notify
2018 application.SendNotification();
2019 application.Render();
2021 // Executes the idle callbacks added by the text control on the change of input style.
2022 application.RunIdles();
2024 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2025 if( gInputStyleChangedCallbackCalled )
2027 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2028 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
2031 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2032 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
2034 DALI_TEST_CHECK( inputStyleChangedSignal );
2036 gInputStyleChangedCallbackCalled = false;
2037 gInputStyleMask = TextField::InputStyle::NONE;
2038 inputStyleChangedSignal = false;
2040 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2042 // Render and notify
2043 application.SendNotification();
2044 application.Render();
2046 // Executes the idle callbacks added by the text control on the change of input style.
2047 application.RunIdles();
2049 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
2050 DALI_TEST_CHECK( !inputStyleChangedSignal );
2052 gInputStyleChangedCallbackCalled = false;
2053 gInputStyleMask = TextField::InputStyle::NONE;
2054 inputStyleChangedSignal = false;
2056 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2058 // Render and notify
2059 application.SendNotification();
2060 application.Render();
2062 // Executes the idle callbacks added by the text control on the change of input style.
2063 application.RunIdles();
2065 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2066 if( gInputStyleChangedCallbackCalled )
2068 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2069 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
2072 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2073 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
2075 DALI_TEST_CHECK( inputStyleChangedSignal );
2077 gInputStyleChangedCallbackCalled = false;
2078 gInputStyleMask = TextField::InputStyle::NONE;
2079 inputStyleChangedSignal = false;
2081 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
2083 Property::Map fontStyleMapSet;
2084 fontStyleMapSet.Insert( "weight", "thin" );
2085 fontStyleMapSet.Insert( "width", "condensed" );
2086 fontStyleMapSet.Insert( "slant", "italic" );
2088 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2089 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
2091 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
2092 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
2093 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
2094 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
2096 // Render and notify
2097 application.SendNotification();
2098 application.Render();
2100 // Executes the idle callbacks added by the text control on the change of input style.
2101 application.RunIdles();
2103 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
2104 DALI_TEST_CHECK( !inputStyleChangedSignal );
2106 // Create a tap event to touch the text field.
2107 TestGenerateTap( application, 63.0f, 25.0f, 700 );
2109 // Render and notify
2110 application.SendNotification();
2111 application.Render();
2113 // Executes the idle callbacks added by the text control on the change of input style.
2114 application.RunIdles();
2116 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2117 if( gInputStyleChangedCallbackCalled )
2119 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2120 static_cast<unsigned int>( TextField::InputStyle::COLOR |
2121 TextField::InputStyle::POINT_SIZE |
2122 TextField::InputStyle::FONT_STYLE |
2123 TextField::InputStyle::UNDERLINE |
2124 TextField::InputStyle::SHADOW |
2125 TextField::InputStyle::EMBOSS |
2126 TextField::InputStyle::OUTLINE ),
2129 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2130 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
2132 DALI_TEST_CHECK( inputStyleChangedSignal );
2137 int utcDaliTextFieldEvent01(void)
2139 ToolkitTestApplication application;
2140 tet_infoline(" utcDaliTextFieldEvent01");
2142 // Creates a tap event. After creating a tap event the text field should
2143 // have the focus and add text with key events should be possible.
2145 TextField field = TextField::New();
2146 DALI_TEST_CHECK( field );
2148 application.GetScene().Add( field );
2150 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2151 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2152 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2154 // Render and notify
2155 application.SendNotification();
2156 application.Render();
2158 // Avoid a crash when core load gl resources.
2159 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2161 // Render and notify
2162 application.SendNotification();
2163 application.Render();
2165 // Add a key event but as the text field has not the focus it should do nothing.
2166 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2168 // Render and notify
2169 application.SendNotification();
2170 application.Render();
2172 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2174 // Create a tap event to touch the text field.
2175 TestGenerateTap( application, 150.0f, 25.0f );
2177 // Render and notify
2178 application.SendNotification();
2179 application.Render();
2181 // Pressing delete key should be fine even if there is no text in TextField.
2182 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 ) );
2183 // Render and notify
2184 application.SendNotification();
2185 application.Render();
2187 // Now the text field has the focus, so it can handle the key events.
2188 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2189 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2191 // Render and notify
2192 application.SendNotification();
2193 application.Render();
2195 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2197 // Create a second text field and send key events to it.
2198 TextField field2 = TextField::New();
2200 field2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2201 field2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2202 field2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2203 field2.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
2205 application.GetScene().Add( field2 );
2207 // Render and notify
2208 application.SendNotification();
2209 application.Render();
2211 // Create a tap event on the second text field.
2212 TestGenerateTap( application, 150.0f, 125.0f );
2214 // Render and notify
2215 application.SendNotification();
2216 application.Render();
2218 // The second text field has the focus. It should handle the key events.
2219 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2220 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2222 // Render and notify
2223 application.SendNotification();
2224 application.Render();
2226 // Check the text has been added to the second text field.
2227 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2232 int utcDaliTextFieldEvent02(void)
2234 ToolkitTestApplication application;
2235 tet_infoline(" utcDaliTextFieldEvent02");
2237 // Checks if the right number of actors are created.
2239 TextField field = TextField::New();
2240 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2241 DALI_TEST_CHECK( field );
2242 LoadMarkerImages(application, field);
2244 application.GetScene().Add( field );
2246 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2247 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2248 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2250 // Avoid a crash when core load gl resources.
2251 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2253 // Render and notify
2254 application.SendNotification();
2255 application.Render();
2257 // Check there are the expected number of children ( stencil ).
2258 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
2260 Actor stencil = field.GetChildAt( 0u );
2261 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2263 // Create a tap event to touch the text field.
2264 TestGenerateTap( application, 150.0f, 25.0f, 300 );
2266 // Render and notify
2267 application.SendNotification();
2268 application.Render();
2270 Actor layer = field.GetChildAt( 1u );
2271 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2272 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2274 // Now the text field has the focus, so it can handle the key events.
2275 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2276 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2278 // Render and notify
2279 application.SendNotification();
2280 application.Render();
2282 // Checks the cursor and the renderer have been created.
2283 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2284 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
2286 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
2287 DALI_TEST_CHECK( cursor );
2289 // The offscreen root actor has a container with all the actors which contain the text renderers.
2290 Actor container = stencil.GetChildAt( 0u );
2291 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2293 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2294 DALI_TEST_CHECK( renderer );
2297 // Move the cursor and check the position changes.
2298 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2299 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2301 // Render and notify
2302 application.SendNotification();
2303 application.Render();
2305 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2306 DALI_TEST_CHECK( position2.x < position1.x );
2308 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2310 // Render and notify
2311 application.SendNotification();
2312 application.Render();
2314 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2315 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
2318 // Move the cursor to the first position.
2319 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2320 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2322 // Render and notify
2323 application.SendNotification();
2324 application.Render();
2326 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2328 // Send some taps and check the cursor positions.
2330 // Try to tap at the beginning.
2331 TestGenerateTap( application, 1.0f, 25.0f, 900 );
2333 // Render and notify
2334 application.SendNotification();
2335 application.Render();
2337 // Cursor position should be the same than position1.
2338 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2340 DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
2342 // Tap away from the start position.
2343 TestGenerateTap( application, 16.0f, 25.0f, 1500 );
2345 // Render and notify
2346 application.SendNotification();
2347 application.Render();
2349 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2351 DALI_TEST_CHECK( position6.x > position5.x );
2353 // Remove all the text.
2354 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2355 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2356 field.SetProperty( TextField::Property::TEXT, "" );
2358 // Render and notify
2359 application.SendNotification();
2360 application.Render();
2362 // Cursor position should be the same than position2.
2363 Vector3 position7 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2365 DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
2367 // Should not be a renderer.
2368 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2370 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2371 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2372 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
2374 application.SendNotification();
2375 application.Render();
2377 // There are renderer and decorator layer
2378 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
2383 int utcDaliTextFieldEvent03(void)
2385 ToolkitTestApplication application;
2386 tet_infoline(" utcDaliTextFieldEvent03");
2388 // Checks if the highlight actor is created.
2390 TextField field = TextField::New();
2391 DALI_TEST_CHECK( field );
2393 application.GetScene().Add( field );
2395 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2396 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2397 field.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
2398 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2399 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2401 // Avoid a crash when core load gl resources.
2402 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2403 LoadMarkerImages(application, field);
2405 // Render and notify
2406 application.SendNotification();
2407 application.Render();
2409 // Tap first to get the focus.
2410 TestGenerateTap( application, 3.0f, 25.0f );
2412 // Render and notify
2413 application.SendNotification();
2414 application.Render();
2416 // Double tap to select a word.
2417 TestGenerateTap( application, 3.0f, 25.0f );
2419 // Render and notify
2420 application.SendNotification();
2421 application.Render();
2423 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2424 Actor stencil = field.GetChildAt( 0u );
2426 // The highlight actor is drawn first, so is the first actor in the list
2427 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2428 DALI_TEST_CHECK( highlight );
2430 // The offscreen root actor has a container with all the actors which contain the text renderers.
2431 Actor container = stencil.GetChildAt( 1u );
2432 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2434 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2435 DALI_TEST_CHECK( renderer );
2441 int utcDaliTextFieldEvent04(void)
2443 ToolkitTestApplication application;
2444 tet_infoline(" utcDaliTextFieldEvent04");
2446 // Checks if the highlight actor is created.
2448 TextField field = TextField::New();
2449 DALI_TEST_CHECK( field );
2450 application.GetScene().Add( field );
2451 LoadMarkerImages(application, field);
2452 // Render and notify
2453 application.SendNotification();
2454 application.Render();
2456 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2457 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2458 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2459 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2460 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2462 // Avoid a crash when core load gl resources.
2463 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2464 // Render and notify
2465 application.SendNotification();
2466 application.Render();
2468 // Create a tap event to touch the text field.
2469 TestGenerateTap( application, 150.0f, 25.0f );
2470 // Render and notify
2471 application.SendNotification();
2472 application.Render();
2475 // Tap first to get the focus.
2476 TestGenerateTap( application, 1.0f, 25.0f );
2478 // Render and notify
2479 application.SendNotification();
2480 application.Render();
2482 // Double tap to select a word.
2483 TestGenerateTap( application, 1.0f, 25.0f );
2485 // Render and notify
2486 application.SendNotification();
2487 application.Render();
2490 TestGenerateTap( application, 0.0f, 40.0f );
2494 int utcDaliTextFieldEvent05(void)
2496 ToolkitTestApplication application;
2497 tet_infoline(" utcDaliTextFieldEvent05");
2499 // Checks dragging of cursor/grab handle
2501 TextField field = TextField::New();
2502 DALI_TEST_CHECK( field );
2503 application.GetScene().Add( field );
2504 LoadMarkerImages(application, field);
2505 // Render and notify
2506 application.SendNotification();
2507 application.Render();
2509 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2510 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2511 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2512 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2513 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2515 // Avoid a crash when core load gl resources.
2516 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2517 // Render and notify
2518 application.SendNotification();
2519 application.Render();
2521 // Create a tap event to touch the text field.
2522 TestGenerateTap( application, 150.0f, 25.0f );
2523 // Render and notify
2524 application.SendNotification();
2525 application.Render();
2527 // Tap first to get the focus.
2528 TestGenerateTap( application, 1.0f, 25.0f );
2530 // Render and notify
2531 application.SendNotification();
2532 application.Render();
2534 // Double tap to select a word.
2535 TestGenerateTap( application, 1.0f, 25.0f );
2537 // Render and notify
2538 application.SendNotification();
2539 application.Render();
2541 Actor stencil = field.GetChildAt( 1u );
2545 int utcDaliTextFieldEvent06(void)
2547 ToolkitTestApplication application;
2548 tet_infoline(" utcDaliTextFieldEvent06");
2550 // Checks Longpress when in edit mode
2552 TextField field = TextField::New();
2553 DALI_TEST_CHECK( field );
2554 application.GetScene().Add( field );
2555 LoadMarkerImages(application, field);
2556 // Render and notify
2557 application.SendNotification();
2558 application.Render();
2560 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2561 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2562 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2563 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2564 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2566 // Avoid a crash when core load gl resources.
2567 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2568 // Render and notify
2569 application.SendNotification();
2570 application.Render();
2572 // Create a tap event to touch the text field.
2573 TestGenerateTap( application, 150.0f, 25.0f );
2574 // Render and notify
2575 application.SendNotification();
2576 application.Render();
2579 // Tap first to get the focus.
2580 TestGenerateTap( application, 1.0f, 25.0f );
2582 // Render and notify
2583 application.SendNotification();
2584 application.Render();
2587 TestGenerateLongPress(application, 1.0f, 25.0f);
2589 // Render and notify
2590 application.SendNotification();
2591 application.Render();
2596 int utcDaliTextFieldEvent07(void)
2598 ToolkitTestApplication application;
2599 tet_infoline(" utcDaliTextFieldEvent07");
2601 // Checks Longpress to start edit mode
2603 TextField field = TextField::New();
2604 DALI_TEST_CHECK( field );
2605 application.GetScene().Add( field );
2606 LoadMarkerImages(application, field);
2607 // Render and notify
2608 application.SendNotification();
2609 application.Render();
2611 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2612 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2613 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2614 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2615 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2616 Property::Map propertyMap;
2617 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2618 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2620 // Avoid a crash when core load gl resources.
2621 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2622 // Render and notify
2623 application.SendNotification();
2624 application.Render();
2627 TestGenerateLongPress(application, 1.0f, 25.0f);
2629 // Render and notify
2630 application.SendNotification();
2631 application.Render();
2636 int utcDaliTextFieldEvent08(void)
2638 ToolkitTestApplication application;
2639 tet_infoline(" utcDaliTextFieldEvent08");
2641 Dali::Clipboard clipboard = Clipboard::Get();
2642 clipboard.SetItem("testTextFieldEvent");
2644 // Checks Longpress when only place holder text
2646 TextField field = TextField::New();
2647 DALI_TEST_CHECK( field );
2648 application.GetScene().Add( field );
2649 LoadMarkerImages(application, field);
2650 // Render and notify
2651 application.SendNotification();
2652 application.Render();
2654 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2655 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2656 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2657 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2658 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2660 // Avoid a crash when core load gl resources.
2661 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2662 // Render and notify
2663 application.SendNotification();
2664 application.Render();
2667 TestGenerateLongPress( application, 1.0f, 25.0f, 20 );
2669 // Render and notify
2670 application.SendNotification();
2671 application.Render();
2673 Wait(application, 500);
2675 TestEndLongPress( application, 1.0f, 25.0f, 520 );
2678 TestGenerateLongPress( application, 1.0f, 25.0f, 600 );
2680 // Render and notify
2681 application.Render();
2683 Wait(application, 500);
2685 Integration::Scene stage = application.GetScene();
2686 Layer layer = stage.GetRootLayer();
2687 Actor actor = layer.FindChildByName("optionPaste");
2691 Vector3 worldPosition = actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION );
2692 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2693 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2695 Dali::Integration::TouchEvent event;
2696 event = Dali::Integration::TouchEvent();
2697 event.AddPoint( GetPointDownInside( position ) );
2698 application.ProcessEvent( event );
2700 event = Dali::Integration::TouchEvent();
2701 event.AddPoint( GetPointUpInside( position ) );
2702 application.ProcessEvent( event );
2704 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2709 int utcDaliTextFieldEvent09(void)
2711 ToolkitTestApplication application;
2712 tet_infoline(" utcDaliTextFieldEvent09");
2714 TextField field = TextField::New();
2715 DALI_TEST_CHECK( field );
2716 application.GetScene().Add( field );
2717 LoadMarkerImages(application, field);
2718 // Render and notify
2719 application.SendNotification();
2720 application.Render();
2722 field.SetProperty( TextField::Property::TEXT, "Hello" );
2723 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2724 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2725 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2726 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2728 // Avoid a crash when core load gl resources.
2729 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2731 // Create a tap event to touch the text field.
2732 TestGenerateTap( application, 150.0f, 25.0f );
2733 application.SendNotification();
2734 application.Render();
2737 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2738 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2739 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2740 application.SendNotification();
2741 application.Render();
2743 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2744 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2745 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2746 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2747 application.SendNotification();
2748 application.Render();
2750 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_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_COUNT;
2761 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2762 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2763 for( unsigned int index = 0u; index < 5u; ++index )
2765 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2766 application.SendNotification();
2767 application.Render();
2770 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2771 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2772 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2773 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2774 application.SendNotification();
2775 application.Render();
2776 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2777 application.SendNotification();
2778 application.Render();
2780 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2781 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2782 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2783 application.SendNotification();
2784 application.Render();
2786 Property::Map mapGet;
2787 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2788 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2789 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2794 int utcDaliTextFieldStyleWhilstSelected(void)
2796 ToolkitTestApplication application;
2797 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2799 // Change font and styles whilst text is selected whilst word selected
2801 TextField field = TextField::New();
2802 DALI_TEST_CHECK( field );
2803 application.GetScene().Add( field );
2804 LoadMarkerImages(application, field);
2805 // Render and notify
2806 application.SendNotification();
2807 application.Render();
2809 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2810 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2811 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2812 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2813 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2815 // Avoid a crash when core load gl resources.
2816 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2817 // Render and notify
2818 application.SendNotification();
2819 application.Render();
2821 // Create a tap event to touch the text field.
2822 TestGenerateTap( application, 150.0f, 25.0f );
2823 // Render and notify
2824 application.SendNotification();
2825 application.Render();
2828 // Tap first to get the focus.
2829 TestGenerateTap( application, 1.0f, 25.0f );
2831 // Render and notify
2832 application.SendNotification();
2833 application.Render();
2835 // Double tap to select a word.
2836 TestGenerateTap( application, 1.0f, 25.0f );
2838 // Render and notify
2839 application.SendNotification();
2840 application.Render();
2842 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2843 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2845 Property::Map fontStyleMapSet;
2846 Property::Map fontStyleMapGet;
2848 fontStyleMapSet.Insert( "weight", "bold" );
2849 fontStyleMapSet.Insert( "slant", "italic" );
2850 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2852 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2853 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2854 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2856 fontStyleMapSet.Clear();
2857 fontStyleMapSet.Insert( "width", "expanded" );
2858 fontStyleMapSet.Insert( "slant", "italic" );
2859 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2861 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2862 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2863 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2865 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2866 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2868 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2869 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2871 fontStyleMapSet.Clear();
2872 fontStyleMapSet.Insert( "weight", "bold" );
2873 fontStyleMapSet.Insert( "slant", "italic" );
2875 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2877 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2878 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2879 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2881 fontStyleMapSet.Clear();
2882 fontStyleMapSet.Insert( "width", "expanded" );
2884 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2886 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2887 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2888 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2890 // Press Escape to increase coverage
2891 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2892 application.SendNotification();
2893 application.Render();
2895 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2900 int utcDaliTextFieldEscKeyLoseFocus(void)
2902 ToolkitTestApplication application;
2903 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2905 // Creates a tap event. After creating a tap event the text field should
2906 // have the focus and add text with key events should be possible.
2908 TextField field = TextField::New();
2909 DALI_TEST_CHECK( field );
2911 application.GetScene().Add( field );
2913 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2914 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2915 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2917 // Avoid a crash when core load gl resources.
2918 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2920 // Render and notify
2921 application.SendNotification();
2922 application.Render();
2924 // Add a key event but as the text field has not the focus it should do nothing.
2925 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2926 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2928 // Render and notify
2929 application.SendNotification();
2930 application.Render();
2932 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2934 // Create a tap event to touch the text field.
2935 TestGenerateTap( application, 150.0f, 25.0f );
2937 // Render and notify
2938 application.SendNotification();
2939 application.Render();
2941 // Now the text field has the focus, so it can handle the key events.
2942 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2943 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2944 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2945 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2947 // Render and notify
2948 application.SendNotification();
2949 application.Render();
2951 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2953 // Generate a Esc key event. The text field should lose the focus.
2954 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2955 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2957 // Render and notify
2958 application.SendNotification();
2959 application.Render();
2961 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2963 // No more text should be introduced
2964 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2965 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2967 // Render and notify
2968 application.SendNotification();
2969 application.Render();
2971 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2976 int utcDaliTextFieldSomeSpecialKeys(void)
2978 ToolkitTestApplication application;
2979 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2981 // Checks some special keys when the text is selected.
2983 TextField field = TextField::New();
2984 DALI_TEST_CHECK( field );
2985 application.GetScene().Add( field );
2986 LoadMarkerImages(application, field);
2987 // Render and notify
2988 application.SendNotification();
2989 application.Render();
2991 const std::string longText( "This is a long text for the size of the text-field." );
2993 field.SetProperty( TextField::Property::TEXT, longText );
2994 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2995 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2996 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2997 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2999 // Avoid a crash when core load gl resources.
3000 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3001 // Render and notify
3002 application.SendNotification();
3003 application.Render();
3005 // Create a tap event to touch the text field.
3006 TestGenerateTap( application, 150.0f, 25.0f );
3008 // Render and notify
3009 application.SendNotification();
3010 application.Render();
3012 // Tap first to get the focus.
3013 TestGenerateTap( application, 1.0f, 25.0f );
3015 // Render and notify
3016 application.SendNotification();
3017 application.Render();
3019 // Double tap to select a word.
3020 TestGenerateTap( application, 1.0f, 25.0f );
3022 // Render and notify
3023 application.SendNotification();
3024 application.Render();
3026 // Generate a Esc key event. The text field should lose the focus.
3027 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3028 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3030 // Render and notify
3031 application.SendNotification();
3032 application.Render();
3034 // Generate a Esc key event. The text field should lose the focus.
3035 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3036 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3038 // Render and notify
3039 application.SendNotification();
3040 application.Render();
3042 // Generate a Esc key event. The text field should lose the focus.
3043 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3044 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3046 // Render and notify
3047 application.SendNotification();
3048 application.Render();
3050 // The text shouldn't be deleted.
3051 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
3056 int utcDaliTextFieldSizeUpdate(void)
3058 ToolkitTestApplication application;
3059 tet_infoline("utcDaliTextFieldSizeUpdate");
3061 // Checks some special keys when the text is selected.
3062 TextField field = TextField::New();
3063 DALI_TEST_CHECK( field );
3064 application.GetScene().Add( field );
3066 float previousHeight = 0.0f;
3067 float currentHeight = 0.0f;
3068 const float fieldWidth = 1920.0f;
3071 // "ㅁ" is bigger then "ኢ"
3072 field.SetProperty( Actor::Property::SIZE, Vector2( fieldWidth ,10.0f ) );
3073 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
3074 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
3076 field.SetProperty( TextField::Property::TEXT, "ኢ");
3077 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3078 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3080 field.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
3081 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
3083 application.SendNotification();
3084 application.Render();
3086 previousHeight = field.GetHeightForWidth( fieldWidth );
3087 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
3089 // Add another script characters ( glyph height is defferent )
3090 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3091 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3093 application.SendNotification();
3094 application.Render();
3096 currentHeight = field.GetHeightForWidth( fieldWidth );
3097 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
3098 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
3103 int utcDaliTextFieldExtremlyLargePointSize(void)
3105 ToolkitTestApplication application;
3106 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
3108 TextField field = TextField::New();
3110 field.SetProperty( TextField::Property::TEXT, "Text" );
3111 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3112 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3113 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3114 application.GetScene().Add( field );
3118 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
3119 application.SendNotification();
3120 DALI_TEST_CHECK( field );
3124 tet_result(TET_FAIL);
3129 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
3131 ToolkitTestApplication application;
3132 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
3133 TextField field = TextField::New();
3134 DALI_TEST_CHECK( field );
3135 application.GetScene().Add( field );
3137 Property::Map fontStyleMapGet;
3139 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
3141 Property::Value* weightValue = NULL;
3142 Property::Value* widthValue = NULL;
3143 Property::Value* slantValue = NULL;
3144 weightValue = fontStyleMapGet.Find( "weight" );
3145 widthValue = fontStyleMapGet.Find( "width" );
3146 slantValue = fontStyleMapGet.Find( "slant" );
3147 DALI_TEST_CHECK( !weightValue );
3148 DALI_TEST_CHECK( !widthValue );
3149 DALI_TEST_CHECK( !slantValue );
3154 int UtcDaliTextFieldSettingPlaceholder(void)
3156 ToolkitTestApplication application;
3157 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
3159 TextField field = TextField::New();
3160 DALI_TEST_CHECK( field );
3161 application.GetScene().Add( field );
3163 // Check the placeholder property with pixel size
3164 Property::Map placeholderPixelSizeMapSet;
3165 Property::Map placeholderPixelSizeMapGet;
3166 Property::Map placeholderFontstyleMap;
3167 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
3168 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
3169 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
3170 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
3171 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
3172 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
3174 placeholderFontstyleMap.Insert( "weight", "bold" );
3175 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3176 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
3178 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3179 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
3180 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
3182 // Check the placeholder property with point size
3183 Property::Map placeholderMapSet;
3184 Property::Map placeholderMapGet;
3185 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
3186 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
3187 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
3188 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
3189 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
3190 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
3192 // Check the placeholder font style property
3193 placeholderFontstyleMap.Clear();
3195 placeholderFontstyleMap.Insert( "weight", "bold" );
3196 placeholderFontstyleMap.Insert( "width", "condensed" );
3197 placeholderFontstyleMap.Insert( "slant", "italic" );
3198 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3199 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3201 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3202 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3203 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3205 // Reset font style.
3206 placeholderFontstyleMap.Clear();
3207 placeholderFontstyleMap.Insert( "weight", "normal" );
3208 placeholderFontstyleMap.Insert( "slant", "oblique" );
3209 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3210 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3212 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3213 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3214 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3216 placeholderFontstyleMap.Clear();
3217 placeholderFontstyleMap.Insert( "slant", "roman" );
3218 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3219 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3221 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3223 placeholderFontstyleMap.Clear();
3224 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3226 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3227 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3228 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3229 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3234 int UtcDaliTextFieldPlaceholderCoverage(void)
3236 ToolkitTestApplication application;
3237 tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
3239 // mPlaceholderFont is created only once, so create a new control for coverage.
3240 TextField fieldForCoverage = TextField::New();
3241 DALI_TEST_CHECK(fieldForCoverage);
3242 application.GetScene().Add(fieldForCoverage);
3244 // for SetPlaceholderFontFamily() coverage.
3245 Property::Map fontFamilyMap;
3246 fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3247 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
3249 // mPlaceholderFont is created only once, so create a new control for coverage.
3250 fieldForCoverage = TextField::New();
3251 DALI_TEST_CHECK(fieldForCoverage);
3252 application.GetScene().Add(fieldForCoverage);
3254 // for SetPlaceholderTextFontSize coverage.
3255 Property::Map fontSizeMap;
3256 fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3257 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
3259 // mPlaceholderFont is created only once, so create a new control for coverage.
3260 fieldForCoverage = TextField::New();
3261 DALI_TEST_CHECK(fieldForCoverage);
3262 application.GetScene().Add(fieldForCoverage);
3264 // for SetPlaceholderTextFontWeight coverage.
3265 Property::Map fontStyleWeightMap;
3266 Property::Map fontStyleWeightPropertyMap;
3267 fontStyleWeightPropertyMap.Insert("weight", "bold");
3268 fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
3269 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
3271 // mPlaceholderFont is created only once, so create a new control for coverage.
3272 fieldForCoverage = TextField::New();
3273 DALI_TEST_CHECK(fieldForCoverage);
3274 application.GetScene().Add(fieldForCoverage);
3276 // for SetPlaceholderTextFontWidth coverage.
3277 Property::Map fontStyleWidthMap;
3278 Property::Map fontStyleWidthPropertyMap;
3279 fontStyleWidthPropertyMap.Insert("width", "expanded");
3280 fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
3281 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
3283 // mPlaceholderFont is created only once, so create a new control for coverage.
3284 fieldForCoverage = TextField::New();
3285 DALI_TEST_CHECK(fieldForCoverage);
3286 application.GetScene().Add(fieldForCoverage);
3288 // for SetPlaceholderTextFontSlant coverage.
3289 Property::Map fontStyleSlantMap;
3290 Property::Map fontStyleSlantPropertyMap;
3291 fontStyleSlantPropertyMap.Insert("slant", "italic");
3292 fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
3293 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
3298 int UtcDaliTextFieldSetPaddingProperty(void)
3300 ToolkitTestApplication application;
3301 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3303 TextField field = TextField::New();
3304 DALI_TEST_CHECK( field );
3305 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3306 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3307 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3308 application.GetScene().Add( field );
3310 application.SendNotification();
3311 application.Render();
3313 Vector3 originalSize = field.GetNaturalSize();
3315 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
3317 application.SendNotification();
3318 application.Render();
3320 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
3322 Vector3 paddingAddedSize = field.GetNaturalSize();
3324 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3326 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3331 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3333 ToolkitTestApplication application;
3334 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3336 TextField field = TextField::New();
3337 DALI_TEST_CHECK( field );
3338 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3339 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3340 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3341 application.GetScene().Add( field );
3343 application.SendNotification();
3344 application.Render();
3346 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3347 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
3349 // Check the enable shift selection property
3350 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
3351 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
3353 application.SendNotification();
3354 application.Render();
3359 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3361 ToolkitTestApplication application;
3362 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3364 TextField field = TextField::New();
3365 DALI_TEST_CHECK( field );
3366 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3367 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3368 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3369 application.GetScene().Add( field );
3371 application.SendNotification();
3372 application.Render();
3374 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3375 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
3377 // Check the enable grab handle property
3378 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
3379 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
3381 application.SendNotification();
3382 application.Render();
3387 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
3389 ToolkitTestApplication application;
3390 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
3392 TextField field = TextField::New();
3393 DALI_TEST_CHECK( field );
3394 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3395 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3396 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3397 application.GetScene().Add( field );
3399 application.SendNotification();
3400 application.Render();
3402 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3403 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
3405 // Check the match system language direction property
3406 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
3407 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
3409 application.SendNotification();
3410 application.Render();
3415 int utcDaliTextFieldLayoutDirectionCoverage(void)
3417 ToolkitTestApplication application;
3418 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
3420 // Creates a tap event. After creating a tap event the text field should
3421 // have the focus and add text with key events should be possible.
3422 TextField field = TextField::New();
3423 DALI_TEST_CHECK( field );
3425 application.GetScene().Add( field );
3427 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3428 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3429 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3431 // Avoid a crash when core load gl resources.
3432 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3434 // Render and notify
3435 application.SendNotification();
3436 application.Render();
3438 // init direction for coverage
3439 // Set horizontal alignment END
3440 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3442 // Create a tap event to touch the text field.
3443 TestGenerateTap( application, 150.0f, 25.0f );
3445 // Render and notify
3446 application.SendNotification();
3447 application.Render();
3449 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
3450 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
3451 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
3453 // Set horizontal alignment BEGIN
3454 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
3456 // Create a tap event to touch the text field.
3457 TestGenerateTap( application, 150.0f, 25.0f );
3459 // Render and notify
3460 application.SendNotification();
3461 application.Render();
3463 // Set horizontal alignment CENTER
3464 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
3466 // Create a tap event to touch the text field.
3467 TestGenerateTap( application, 150.0f, 25.0f );
3469 // Render and notify
3470 application.SendNotification();
3471 application.Render();
3473 // Set horizontal alignment END
3474 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3476 // Create a tap event to touch the text field.
3477 TestGenerateTap( application, 150.0f, 25.0f );
3479 // Render and notify
3480 application.SendNotification();
3481 application.Render();
3483 // Generate a Esc key event. The text field should lose the focus.
3484 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3485 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3487 // Render and notify
3488 application.SendNotification();
3489 application.Render();
3491 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
3496 int UtcDaliTextFieldGetInputMethodContext(void)
3498 ToolkitTestApplication application;
3499 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
3501 TextField field = TextField::New();
3502 DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );
3507 int UtcDaliTextFieldSelectWholeText(void)
3509 ToolkitTestApplication application;
3510 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3512 TextField textField = TextField::New();
3514 application.GetScene().Add( textField );
3516 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3517 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3518 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3520 // Avoid a crash when core load gl resources.
3521 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3523 application.SendNotification();
3524 application.Render();
3526 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
3528 DevelTextField::SelectWholeText( textField );
3530 application.SendNotification();
3531 application.Render();
3533 // Nothing should have been selected. The number of children is still 1
3534 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
3536 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3538 application.SendNotification();
3539 application.Render();
3541 DevelTextField::SelectWholeText( textField );
3543 application.SendNotification();
3544 application.Render();
3546 // Should be 2 children, the stencil and the layer
3547 DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
3549 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3550 Actor stencil = textField.GetChildAt( 0u );
3552 // The highlight actor is drawn first, so is the first actor in the list
3553 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3554 DALI_TEST_CHECK( highlight );
3559 int UtcDaliTextFieldSelectText(void)
3561 ToolkitTestApplication application;
3562 tet_infoline(" UtcDaliTextFieldSelectText ");
3564 TextField textField = TextField::New();
3566 application.GetScene().Add( textField );
3568 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3569 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3570 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3572 // Avoid a crash when core load gl resources.
3573 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3575 application.SendNotification();
3576 application.Render();
3578 DevelTextField::SelectText( textField, 0, 5 );
3580 application.SendNotification();
3581 application.Render();
3583 // Nothing is selected
3584 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3585 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3587 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3589 application.SendNotification();
3590 application.Render();
3592 // Hello is selected
3593 DevelTextField::SelectText( textField, 0, 5 );
3595 application.SendNotification();
3596 application.Render();
3598 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3599 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3601 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3602 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3604 // world is selected
3605 DevelTextField::SelectText( textField, 6, 11 );
3607 application.SendNotification();
3608 application.Render();
3610 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3611 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3613 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3614 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3619 int UtcDaliTextFieldSelectNone(void)
3621 ToolkitTestApplication application;
3622 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3624 TextField textField = TextField::New();
3626 application.GetScene().Add( textField );
3628 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3629 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3630 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3632 // Avoid a crash when core load gl resources.
3633 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3635 application.SendNotification();
3636 application.Render();
3638 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3640 application.SendNotification();
3641 application.Render();
3643 // Nothing is selected
3644 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3645 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3647 DevelTextField::SelectWholeText( textField );
3649 application.SendNotification();
3650 application.Render();
3652 // whole text is selected
3653 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3654 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3656 DevelTextField::SelectNone( textField );
3658 application.SendNotification();
3659 application.Render();
3661 // Nothing is selected
3662 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3663 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3668 int UtcDaliTextFieldSelectRange(void)
3670 ToolkitTestApplication application;
3671 tet_infoline(" UtcDaliTextFieldSelectRange ");
3673 TextField textField = TextField::New();
3675 application.GetScene().Add( textField );
3677 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3678 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3679 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3681 // Avoid a crash when core load gl resources.
3682 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3684 application.SendNotification();
3685 application.Render();
3687 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3689 application.SendNotification();
3690 application.Render();
3692 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 0);
3693 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 5);
3695 // Hello is selected
3696 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3697 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3699 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3700 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3702 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 6);
3703 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 11);
3705 // world is selected
3706 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3707 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3709 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3710 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3715 int UtcDaliTextFieldEnableEditing(void)
3717 ToolkitTestApplication application;
3718 tet_infoline(" UtcDaliTextFieldEnableEditing ");
3720 TextField textField = TextField::New();
3722 application.GetScene().Add( textField );
3724 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3725 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3726 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3728 // Avoid a crash when core load gl resources.
3729 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3731 application.SendNotification();
3732 application.Render();
3734 textField.SetKeyInputFocus();
3735 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, false );
3736 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3738 // Render and notify
3739 application.SendNotification();
3740 application.Render();
3742 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3743 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3746 textField.SetKeyInputFocus();
3747 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
3748 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3750 // Render and notify
3751 application.SendNotification();
3752 application.Render();
3754 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3755 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3760 int UtcDaliToolkitTextFieldFontSizeScale(void)
3762 ToolkitTestApplication application;
3763 tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
3765 TextField textField = TextField::New();
3766 textField.SetProperty( TextField::Property::POINT_SIZE, 30.f );
3767 textField.SetProperty( TextField::Property::TEXT, "Test" );
3768 Vector3 nonScaledSize = textField.GetNaturalSize();
3770 TextField textFieldScaled = TextField::New();
3771 textFieldScaled.SetProperty( TextField::Property::POINT_SIZE, 15.f );
3772 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3773 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3774 Vector3 scaledSize = textFieldScaled.GetNaturalSize();
3776 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3778 textField.SetProperty( TextField::Property::PIXEL_SIZE, 30.f );
3779 textField.SetProperty( TextField::Property::TEXT, "Test" );
3780 nonScaledSize = textField.GetNaturalSize();
3782 textFieldScaled.SetProperty( TextField::Property::PIXEL_SIZE, 15.f );
3783 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3784 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3785 scaledSize = textFieldScaled.GetNaturalSize();
3787 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3792 int UtcDaliTextFieldPrimaryCursorPosition(void)
3794 ToolkitTestApplication application;
3795 tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
3797 TextField textField = TextField::New();
3799 application.GetScene().Add( textField );
3801 textField.SetProperty( TextField::Property::TEXT, "ABCEF");
3802 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3803 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3804 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3806 // Avoid a crash when core load gl resources.
3807 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3809 textField.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
3810 application.SendNotification();
3811 application.Render();
3812 textField.SetKeyInputFocus();
3814 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3816 // Render and notify
3817 application.SendNotification();
3818 application.Render();
3820 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3821 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3826 // test max length when set after setting long text
3827 int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
3829 ToolkitTestApplication application;
3830 tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
3831 TextField field = TextField::New();
3832 DALI_TEST_CHECK( field );
3834 application.GetScene().Add( field );
3836 field.SetProperty(TextField::Property::TEXT, "123456789");
3838 const int maxNumberOfCharacters = 3;
3839 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
3841 field.SetKeyInputFocus();
3843 // connect to the text max lengh reached signal.
3844 ConnectionTracker* testTracker = new ConnectionTracker();
3845 bool maxLengthReachedSignal = false;
3846 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
3848 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3849 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3851 DALI_TEST_CHECK( maxLengthReachedSignal );
3853 DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "123456789", TEST_LOCATION );
3860 int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
3862 ToolkitTestApplication application;
3863 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
3865 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3866 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3867 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3869 // Create a text field
3870 TextField textField = TextField::New();
3872 //Set size to avoid automatic eliding
3873 textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3874 //Set very large font-size using point-size
3875 textField.SetProperty( TextField::Property::POINT_SIZE, 1000) ;
3876 //Specify font-family
3877 textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
3878 //Set text to check if appear or not
3879 textField.SetProperty( TextField::Property::TEXT, "A");
3881 application.GetScene().Add( textField );
3883 application.SendNotification();
3884 application.Render();
3885 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3886 Vector3 naturalSize = textField.GetNaturalSize();
3888 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3889 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3894 int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
3896 ToolkitTestApplication application;
3897 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
3899 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3900 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3901 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3903 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3904 // Create a text editor
3905 TextField textField = TextField::New();
3907 //Set size to avoid automatic eliding
3908 textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3909 textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
3910 textField.SetProperty( TextField::Property::TEXT, "A");
3912 const int numberOfCases = 6;
3913 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
3915 for (int index=0; index < numberOfCases; index++)
3917 tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
3918 textField.SetProperty( TextField::Property::POINT_SIZE, arrayCases[index]) ;
3919 application.GetScene().Add( textField );
3920 application.SendNotification();
3921 application.Render();
3922 naturalSize = textField.GetNaturalSize();
3923 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3924 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3931 int UtcDaliToolkitTextFieldEllipsisPositionProperty(void)
3933 ToolkitTestApplication application;
3934 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty ");
3935 TextField textField = TextField::New();
3937 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Default is END");
3938 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3940 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START");
3941 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
3942 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3944 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE");
3945 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
3946 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3948 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END");
3949 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
3950 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3952 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START using integer");
3953 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 1);
3954 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3956 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE using integer");
3957 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 2);
3958 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3960 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END using integer");
3961 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 0);
3962 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3964 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
3965 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "START");
3966 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3968 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
3969 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "MIDDLE");
3970 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3972 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
3973 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "END");
3974 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3976 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
3977 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "start");
3978 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3980 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
3981 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "middle");
3982 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3984 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
3985 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "end");
3986 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3991 int utcDaliTextFieldCursorPositionChangedSignal(void)
3993 ToolkitTestApplication application;
3994 tet_infoline(" utcDaliTextFieldCursorPositionChangedSignal");
3996 TextField field = TextField::New();
3997 DALI_TEST_CHECK( field );
3999 application.GetScene().Add( field );
4001 // connect to the selection changed signal.
4002 ConnectionTracker* testTracker = new ConnectionTracker();
4003 DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
4004 bool cursorPositionChangedSignal = false;
4005 field.ConnectSignal( testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal) );
4007 field.SetProperty( TextField::Property::TEXT, "Hello world Hello world" );
4008 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
4009 field.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4010 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4011 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4013 // Avoid a crash when core load gl resources.
4014 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4016 // Render and notify
4017 application.SendNotification();
4018 application.Render();
4020 field.SetKeyInputFocus();
4022 // Tap on the text field
4023 TestGenerateTap( application, 3.0f, 25.0f );
4025 // Render and notify
4026 application.SendNotification();
4027 application.Render();
4029 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4030 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4032 gCursorPositionChangedCallbackCalled = false;
4035 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4037 // Render and notify
4038 application.SendNotification();
4039 application.Render();
4041 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4042 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4044 gCursorPositionChangedCallbackCalled = false;
4047 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4049 // Render and notify
4050 application.SendNotification();
4051 application.Render();
4053 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4054 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4056 gCursorPositionChangedCallbackCalled = false;
4058 //delete one character
4059 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4061 // Render and notify
4062 application.SendNotification();
4063 application.Render();
4065 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4066 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4068 gCursorPositionChangedCallbackCalled = false;
4070 field.SetProperty( TextField::Property::TEXT, "Hello" );
4072 // Render and notify
4073 application.SendNotification();
4074 application.Render();
4076 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4077 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4079 gCursorPositionChangedCallbackCalled = false;
4081 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4083 // Render and notify
4084 application.SendNotification();
4085 application.Render();
4087 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4088 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);