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"
35 using namespace Toolkit;
37 void dali_textfield_startup(void)
39 test_return_value = TET_UNDEF;
42 void dali_textfield_cleanup(void)
44 test_return_value = TET_PASS;
50 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
51 const char* const PROPERTY_NAME_TEXT = "text";
52 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
53 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
54 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
55 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
56 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
57 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
58 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
59 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
60 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
61 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
62 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
63 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
64 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
65 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
66 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
67 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
68 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
69 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
70 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
71 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
72 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
73 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
80 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
81 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
82 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
83 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
84 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
85 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
86 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
88 const char* const PROPERTY_NAME_UNDERLINE = "underline";
89 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
90 const char* const PROPERTY_NAME_SHADOW = "shadow";
91 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
92 const char* const PROPERTY_NAME_EMBOSS = "emboss";
93 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
94 const char* const PROPERTY_NAME_OUTLINE = "outline";
95 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
97 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
98 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
99 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
100 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
101 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
102 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
103 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
104 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
105 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
106 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
107 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
108 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
110 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
111 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
113 const float RENDER_FRAME_INTERVAL = 16.66f;
115 const unsigned int DEFAULT_FONT_SIZE = 1152u;
116 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
118 const int KEY_RETURN_CODE = 36;
119 const int KEY_A_CODE = 38;
120 const int KEY_D_CODE = 40;
122 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
124 static bool gAnchorClickedCallBackCalled;
125 static bool gAnchorClickedCallBackNotCalled;
126 static bool gTextChangedCallBackCalled;
127 static bool gMaxCharactersCallBackCalled;
128 static bool gInputStyleChangedCallbackCalled;
129 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
131 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
133 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
134 Integration::ResourcePointer resource(bitmap);
135 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
138 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
142 LoadBitmapResource( app.GetPlatform(), width, height );
144 Property::Map propertyMap;
145 propertyMap["filename"] = "image.png";
146 propertyMap["width"] = width;
147 propertyMap["height"] = height;
148 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
149 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
150 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
151 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
152 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
153 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
154 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
155 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
159 * Simulate time passed by.
161 * @note this will always process at least 1 frame (1/60 sec)
163 * @param application Test application instance
164 * @param duration Time to pass in milliseconds.
165 * @return The actual time passed in milliseconds
167 static int Wait(ToolkitTestApplication& application, int duration = 0)
171 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
173 application.SendNotification();
174 application.Render(RENDER_FRAME_INTERVAL);
175 time += RENDER_FRAME_INTERVAL;
181 Dali::Integration::Point GetPointDownInside( Vector2& pos )
183 Dali::Integration::Point point;
184 point.SetState( PointState::DOWN );
185 point.SetScreenPosition( pos );
189 Dali::Integration::Point GetPointUpInside( Vector2& pos )
191 Dali::Integration::Point point;
192 point.SetState( PointState::UP );
193 point.SetScreenPosition( pos );
197 struct CallbackFunctor
199 CallbackFunctor(bool* callbackFlag)
200 : mCallbackFlag( callbackFlag )
206 *mCallbackFlag = true;
211 static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength)
213 tet_infoline(" TestAnchorClickedCallback");
215 gAnchorClickedCallBackNotCalled = false;
217 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
219 gAnchorClickedCallBackCalled = true;
223 static void TestTextChangedCallback( TextField control )
225 tet_infoline(" TestTextChangedCallback");
227 gTextChangedCallBackCalled = true;
230 static void TestMaxLengthReachedCallback( TextField control )
232 tet_infoline(" TestMaxLengthReachedCallback");
234 gMaxCharactersCallBackCalled = true;
237 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
239 tet_infoline(" TestInputStyleChangedCallback");
241 gInputStyleChangedCallbackCalled = true;
242 gInputStyleMask = mask;
245 // Generate a KeyEvent to send to Core.
246 Integration::KeyEvent GenerateKey( const std::string& keyName,
247 const std::string& logicalKey,
248 const std::string& keyString,
251 unsigned long timeStamp,
252 const Integration::KeyEvent::State& keyState,
253 const std::string& compose = "",
254 const std::string& deviceName = DEFAULT_DEVICE_NAME,
255 const Device::Class::Type& deviceClass = Device::Class::NONE,
256 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
258 return Integration::KeyEvent( keyName,
271 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
273 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
275 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
277 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
279 Property::Value* valueSet = NULL;
280 if ( valueGet.first.type == Property::Key::INDEX )
282 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
286 // Get Key is a string so searching Set Map for a string key
287 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
290 if( NULL != valueSet )
292 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
294 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
297 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
299 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
302 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
304 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
307 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
309 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
312 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
314 Vector2 vector2Get = valueGet.second.Get<Vector2>();
315 Vector2 vector2Set = valueSet->Get<Vector2>();
316 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
319 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
321 Vector4 vector4Get = valueGet.second.Get<Vector4>();
322 Vector4 vector4Set = valueSet->Get<Vector4>();
323 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 );
329 if ( valueGet.first.type == Property::Key::INDEX )
331 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
335 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
347 int UtcDaliToolkitTextFieldConstructorP(void)
349 ToolkitTestApplication application;
350 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
352 DALI_TEST_CHECK( !textField );
356 int UtcDaliToolkitTextFieldNewP(void)
358 ToolkitTestApplication application;
359 tet_infoline(" UtcDaliToolkitTextFieldNewP");
360 TextField textField = TextField::New();
361 DALI_TEST_CHECK( textField );
365 int UtcDaliToolkitTextFieldDownCastP(void)
367 ToolkitTestApplication application;
368 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
369 TextField textField1 = TextField::New();
370 BaseHandle object( textField1 );
372 TextField textField2 = TextField::DownCast( object );
373 DALI_TEST_CHECK( textField2 );
375 TextField textField3 = DownCast< TextField >( object );
376 DALI_TEST_CHECK( textField3 );
380 int UtcDaliToolkitTextFieldDownCastN(void)
382 ToolkitTestApplication application;
383 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
384 BaseHandle uninitializedObject;
385 TextField textField1 = TextField::DownCast( uninitializedObject );
386 DALI_TEST_CHECK( !textField1 );
388 TextField textField2 = DownCast< TextField >( uninitializedObject );
389 DALI_TEST_CHECK( !textField2 );
393 int UtcDaliToolkitTextFieldCopyConstructorP(void)
395 ToolkitTestApplication application;
396 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
397 TextField textField = TextField::New();
398 textField.SetProperty( TextField::Property::TEXT, "Test" );
400 TextField copy( textField );
401 DALI_TEST_CHECK( copy );
402 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
406 int UtcDaliTextFieldMoveConstructor(void)
408 ToolkitTestApplication application;
410 TextField textField = TextField::New();
411 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
412 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
414 TextField moved = std::move( textField );
415 DALI_TEST_CHECK( moved );
416 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
417 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
418 DALI_TEST_CHECK( !textField );
423 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
425 ToolkitTestApplication application;
426 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
427 TextField textField = TextField::New();
428 textField.SetProperty( TextField::Property::TEXT, "Test" );
430 TextField copy = textField;
431 DALI_TEST_CHECK( copy );
432 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
436 int UtcDaliTextFieldMoveAssignment(void)
438 ToolkitTestApplication application;
440 TextField textField = TextField::New();
441 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
442 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
445 moved = std::move( textField );
446 DALI_TEST_CHECK( moved );
447 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
448 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
449 DALI_TEST_CHECK( !textField );
454 int UtcDaliTextFieldNewP(void)
456 ToolkitTestApplication application;
457 tet_infoline(" UtcDaliToolkitTextFieldNewP");
458 TextField textField = TextField::New();
459 DALI_TEST_CHECK( textField );
463 // Positive test case for a method
464 int UtcDaliTextFieldGetPropertyP(void)
466 ToolkitTestApplication application;
467 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
468 TextField field = TextField::New();
469 DALI_TEST_CHECK( field );
471 // Check Property Indices are correct
472 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextField::Property::RENDERING_BACKEND );
473 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
474 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
475 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
476 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
477 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
478 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
479 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
480 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
481 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
482 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
483 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
484 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
485 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
486 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
487 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
488 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
489 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
490 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
491 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
492 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
493 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
494 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
495 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
496 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
497 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
498 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
499 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
500 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
501 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
502 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
503 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
504 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
505 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
506 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
507 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
508 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
509 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
510 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
511 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
512 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
513 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
514 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
515 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
516 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
517 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
518 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
519 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
520 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
521 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
522 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextField::Property::FONT_SIZE_SCALE );
523 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
524 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
525 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
526 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP );
527 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextField::Property::BACKGROUND );
528 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextField::Property::GRAB_HANDLE_COLOR );
533 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
536 Property::Map imageMap;
537 imageMap[mapKey] =mapValue;
539 field.SetProperty( property , imageMap );
540 Property::Value propValue = field.GetProperty( property );
541 Property::Map* resultMap = propValue.GetMap();
543 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
551 // Positive test case for a method
552 int UtcDaliTextFieldSetPropertyP(void)
554 ToolkitTestApplication application;
555 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
556 TextField field = TextField::New();
557 DALI_TEST_CHECK( field );
558 application.GetScene().Add( field );
560 // Note - we can't check the defaults since the stylesheets are platform-specific
562 // Check the render backend property.
563 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
564 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
566 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
567 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION );
569 // Check text property.
570 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
571 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
573 // Check placeholder text properties.
574 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
575 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
577 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
578 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
580 // Check font properties.
581 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
582 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
584 Property::Map fontStyleMapSet;
585 Property::Map fontStyleMapGet;
586 Property::Value* slantValue = NULL;
588 fontStyleMapSet.Insert( "weight", "bold" );
589 fontStyleMapSet.Insert( "width", "condensed" );
590 fontStyleMapSet.Insert( "slant", "italic" );
591 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
593 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
594 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
595 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
597 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
598 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
600 field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 2.5f );
601 DALI_TEST_EQUALS( field.GetProperty<float>( DevelTextField::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
602 field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 1.0f );
605 fontStyleMapSet.Clear();
606 fontStyleMapSet.Insert( "weight", "normal" );
607 fontStyleMapSet.Insert( "slant", "oblique" );
608 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
610 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
611 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
612 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
614 fontStyleMapSet.Clear();
615 fontStyleMapSet.Insert( "slant", "roman" );
616 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
617 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
619 // Replace 'roman' for 'normal'.
620 slantValue = fontStyleMapGet.Find( "slant" );
621 if( NULL != slantValue )
623 if( "normal" == slantValue->Get<std::string>() )
625 fontStyleMapGet["slant"] = "roman";
628 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
629 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
631 fontStyleMapSet.Clear();
633 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
634 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
635 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
636 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
638 // Check that the MAX_LENGTH property can be correctly set
639 const int maxNumberOfCharacters = 20;
640 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
641 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
643 // Check exceed policy
644 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
645 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
646 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
647 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
649 // Check that the Alignment properties can be correctly set
650 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
651 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
652 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
653 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
655 // Check text's color property
656 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
657 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
659 // Check placeholder text's color property.
660 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
661 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
663 // Check cursor properties
664 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
665 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
666 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
667 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
669 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
670 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
671 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
672 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
673 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
674 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
675 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
676 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
678 // Check scroll properties.
679 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
680 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
681 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
682 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
684 // Check handle images
685 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
686 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
687 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
688 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
689 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
691 // Check handle images
692 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
693 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
694 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
695 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
696 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
697 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
699 // Check the highlight color
700 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
701 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
703 // Decoration bounding box
704 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
705 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
707 // Check the input method setting
708 Property::Map propertyMap;
709 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
710 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
711 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
712 int inputVariation = 1;
713 propertyMap["PANEL_LAYOUT"] = panelLayout;
714 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
715 propertyMap["BUTTON_ACTION"] = buttonAction;
716 propertyMap["VARIATION"] = inputVariation;
717 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
719 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
721 DALI_TEST_CHECK( value.Get( map ) );
724 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
725 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
728 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
729 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
732 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
733 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
736 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
737 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
739 // Check input color property.
740 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
741 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
743 // Check the enable markup property.
744 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
745 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
746 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
748 // Check input font properties.
749 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
750 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
752 fontStyleMapSet.Clear();
753 fontStyleMapSet.Insert( "weight", "bold" );
754 fontStyleMapSet.Insert( "width", "condensed" );
755 fontStyleMapSet.Insert( "slant", "italic" );
757 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
758 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
759 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
760 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
762 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
763 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
765 // Reset input font style.
766 fontStyleMapSet.Clear();
767 fontStyleMapSet.Insert( "weight", "normal" );
768 fontStyleMapSet.Insert( "slant", "oblique" );
770 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
771 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
772 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
773 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
775 fontStyleMapSet.Clear();
776 fontStyleMapSet.Insert( "slant", "roman" );
778 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
779 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
781 // Replace 'roman' for 'normal'.
782 slantValue = fontStyleMapGet.Find( "slant" );
783 if( NULL != slantValue )
785 if( "normal" == slantValue->Get<std::string>() )
787 fontStyleMapGet["slant"] = "roman";
790 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
791 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
793 fontStyleMapSet.Clear();
795 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
796 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
797 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
798 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
800 Property::Map underlineMapSet;
801 Property::Map underlineMapGet;
803 underlineMapSet.Insert( "enable", true );
804 underlineMapSet.Insert( "color", Color::RED );
805 underlineMapSet.Insert( "height", 1 );
807 // Check the underline property
808 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
810 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
811 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
812 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
814 // Check the input underline property
815 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
816 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
818 // Check the shadow property
819 Property::Map shadowMapSet;
820 Property::Map shadowMapGet;
822 shadowMapSet.Insert( "color", Color::GREEN );
823 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
824 shadowMapSet.Insert( "blurRadius", 3.0f );
826 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
828 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
829 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
830 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
832 // Check the input shadow property
833 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
834 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
836 // Check the emboss property
837 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
838 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
840 // Check the input emboss property
841 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
842 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
844 // Check the outline property
846 // Test string type first
847 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
848 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
849 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
851 // Then test the property map type
852 Property::Map outlineMapSet;
853 Property::Map outlineMapGet;
855 outlineMapSet["color"] = Color::RED;
856 outlineMapSet["width"] = 2.0f;
858 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
860 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
861 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
862 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
864 // Check the input outline property
865 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
866 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
868 // Check the hidden input settings property
869 Property::Map hiddenMapSet;
870 Property::Map hiddenMapGet;
871 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
872 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
873 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
874 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
875 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
877 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
878 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
879 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
881 // Check the pixel size of font
882 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
883 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
885 // Check the enable selection property
886 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
887 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
889 // Check the placeholder property with pixel size
890 Property::Map placeholderPixelSizeMapSet;
891 Property::Map placeholderPixelSizeMapGet;
892 Property::Map placeholderFontstyleMap;
893 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
894 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
895 placeholderPixelSizeMapSet["color"] = Color::BLUE;
896 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
897 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
898 placeholderPixelSizeMapSet["ellipsis"] = true;
900 placeholderFontstyleMap.Insert( "weight", "bold" );
901 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
902 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
904 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
905 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
907 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
908 Property::Map placeholderConversionMap;
909 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
910 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
911 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
912 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
913 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
914 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
916 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
918 // Check the placeholder property with point size
919 Property::Map placeholderMapSet;
920 Property::Map placeholderMapGet;
921 placeholderMapSet["text"] = "Setting Placeholder Text";
922 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
923 placeholderMapSet["color"] = Color::RED;
924 placeholderMapSet["fontFamily"] = "Arial";
925 placeholderMapSet["pointSize"] = 12.0f;
926 placeholderMapSet["ellipsis"] = false;
928 // Check the placeholder font style property
929 placeholderFontstyleMap.Clear();
931 placeholderFontstyleMap.Insert( "weight", "bold" );
932 placeholderFontstyleMap.Insert( "width", "condensed" );
933 placeholderFontstyleMap.Insert( "slant", "italic" );
934 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
935 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
937 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
938 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
940 placeholderConversionMap.Clear();
941 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
942 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
943 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
944 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
945 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
946 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
948 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
951 placeholderFontstyleMap.Clear();
952 placeholderFontstyleMap.Insert( "weight", "normal" );
953 placeholderFontstyleMap.Insert( "slant", "oblique" );
954 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
955 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
957 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
958 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
960 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
961 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
963 placeholderFontstyleMap.Clear();
964 placeholderFontstyleMap.Insert( "slant", "roman" );
965 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
966 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
968 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
970 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
972 placeholderFontstyleMap.Clear();
973 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
974 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
976 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
977 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
978 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
980 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
982 // Check the ellipsis property
983 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
984 field.SetProperty( TextField::Property::ELLIPSIS, true );
985 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
987 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
988 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
990 // Test the ENABLE_GRAB_HANDLE_POPUP property
991 DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
992 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false );
993 DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
995 // Check the background property
996 field.SetProperty( DevelTextField::Property::BACKGROUND, Color::RED );
997 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::BACKGROUND ), Color::RED, TEST_LOCATION );
1000 field.SetProperty( DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN );
1001 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
1003 application.SendNotification();
1004 application.Render();
1009 // Positive Atlas Text Renderer test
1010 int utcDaliTextFieldAtlasRenderP(void)
1012 ToolkitTestApplication application;
1013 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1014 StyleManager styleManager = StyleManager::Get();
1015 styleManager.ApplyDefaultTheme();
1016 TextField field = TextField::New();
1017 DALI_TEST_CHECK( field );
1019 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1021 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1023 application.GetScene().Add( field );
1027 // Render some text with the shared atlas backend
1028 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1029 application.SendNotification();
1030 application.Render();
1034 tet_result(TET_FAIL);
1039 // Positive test for the anchorClicked signal.
1040 int utcDaliTextFieldAnchorClicked01(void)
1042 ToolkitTestApplication application;
1043 tet_infoline(" utcDaliTextFieldAnchorClicked01");
1044 TextField field = TextField::New();
1045 DALI_TEST_CHECK(field);
1047 application.GetScene().Add(field);
1049 // connect to the anchor clicked signal.
1050 ConnectionTracker* testTracker = new ConnectionTracker();
1051 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1052 bool anchorClickedSignal = false;
1053 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1055 gAnchorClickedCallBackCalled = false;
1056 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1057 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1058 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1059 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1060 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1062 application.SendNotification();
1063 application.Render();
1064 field.SetKeyInputFocus();
1066 // Create a tap event to touch the text field.
1067 TestGenerateTap(application, 5.0f, 25.0f);
1068 application.SendNotification();
1069 application.Render();
1071 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1072 DALI_TEST_CHECK(anchorClickedSignal);
1074 gAnchorClickedCallBackNotCalled = true;
1075 // Tap the outside of anchor, callback should not be called.
1076 TestGenerateTap(application, 150.f, 100.f);
1077 application.SendNotification();
1078 application.Render();
1080 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1085 // Positive test for the anchorClicked signal.
1086 int utcDaliTextFieldAnchorClicked02(void)
1088 ToolkitTestApplication application;
1089 tet_infoline(" utcDaliTextFieldAnchorClicked02");
1090 TextField field = TextField::New();
1091 DALI_TEST_CHECK(field);
1093 application.GetScene().Add(field);
1095 // connect to the anchor clicked signal.
1096 ConnectionTracker* testTracker = new ConnectionTracker();
1097 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1098 bool anchorClickedSignal = false;
1099 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1101 gAnchorClickedCallBackCalled = false;
1102 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1103 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1104 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1105 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1106 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1108 application.SendNotification();
1109 application.Render();
1110 field.SetKeyInputFocus();
1112 // Avoid a crash when core load gl resources.
1113 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1115 // Create a tap event to touch the text field.
1116 TestGenerateTap(application, 30.0f, 25.0f, 100);
1117 application.SendNotification();
1118 application.Render();
1120 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1121 DALI_TEST_CHECK(anchorClickedSignal);
1124 // For coverage InsertTextAnchor, RemoveTextAnchor
1125 // first index insert
1126 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1127 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1128 application.SendNotification();
1129 application.Render();
1131 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1132 application.SendNotification();
1133 application.Render();
1135 gAnchorClickedCallBackCalled = false;
1136 // Create a tap event to touch the text field.
1137 TestGenerateTap(application, 30.0f, 25.0f, 700);
1138 application.SendNotification();
1139 field.SetKeyInputFocus();
1141 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1143 // last index insert
1144 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1145 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1146 application.SendNotification();
1147 application.Render();
1149 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1150 application.SendNotification();
1151 application.Render();
1153 gAnchorClickedCallBackCalled = false;
1154 // Create a tap event to touch the text field.
1155 TestGenerateTap(application, 30.0f, 25.0f, 1300);
1156 application.SendNotification();
1157 field.SetKeyInputFocus();
1159 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1162 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1163 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1164 application.SendNotification();
1165 application.Render();
1167 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1168 application.SendNotification();
1169 application.Render();
1171 gAnchorClickedCallBackCalled = false;
1172 // Create a tap event to touch the text field.
1173 TestGenerateTap(application, 30.0f, 25.0f, 1900);
1174 application.SendNotification();
1175 field.SetKeyInputFocus();
1177 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1179 // first index remove
1180 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1181 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1182 application.SendNotification();
1183 application.Render();
1185 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1186 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));
1187 application.SendNotification();
1188 application.Render();
1190 gAnchorClickedCallBackCalled = false;
1191 // Create a tap event to touch the text field.
1192 TestGenerateTap(application, 30.0f, 25.0f, 2500);
1193 application.SendNotification();
1194 field.SetKeyInputFocus();
1196 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1198 // last index remove
1199 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1200 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1201 application.SendNotification();
1202 application.Render();
1204 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1205 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));
1206 application.SendNotification();
1207 application.Render();
1209 gAnchorClickedCallBackCalled = false;
1210 // Create a tap event to touch the text field.
1211 TestGenerateTap(application, 30.0f, 25.0f, 3100);
1212 application.SendNotification();
1213 application.Render();
1215 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1218 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1219 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1220 application.SendNotification();
1221 application.Render();
1223 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1224 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));
1225 application.SendNotification();
1226 application.Render();
1228 gAnchorClickedCallBackCalled = false;
1229 // Create a tap event to touch the text field.
1230 TestGenerateTap(application, 30.0f, 25.0f, 3700);
1231 application.SendNotification();
1232 application.Render();
1234 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1236 // 0 ~ 1 index remove
1237 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1238 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 0);
1239 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 1);
1240 application.SendNotification();
1241 application.Render();
1243 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1244 application.SendNotification();
1245 application.Render();
1247 gAnchorClickedCallBackCalled = false;
1248 // Create a tap event to touch the text field.
1249 TestGenerateTap(application, 30.0f, 25.0f, 4300);
1250 application.SendNotification();
1251 application.Render();
1253 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1255 // 1 ~ 3 index remove
1256 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1257 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 1);
1258 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 3);
1259 application.SendNotification();
1260 application.Render();
1262 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1263 application.SendNotification();
1264 application.Render();
1266 gAnchorClickedCallBackCalled = false;
1267 // Create a tap event to touch the text field.
1268 TestGenerateTap(application, 30.0f, 25.0f, 4900);
1269 application.SendNotification();
1270 application.Render();
1272 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1274 // 3 ~ 4 index remove
1275 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1276 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 3);
1277 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 4);
1278 application.SendNotification();
1279 application.Render();
1281 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1282 application.SendNotification();
1283 application.Render();
1285 gAnchorClickedCallBackCalled = false;
1286 // Create a tap event to touch the text field.
1287 TestGenerateTap(application, 30.0f, 25.0f, 5500);
1288 application.SendNotification();
1289 application.Render();
1291 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1293 // Remove front of anchor
1294 field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
1295 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
1296 application.SendNotification();
1297 application.Render();
1299 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1300 application.SendNotification();
1301 application.Render();
1303 // Remove whole text
1304 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1305 DevelTextField::SelectWholeText(field);
1306 application.SendNotification();
1307 application.Render();
1309 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1310 application.SendNotification();
1311 application.Render();
1313 // Remove all with backspace
1314 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1315 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
1316 application.SendNotification();
1317 application.Render();
1319 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1320 application.SendNotification();
1321 application.Render();
1323 // Remove all with delete
1324 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1325 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1326 application.SendNotification();
1327 application.Render();
1329 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));
1330 application.SendNotification();
1331 application.Render();
1336 // Positive test for the textChanged signal.
1337 int utcDaliTextFieldTextChangedP(void)
1339 ToolkitTestApplication application;
1340 tet_infoline(" utcDaliTextFieldTextChangedP");
1341 TextField field = TextField::New();
1342 DALI_TEST_CHECK( field );
1344 application.GetScene().Add( field );
1346 // connect to the text changed signal.
1347 ConnectionTracker* testTracker = new ConnectionTracker();
1348 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1349 bool textChangedSignal = false;
1350 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1352 gTextChangedCallBackCalled = false;
1353 field.SetProperty( TextField::Property::TEXT, "ABC" );
1354 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1355 DALI_TEST_CHECK( textChangedSignal );
1357 application.SendNotification();
1358 field.SetKeyInputFocus();
1360 gTextChangedCallBackCalled = false;
1361 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1362 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1365 field.SetProperty( TextField::Property::TEXT, "" );
1367 // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1368 gTextChangedCallBackCalled = false;
1369 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1370 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1372 // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1373 gTextChangedCallBackCalled = false;
1374 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1375 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1380 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1382 ToolkitTestApplication application;
1383 tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1384 TextField field = TextField::New();
1385 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) );
1397 // get InputMethodContext
1399 InputMethodContext::EventData imfEvent;
1400 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext( field );
1402 field.SetKeyInputFocus();
1403 field.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
1406 gTextChangedCallBackCalled = false;
1407 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1408 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1409 application.SendNotification();
1410 application.Render();
1411 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1412 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1414 gTextChangedCallBackCalled = false;
1415 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1416 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1417 application.SendNotification();
1418 application.Render();
1419 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1420 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호"), TEST_LOCATION );
1422 gTextChangedCallBackCalled = false;
1423 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1424 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1425 application.SendNotification();
1426 application.Render();
1427 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1428 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1430 gTextChangedCallBackCalled = false;
1431 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1432 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1433 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1435 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1436 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1437 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1439 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1440 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1441 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1443 application.SendNotification();
1444 application.Render();
1445 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1446 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1452 // Negative test for the textChanged signal.
1453 int utcDaliTextFieldTextChangedN(void)
1455 ToolkitTestApplication application;
1456 tet_infoline(" utcDaliTextFieldTextChangedN");
1457 TextField field = TextField::New();
1458 DALI_TEST_CHECK( field );
1460 application.GetScene().Add( field );
1462 // connect to the text changed signal.
1463 ConnectionTracker* testTracker = new ConnectionTracker();
1464 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1465 bool textChangedSignal = false;
1466 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1468 gTextChangedCallBackCalled = false;
1469 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1470 application.SendNotification();
1471 application.Render();
1472 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1473 DALI_TEST_CHECK( !textChangedSignal );
1478 // Positive test for Max Characters reached signal.
1479 int utcDaliTextFieldMaxCharactersReachedP(void)
1481 ToolkitTestApplication application;
1482 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1483 TextField field = TextField::New();
1484 DALI_TEST_CHECK( field );
1486 application.GetScene().Add( field );
1488 const int maxNumberOfCharacters = 1;
1489 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1491 field.SetKeyInputFocus();
1493 // connect to the text changed signal.
1494 ConnectionTracker* testTracker = new ConnectionTracker();
1495 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1496 bool maxLengthReachedSignal = false;
1497 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1499 gMaxCharactersCallBackCalled = false;
1501 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1502 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1504 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1505 DALI_TEST_CHECK( maxLengthReachedSignal );
1510 // Negative test for Max Characters reached signal.
1511 int utcDaliTextFieldMaxCharactersReachedN(void)
1513 ToolkitTestApplication application;
1514 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1515 TextField field = TextField::New();
1516 DALI_TEST_CHECK( field );
1518 application.GetScene().Add( field );
1520 const int maxNumberOfCharacters = 3;
1521 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1523 field.SetKeyInputFocus();
1525 // connect to the text changed signal.
1526 ConnectionTracker* testTracker = new ConnectionTracker();
1527 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1528 bool maxLengthReachedSignal = false;
1529 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1531 gMaxCharactersCallBackCalled = false;
1533 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1534 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1536 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1537 DALI_TEST_CHECK( !maxLengthReachedSignal );
1539 application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1541 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1542 DALI_TEST_CHECK( !maxLengthReachedSignal );
1547 int utcDaliTextFieldInputStyleChanged01(void)
1549 // The text-field emits signals when the input style changes. These changes of style are
1550 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1551 // can't be emitted during the size negotiation as the callbacks may update the UI.
1552 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1553 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1554 ToolkitTestApplication application;
1555 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1559 char* pathNamePtr = get_current_dir_name();
1560 const std::string pathName( pathNamePtr );
1561 free( pathNamePtr );
1563 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1564 fontClient.SetDpi( 93u, 93u );
1566 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1567 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1569 TextField field = TextField::New();
1570 DALI_TEST_CHECK( field );
1573 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1574 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1575 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1577 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1578 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1580 // connect to the text changed signal.
1581 ConnectionTracker* testTracker = new ConnectionTracker();
1582 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1583 bool inputStyleChangedSignal = false;
1584 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1586 application.GetScene().Add( field );
1588 // Render and notify
1589 application.SendNotification();
1590 application.Render();
1592 // Executes the idle callbacks added by the text control on the change of input style.
1593 application.RunIdles();
1595 gInputStyleChangedCallbackCalled = false;
1596 gInputStyleMask = TextField::InputStyle::NONE;
1597 inputStyleChangedSignal = false;
1599 // Create a tap event to touch the text field.
1600 TestGenerateTap( application, 18.0f, 25.0f );
1602 // Render and notify
1603 application.SendNotification();
1604 application.Render();
1606 // Executes the idle callbacks added by the text control on the change of input style.
1607 application.RunIdles();
1609 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1610 if( gInputStyleChangedCallbackCalled )
1612 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1614 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1615 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1617 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1618 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1620 DALI_TEST_CHECK( inputStyleChangedSignal );
1622 gInputStyleChangedCallbackCalled = false;
1623 gInputStyleMask = TextField::InputStyle::NONE;
1624 inputStyleChangedSignal = false;
1626 // Create a tap event to touch the text field.
1627 TestGenerateTap( application, 30.0f, 25.0f );
1629 // Render and notify
1630 application.SendNotification();
1631 application.Render();
1633 // Executes the idle callbacks added by the text control on the change of input style.
1634 application.RunIdles();
1636 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1637 DALI_TEST_CHECK( !inputStyleChangedSignal );
1639 gInputStyleChangedCallbackCalled = false;
1640 gInputStyleMask = TextField::InputStyle::NONE;
1641 inputStyleChangedSignal = false;
1643 // Create a tap event to touch the text field.
1644 TestGenerateTap( application, 43.0f, 25.0f );
1646 // Render and notify
1647 application.SendNotification();
1648 application.Render();
1650 // Executes the idle callbacks added by the text control on the change of input style.
1651 application.RunIdles();
1653 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1654 if( gInputStyleChangedCallbackCalled )
1656 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1658 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1659 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1661 DALI_TEST_CHECK( inputStyleChangedSignal );
1663 gInputStyleChangedCallbackCalled = false;
1664 gInputStyleMask = TextField::InputStyle::NONE;
1665 inputStyleChangedSignal = false;
1667 // Create a tap event to touch the text field.
1668 TestGenerateTap( application, 88.0f, 25.0f );
1670 // Render and notify
1671 application.SendNotification();
1672 application.Render();
1674 // Executes the idle callbacks added by the text control on the change of input style.
1675 application.RunIdles();
1677 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1678 if( gInputStyleChangedCallbackCalled )
1680 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1682 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1683 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1685 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1687 Property::Map fontStyleMapSet;
1688 fontStyleMapSet.Insert( "weight", "bold" );
1690 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1691 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1693 DALI_TEST_CHECK( inputStyleChangedSignal );
1695 gInputStyleChangedCallbackCalled = false;
1696 gInputStyleMask = TextField::InputStyle::NONE;
1697 inputStyleChangedSignal = false;
1699 // Create a tap event to touch the text field.
1700 TestGenerateTap( application, 115.0f, 25.0f );
1702 // Render and notify
1703 application.SendNotification();
1704 application.Render();
1706 // Executes the idle callbacks added by the text control on the change of input style.
1707 application.RunIdles();
1709 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1710 DALI_TEST_CHECK( !inputStyleChangedSignal );
1712 gInputStyleChangedCallbackCalled = false;
1713 gInputStyleMask = TextField::InputStyle::NONE;
1714 inputStyleChangedSignal = false;
1716 // Create a tap event to touch the text field.
1717 TestGenerateTap( application, 164.0f, 25.0f );
1719 // Render and notify
1720 application.SendNotification();
1721 application.Render();
1723 // Executes the idle callbacks added by the text control on the change of input style.
1724 application.RunIdles();
1726 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1727 if( gInputStyleChangedCallbackCalled )
1729 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1731 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1732 DALI_TEST_CHECK( style.empty() );
1734 DALI_TEST_CHECK( inputStyleChangedSignal );
1736 gInputStyleChangedCallbackCalled = false;
1737 gInputStyleMask = TextField::InputStyle::NONE;
1738 inputStyleChangedSignal = false;
1740 // Create a tap event to touch the text field.
1741 TestGenerateTap( application, 191.0f, 25.0f );
1743 // Render and notify
1744 application.SendNotification();
1745 application.Render();
1747 // Executes the idle callbacks added by the text control on the change of input style.
1748 application.RunIdles();
1750 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1751 DALI_TEST_CHECK( !inputStyleChangedSignal );
1756 int utcDaliTextFieldInputStyleChanged02(void)
1758 // The text-field emits signals when the input style changes. These changes of style are
1759 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1760 // can't be emitted during the size negotiation as the callbacks may update the UI.
1761 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1762 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1763 ToolkitTestApplication application;
1764 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1768 char* pathNamePtr = get_current_dir_name();
1769 const std::string pathName( pathNamePtr );
1770 free( pathNamePtr );
1772 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1773 fontClient.SetDpi( 93u, 93u );
1775 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1776 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1778 TextField field = TextField::New();
1779 DALI_TEST_CHECK( field );
1781 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1782 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1783 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1785 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1786 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>" );
1788 // connect to the text changed signal.
1789 ConnectionTracker* testTracker = new ConnectionTracker();
1790 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1791 bool inputStyleChangedSignal = false;
1792 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1794 application.GetScene().Add( field );
1796 // Render and notify
1797 application.SendNotification();
1798 application.Render();
1800 // Executes the idle callbacks added by the text control on the change of input style.
1801 application.RunIdles();
1803 gInputStyleChangedCallbackCalled = false;
1804 gInputStyleMask = TextField::InputStyle::NONE;
1805 inputStyleChangedSignal = false;
1807 // Create a tap event to touch the text field.
1808 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1809 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1811 // Render and notify
1812 application.SendNotification();
1813 application.Render();
1815 // Executes the idle callbacks added by the text control on the change of input style.
1816 application.RunIdles();
1818 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1819 if( gInputStyleChangedCallbackCalled )
1821 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1822 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1823 TextField::InputStyle::POINT_SIZE |
1824 TextField::InputStyle::COLOR ),
1827 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1828 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1830 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1831 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1833 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1834 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1836 DALI_TEST_CHECK( inputStyleChangedSignal );
1838 gInputStyleChangedCallbackCalled = false;
1839 gInputStyleMask = TextField::InputStyle::NONE;
1840 inputStyleChangedSignal = false;
1842 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1844 // Render and notify
1845 application.SendNotification();
1846 application.Render();
1848 // Executes the idle callbacks added by the text control on the change of input style.
1849 application.RunIdles();
1851 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1852 if( gInputStyleChangedCallbackCalled )
1854 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1855 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1858 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1859 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1861 DALI_TEST_CHECK( inputStyleChangedSignal );
1863 gInputStyleChangedCallbackCalled = false;
1864 gInputStyleMask = TextField::InputStyle::NONE;
1865 inputStyleChangedSignal = false;
1867 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1869 // Render and notify
1870 application.SendNotification();
1871 application.Render();
1873 // Executes the idle callbacks added by the text control on the change of input style.
1874 application.RunIdles();
1876 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1877 DALI_TEST_CHECK( !inputStyleChangedSignal );
1879 gInputStyleChangedCallbackCalled = false;
1880 gInputStyleMask = TextField::InputStyle::NONE;
1881 inputStyleChangedSignal = false;
1883 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1885 // Render and notify
1886 application.SendNotification();
1887 application.Render();
1889 // Executes the idle callbacks added by the text control on the change of input style.
1890 application.RunIdles();
1892 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1893 if( gInputStyleChangedCallbackCalled )
1895 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1896 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1899 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1900 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1902 DALI_TEST_CHECK( inputStyleChangedSignal );
1904 gInputStyleChangedCallbackCalled = false;
1905 gInputStyleMask = TextField::InputStyle::NONE;
1906 inputStyleChangedSignal = false;
1908 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1910 Property::Map fontStyleMapSet;
1911 fontStyleMapSet.Insert( "weight", "thin" );
1912 fontStyleMapSet.Insert( "width", "condensed" );
1913 fontStyleMapSet.Insert( "slant", "italic" );
1915 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1916 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1918 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1919 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1920 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1921 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1923 // Render and notify
1924 application.SendNotification();
1925 application.Render();
1927 // Executes the idle callbacks added by the text control on the change of input style.
1928 application.RunIdles();
1930 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1931 DALI_TEST_CHECK( !inputStyleChangedSignal );
1933 // Create a tap event to touch the text field.
1934 TestGenerateTap( application, 63.0f, 25.0f, 700 );
1936 // Render and notify
1937 application.SendNotification();
1938 application.Render();
1940 // Executes the idle callbacks added by the text control on the change of input style.
1941 application.RunIdles();
1943 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1944 if( gInputStyleChangedCallbackCalled )
1946 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1947 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1948 TextField::InputStyle::POINT_SIZE |
1949 TextField::InputStyle::FONT_STYLE |
1950 TextField::InputStyle::UNDERLINE |
1951 TextField::InputStyle::SHADOW |
1952 TextField::InputStyle::EMBOSS |
1953 TextField::InputStyle::OUTLINE ),
1956 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1957 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1959 DALI_TEST_CHECK( inputStyleChangedSignal );
1964 int utcDaliTextFieldEvent01(void)
1966 ToolkitTestApplication application;
1967 tet_infoline(" utcDaliTextFieldEvent01");
1969 // Creates a tap event. After creating a tap event the text field should
1970 // have the focus and add text with key events should be possible.
1972 TextField field = TextField::New();
1973 DALI_TEST_CHECK( field );
1975 application.GetScene().Add( field );
1977 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1978 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1979 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1981 // Render and notify
1982 application.SendNotification();
1983 application.Render();
1985 // Avoid a crash when core load gl resources.
1986 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1988 // Render and notify
1989 application.SendNotification();
1990 application.Render();
1992 // Add a key event but as the text field has not the focus it should do nothing.
1993 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1995 // Render and notify
1996 application.SendNotification();
1997 application.Render();
1999 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2001 // Create a tap event to touch the text field.
2002 TestGenerateTap( application, 150.0f, 25.0f );
2004 // Render and notify
2005 application.SendNotification();
2006 application.Render();
2008 // Pressing delete key should be fine even if there is no text in TextField.
2009 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 ) );
2010 // Render and notify
2011 application.SendNotification();
2012 application.Render();
2014 // Now the text field has the focus, so it can handle the key events.
2015 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2016 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2018 // Render and notify
2019 application.SendNotification();
2020 application.Render();
2022 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2024 // Create a second text field and send key events to it.
2025 TextField field2 = TextField::New();
2027 field2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2028 field2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2029 field2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2030 field2.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
2032 application.GetScene().Add( field2 );
2034 // Render and notify
2035 application.SendNotification();
2036 application.Render();
2038 // Create a tap event on the second text field.
2039 TestGenerateTap( application, 150.0f, 125.0f );
2041 // Render and notify
2042 application.SendNotification();
2043 application.Render();
2045 // The second text field has the focus. It should handle the key events.
2046 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2047 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2049 // Render and notify
2050 application.SendNotification();
2051 application.Render();
2053 // Check the text has been added to the second text field.
2054 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2059 int utcDaliTextFieldEvent02(void)
2061 ToolkitTestApplication application;
2062 tet_infoline(" utcDaliTextFieldEvent02");
2064 // Checks if the right number of actors are created.
2066 TextField field = TextField::New();
2067 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2068 DALI_TEST_CHECK( field );
2069 LoadMarkerImages(application, field);
2071 application.GetScene().Add( field );
2073 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2074 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2075 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2077 // Avoid a crash when core load gl resources.
2078 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2080 // Render and notify
2081 application.SendNotification();
2082 application.Render();
2084 // Check there are the expected number of children ( stencil ).
2085 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
2087 Actor stencil = field.GetChildAt( 0u );
2088 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2090 // Create a tap event to touch the text field.
2091 TestGenerateTap( application, 150.0f, 25.0f, 300 );
2093 // Render and notify
2094 application.SendNotification();
2095 application.Render();
2097 Actor layer = field.GetChildAt( 1u );
2098 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2099 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2101 // Now the text field has the focus, so it can handle the key events.
2102 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2103 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2105 // Render and notify
2106 application.SendNotification();
2107 application.Render();
2109 // Checks the cursor and the renderer have been created.
2110 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2111 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
2113 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
2114 DALI_TEST_CHECK( cursor );
2116 // The offscreen root actor has a container with all the actors which contain the text renderers.
2117 Actor container = stencil.GetChildAt( 0u );
2118 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2120 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2121 DALI_TEST_CHECK( renderer );
2124 // Move the cursor and check the position changes.
2125 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2126 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2128 // Render and notify
2129 application.SendNotification();
2130 application.Render();
2132 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2133 DALI_TEST_CHECK( position2.x < position1.x );
2135 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2137 // Render and notify
2138 application.SendNotification();
2139 application.Render();
2141 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2142 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
2145 // Move the cursor to the first position.
2146 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2147 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2149 // Render and notify
2150 application.SendNotification();
2151 application.Render();
2153 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2155 // Send some taps and check the cursor positions.
2157 // Try to tap at the beginning.
2158 TestGenerateTap( application, 1.0f, 25.0f, 900 );
2160 // Render and notify
2161 application.SendNotification();
2162 application.Render();
2164 // Cursor position should be the same than position1.
2165 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2167 DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
2169 // Tap away from the start position.
2170 TestGenerateTap( application, 16.0f, 25.0f, 1500 );
2172 // Render and notify
2173 application.SendNotification();
2174 application.Render();
2176 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2178 DALI_TEST_CHECK( position6.x > position5.x );
2180 // Remove all the text.
2181 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2182 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2183 field.SetProperty( TextField::Property::TEXT, "" );
2185 // Render and notify
2186 application.SendNotification();
2187 application.Render();
2189 // Cursor position should be the same than position2.
2190 Vector3 position7 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2192 DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
2194 // Should not be a renderer.
2195 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2197 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2198 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2199 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
2201 application.SendNotification();
2202 application.Render();
2204 // There are renderer and decorator layer
2205 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
2210 int utcDaliTextFieldEvent03(void)
2212 ToolkitTestApplication application;
2213 tet_infoline(" utcDaliTextFieldEvent03");
2215 // Checks if the highlight actor is created.
2217 TextField field = TextField::New();
2218 DALI_TEST_CHECK( field );
2220 application.GetScene().Add( field );
2222 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2223 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2224 field.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
2225 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2226 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2228 // Avoid a crash when core load gl resources.
2229 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2230 LoadMarkerImages(application, field);
2232 // Render and notify
2233 application.SendNotification();
2234 application.Render();
2236 // Tap first to get the focus.
2237 TestGenerateTap( application, 3.0f, 25.0f );
2239 // Render and notify
2240 application.SendNotification();
2241 application.Render();
2243 // Double tap to select a word.
2244 TestGenerateTap( application, 3.0f, 25.0f );
2246 // Render and notify
2247 application.SendNotification();
2248 application.Render();
2250 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2251 Actor stencil = field.GetChildAt( 0u );
2253 // The highlight actor is drawn first, so is the first actor in the list
2254 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2255 DALI_TEST_CHECK( highlight );
2257 // The offscreen root actor has a container with all the actors which contain the text renderers.
2258 Actor container = stencil.GetChildAt( 1u );
2259 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2261 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2262 DALI_TEST_CHECK( renderer );
2268 int utcDaliTextFieldEvent04(void)
2270 ToolkitTestApplication application;
2271 tet_infoline(" utcDaliTextFieldEvent04");
2273 // Checks if the highlight actor is created.
2275 TextField field = TextField::New();
2276 DALI_TEST_CHECK( field );
2277 application.GetScene().Add( field );
2278 LoadMarkerImages(application, field);
2279 // Render and notify
2280 application.SendNotification();
2281 application.Render();
2283 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2284 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2285 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2286 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2287 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2289 // Avoid a crash when core load gl resources.
2290 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2291 // Render and notify
2292 application.SendNotification();
2293 application.Render();
2295 // Create a tap event to touch the text field.
2296 TestGenerateTap( application, 150.0f, 25.0f );
2297 // Render and notify
2298 application.SendNotification();
2299 application.Render();
2302 // Tap first to get the focus.
2303 TestGenerateTap( application, 1.0f, 25.0f );
2305 // Render and notify
2306 application.SendNotification();
2307 application.Render();
2309 // Double tap to select a word.
2310 TestGenerateTap( application, 1.0f, 25.0f );
2312 // Render and notify
2313 application.SendNotification();
2314 application.Render();
2317 TestGenerateTap( application, 0.0f, 40.0f );
2321 int utcDaliTextFieldEvent05(void)
2323 ToolkitTestApplication application;
2324 tet_infoline(" utcDaliTextFieldEvent05");
2326 // Checks dragging of cursor/grab handle
2328 TextField field = TextField::New();
2329 DALI_TEST_CHECK( field );
2330 application.GetScene().Add( field );
2331 LoadMarkerImages(application, field);
2332 // Render and notify
2333 application.SendNotification();
2334 application.Render();
2336 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2337 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2338 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2339 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2340 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2342 // Avoid a crash when core load gl resources.
2343 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2344 // Render and notify
2345 application.SendNotification();
2346 application.Render();
2348 // Create a tap event to touch the text field.
2349 TestGenerateTap( application, 150.0f, 25.0f );
2350 // Render and notify
2351 application.SendNotification();
2352 application.Render();
2354 // Tap first to get the focus.
2355 TestGenerateTap( application, 1.0f, 25.0f );
2357 // Render and notify
2358 application.SendNotification();
2359 application.Render();
2361 // Double tap to select a word.
2362 TestGenerateTap( application, 1.0f, 25.0f );
2364 // Render and notify
2365 application.SendNotification();
2366 application.Render();
2368 Actor stencil = field.GetChildAt( 1u );
2372 int utcDaliTextFieldEvent06(void)
2374 ToolkitTestApplication application;
2375 tet_infoline(" utcDaliTextFieldEvent06");
2377 // Checks Longpress when in edit mode
2379 TextField field = TextField::New();
2380 DALI_TEST_CHECK( field );
2381 application.GetScene().Add( field );
2382 LoadMarkerImages(application, field);
2383 // Render and notify
2384 application.SendNotification();
2385 application.Render();
2387 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2388 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2389 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2390 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2391 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2393 // Avoid a crash when core load gl resources.
2394 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2395 // Render and notify
2396 application.SendNotification();
2397 application.Render();
2399 // Create a tap event to touch the text field.
2400 TestGenerateTap( application, 150.0f, 25.0f );
2401 // Render and notify
2402 application.SendNotification();
2403 application.Render();
2406 // Tap first to get the focus.
2407 TestGenerateTap( application, 1.0f, 25.0f );
2409 // Render and notify
2410 application.SendNotification();
2411 application.Render();
2414 TestGenerateLongPress(application, 1.0f, 25.0f);
2416 // Render and notify
2417 application.SendNotification();
2418 application.Render();
2423 int utcDaliTextFieldEvent07(void)
2425 ToolkitTestApplication application;
2426 tet_infoline(" utcDaliTextFieldEvent07");
2428 // Checks Longpress to start edit mode
2430 TextField field = TextField::New();
2431 DALI_TEST_CHECK( field );
2432 application.GetScene().Add( field );
2433 LoadMarkerImages(application, field);
2434 // Render and notify
2435 application.SendNotification();
2436 application.Render();
2438 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2439 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2440 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2441 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2442 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2443 Property::Map propertyMap;
2444 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2445 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2447 // Avoid a crash when core load gl resources.
2448 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2449 // Render and notify
2450 application.SendNotification();
2451 application.Render();
2454 TestGenerateLongPress(application, 1.0f, 25.0f);
2456 // Render and notify
2457 application.SendNotification();
2458 application.Render();
2463 int utcDaliTextFieldEvent08(void)
2465 ToolkitTestApplication application;
2466 tet_infoline(" utcDaliTextFieldEvent08");
2468 Dali::Clipboard clipboard = Clipboard::Get();
2469 clipboard.SetItem("testTextFieldEvent");
2471 // Checks Longpress when only place holder text
2473 TextField field = TextField::New();
2474 DALI_TEST_CHECK( field );
2475 application.GetScene().Add( field );
2476 LoadMarkerImages(application, field);
2477 // Render and notify
2478 application.SendNotification();
2479 application.Render();
2481 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2482 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2483 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2484 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2485 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2487 // Avoid a crash when core load gl resources.
2488 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2489 // Render and notify
2490 application.SendNotification();
2491 application.Render();
2494 TestGenerateLongPress( application, 1.0f, 25.0f, 20 );
2496 // Render and notify
2497 application.SendNotification();
2498 application.Render();
2500 Wait(application, 500);
2502 TestEndLongPress( application, 1.0f, 25.0f, 520 );
2505 TestGenerateLongPress( application, 1.0f, 25.0f, 600 );
2507 // Render and notify
2508 application.Render();
2510 Wait(application, 500);
2512 Integration::Scene stage = application.GetScene();
2513 Layer layer = stage.GetRootLayer();
2514 Actor actor = layer.FindChildByName("optionPaste");
2518 Vector3 worldPosition = actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION );
2519 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2520 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2522 Dali::Integration::TouchEvent event;
2523 event = Dali::Integration::TouchEvent();
2524 event.AddPoint( GetPointDownInside( position ) );
2525 application.ProcessEvent( event );
2527 event = Dali::Integration::TouchEvent();
2528 event.AddPoint( GetPointUpInside( position ) );
2529 application.ProcessEvent( event );
2531 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2536 int utcDaliTextFieldEvent09(void)
2538 ToolkitTestApplication application;
2539 tet_infoline(" utcDaliTextFieldEvent09");
2541 TextField field = TextField::New();
2542 DALI_TEST_CHECK( field );
2543 application.GetScene().Add( field );
2544 LoadMarkerImages(application, field);
2545 // Render and notify
2546 application.SendNotification();
2547 application.Render();
2549 field.SetProperty( TextField::Property::TEXT, "Hello" );
2550 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2551 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2552 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2553 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2555 // Avoid a crash when core load gl resources.
2556 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2558 // Create a tap event to touch the text field.
2559 TestGenerateTap( application, 150.0f, 25.0f );
2560 application.SendNotification();
2561 application.Render();
2564 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2565 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2566 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2567 application.SendNotification();
2568 application.Render();
2570 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2571 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2572 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2573 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2574 application.SendNotification();
2575 application.Render();
2577 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2578 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2579 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2580 for( unsigned int index = 0u; index < 5u; ++index )
2582 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2583 application.SendNotification();
2584 application.Render();
2587 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2588 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2589 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2590 for( unsigned int index = 0u; index < 5u; ++index )
2592 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2593 application.SendNotification();
2594 application.Render();
2597 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2598 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2599 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2600 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2601 application.SendNotification();
2602 application.Render();
2603 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2604 application.SendNotification();
2605 application.Render();
2607 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2608 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2609 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2610 application.SendNotification();
2611 application.Render();
2613 Property::Map mapGet;
2614 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2615 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2616 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2621 int utcDaliTextFieldStyleWhilstSelected(void)
2623 ToolkitTestApplication application;
2624 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2626 // Change font and styles whilst text is selected whilst word selected
2628 TextField field = TextField::New();
2629 DALI_TEST_CHECK( field );
2630 application.GetScene().Add( field );
2631 LoadMarkerImages(application, field);
2632 // Render and notify
2633 application.SendNotification();
2634 application.Render();
2636 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2637 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2638 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2639 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2640 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2642 // Avoid a crash when core load gl resources.
2643 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2644 // Render and notify
2645 application.SendNotification();
2646 application.Render();
2648 // Create a tap event to touch the text field.
2649 TestGenerateTap( application, 150.0f, 25.0f );
2650 // Render and notify
2651 application.SendNotification();
2652 application.Render();
2655 // Tap first to get the focus.
2656 TestGenerateTap( application, 1.0f, 25.0f );
2658 // Render and notify
2659 application.SendNotification();
2660 application.Render();
2662 // Double tap to select a word.
2663 TestGenerateTap( application, 1.0f, 25.0f );
2665 // Render and notify
2666 application.SendNotification();
2667 application.Render();
2669 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2670 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2672 Property::Map fontStyleMapSet;
2673 Property::Map fontStyleMapGet;
2675 fontStyleMapSet.Insert( "weight", "bold" );
2676 fontStyleMapSet.Insert( "slant", "italic" );
2677 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2679 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2680 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2681 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2683 fontStyleMapSet.Clear();
2684 fontStyleMapSet.Insert( "width", "expanded" );
2685 fontStyleMapSet.Insert( "slant", "italic" );
2686 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2688 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2689 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2690 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2692 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2693 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2695 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2696 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2698 fontStyleMapSet.Clear();
2699 fontStyleMapSet.Insert( "weight", "bold" );
2700 fontStyleMapSet.Insert( "slant", "italic" );
2702 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2704 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2705 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2706 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2708 fontStyleMapSet.Clear();
2709 fontStyleMapSet.Insert( "width", "expanded" );
2711 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2713 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2714 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2715 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2717 // Press Escape to increase coverage
2718 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2719 application.SendNotification();
2720 application.Render();
2722 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2727 int utcDaliTextFieldEscKeyLoseFocus(void)
2729 ToolkitTestApplication application;
2730 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2732 // Creates a tap event. After creating a tap event the text field should
2733 // have the focus and add text with key events should be possible.
2735 TextField field = TextField::New();
2736 DALI_TEST_CHECK( field );
2738 application.GetScene().Add( field );
2740 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2741 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2742 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2744 // Avoid a crash when core load gl resources.
2745 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2747 // Render and notify
2748 application.SendNotification();
2749 application.Render();
2751 // Add a key event but as the text field has not the focus it should do nothing.
2752 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2753 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2755 // Render and notify
2756 application.SendNotification();
2757 application.Render();
2759 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2761 // Create a tap event to touch the text field.
2762 TestGenerateTap( application, 150.0f, 25.0f );
2764 // Render and notify
2765 application.SendNotification();
2766 application.Render();
2768 // Now the text field has the focus, so it can handle the key events.
2769 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2770 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2771 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2772 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2774 // Render and notify
2775 application.SendNotification();
2776 application.Render();
2778 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2780 // Generate a Esc key event. The text field should lose the focus.
2781 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2782 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2784 // Render and notify
2785 application.SendNotification();
2786 application.Render();
2788 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2790 // No more text should be introduced
2791 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2792 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2794 // Render and notify
2795 application.SendNotification();
2796 application.Render();
2798 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2803 int utcDaliTextFieldSomeSpecialKeys(void)
2805 ToolkitTestApplication application;
2806 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2808 // Checks some special keys when the text is selected.
2810 TextField field = TextField::New();
2811 DALI_TEST_CHECK( field );
2812 application.GetScene().Add( field );
2813 LoadMarkerImages(application, field);
2814 // Render and notify
2815 application.SendNotification();
2816 application.Render();
2818 const std::string longText( "This is a long text for the size of the text-field." );
2820 field.SetProperty( TextField::Property::TEXT, longText );
2821 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2822 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2823 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2824 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2826 // Avoid a crash when core load gl resources.
2827 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2828 // Render and notify
2829 application.SendNotification();
2830 application.Render();
2832 // Create a tap event to touch the text field.
2833 TestGenerateTap( application, 150.0f, 25.0f );
2835 // Render and notify
2836 application.SendNotification();
2837 application.Render();
2839 // Tap first to get the focus.
2840 TestGenerateTap( application, 1.0f, 25.0f );
2842 // Render and notify
2843 application.SendNotification();
2844 application.Render();
2846 // Double tap to select a word.
2847 TestGenerateTap( application, 1.0f, 25.0f );
2849 // Render and notify
2850 application.SendNotification();
2851 application.Render();
2853 // Generate a Esc key event. The text field should lose the focus.
2854 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2855 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2857 // Render and notify
2858 application.SendNotification();
2859 application.Render();
2861 // Generate a Esc key event. The text field should lose the focus.
2862 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2863 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2865 // Render and notify
2866 application.SendNotification();
2867 application.Render();
2869 // Generate a Esc key event. The text field should lose the focus.
2870 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2871 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2873 // Render and notify
2874 application.SendNotification();
2875 application.Render();
2877 // The text shouldn't be deleted.
2878 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2883 int utcDaliTextFieldSizeUpdate(void)
2885 ToolkitTestApplication application;
2886 tet_infoline("utcDaliTextFieldSizeUpdate");
2888 // Checks some special keys when the text is selected.
2889 TextField field = TextField::New();
2890 DALI_TEST_CHECK( field );
2891 application.GetScene().Add( field );
2893 float previousHeight = 0.0f;
2894 float currentHeight = 0.0f;
2895 const float fieldWidth = 1920.0f;
2898 // "ㅁ" is bigger then "ኢ"
2899 field.SetProperty( Actor::Property::SIZE, Vector2( fieldWidth ,10.0f ) );
2900 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2901 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2903 field.SetProperty( TextField::Property::TEXT, "ኢ");
2904 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2905 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2907 field.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2908 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2910 application.SendNotification();
2911 application.Render();
2913 previousHeight = field.GetHeightForWidth( fieldWidth );
2914 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2916 // Add another script characters ( glyph height is defferent )
2917 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2918 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2920 application.SendNotification();
2921 application.Render();
2923 currentHeight = field.GetHeightForWidth( fieldWidth );
2924 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2925 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2930 int utcDaliTextFieldExtremlyLargePointSize(void)
2932 ToolkitTestApplication application;
2933 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2935 TextField field = TextField::New();
2937 field.SetProperty( TextField::Property::TEXT, "Text" );
2938 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2939 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2940 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2941 application.GetScene().Add( field );
2945 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2946 application.SendNotification();
2947 DALI_TEST_CHECK( field );
2951 tet_result(TET_FAIL);
2956 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2958 ToolkitTestApplication application;
2959 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2960 TextField field = TextField::New();
2961 DALI_TEST_CHECK( field );
2962 application.GetScene().Add( field );
2964 Property::Map fontStyleMapGet;
2966 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2968 Property::Value* weightValue = NULL;
2969 Property::Value* widthValue = NULL;
2970 Property::Value* slantValue = NULL;
2971 weightValue = fontStyleMapGet.Find( "weight" );
2972 widthValue = fontStyleMapGet.Find( "width" );
2973 slantValue = fontStyleMapGet.Find( "slant" );
2974 DALI_TEST_CHECK( !weightValue );
2975 DALI_TEST_CHECK( !widthValue );
2976 DALI_TEST_CHECK( !slantValue );
2981 int UtcDaliTextFieldSettingPlaceholder(void)
2983 ToolkitTestApplication application;
2984 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
2986 TextField field = TextField::New();
2987 DALI_TEST_CHECK( field );
2988 application.GetScene().Add( field );
2990 // Check the placeholder property with pixel size
2991 Property::Map placeholderPixelSizeMapSet;
2992 Property::Map placeholderPixelSizeMapGet;
2993 Property::Map placeholderFontstyleMap;
2994 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
2995 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
2996 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
2997 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
2998 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
2999 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
3001 placeholderFontstyleMap.Insert( "weight", "bold" );
3002 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3003 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
3005 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3006 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
3007 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
3009 // Check the placeholder property with point size
3010 Property::Map placeholderMapSet;
3011 Property::Map placeholderMapGet;
3012 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
3013 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
3014 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
3015 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
3016 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
3017 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
3019 // Check the placeholder font style property
3020 placeholderFontstyleMap.Clear();
3022 placeholderFontstyleMap.Insert( "weight", "bold" );
3023 placeholderFontstyleMap.Insert( "width", "condensed" );
3024 placeholderFontstyleMap.Insert( "slant", "italic" );
3025 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3026 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3028 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3029 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3030 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3032 // Reset font style.
3033 placeholderFontstyleMap.Clear();
3034 placeholderFontstyleMap.Insert( "weight", "normal" );
3035 placeholderFontstyleMap.Insert( "slant", "oblique" );
3036 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3037 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3039 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3040 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3041 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3043 placeholderFontstyleMap.Clear();
3044 placeholderFontstyleMap.Insert( "slant", "roman" );
3045 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3046 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3048 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3050 placeholderFontstyleMap.Clear();
3051 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3053 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3054 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3055 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3056 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3061 int UtcDaliTextFieldSetPaddingProperty(void)
3063 ToolkitTestApplication application;
3064 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3066 TextField field = TextField::New();
3067 DALI_TEST_CHECK( field );
3068 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3069 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3070 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3071 application.GetScene().Add( field );
3073 application.SendNotification();
3074 application.Render();
3076 Vector3 originalSize = field.GetNaturalSize();
3078 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
3080 application.SendNotification();
3081 application.Render();
3083 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
3085 Vector3 paddingAddedSize = field.GetNaturalSize();
3087 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3089 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3094 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3096 ToolkitTestApplication application;
3097 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3099 TextField field = TextField::New();
3100 DALI_TEST_CHECK( field );
3101 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3102 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3103 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3104 application.GetScene().Add( field );
3106 application.SendNotification();
3107 application.Render();
3109 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3110 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
3112 // Check the enable shift selection property
3113 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
3114 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
3116 application.SendNotification();
3117 application.Render();
3122 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3124 ToolkitTestApplication application;
3125 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3127 TextField field = TextField::New();
3128 DALI_TEST_CHECK( field );
3129 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3130 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3131 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3132 application.GetScene().Add( field );
3134 application.SendNotification();
3135 application.Render();
3137 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3138 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
3140 // Check the enable grab handle property
3141 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
3142 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
3144 application.SendNotification();
3145 application.Render();
3150 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
3152 ToolkitTestApplication application;
3153 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
3155 TextField field = TextField::New();
3156 DALI_TEST_CHECK( field );
3157 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3158 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3159 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3160 application.GetScene().Add( field );
3162 application.SendNotification();
3163 application.Render();
3165 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
3166 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
3168 // Check the match system language direction property
3169 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
3170 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
3172 application.SendNotification();
3173 application.Render();
3178 int utcDaliTextFieldLayoutDirectionCoverage(void)
3180 ToolkitTestApplication application;
3181 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
3183 // Creates a tap event. After creating a tap event the text field should
3184 // have the focus and add text with key events should be possible.
3185 TextField field = TextField::New();
3186 DALI_TEST_CHECK( field );
3188 application.GetScene().Add( field );
3190 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3191 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3192 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3194 // Avoid a crash when core load gl resources.
3195 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3197 // Render and notify
3198 application.SendNotification();
3199 application.Render();
3201 // init direction for coverage
3202 // Set horizontal alignment END
3203 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3205 // Create a tap event to touch the text field.
3206 TestGenerateTap( application, 150.0f, 25.0f );
3208 // Render and notify
3209 application.SendNotification();
3210 application.Render();
3212 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
3213 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
3214 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
3216 // Set horizontal alignment BEGIN
3217 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
3219 // Create a tap event to touch the text field.
3220 TestGenerateTap( application, 150.0f, 25.0f );
3222 // Render and notify
3223 application.SendNotification();
3224 application.Render();
3226 // Set horizontal alignment CENTER
3227 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
3229 // Create a tap event to touch the text field.
3230 TestGenerateTap( application, 150.0f, 25.0f );
3232 // Render and notify
3233 application.SendNotification();
3234 application.Render();
3236 // Set horizontal alignment END
3237 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3239 // Create a tap event to touch the text field.
3240 TestGenerateTap( application, 150.0f, 25.0f );
3242 // Render and notify
3243 application.SendNotification();
3244 application.Render();
3246 // Generate a Esc key event. The text field should lose the focus.
3247 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3248 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3250 // Render and notify
3251 application.SendNotification();
3252 application.Render();
3254 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
3259 int UtcDaliTextFieldGetInputMethodContext(void)
3261 ToolkitTestApplication application;
3262 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
3264 TextField field = TextField::New();
3265 DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );
3270 int UtcDaliTextFieldSelectWholeText(void)
3272 ToolkitTestApplication application;
3273 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3275 TextField textField = TextField::New();
3277 application.GetScene().Add( textField );
3279 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3280 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3281 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3283 // Avoid a crash when core load gl resources.
3284 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3286 application.SendNotification();
3287 application.Render();
3289 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
3291 DevelTextField::SelectWholeText( textField );
3293 application.SendNotification();
3294 application.Render();
3296 // Nothing should have been selected. The number of children is still 1
3297 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
3299 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3301 application.SendNotification();
3302 application.Render();
3304 DevelTextField::SelectWholeText( textField );
3306 application.SendNotification();
3307 application.Render();
3309 // Should be 2 children, the stencil and the layer
3310 DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
3312 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3313 Actor stencil = textField.GetChildAt( 0u );
3315 // The highlight actor is drawn first, so is the first actor in the list
3316 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3317 DALI_TEST_CHECK( highlight );
3322 int UtcDaliTextFieldSelectNone(void)
3324 ToolkitTestApplication application;
3325 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3327 TextField textField = TextField::New();
3329 application.GetScene().Add( textField );
3331 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3332 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3333 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3335 // Avoid a crash when core load gl resources.
3336 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3338 application.SendNotification();
3339 application.Render();
3341 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3343 application.SendNotification();
3344 application.Render();
3346 // Nothing is selected
3347 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3348 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3350 DevelTextField::SelectWholeText( textField );
3352 application.SendNotification();
3353 application.Render();
3355 // whole text is selected
3356 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3357 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3359 DevelTextField::SelectNone( textField );
3361 application.SendNotification();
3362 application.Render();
3364 // Nothing is selected
3365 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3366 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3371 int UtcDaliTextFieldSelectRange(void)
3373 ToolkitTestApplication application;
3374 tet_infoline(" UtcDaliTextFieldSelectRange ");
3376 TextField textField = TextField::New();
3378 application.GetScene().Add( textField );
3380 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3381 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3382 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3384 // Avoid a crash when core load gl resources.
3385 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3387 application.SendNotification();
3388 application.Render();
3390 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3392 application.SendNotification();
3393 application.Render();
3395 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 0);
3396 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 5);
3398 // Hello is selected
3399 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3400 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3402 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3403 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3405 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 6);
3406 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 11);
3408 // world is selected
3409 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3410 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3412 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3413 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3418 int UtcDaliTextFieldEnableEditing(void)
3420 ToolkitTestApplication application;
3421 tet_infoline(" UtcDaliTextFieldEnableEditing ");
3423 TextField textField = TextField::New();
3425 application.GetScene().Add( textField );
3427 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3428 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3429 textField.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 application.SendNotification();
3435 application.Render();
3437 textField.SetKeyInputFocus();
3438 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, false );
3439 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3441 // Render and notify
3442 application.SendNotification();
3443 application.Render();
3445 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3446 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3449 textField.SetKeyInputFocus();
3450 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
3451 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3453 // Render and notify
3454 application.SendNotification();
3455 application.Render();
3457 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3458 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3463 int UtcDaliToolkitTextFieldFontSizeScale(void)
3465 ToolkitTestApplication application;
3466 tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
3468 TextField textField = TextField::New();
3469 textField.SetProperty( TextField::Property::POINT_SIZE, 30.f );
3470 textField.SetProperty( TextField::Property::TEXT, "Test" );
3471 Vector3 nonScaledSize = textField.GetNaturalSize();
3473 TextField textFieldScaled = TextField::New();
3474 textFieldScaled.SetProperty( TextField::Property::POINT_SIZE, 15.f );
3475 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3476 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3477 Vector3 scaledSize = textFieldScaled.GetNaturalSize();
3479 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3481 textField.SetProperty( TextField::Property::PIXEL_SIZE, 30.f );
3482 textField.SetProperty( TextField::Property::TEXT, "Test" );
3483 nonScaledSize = textField.GetNaturalSize();
3485 textFieldScaled.SetProperty( TextField::Property::PIXEL_SIZE, 15.f );
3486 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3487 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3488 scaledSize = textFieldScaled.GetNaturalSize();
3490 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3495 int UtcDaliTextFieldPrimaryCursorPosition(void)
3497 ToolkitTestApplication application;
3498 tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
3500 TextField textField = TextField::New();
3502 application.GetScene().Add( textField );
3504 textField.SetProperty( TextField::Property::TEXT, "ABCEF");
3505 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3506 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3507 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3509 // Avoid a crash when core load gl resources.
3510 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3512 textField.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
3513 application.SendNotification();
3514 application.Render();
3516 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3518 // Render and notify
3519 application.SendNotification();
3520 application.Render();
3522 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3523 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3528 // test max length when set after setting long text
3529 int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
3531 ToolkitTestApplication application;
3532 tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
3533 TextField field = TextField::New();
3534 DALI_TEST_CHECK( field );
3536 application.GetScene().Add( field );
3538 field.SetProperty(TextField::Property::TEXT, "123456789");
3540 const int maxNumberOfCharacters = 3;
3541 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
3543 field.SetKeyInputFocus();
3545 // connect to the text max lengh reached signal.
3546 ConnectionTracker* testTracker = new ConnectionTracker();
3547 bool maxLengthReachedSignal = false;
3548 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
3550 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3551 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3553 DALI_TEST_CHECK( maxLengthReachedSignal );
3555 DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "123456789", TEST_LOCATION );
3562 int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
3564 ToolkitTestApplication application;
3565 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
3567 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3568 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3569 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3571 // Create a text field
3572 TextField textField = TextField::New();
3574 //Set size to avoid automatic eliding
3575 textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3576 //Set very large font-size using point-size
3577 textField.SetProperty( TextField::Property::POINT_SIZE, 1000) ;
3578 //Specify font-family
3579 textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
3580 //Set text to check if appear or not
3581 textField.SetProperty( TextField::Property::TEXT, "A");
3583 application.GetScene().Add( textField );
3585 application.SendNotification();
3586 application.Render();
3587 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3588 Vector3 naturalSize = textField.GetNaturalSize();
3590 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3591 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3596 int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
3598 ToolkitTestApplication application;
3599 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
3601 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3602 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3603 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3605 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3606 // Create a text editor
3607 TextField textField = TextField::New();
3609 //Set size to avoid automatic eliding
3610 textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3611 textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
3612 textField.SetProperty( TextField::Property::TEXT, "A");
3614 const int numberOfCases = 6;
3615 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
3617 for (int index=0; index < numberOfCases; index++)
3619 tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
3620 textField.SetProperty( TextField::Property::POINT_SIZE, arrayCases[index]) ;
3621 application.GetScene().Add( textField );
3622 application.SendNotification();
3623 application.Render();
3624 naturalSize = textField.GetNaturalSize();
3625 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3626 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );