2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali/public-api/rendering/renderer.h>
23 #include <dali/integration-api/events/key-event-integ.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/devel-api/adaptor-framework/key-devel.h>
27 #include <dali/devel-api/text-abstraction/font-client.h>
28 #include <dali-toolkit-test-suite-utils.h>
29 #include <dali-toolkit/dali-toolkit.h>
30 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
31 #include <dali-toolkit/devel-api/text/rendering-backend.h>
32 #include "toolkit-clipboard.h"
33 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
34 #include "test-text-geometry-utils.h"
37 using namespace Toolkit;
39 void dali_textfield_startup(void)
41 test_return_value = TET_UNDEF;
44 void dali_textfield_cleanup(void)
46 test_return_value = TET_PASS;
52 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
53 const char* const PROPERTY_NAME_TEXT = "text";
54 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
55 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
56 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
57 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
58 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
59 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
60 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
61 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
62 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
63 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
64 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
65 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
66 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
67 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
68 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
69 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
70 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
71 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
72 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
73 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
74 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
80 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
81 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
82 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
83 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
84 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
85 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
86 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
87 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
88 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
90 const char* const PROPERTY_NAME_UNDERLINE = "underline";
91 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
92 const char* const PROPERTY_NAME_SHADOW = "shadow";
93 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
94 const char* const PROPERTY_NAME_EMBOSS = "emboss";
95 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
96 const char* const PROPERTY_NAME_OUTLINE = "outline";
97 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
98 const char* const PROPERTY_NAME_STRIKETHROUGH = "strikethrough";
99 const char* const PROPERTY_NAME_INPUT_STRIKETHROUGH = "inputStrikethrough";
101 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
102 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
103 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
104 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
105 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
106 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
107 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
108 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
109 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
110 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
111 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
112 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
113 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
115 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
116 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
118 const float RENDER_FRAME_INTERVAL = 16.66f;
120 const unsigned int DEFAULT_FONT_SIZE = 1152u;
121 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
123 const int KEY_RETURN_CODE = 36;
124 const int KEY_A_CODE = 38;
125 const int KEY_D_CODE = 40;
126 const int KEY_SHIFT_MODIFIER = 257;
128 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
130 static bool gSelectionChangedCallbackCalled;
131 static uint32_t oldSelectionStart;
132 static uint32_t oldSelectionEnd;
133 static bool gSelectionClearedCallbackCalled;
134 static bool gAnchorClickedCallBackCalled;
135 static bool gAnchorClickedCallBackNotCalled;
136 static bool gTextChangedCallBackCalled;
137 static bool gMaxCharactersCallBackCalled;
138 static bool gInputFilteredAcceptedCallbackCalled;
139 static bool gInputFilteredRejectedCallbackCalled;
140 static bool gInputStyleChangedCallbackCalled;
141 static bool gCursorPositionChangedCallbackCalled;
142 static uint32_t oldCursorPos;
143 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
145 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
147 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
148 Integration::ResourcePointer resource(bitmap);
149 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
152 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
156 LoadBitmapResource( app.GetPlatform(), width, height );
158 Property::Map propertyMap;
159 propertyMap["filename"] = "image.png";
160 propertyMap["width"] = width;
161 propertyMap["height"] = height;
162 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
163 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
164 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
165 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
166 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
167 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
168 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
169 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
173 * Simulate time passed by.
175 * @note this will always process at least 1 frame (1/60 sec)
177 * @param application Test application instance
178 * @param duration Time to pass in milliseconds.
179 * @return The actual time passed in milliseconds
181 static int Wait(ToolkitTestApplication& application, int duration = 0)
185 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
187 application.SendNotification();
188 application.Render(RENDER_FRAME_INTERVAL);
189 time += RENDER_FRAME_INTERVAL;
195 Dali::Integration::Point GetPointDownInside( Vector2& pos )
197 Dali::Integration::Point point;
198 point.SetState( PointState::DOWN );
199 point.SetScreenPosition( pos );
203 Dali::Integration::Point GetPointUpInside( Vector2& pos )
205 Dali::Integration::Point point;
206 point.SetState( PointState::UP );
207 point.SetScreenPosition( pos );
211 struct CallbackFunctor
213 CallbackFunctor(bool* callbackFlag)
214 : mCallbackFlag( callbackFlag )
220 *mCallbackFlag = true;
225 static void TestSelectionClearedCallback(TextField control)
227 tet_infoline(" TestSelectionClearedCallback");
229 gSelectionClearedCallbackCalled = true;
232 static void TestSelectionChangedCallback(TextField control, uint32_t oldStart, uint32_t oldEnd)
234 tet_infoline(" TestSelectionChangedCallback");
236 gSelectionChangedCallbackCalled = true;
237 oldSelectionStart = oldStart;
238 oldSelectionEnd = oldEnd;
241 static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength)
243 tet_infoline(" TestAnchorClickedCallback");
245 gAnchorClickedCallBackNotCalled = false;
247 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
249 gAnchorClickedCallBackCalled = true;
253 static void TestCursorPositionChangedCallback( TextField control, unsigned int oldPos )
255 tet_infoline(" TestCursorPositionChangedCallback");
257 gCursorPositionChangedCallbackCalled = true;
258 oldCursorPos = oldPos;
261 static void TestTextChangedCallback( TextField control )
263 tet_infoline(" TestTextChangedCallback");
265 gTextChangedCallBackCalled = true;
268 static void TestMaxLengthReachedCallback( TextField control )
270 tet_infoline(" TestMaxLengthReachedCallback");
272 gMaxCharactersCallBackCalled = true;
275 static void TestInputFilteredCallback(TextField control, Toolkit::InputFilter::Property::Type type)
277 tet_infoline(" TestInputFilteredCallback");
279 if(type == Toolkit::InputFilter::Property::ACCEPTED)
281 gInputFilteredAcceptedCallbackCalled = true;
283 else if(type == Toolkit::InputFilter::Property::REJECTED)
285 gInputFilteredRejectedCallbackCalled = true;
289 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
291 tet_infoline(" TestInputStyleChangedCallback");
293 gInputStyleChangedCallbackCalled = true;
294 gInputStyleMask = mask;
297 // Generate a KeyEvent to send to Core.
298 Integration::KeyEvent GenerateKey( const std::string& keyName,
299 const std::string& logicalKey,
300 const std::string& keyString,
303 unsigned long timeStamp,
304 const Integration::KeyEvent::State& keyState,
305 const std::string& compose = "",
306 const std::string& deviceName = DEFAULT_DEVICE_NAME,
307 const Device::Class::Type& deviceClass = Device::Class::NONE,
308 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
310 return Integration::KeyEvent( keyName,
323 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
325 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
327 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
329 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
331 Property::Value* valueSet = NULL;
332 if ( valueGet.first.type == Property::Key::INDEX )
334 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
338 // Get Key is a string so searching Set Map for a string key
339 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
342 if( NULL != valueSet )
344 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
346 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
349 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
351 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
354 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
356 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
359 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
361 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
364 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
366 Vector2 vector2Get = valueGet.second.Get<Vector2>();
367 Vector2 vector2Set = valueSet->Get<Vector2>();
368 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
371 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
373 Vector4 vector4Get = valueGet.second.Get<Vector4>();
374 Vector4 vector4Set = valueSet->Get<Vector4>();
375 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 );
381 if ( valueGet.first.type == Property::Key::INDEX )
383 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
387 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
399 int UtcDaliToolkitTextFieldConstructorP(void)
401 ToolkitTestApplication application;
402 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
404 DALI_TEST_CHECK( !textField );
408 int UtcDaliToolkitTextFieldNewP(void)
410 ToolkitTestApplication application;
411 tet_infoline(" UtcDaliToolkitTextFieldNewP");
412 TextField textField = TextField::New();
413 DALI_TEST_CHECK( textField );
417 int UtcDaliToolkitTextFieldDownCastP(void)
419 ToolkitTestApplication application;
420 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
421 TextField textField1 = TextField::New();
422 BaseHandle object( textField1 );
424 TextField textField2 = TextField::DownCast( object );
425 DALI_TEST_CHECK( textField2 );
427 TextField textField3 = DownCast< TextField >( object );
428 DALI_TEST_CHECK( textField3 );
432 int UtcDaliToolkitTextFieldDownCastN(void)
434 ToolkitTestApplication application;
435 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
436 BaseHandle uninitializedObject;
437 TextField textField1 = TextField::DownCast( uninitializedObject );
438 DALI_TEST_CHECK( !textField1 );
440 TextField textField2 = DownCast< TextField >( uninitializedObject );
441 DALI_TEST_CHECK( !textField2 );
445 int UtcDaliToolkitTextFieldCopyConstructorP(void)
447 ToolkitTestApplication application;
448 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
449 TextField textField = TextField::New();
450 textField.SetProperty( TextField::Property::TEXT, "Test" );
452 TextField copy( textField );
453 DALI_TEST_CHECK( copy );
454 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
458 int UtcDaliTextFieldMoveConstructor(void)
460 ToolkitTestApplication application;
462 TextField textField = TextField::New();
463 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
464 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
466 TextField moved = std::move( textField );
467 DALI_TEST_CHECK( moved );
468 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
469 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
470 DALI_TEST_CHECK( !textField );
475 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
477 ToolkitTestApplication application;
478 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
479 TextField textField = TextField::New();
480 textField.SetProperty( TextField::Property::TEXT, "Test" );
482 TextField copy = textField;
483 DALI_TEST_CHECK( copy );
484 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
488 int UtcDaliTextFieldMoveAssignment(void)
490 ToolkitTestApplication application;
492 TextField textField = TextField::New();
493 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
494 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
497 moved = std::move( textField );
498 DALI_TEST_CHECK( moved );
499 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
500 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
501 DALI_TEST_CHECK( !textField );
506 int UtcDaliTextFieldNewP(void)
508 ToolkitTestApplication application;
509 tet_infoline(" UtcDaliToolkitTextFieldNewP");
510 TextField textField = TextField::New();
511 DALI_TEST_CHECK( textField );
515 // Positive test case for a method
516 int UtcDaliTextFieldGetPropertyP(void)
518 ToolkitTestApplication application;
519 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
520 TextField field = TextField::New();
521 DALI_TEST_CHECK( field );
523 // Check Property Indices are correct
524 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextField::Property::RENDERING_BACKEND );
525 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
526 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
527 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
528 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
529 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
530 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
531 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
532 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
533 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
534 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
535 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
536 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
537 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
538 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
539 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
540 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
541 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
542 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
543 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
544 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
545 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
546 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
547 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
548 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
549 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
550 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
551 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
552 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
553 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
554 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
555 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
556 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
557 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
558 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
559 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
560 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
561 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
562 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
563 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
564 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
565 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
566 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
567 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
568 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
569 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
570 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
571 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
572 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
573 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
574 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextField::Property::FONT_SIZE_SCALE );
575 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
576 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
577 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
578 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP );
579 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextField::Property::BACKGROUND );
580 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextField::Property::GRAB_HANDLE_COLOR );
581 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FILTER ) == DevelTextField::Property::INPUT_FILTER );
582 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_STRIKETHROUGH ) == DevelTextField::Property::STRIKETHROUGH );
583 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_STRIKETHROUGH ) == DevelTextField::Property::INPUT_STRIKETHROUGH );
588 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
591 Property::Map imageMap;
592 imageMap[mapKey] =mapValue;
594 field.SetProperty( property , imageMap );
595 Property::Value propValue = field.GetProperty( property );
596 Property::Map* resultMap = propValue.GetMap();
598 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
606 // Positive test case for a method
607 int UtcDaliTextFieldSetPropertyP(void)
609 ToolkitTestApplication application;
610 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
611 TextField field = TextField::New();
612 DALI_TEST_CHECK( field );
613 application.GetScene().Add( field );
615 // Note - we can't check the defaults since the stylesheets are platform-specific
617 // Check the render backend property.
618 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
619 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
621 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
622 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION );
624 // Check text property.
625 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
626 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
628 // Check placeholder text properties.
629 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
630 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
632 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
633 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
635 // Check font properties.
636 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
637 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
639 Property::Map fontStyleMapSet;
640 Property::Map fontStyleMapGet;
641 Property::Value* slantValue = NULL;
643 fontStyleMapSet.Insert( "weight", "bold" );
644 fontStyleMapSet.Insert( "width", "condensed" );
645 fontStyleMapSet.Insert( "slant", "italic" );
646 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
648 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
649 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
650 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
652 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
653 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
655 field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 2.5f );
656 DALI_TEST_EQUALS( field.GetProperty<float>( DevelTextField::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
657 field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 1.0f );
660 fontStyleMapSet.Clear();
661 fontStyleMapSet.Insert( "weight", "normal" );
662 fontStyleMapSet.Insert( "slant", "oblique" );
663 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
665 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
666 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
667 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
669 fontStyleMapSet.Clear();
670 fontStyleMapSet.Insert( "slant", "roman" );
671 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
672 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
674 // Replace 'roman' for 'normal'.
675 slantValue = fontStyleMapGet.Find( "slant" );
676 if( NULL != slantValue )
678 if( "normal" == slantValue->Get<std::string>() )
680 fontStyleMapGet["slant"] = "roman";
683 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
684 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
686 fontStyleMapSet.Clear();
688 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
689 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
690 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
691 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
693 // Check that the MAX_LENGTH property can be correctly set
694 const int maxNumberOfCharacters = 20;
695 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
696 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
698 // Check exceed policy
699 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
700 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
701 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
702 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
704 // Check that the Alignment properties can be correctly set
705 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
706 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
707 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
708 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
710 // Check text's color property
711 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
712 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
714 // Check placeholder text's color property.
715 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
716 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
718 // Check cursor properties
719 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
720 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
721 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
722 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
724 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
725 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
726 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
727 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
728 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
729 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
730 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
731 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
733 // Check scroll properties.
734 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
735 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
736 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
737 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
739 // Check handle images
740 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
741 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
742 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
743 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
744 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
746 // Check handle images
747 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
748 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
749 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
750 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
751 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
752 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
754 // Check the highlight color
755 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
756 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
758 // Decoration bounding box
759 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
760 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
762 // Check the input method setting
763 Property::Map propertyMap;
764 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
765 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
766 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
767 int inputVariation = 1;
768 propertyMap["PANEL_LAYOUT"] = panelLayout;
769 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
770 propertyMap["BUTTON_ACTION"] = buttonAction;
771 propertyMap["VARIATION"] = inputVariation;
772 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
774 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
776 DALI_TEST_CHECK( value.Get( map ) );
779 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
780 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
783 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
784 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
787 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
788 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
791 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
792 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
794 // Check input color property.
795 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
796 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
798 // Check the enable markup property.
799 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
800 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
801 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
803 // Check input font properties.
804 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
805 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
807 fontStyleMapSet.Clear();
808 fontStyleMapSet.Insert( "weight", "bold" );
809 fontStyleMapSet.Insert( "width", "condensed" );
810 fontStyleMapSet.Insert( "slant", "italic" );
812 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
813 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
814 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
815 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
817 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
818 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
820 // Reset input font style.
821 fontStyleMapSet.Clear();
822 fontStyleMapSet.Insert( "weight", "normal" );
823 fontStyleMapSet.Insert( "slant", "oblique" );
825 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
826 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
827 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
828 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
830 fontStyleMapSet.Clear();
831 fontStyleMapSet.Insert( "slant", "roman" );
833 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
834 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
836 // Replace 'roman' for 'normal'.
837 slantValue = fontStyleMapGet.Find( "slant" );
838 if( NULL != slantValue )
840 if( "normal" == slantValue->Get<std::string>() )
842 fontStyleMapGet["slant"] = "roman";
845 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
846 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
848 fontStyleMapSet.Clear();
850 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
851 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
852 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
853 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
855 Property::Map strikethroughMapSet;
856 Property::Map strikethroughMapGet;
858 strikethroughMapSet.Insert( "enable", true );
859 strikethroughMapSet.Insert( "color", Color::RED );
860 strikethroughMapSet.Insert( "height", 2.0f );
862 // Check the strikethrough property
863 field.SetProperty( DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet );
865 strikethroughMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::STRIKETHROUGH );
866 DALI_TEST_EQUALS( strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION );
867 DALI_TEST_EQUALS( DaliTestCheckMaps( strikethroughMapGet, strikethroughMapSet ), true, TEST_LOCATION );
869 // Check the input strikethrough property
870 field.SetProperty( DevelTextField::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties" );
871 DALI_TEST_EQUALS( field.GetProperty<std::string>( DevelTextField::Property::INPUT_STRIKETHROUGH ), std::string("Strikethrough input properties"), TEST_LOCATION );
873 Property::Map underlineMapSet;
874 Property::Map underlineMapGet;
876 underlineMapSet.Insert( "enable", true );
877 underlineMapSet.Insert( "color", Color::RED );
878 underlineMapSet.Insert( "height", 1 );
880 // Check the underline property
881 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
883 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
884 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
885 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
887 // Check the input underline property
888 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
889 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
891 // Check the shadow property
892 Property::Map shadowMapSet;
893 Property::Map shadowMapGet;
895 shadowMapSet.Insert( "color", Color::GREEN );
896 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
897 shadowMapSet.Insert( "blurRadius", 3.0f );
899 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
901 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
902 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
903 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
905 // Check the input shadow property
906 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
907 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
909 // Check the emboss property
910 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
911 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
913 // Check the input emboss property
914 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
915 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
917 // Check the outline property
919 // Test string type first
920 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
921 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
922 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
924 // Then test the property map type
925 Property::Map outlineMapSet;
926 Property::Map outlineMapGet;
928 outlineMapSet["color"] = Color::RED;
929 outlineMapSet["width"] = 2.0f;
931 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
933 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
934 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
935 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
937 // Check the input outline property
938 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
939 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
941 // Check the hidden input settings property
942 Property::Map hiddenMapSet;
943 Property::Map hiddenMapGet;
944 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
945 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
946 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
947 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
948 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
950 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
951 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
952 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
954 // Check the pixel size of font
955 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
956 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
958 // Check the enable selection property
959 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
960 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
962 // Check the placeholder property with pixel size
963 Property::Map placeholderPixelSizeMapSet;
964 Property::Map placeholderPixelSizeMapGet;
965 Property::Map placeholderFontstyleMap;
966 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
967 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
968 placeholderPixelSizeMapSet["color"] = Color::BLUE;
969 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
970 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
971 placeholderPixelSizeMapSet["ellipsis"] = true;
973 placeholderFontstyleMap.Insert( "weight", "bold" );
974 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
975 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
977 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
978 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
980 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
981 Property::Map placeholderConversionMap;
982 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
983 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
984 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
985 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
986 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
987 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
989 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
991 // Check the placeholder property with point size
992 Property::Map placeholderMapSet;
993 Property::Map placeholderMapGet;
994 placeholderMapSet["text"] = "Setting Placeholder Text";
995 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
996 placeholderMapSet["color"] = Color::RED;
997 placeholderMapSet["fontFamily"] = "Arial";
998 placeholderMapSet["pointSize"] = 12.0f;
999 placeholderMapSet["ellipsis"] = false;
1001 // Check the placeholder font style property
1002 placeholderFontstyleMap.Clear();
1004 placeholderFontstyleMap.Insert( "weight", "bold" );
1005 placeholderFontstyleMap.Insert( "width", "condensed" );
1006 placeholderFontstyleMap.Insert( "slant", "italic" );
1007 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1008 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1010 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1011 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1013 placeholderConversionMap.Clear();
1014 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
1015 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
1016 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
1017 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1018 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
1019 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
1021 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1023 // Reset font style.
1024 placeholderFontstyleMap.Clear();
1025 placeholderFontstyleMap.Insert( "weight", "normal" );
1026 placeholderFontstyleMap.Insert( "slant", "oblique" );
1027 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1028 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1030 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1031 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1033 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1034 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1036 placeholderFontstyleMap.Clear();
1037 placeholderFontstyleMap.Insert( "slant", "roman" );
1038 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1039 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1041 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1043 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1045 placeholderFontstyleMap.Clear();
1046 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1047 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1049 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1050 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1051 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1053 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1055 // Check the ellipsis property
1056 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1057 field.SetProperty( TextField::Property::ELLIPSIS, true );
1058 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1060 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
1061 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1063 // Test the ENABLE_GRAB_HANDLE_POPUP property
1064 DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1065 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false );
1066 DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1068 // Check the background property
1069 field.SetProperty( DevelTextField::Property::BACKGROUND, Color::RED );
1070 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::BACKGROUND ), Color::RED, TEST_LOCATION );
1072 //Check handle color
1073 field.SetProperty( DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN );
1074 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
1076 // Check the input filter property
1077 Property::Map inputFilterMapSet;
1078 Property::Map inputFilterMapGet;
1079 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1080 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1082 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1084 inputFilterMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::INPUT_FILTER);
1085 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1088 inputFilterMapSet.Clear();
1089 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1091 application.SendNotification();
1092 application.Render();
1097 // Positive Atlas Text Renderer test
1098 int utcDaliTextFieldAtlasRenderP(void)
1100 ToolkitTestApplication application;
1101 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1102 StyleManager styleManager = StyleManager::Get();
1103 styleManager.ApplyDefaultTheme();
1104 TextField field = TextField::New();
1105 DALI_TEST_CHECK( field );
1107 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1109 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1111 application.GetScene().Add( field );
1115 // Render some text with the shared atlas backend
1116 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1117 application.SendNotification();
1118 application.Render();
1122 tet_result(TET_FAIL);
1127 // Positive test for the anchorClicked signal.
1128 int utcDaliTextFieldAnchorClicked01(void)
1130 ToolkitTestApplication application;
1131 tet_infoline(" utcDaliTextFieldAnchorClicked01");
1132 TextField field = TextField::New();
1133 DALI_TEST_CHECK(field);
1135 application.GetScene().Add(field);
1137 // connect to the anchor clicked signal.
1138 ConnectionTracker* testTracker = new ConnectionTracker();
1139 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1140 bool anchorClickedSignal = false;
1141 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1143 gAnchorClickedCallBackCalled = false;
1144 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1145 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1146 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1147 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1148 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1150 application.SendNotification();
1151 application.Render();
1152 field.SetKeyInputFocus();
1154 // Create a tap event to touch the text field.
1155 TestGenerateTap(application, 5.0f, 25.0f);
1156 application.SendNotification();
1157 application.Render();
1159 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1160 DALI_TEST_CHECK(anchorClickedSignal);
1162 gAnchorClickedCallBackNotCalled = true;
1163 // Tap the outside of anchor, callback should not be called.
1164 TestGenerateTap(application, 150.f, 100.f);
1165 application.SendNotification();
1166 application.Render();
1168 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1173 // Positive test for the anchorClicked signal.
1174 int utcDaliTextFieldAnchorClicked02(void)
1176 ToolkitTestApplication application;
1177 tet_infoline(" utcDaliTextFieldAnchorClicked02");
1178 TextField field = TextField::New();
1179 DALI_TEST_CHECK(field);
1181 application.GetScene().Add(field);
1183 // connect to the anchor clicked signal.
1184 ConnectionTracker* testTracker = new ConnectionTracker();
1185 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1186 bool anchorClickedSignal = false;
1187 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1189 gAnchorClickedCallBackCalled = false;
1190 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1191 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1192 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1193 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1194 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1196 application.SendNotification();
1197 application.Render();
1198 field.SetKeyInputFocus();
1200 // Avoid a crash when core load gl resources.
1201 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1203 // Create a tap event to touch the text field.
1204 TestGenerateTap(application, 30.0f, 25.0f, 100);
1205 application.SendNotification();
1206 application.Render();
1208 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1209 DALI_TEST_CHECK(anchorClickedSignal);
1212 // For coverage InsertTextAnchor, RemoveTextAnchor
1213 // first index insert
1214 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1215 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1216 application.SendNotification();
1217 application.Render();
1219 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1220 application.SendNotification();
1221 application.Render();
1223 gAnchorClickedCallBackCalled = false;
1224 // Create a tap event to touch the text field.
1225 TestGenerateTap(application, 30.0f, 25.0f, 700);
1226 application.SendNotification();
1227 field.SetKeyInputFocus();
1229 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1231 // last index insert
1232 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1233 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1234 application.SendNotification();
1235 application.Render();
1237 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1238 application.SendNotification();
1239 application.Render();
1241 gAnchorClickedCallBackCalled = false;
1242 // Create a tap event to touch the text field.
1243 TestGenerateTap(application, 30.0f, 25.0f, 1300);
1244 application.SendNotification();
1245 field.SetKeyInputFocus();
1247 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1250 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1251 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1252 application.SendNotification();
1253 application.Render();
1255 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1256 application.SendNotification();
1257 application.Render();
1259 gAnchorClickedCallBackCalled = false;
1260 // Create a tap event to touch the text field.
1261 TestGenerateTap(application, 30.0f, 25.0f, 1900);
1262 application.SendNotification();
1263 field.SetKeyInputFocus();
1265 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1267 // first index remove
1268 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1269 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1270 application.SendNotification();
1271 application.Render();
1273 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1274 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));
1275 application.SendNotification();
1276 application.Render();
1278 gAnchorClickedCallBackCalled = false;
1279 // Create a tap event to touch the text field.
1280 TestGenerateTap(application, 30.0f, 25.0f, 2500);
1281 application.SendNotification();
1282 field.SetKeyInputFocus();
1284 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1286 // last index remove
1287 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1288 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1289 application.SendNotification();
1290 application.Render();
1292 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1293 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));
1294 application.SendNotification();
1295 application.Render();
1297 gAnchorClickedCallBackCalled = false;
1298 // Create a tap event to touch the text field.
1299 TestGenerateTap(application, 30.0f, 25.0f, 3100);
1300 application.SendNotification();
1301 application.Render();
1303 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1306 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1307 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1308 application.SendNotification();
1309 application.Render();
1311 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1312 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));
1313 application.SendNotification();
1314 application.Render();
1316 gAnchorClickedCallBackCalled = false;
1317 // Create a tap event to touch the text field.
1318 TestGenerateTap(application, 30.0f, 25.0f, 3700);
1319 application.SendNotification();
1320 application.Render();
1322 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1324 // 0 ~ 1 index remove
1325 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1326 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 0);
1327 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 1);
1328 application.SendNotification();
1329 application.Render();
1331 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1332 application.SendNotification();
1333 application.Render();
1335 gAnchorClickedCallBackCalled = false;
1336 // Create a tap event to touch the text field.
1337 TestGenerateTap(application, 30.0f, 25.0f, 4300);
1338 application.SendNotification();
1339 application.Render();
1341 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1343 // 1 ~ 3 index remove
1344 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1345 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 1);
1346 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 3);
1347 application.SendNotification();
1348 application.Render();
1350 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1351 application.SendNotification();
1352 application.Render();
1354 gAnchorClickedCallBackCalled = false;
1355 // Create a tap event to touch the text field.
1356 TestGenerateTap(application, 30.0f, 25.0f, 4900);
1357 application.SendNotification();
1358 application.Render();
1360 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1362 // 3 ~ 4 index remove
1363 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1364 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 3);
1365 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 4);
1366 application.SendNotification();
1367 application.Render();
1369 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1370 application.SendNotification();
1371 application.Render();
1373 gAnchorClickedCallBackCalled = false;
1374 // Create a tap event to touch the text field.
1375 TestGenerateTap(application, 30.0f, 25.0f, 5500);
1376 application.SendNotification();
1377 application.Render();
1379 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1381 // Remove front of anchor
1382 field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
1383 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
1384 application.SendNotification();
1385 application.Render();
1387 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1388 application.SendNotification();
1389 application.Render();
1391 // Remove whole text
1392 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1393 DevelTextField::SelectWholeText(field);
1394 application.SendNotification();
1395 application.Render();
1397 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1398 application.SendNotification();
1399 application.Render();
1401 // Remove all with backspace
1402 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1403 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
1404 application.SendNotification();
1405 application.Render();
1407 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1408 application.SendNotification();
1409 application.Render();
1411 // Remove all with delete
1412 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1413 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1414 application.SendNotification();
1415 application.Render();
1417 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));
1418 application.SendNotification();
1419 application.Render();
1424 // Positive test for the textChanged signal.
1425 int utcDaliTextFieldTextChangedP(void)
1427 ToolkitTestApplication application;
1428 tet_infoline(" utcDaliTextFieldTextChangedP");
1429 TextField field = TextField::New();
1430 DALI_TEST_CHECK( field );
1432 application.GetScene().Add( field );
1434 // connect to the text changed signal.
1435 ConnectionTracker* testTracker = new ConnectionTracker();
1436 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1437 bool textChangedSignal = false;
1438 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1440 gTextChangedCallBackCalled = false;
1441 field.SetProperty( TextField::Property::TEXT, "ABC" );
1442 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1443 DALI_TEST_CHECK( textChangedSignal );
1445 application.SendNotification();
1446 field.SetKeyInputFocus();
1448 gTextChangedCallBackCalled = false;
1449 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1450 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1453 field.SetProperty( TextField::Property::TEXT, "" );
1455 // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1456 gTextChangedCallBackCalled = false;
1457 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1458 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1460 // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1461 gTextChangedCallBackCalled = false;
1462 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1463 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1468 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1470 ToolkitTestApplication application;
1471 tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1472 TextField field = TextField::New();
1473 DALI_TEST_CHECK( field );
1476 application.GetScene().Add( field );
1478 // connect to the text changed signal.
1479 ConnectionTracker* testTracker = new ConnectionTracker();
1480 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1481 bool textChangedSignal = false;
1482 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1485 // get InputMethodContext
1487 InputMethodContext::EventData imfEvent;
1488 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext( field );
1490 field.SetKeyInputFocus();
1491 field.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
1494 gTextChangedCallBackCalled = false;
1495 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1496 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1497 application.SendNotification();
1498 application.Render();
1499 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1500 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1502 gTextChangedCallBackCalled = false;
1503 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1504 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1505 application.SendNotification();
1506 application.Render();
1507 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1508 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호"), TEST_LOCATION );
1510 gTextChangedCallBackCalled = false;
1511 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1512 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1513 application.SendNotification();
1514 application.Render();
1515 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1516 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1518 gTextChangedCallBackCalled = false;
1519 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1520 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1521 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1523 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1524 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1525 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1527 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1528 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1529 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1531 application.SendNotification();
1532 application.Render();
1533 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1534 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1540 // Negative test for the textChanged signal.
1541 int utcDaliTextFieldTextChangedN(void)
1543 ToolkitTestApplication application;
1544 tet_infoline(" utcDaliTextFieldTextChangedN");
1545 TextField field = TextField::New();
1546 DALI_TEST_CHECK( field );
1548 application.GetScene().Add( field );
1550 // connect to the text changed signal.
1551 ConnectionTracker* testTracker = new ConnectionTracker();
1552 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1553 bool textChangedSignal = false;
1554 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1556 gTextChangedCallBackCalled = false;
1557 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1558 application.SendNotification();
1559 application.Render();
1560 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1561 DALI_TEST_CHECK( !textChangedSignal );
1566 // Positive test for Max Characters reached signal.
1567 int utcDaliTextFieldMaxCharactersReachedP(void)
1569 ToolkitTestApplication application;
1570 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1571 TextField field = TextField::New();
1572 DALI_TEST_CHECK( field );
1574 application.GetScene().Add( field );
1576 const int maxNumberOfCharacters = 1;
1577 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1579 field.SetKeyInputFocus();
1581 // connect to the text changed signal.
1582 ConnectionTracker* testTracker = new ConnectionTracker();
1583 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1584 bool maxLengthReachedSignal = false;
1585 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1587 gMaxCharactersCallBackCalled = false;
1589 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1590 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1592 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1593 DALI_TEST_CHECK( maxLengthReachedSignal );
1598 // Negative test for Max Characters reached signal.
1599 int utcDaliTextFieldMaxCharactersReachedN(void)
1601 ToolkitTestApplication application;
1602 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1603 TextField field = TextField::New();
1604 DALI_TEST_CHECK( field );
1606 application.GetScene().Add( field );
1608 const int maxNumberOfCharacters = 3;
1609 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1611 field.SetKeyInputFocus();
1613 // connect to the text changed signal.
1614 ConnectionTracker* testTracker = new ConnectionTracker();
1615 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1616 bool maxLengthReachedSignal = false;
1617 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1619 gMaxCharactersCallBackCalled = false;
1621 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1622 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1624 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1625 DALI_TEST_CHECK( !maxLengthReachedSignal );
1627 application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1629 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1630 DALI_TEST_CHECK( !maxLengthReachedSignal );
1635 // Positive test for Input Filtered signal.
1636 int utcDaliTextFieldInputFilteredP(void)
1638 ToolkitTestApplication application;
1639 tet_infoline(" utcDaliTextFieldInputFilteredP");
1640 TextField field = TextField::New();
1641 DALI_TEST_CHECK(field);
1643 application.GetScene().Add(field);
1645 Property::Map inputFilter;
1647 // Only digit is accepted.
1648 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1650 // Set input filter to TextField.
1651 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1653 field.SetKeyInputFocus();
1655 // connect to the input filtered signal.
1656 ConnectionTracker* testTracker = new ConnectionTracker();
1657 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1658 bool inputFilteredSignal = false;
1659 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1661 gInputFilteredAcceptedCallbackCalled = false;
1663 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ));
1665 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1666 DALI_TEST_CHECK(inputFilteredSignal);
1668 // Word is rejected.
1669 inputFilter[InputFilter::Property::ACCEPTED] = "";
1670 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1672 // Set input filter to TextField.
1673 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1675 field.SetKeyInputFocus();
1677 inputFilteredSignal = false;
1678 gInputFilteredRejectedCallbackCalled = false;
1680 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1682 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1683 DALI_TEST_CHECK(inputFilteredSignal);
1688 // Negative test for Input Filtered signal.
1689 int utcDaliTextFieldInputFilteredN(void)
1691 ToolkitTestApplication application;
1692 tet_infoline(" utcDaliTextFieldInputFilteredP");
1693 TextField field = TextField::New();
1694 DALI_TEST_CHECK(field);
1696 application.GetScene().Add(field);
1698 Property::Map inputFilter;
1700 // Only word is accepted.
1701 inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
1703 // Set input filter to TextField.
1704 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1706 field.SetKeyInputFocus();
1708 // connect to the input filtered signal.
1709 ConnectionTracker* testTracker = new ConnectionTracker();
1710 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1711 bool inputFilteredSignal = false;
1712 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1714 gInputFilteredAcceptedCallbackCalled = false;
1716 // Key a, d should not be filtered.
1717 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1718 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1719 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1720 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1722 // Backspace, Delete should not be filtered.
1723 application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1724 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));
1726 // Render and notify
1727 application.SendNotification();
1728 application.Render();
1730 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1731 DALI_TEST_CHECK(!inputFilteredSignal);
1733 // Digit is rejected.
1734 inputFilter[InputFilter::Property::ACCEPTED] = "";
1735 inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
1737 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1739 field.SetKeyInputFocus();
1741 inputFilteredSignal = false;
1742 gInputFilteredRejectedCallbackCalled = false;
1744 // Key a, d should not be filtered.
1745 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1746 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1747 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1748 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1750 // Backspace, Delete should not be filtered.
1751 application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1752 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));
1754 // Render and notify
1755 application.SendNotification();
1756 application.Render();
1758 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1759 DALI_TEST_CHECK(!inputFilteredSignal);
1764 int utcDaliTextFieldInputStyleChanged01(void)
1766 // The text-field emits signals when the input style changes. These changes of style are
1767 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1768 // can't be emitted during the size negotiation as the callbacks may update the UI.
1769 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1770 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1771 ToolkitTestApplication application;
1772 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1776 char* pathNamePtr = get_current_dir_name();
1777 const std::string pathName( pathNamePtr );
1778 free( pathNamePtr );
1780 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1781 fontClient.SetDpi( 93u, 93u );
1783 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1784 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1786 TextField field = TextField::New();
1787 DALI_TEST_CHECK( field );
1790 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1791 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1792 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1794 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1795 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1797 // connect to the text changed signal.
1798 ConnectionTracker* testTracker = new ConnectionTracker();
1799 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1800 bool inputStyleChangedSignal = false;
1801 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1803 application.GetScene().Add( field );
1805 // Render and notify
1806 application.SendNotification();
1807 application.Render();
1809 // Executes the idle callbacks added by the text control on the change of input style.
1810 application.RunIdles();
1812 gInputStyleChangedCallbackCalled = false;
1813 gInputStyleMask = TextField::InputStyle::NONE;
1814 inputStyleChangedSignal = false;
1816 // Create a tap event to touch the text field.
1817 TestGenerateTap( application, 18.0f, 25.0f );
1819 // Render and notify
1820 application.SendNotification();
1821 application.Render();
1823 // Executes the idle callbacks added by the text control on the change of input style.
1824 application.RunIdles();
1826 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1827 if( gInputStyleChangedCallbackCalled )
1829 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1831 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1832 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1834 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1835 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1837 DALI_TEST_CHECK( inputStyleChangedSignal );
1839 gInputStyleChangedCallbackCalled = false;
1840 gInputStyleMask = TextField::InputStyle::NONE;
1841 inputStyleChangedSignal = false;
1843 // Create a tap event to touch the text field.
1844 TestGenerateTap( application, 30.0f, 25.0f );
1846 // Render and notify
1847 application.SendNotification();
1848 application.Render();
1850 // Executes the idle callbacks added by the text control on the change of input style.
1851 application.RunIdles();
1853 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1854 DALI_TEST_CHECK( !inputStyleChangedSignal );
1856 gInputStyleChangedCallbackCalled = false;
1857 gInputStyleMask = TextField::InputStyle::NONE;
1858 inputStyleChangedSignal = false;
1860 // Create a tap event to touch the text field.
1861 TestGenerateTap( application, 43.0f, 25.0f );
1863 // Render and notify
1864 application.SendNotification();
1865 application.Render();
1867 // Executes the idle callbacks added by the text control on the change of input style.
1868 application.RunIdles();
1870 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1871 if( gInputStyleChangedCallbackCalled )
1873 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1875 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1876 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1878 DALI_TEST_CHECK( inputStyleChangedSignal );
1880 gInputStyleChangedCallbackCalled = false;
1881 gInputStyleMask = TextField::InputStyle::NONE;
1882 inputStyleChangedSignal = false;
1884 // Create a tap event to touch the text field.
1885 TestGenerateTap( application, 88.0f, 25.0f );
1887 // Render and notify
1888 application.SendNotification();
1889 application.Render();
1891 // Executes the idle callbacks added by the text control on the change of input style.
1892 application.RunIdles();
1894 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1895 if( gInputStyleChangedCallbackCalled )
1897 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1899 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1900 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1902 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1904 Property::Map fontStyleMapSet;
1905 fontStyleMapSet.Insert( "weight", "bold" );
1907 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1908 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1910 DALI_TEST_CHECK( inputStyleChangedSignal );
1912 gInputStyleChangedCallbackCalled = false;
1913 gInputStyleMask = TextField::InputStyle::NONE;
1914 inputStyleChangedSignal = false;
1916 // Create a tap event to touch the text field.
1917 TestGenerateTap( application, 115.0f, 25.0f );
1919 // Render and notify
1920 application.SendNotification();
1921 application.Render();
1923 // Executes the idle callbacks added by the text control on the change of input style.
1924 application.RunIdles();
1926 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1927 DALI_TEST_CHECK( !inputStyleChangedSignal );
1929 gInputStyleChangedCallbackCalled = false;
1930 gInputStyleMask = TextField::InputStyle::NONE;
1931 inputStyleChangedSignal = false;
1933 // Create a tap event to touch the text field.
1934 TestGenerateTap( application, 164.0f, 25.0f );
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 ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1948 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1949 DALI_TEST_CHECK( style.empty() );
1951 DALI_TEST_CHECK( inputStyleChangedSignal );
1953 gInputStyleChangedCallbackCalled = false;
1954 gInputStyleMask = TextField::InputStyle::NONE;
1955 inputStyleChangedSignal = false;
1957 // Create a tap event to touch the text field.
1958 TestGenerateTap( application, 191.0f, 25.0f );
1960 // Render and notify
1961 application.SendNotification();
1962 application.Render();
1964 // Executes the idle callbacks added by the text control on the change of input style.
1965 application.RunIdles();
1967 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1968 DALI_TEST_CHECK( !inputStyleChangedSignal );
1973 int utcDaliTextFieldInputStyleChanged02(void)
1975 // The text-field emits signals when the input style changes. These changes of style are
1976 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1977 // can't be emitted during the size negotiation as the callbacks may update the UI.
1978 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1979 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1980 ToolkitTestApplication application;
1981 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1985 char* pathNamePtr = get_current_dir_name();
1986 const std::string pathName( pathNamePtr );
1987 free( pathNamePtr );
1989 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1990 fontClient.SetDpi( 93u, 93u );
1992 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1993 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1995 TextField field = TextField::New();
1996 DALI_TEST_CHECK( field );
1998 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1999 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2000 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2002 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
2003 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>" );
2005 // connect to the text changed signal.
2006 ConnectionTracker* testTracker = new ConnectionTracker();
2007 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
2008 bool inputStyleChangedSignal = false;
2009 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
2011 application.GetScene().Add( field );
2013 // Render and notify
2014 application.SendNotification();
2015 application.Render();
2017 // Executes the idle callbacks added by the text control on the change of input style.
2018 application.RunIdles();
2020 gInputStyleChangedCallbackCalled = false;
2021 gInputStyleMask = TextField::InputStyle::NONE;
2022 inputStyleChangedSignal = false;
2024 // Create a tap event to touch the text field.
2025 TestGenerateTap( application, 53.0f, 25.0f, 100 );
2026 TestGenerateTap( application, 53.0f, 25.0f, 200 );
2028 // Render and notify
2029 application.SendNotification();
2030 application.Render();
2032 // Executes the idle callbacks added by the text control on the change of input style.
2033 application.RunIdles();
2035 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2036 if( gInputStyleChangedCallbackCalled )
2038 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2039 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
2040 TextField::InputStyle::POINT_SIZE |
2041 TextField::InputStyle::COLOR ),
2044 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2045 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
2047 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
2048 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
2050 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
2051 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2053 DALI_TEST_CHECK( inputStyleChangedSignal );
2055 gInputStyleChangedCallbackCalled = false;
2056 gInputStyleMask = TextField::InputStyle::NONE;
2057 inputStyleChangedSignal = false;
2059 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2061 // Render and notify
2062 application.SendNotification();
2063 application.Render();
2065 // Executes the idle callbacks added by the text control on the change of input style.
2066 application.RunIdles();
2068 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2069 if( gInputStyleChangedCallbackCalled )
2071 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2072 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
2075 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2076 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
2078 DALI_TEST_CHECK( inputStyleChangedSignal );
2080 gInputStyleChangedCallbackCalled = false;
2081 gInputStyleMask = TextField::InputStyle::NONE;
2082 inputStyleChangedSignal = false;
2084 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2086 // Render and notify
2087 application.SendNotification();
2088 application.Render();
2090 // Executes the idle callbacks added by the text control on the change of input style.
2091 application.RunIdles();
2093 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
2094 DALI_TEST_CHECK( !inputStyleChangedSignal );
2096 gInputStyleChangedCallbackCalled = false;
2097 gInputStyleMask = TextField::InputStyle::NONE;
2098 inputStyleChangedSignal = false;
2100 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2102 // Render and notify
2103 application.SendNotification();
2104 application.Render();
2106 // Executes the idle callbacks added by the text control on the change of input style.
2107 application.RunIdles();
2109 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2110 if( gInputStyleChangedCallbackCalled )
2112 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2113 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
2116 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2117 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
2119 DALI_TEST_CHECK( inputStyleChangedSignal );
2121 gInputStyleChangedCallbackCalled = false;
2122 gInputStyleMask = TextField::InputStyle::NONE;
2123 inputStyleChangedSignal = false;
2125 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
2127 Property::Map fontStyleMapSet;
2128 fontStyleMapSet.Insert( "weight", "thin" );
2129 fontStyleMapSet.Insert( "width", "condensed" );
2130 fontStyleMapSet.Insert( "slant", "italic" );
2132 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2133 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
2135 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
2136 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
2137 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
2138 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
2139 field.SetProperty( DevelTextField::Property::INPUT_STRIKETHROUGH, "strikethrough" );
2141 // Render and notify
2142 application.SendNotification();
2143 application.Render();
2145 // Executes the idle callbacks added by the text control on the change of input style.
2146 application.RunIdles();
2148 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
2149 DALI_TEST_CHECK( !inputStyleChangedSignal );
2151 // Create a tap event to touch the text field.
2152 TestGenerateTap( application, 63.0f, 25.0f, 700 );
2154 // Render and notify
2155 application.SendNotification();
2156 application.Render();
2158 // Executes the idle callbacks added by the text control on the change of input style.
2159 application.RunIdles();
2161 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2162 if( gInputStyleChangedCallbackCalled )
2164 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2165 static_cast<unsigned int>( TextField::InputStyle::COLOR |
2166 TextField::InputStyle::POINT_SIZE |
2167 TextField::InputStyle::FONT_STYLE |
2168 TextField::InputStyle::UNDERLINE |
2169 TextField::InputStyle::SHADOW |
2170 TextField::InputStyle::EMBOSS |
2171 TextField::InputStyle::OUTLINE ),
2174 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2175 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
2177 DALI_TEST_CHECK( inputStyleChangedSignal );
2182 int utcDaliTextFieldEvent01(void)
2184 ToolkitTestApplication application;
2185 tet_infoline(" utcDaliTextFieldEvent01");
2187 // Creates a tap event. After creating a tap event the text field should
2188 // have the focus and add text with key events should be possible.
2190 TextField field = TextField::New();
2191 DALI_TEST_CHECK( field );
2193 application.GetScene().Add( field );
2195 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2196 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2197 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2199 // Render and notify
2200 application.SendNotification();
2201 application.Render();
2203 // Avoid a crash when core load gl resources.
2204 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2206 // Render and notify
2207 application.SendNotification();
2208 application.Render();
2210 // Add a key event but as the text field has not the focus it should do nothing.
2211 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2213 // Render and notify
2214 application.SendNotification();
2215 application.Render();
2217 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2219 // Create a tap event to touch the text field.
2220 TestGenerateTap( application, 150.0f, 25.0f );
2222 // Render and notify
2223 application.SendNotification();
2224 application.Render();
2226 // Pressing delete key should be fine even if there is no text in TextField.
2227 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 ) );
2228 // Render and notify
2229 application.SendNotification();
2230 application.Render();
2232 // Now the text field has the focus, so it can handle the key events.
2233 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2234 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2236 // Render and notify
2237 application.SendNotification();
2238 application.Render();
2240 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2242 // Create a second text field and send key events to it.
2243 TextField field2 = TextField::New();
2245 field2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2246 field2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2247 field2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2248 field2.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
2250 application.GetScene().Add( field2 );
2252 // Render and notify
2253 application.SendNotification();
2254 application.Render();
2256 // Create a tap event on the second text field.
2257 TestGenerateTap( application, 150.0f, 125.0f );
2259 // Render and notify
2260 application.SendNotification();
2261 application.Render();
2263 // The second text field has the focus. It should handle the key events.
2264 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2265 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2267 // Render and notify
2268 application.SendNotification();
2269 application.Render();
2271 // Check the text has been added to the second text field.
2272 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2277 int utcDaliTextFieldEvent02(void)
2279 ToolkitTestApplication application;
2280 tet_infoline(" utcDaliTextFieldEvent02");
2282 // Checks if the right number of actors are created.
2284 TextField field = TextField::New();
2285 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2286 DALI_TEST_CHECK( field );
2287 LoadMarkerImages(application, field);
2289 application.GetScene().Add( field );
2291 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2292 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2293 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2295 // Avoid a crash when core load gl resources.
2296 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2298 // Render and notify
2299 application.SendNotification();
2300 application.Render();
2302 // Check there are the expected number of children ( stencil ).
2303 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
2305 Actor stencil = field.GetChildAt( 0u );
2306 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2308 // Create a tap event to touch the text field.
2309 TestGenerateTap( application, 150.0f, 25.0f, 300 );
2311 // Render and notify
2312 application.SendNotification();
2313 application.Render();
2315 Actor layer = field.GetChildAt( 1u );
2316 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2317 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2319 // Now the text field has the focus, so it can handle the key events.
2320 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2321 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2323 // Render and notify
2324 application.SendNotification();
2325 application.Render();
2327 // Checks the cursor and the renderer have been created.
2328 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2329 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
2331 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
2332 DALI_TEST_CHECK( cursor );
2334 // The offscreen root actor has a container with all the actors which contain the text renderers.
2335 Actor container = stencil.GetChildAt( 0u );
2336 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2338 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2339 DALI_TEST_CHECK( renderer );
2342 // Move the cursor and check the position changes.
2343 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2344 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2346 // Render and notify
2347 application.SendNotification();
2348 application.Render();
2350 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2351 DALI_TEST_CHECK( position2.x < position1.x );
2353 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2355 // Render and notify
2356 application.SendNotification();
2357 application.Render();
2359 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2360 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
2363 // Move the cursor to the first position.
2364 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2365 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2367 // Render and notify
2368 application.SendNotification();
2369 application.Render();
2371 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2373 // Send some taps and check the cursor positions.
2375 // Try to tap at the beginning.
2376 TestGenerateTap( application, 1.0f, 25.0f, 900 );
2378 // Render and notify
2379 application.SendNotification();
2380 application.Render();
2382 // Cursor position should be the same than position1.
2383 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2385 DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
2387 // Tap away from the start position.
2388 TestGenerateTap( application, 16.0f, 25.0f, 1500 );
2390 // Render and notify
2391 application.SendNotification();
2392 application.Render();
2394 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2396 DALI_TEST_CHECK( position6.x > position5.x );
2398 // Remove all the text.
2399 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2400 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2401 field.SetProperty( TextField::Property::TEXT, "" );
2403 // Render and notify
2404 application.SendNotification();
2405 application.Render();
2407 // Cursor position should be the same than position2.
2408 Vector3 position7 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2410 DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
2412 // Should not be a renderer.
2413 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2415 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2416 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2417 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
2419 application.SendNotification();
2420 application.Render();
2422 // There are renderer and decorator layer
2423 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
2428 int utcDaliTextFieldEvent03(void)
2430 ToolkitTestApplication application;
2431 tet_infoline(" utcDaliTextFieldEvent03");
2433 // Checks if the highlight actor is created.
2435 TextField field = TextField::New();
2436 DALI_TEST_CHECK( field );
2438 application.GetScene().Add( field );
2440 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2441 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2442 field.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
2443 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2444 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2446 // Avoid a crash when core load gl resources.
2447 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2448 LoadMarkerImages(application, field);
2450 // Render and notify
2451 application.SendNotification();
2452 application.Render();
2454 // Tap first to get the focus.
2455 TestGenerateTap( application, 3.0f, 25.0f );
2457 // Render and notify
2458 application.SendNotification();
2459 application.Render();
2461 // Double tap to select a word.
2462 TestGenerateTap( application, 3.0f, 25.0f );
2464 // Render and notify
2465 application.SendNotification();
2466 application.Render();
2468 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2469 Actor stencil = field.GetChildAt( 0u );
2471 // The highlight actor is drawn first, so is the first actor in the list
2472 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2473 DALI_TEST_CHECK( highlight );
2475 // The offscreen root actor has a container with all the actors which contain the text renderers.
2476 Actor container = stencil.GetChildAt( 1u );
2477 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2479 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2480 DALI_TEST_CHECK( renderer );
2486 int utcDaliTextFieldEvent04(void)
2488 ToolkitTestApplication application;
2489 tet_infoline(" utcDaliTextFieldEvent04");
2491 // Checks if the highlight actor is created.
2493 TextField field = TextField::New();
2494 DALI_TEST_CHECK( field );
2495 application.GetScene().Add( field );
2496 LoadMarkerImages(application, field);
2497 // Render and notify
2498 application.SendNotification();
2499 application.Render();
2501 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2502 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2503 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2504 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2505 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2507 // Avoid a crash when core load gl resources.
2508 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2509 // Render and notify
2510 application.SendNotification();
2511 application.Render();
2513 // Create a tap event to touch the text field.
2514 TestGenerateTap( application, 150.0f, 25.0f );
2515 // Render and notify
2516 application.SendNotification();
2517 application.Render();
2520 // Tap first to get the focus.
2521 TestGenerateTap( application, 1.0f, 25.0f );
2523 // Render and notify
2524 application.SendNotification();
2525 application.Render();
2527 // Double tap to select a word.
2528 TestGenerateTap( application, 1.0f, 25.0f );
2530 // Render and notify
2531 application.SendNotification();
2532 application.Render();
2535 TestGenerateTap( application, 0.0f, 40.0f );
2539 int utcDaliTextFieldEvent05(void)
2541 ToolkitTestApplication application;
2542 tet_infoline(" utcDaliTextFieldEvent05");
2544 // Checks dragging of cursor/grab handle
2546 TextField field = TextField::New();
2547 DALI_TEST_CHECK( field );
2548 application.GetScene().Add( field );
2549 LoadMarkerImages(application, field);
2550 // Render and notify
2551 application.SendNotification();
2552 application.Render();
2554 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2555 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2556 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2557 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2558 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2560 // Avoid a crash when core load gl resources.
2561 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2562 // Render and notify
2563 application.SendNotification();
2564 application.Render();
2566 // Create a tap event to touch the text field.
2567 TestGenerateTap( application, 150.0f, 25.0f );
2568 // Render and notify
2569 application.SendNotification();
2570 application.Render();
2572 // Tap first to get the focus.
2573 TestGenerateTap( application, 1.0f, 25.0f );
2575 // Render and notify
2576 application.SendNotification();
2577 application.Render();
2579 // Double tap to select a word.
2580 TestGenerateTap( application, 1.0f, 25.0f );
2582 // Render and notify
2583 application.SendNotification();
2584 application.Render();
2586 Actor stencil = field.GetChildAt( 1u );
2590 int utcDaliTextFieldEvent06(void)
2592 ToolkitTestApplication application;
2593 tet_infoline(" utcDaliTextFieldEvent06");
2595 // Checks Longpress when in edit mode
2597 TextField field = TextField::New();
2598 DALI_TEST_CHECK( field );
2599 application.GetScene().Add( field );
2600 LoadMarkerImages(application, field);
2601 // Render and notify
2602 application.SendNotification();
2603 application.Render();
2605 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2606 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2607 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2608 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2609 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2611 // Avoid a crash when core load gl resources.
2612 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2613 // Render and notify
2614 application.SendNotification();
2615 application.Render();
2617 // Create a tap event to touch the text field.
2618 TestGenerateTap( application, 150.0f, 25.0f );
2619 // Render and notify
2620 application.SendNotification();
2621 application.Render();
2624 // Tap first to get the focus.
2625 TestGenerateTap( application, 1.0f, 25.0f );
2627 // Render and notify
2628 application.SendNotification();
2629 application.Render();
2632 TestGenerateLongPress(application, 1.0f, 25.0f);
2634 // Render and notify
2635 application.SendNotification();
2636 application.Render();
2641 int utcDaliTextFieldEvent07(void)
2643 ToolkitTestApplication application;
2644 tet_infoline(" utcDaliTextFieldEvent07");
2646 // Checks Longpress to start edit mode
2648 TextField field = TextField::New();
2649 DALI_TEST_CHECK( field );
2650 application.GetScene().Add( field );
2651 LoadMarkerImages(application, field);
2652 // Render and notify
2653 application.SendNotification();
2654 application.Render();
2656 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2657 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2658 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2659 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2660 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2661 Property::Map propertyMap;
2662 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2663 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2665 // Avoid a crash when core load gl resources.
2666 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2667 // Render and notify
2668 application.SendNotification();
2669 application.Render();
2672 TestGenerateLongPress(application, 1.0f, 25.0f);
2674 // Render and notify
2675 application.SendNotification();
2676 application.Render();
2681 int utcDaliTextFieldEvent08(void)
2683 ToolkitTestApplication application;
2684 tet_infoline(" utcDaliTextFieldEvent08");
2686 Dali::Clipboard clipboard = Clipboard::Get();
2687 clipboard.SetItem("testTextFieldEvent");
2689 // Checks Longpress when only place holder text
2691 TextField field = TextField::New();
2692 DALI_TEST_CHECK( field );
2693 application.GetScene().Add( field );
2694 LoadMarkerImages(application, field);
2695 // Render and notify
2696 application.SendNotification();
2697 application.Render();
2699 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2700 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2701 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2702 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2703 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2705 // Avoid a crash when core load gl resources.
2706 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2707 // Render and notify
2708 application.SendNotification();
2709 application.Render();
2712 TestGenerateLongPress( application, 1.0f, 25.0f, 20 );
2714 // Render and notify
2715 application.SendNotification();
2716 application.Render();
2718 Wait(application, 500);
2720 TestEndLongPress( application, 1.0f, 25.0f, 520 );
2723 TestGenerateLongPress( application, 1.0f, 25.0f, 600 );
2725 // Render and notify
2726 application.Render();
2728 Wait(application, 500);
2730 Integration::Scene stage = application.GetScene();
2731 Layer layer = stage.GetRootLayer();
2732 Actor actor = layer.FindChildByName("optionPaste");
2736 Vector3 worldPosition = actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION );
2737 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2738 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2740 Dali::Integration::TouchEvent event;
2741 event = Dali::Integration::TouchEvent();
2742 event.AddPoint( GetPointDownInside( position ) );
2743 application.ProcessEvent( event );
2745 event = Dali::Integration::TouchEvent();
2746 event.AddPoint( GetPointUpInside( position ) );
2747 application.ProcessEvent( event );
2749 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2754 int utcDaliTextFieldEvent09(void)
2756 ToolkitTestApplication application;
2757 tet_infoline(" utcDaliTextFieldEvent09");
2759 TextField field = TextField::New();
2760 DALI_TEST_CHECK( field );
2761 application.GetScene().Add( field );
2762 LoadMarkerImages(application, field);
2763 // Render and notify
2764 application.SendNotification();
2765 application.Render();
2767 field.SetProperty( TextField::Property::TEXT, "Hello" );
2768 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2769 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2770 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2771 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2773 // Avoid a crash when core load gl resources.
2774 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2776 // Create a tap event to touch the text field.
2777 TestGenerateTap( application, 150.0f, 25.0f );
2778 application.SendNotification();
2779 application.Render();
2782 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2783 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2784 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2785 application.SendNotification();
2786 application.Render();
2788 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2789 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2790 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2791 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2792 application.SendNotification();
2793 application.Render();
2795 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2796 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2797 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2798 for( unsigned int index = 0u; index < 5u; ++index )
2800 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2801 application.SendNotification();
2802 application.Render();
2805 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2806 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2807 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2808 for( unsigned int index = 0u; index < 5u; ++index )
2810 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2811 application.SendNotification();
2812 application.Render();
2815 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2816 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2817 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2818 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2819 application.SendNotification();
2820 application.Render();
2821 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2822 application.SendNotification();
2823 application.Render();
2825 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2826 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2827 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2828 application.SendNotification();
2829 application.Render();
2831 Property::Map mapGet;
2832 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2833 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2834 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2839 int utcDaliTextFieldStyleWhilstSelected(void)
2841 ToolkitTestApplication application;
2842 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2844 // Change font and styles whilst text is selected whilst word selected
2846 TextField field = TextField::New();
2847 DALI_TEST_CHECK( field );
2848 application.GetScene().Add( field );
2849 LoadMarkerImages(application, field);
2850 // Render and notify
2851 application.SendNotification();
2852 application.Render();
2854 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2855 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2856 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2857 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2858 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2860 // Avoid a crash when core load gl resources.
2861 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2862 // Render and notify
2863 application.SendNotification();
2864 application.Render();
2866 // Create a tap event to touch the text field.
2867 TestGenerateTap( application, 150.0f, 25.0f );
2868 // Render and notify
2869 application.SendNotification();
2870 application.Render();
2873 // Tap first to get the focus.
2874 TestGenerateTap( application, 1.0f, 25.0f );
2876 // Render and notify
2877 application.SendNotification();
2878 application.Render();
2880 // Double tap to select a word.
2881 TestGenerateTap( application, 1.0f, 25.0f );
2883 // Render and notify
2884 application.SendNotification();
2885 application.Render();
2887 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2888 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2890 Property::Map fontStyleMapSet;
2891 Property::Map fontStyleMapGet;
2893 fontStyleMapSet.Insert( "weight", "bold" );
2894 fontStyleMapSet.Insert( "slant", "italic" );
2895 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2897 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2898 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2899 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2901 fontStyleMapSet.Clear();
2902 fontStyleMapSet.Insert( "width", "expanded" );
2903 fontStyleMapSet.Insert( "slant", "italic" );
2904 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2906 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2907 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2908 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2910 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2911 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2913 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2914 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2916 fontStyleMapSet.Clear();
2917 fontStyleMapSet.Insert( "weight", "bold" );
2918 fontStyleMapSet.Insert( "slant", "italic" );
2920 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2922 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2923 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2924 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2926 fontStyleMapSet.Clear();
2927 fontStyleMapSet.Insert( "width", "expanded" );
2929 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2931 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2932 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2933 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2935 // Press Escape to increase coverage
2936 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2937 application.SendNotification();
2938 application.Render();
2940 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2945 int utcDaliTextFieldEscKeyLoseFocus(void)
2947 ToolkitTestApplication application;
2948 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2950 // Creates a tap event. After creating a tap event the text field should
2951 // have the focus and add text with key events should be possible.
2953 TextField field = TextField::New();
2954 DALI_TEST_CHECK( field );
2956 application.GetScene().Add( field );
2958 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2959 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2960 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2962 // Avoid a crash when core load gl resources.
2963 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2965 // Render and notify
2966 application.SendNotification();
2967 application.Render();
2969 // Add a key event but as the text field has not the focus it should do nothing.
2970 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2971 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2973 // Render and notify
2974 application.SendNotification();
2975 application.Render();
2977 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2979 // Create a tap event to touch the text field.
2980 TestGenerateTap( application, 150.0f, 25.0f );
2982 // Render and notify
2983 application.SendNotification();
2984 application.Render();
2986 // Now the text field has the focus, so it can handle the key events.
2987 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2988 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2989 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2990 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2992 // Render and notify
2993 application.SendNotification();
2994 application.Render();
2996 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2998 // Generate a Esc key event. The text field should lose the focus.
2999 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3000 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3002 // Render and notify
3003 application.SendNotification();
3004 application.Render();
3006 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
3008 // No more text should be introduced
3009 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3010 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3012 // Render and notify
3013 application.SendNotification();
3014 application.Render();
3016 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
3021 int utcDaliTextFieldSomeSpecialKeys(void)
3023 ToolkitTestApplication application;
3024 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
3026 // Checks some special keys when the text is selected.
3028 TextField field = TextField::New();
3029 DALI_TEST_CHECK( field );
3030 application.GetScene().Add( field );
3031 LoadMarkerImages(application, field);
3032 // Render and notify
3033 application.SendNotification();
3034 application.Render();
3036 const std::string longText( "This is a long text for the size of the text-field." );
3038 field.SetProperty( TextField::Property::TEXT, longText );
3039 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
3040 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3041 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3042 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3044 // Avoid a crash when core load gl resources.
3045 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3046 // Render and notify
3047 application.SendNotification();
3048 application.Render();
3050 // Create a tap event to touch the text field.
3051 TestGenerateTap( application, 150.0f, 25.0f );
3053 // Render and notify
3054 application.SendNotification();
3055 application.Render();
3057 // Tap first to get the focus.
3058 TestGenerateTap( application, 1.0f, 25.0f );
3060 // Render and notify
3061 application.SendNotification();
3062 application.Render();
3064 // Double tap to select a word.
3065 TestGenerateTap( application, 1.0f, 25.0f );
3067 // Render and notify
3068 application.SendNotification();
3069 application.Render();
3071 // Generate a Esc key event. The text field should lose the focus.
3072 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3073 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3075 // Render and notify
3076 application.SendNotification();
3077 application.Render();
3079 // Generate a Esc key event. The text field should lose the focus.
3080 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3081 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3083 // Render and notify
3084 application.SendNotification();
3085 application.Render();
3087 // Generate a Esc key event. The text field should lose the focus.
3088 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3089 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3091 // Render and notify
3092 application.SendNotification();
3093 application.Render();
3095 // The text shouldn't be deleted.
3096 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
3101 int utcDaliTextFieldSizeUpdate(void)
3103 ToolkitTestApplication application;
3104 tet_infoline("utcDaliTextFieldSizeUpdate");
3106 // Checks some special keys when the text is selected.
3107 TextField field = TextField::New();
3108 DALI_TEST_CHECK( field );
3109 application.GetScene().Add( field );
3111 float previousHeight = 0.0f;
3112 float currentHeight = 0.0f;
3113 const float fieldWidth = 1920.0f;
3116 // "ㅁ" is bigger then "ኢ"
3117 field.SetProperty( Actor::Property::SIZE, Vector2( fieldWidth ,10.0f ) );
3118 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
3119 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
3121 field.SetProperty( TextField::Property::TEXT, "ኢ");
3122 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3123 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3125 field.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
3126 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
3128 application.SendNotification();
3129 application.Render();
3131 previousHeight = field.GetHeightForWidth( fieldWidth );
3132 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
3134 // Add another script characters ( glyph height is defferent )
3135 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3136 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3138 application.SendNotification();
3139 application.Render();
3141 currentHeight = field.GetHeightForWidth( fieldWidth );
3142 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
3143 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
3148 int utcDaliTextFieldExtremlyLargePointSize(void)
3150 ToolkitTestApplication application;
3151 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
3153 TextField field = TextField::New();
3155 field.SetProperty( TextField::Property::TEXT, "Text" );
3156 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3157 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3158 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3159 application.GetScene().Add( field );
3163 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
3164 application.SendNotification();
3165 DALI_TEST_CHECK( field );
3169 tet_result(TET_FAIL);
3174 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
3176 ToolkitTestApplication application;
3177 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
3178 TextField field = TextField::New();
3179 DALI_TEST_CHECK( field );
3180 application.GetScene().Add( field );
3182 Property::Map fontStyleMapGet;
3184 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
3186 Property::Value* weightValue = NULL;
3187 Property::Value* widthValue = NULL;
3188 Property::Value* slantValue = NULL;
3189 weightValue = fontStyleMapGet.Find( "weight" );
3190 widthValue = fontStyleMapGet.Find( "width" );
3191 slantValue = fontStyleMapGet.Find( "slant" );
3192 DALI_TEST_CHECK( !weightValue );
3193 DALI_TEST_CHECK( !widthValue );
3194 DALI_TEST_CHECK( !slantValue );
3199 int UtcDaliTextFieldSettingPlaceholder(void)
3201 ToolkitTestApplication application;
3202 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
3204 TextField field = TextField::New();
3205 DALI_TEST_CHECK( field );
3206 application.GetScene().Add( field );
3208 // Check the placeholder property with pixel size
3209 Property::Map placeholderPixelSizeMapSet;
3210 Property::Map placeholderPixelSizeMapGet;
3211 Property::Map placeholderFontstyleMap;
3212 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
3213 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
3214 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
3215 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
3216 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
3217 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
3219 placeholderFontstyleMap.Insert( "weight", "bold" );
3220 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3221 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
3223 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3224 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
3225 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
3227 // Check the placeholder property with point size
3228 Property::Map placeholderMapSet;
3229 Property::Map placeholderMapGet;
3230 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
3231 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
3232 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
3233 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
3234 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
3235 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
3237 // Check the placeholder font style property
3238 placeholderFontstyleMap.Clear();
3240 placeholderFontstyleMap.Insert( "weight", "bold" );
3241 placeholderFontstyleMap.Insert( "width", "condensed" );
3242 placeholderFontstyleMap.Insert( "slant", "italic" );
3243 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3244 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3246 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3247 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3248 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3250 // Reset font style.
3251 placeholderFontstyleMap.Clear();
3252 placeholderFontstyleMap.Insert( "weight", "normal" );
3253 placeholderFontstyleMap.Insert( "slant", "oblique" );
3254 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3255 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3257 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3258 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3259 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3261 placeholderFontstyleMap.Clear();
3262 placeholderFontstyleMap.Insert( "slant", "roman" );
3263 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3264 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3266 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3268 placeholderFontstyleMap.Clear();
3269 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3271 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3272 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3273 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3274 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3279 int UtcDaliTextFieldPlaceholderCoverage(void)
3281 ToolkitTestApplication application;
3282 tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
3284 // mPlaceholderFont is created only once, so create a new control for coverage.
3285 TextField fieldForCoverage = TextField::New();
3286 DALI_TEST_CHECK(fieldForCoverage);
3287 application.GetScene().Add(fieldForCoverage);
3289 // for SetPlaceholderFontFamily() coverage.
3290 Property::Map fontFamilyMap;
3291 fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3292 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
3294 // mPlaceholderFont is created only once, so create a new control for coverage.
3295 fieldForCoverage = TextField::New();
3296 DALI_TEST_CHECK(fieldForCoverage);
3297 application.GetScene().Add(fieldForCoverage);
3299 // for SetPlaceholderTextFontSize coverage.
3300 Property::Map fontSizeMap;
3301 fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3302 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
3304 // mPlaceholderFont is created only once, so create a new control for coverage.
3305 fieldForCoverage = TextField::New();
3306 DALI_TEST_CHECK(fieldForCoverage);
3307 application.GetScene().Add(fieldForCoverage);
3309 // for SetPlaceholderTextFontWeight coverage.
3310 Property::Map fontStyleWeightMap;
3311 Property::Map fontStyleWeightPropertyMap;
3312 fontStyleWeightPropertyMap.Insert("weight", "bold");
3313 fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
3314 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
3316 // mPlaceholderFont is created only once, so create a new control for coverage.
3317 fieldForCoverage = TextField::New();
3318 DALI_TEST_CHECK(fieldForCoverage);
3319 application.GetScene().Add(fieldForCoverage);
3321 // for SetPlaceholderTextFontWidth coverage.
3322 Property::Map fontStyleWidthMap;
3323 Property::Map fontStyleWidthPropertyMap;
3324 fontStyleWidthPropertyMap.Insert("width", "expanded");
3325 fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
3326 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
3328 // mPlaceholderFont is created only once, so create a new control for coverage.
3329 fieldForCoverage = TextField::New();
3330 DALI_TEST_CHECK(fieldForCoverage);
3331 application.GetScene().Add(fieldForCoverage);
3333 // for SetPlaceholderTextFontSlant coverage.
3334 Property::Map fontStyleSlantMap;
3335 Property::Map fontStyleSlantPropertyMap;
3336 fontStyleSlantPropertyMap.Insert("slant", "italic");
3337 fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
3338 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
3343 int UtcDaliTextFieldSetPaddingProperty(void)
3345 ToolkitTestApplication application;
3346 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3348 TextField field = TextField::New();
3349 DALI_TEST_CHECK( field );
3350 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3351 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3352 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3353 application.GetScene().Add( field );
3355 application.SendNotification();
3356 application.Render();
3358 Vector3 originalSize = field.GetNaturalSize();
3360 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
3362 application.SendNotification();
3363 application.Render();
3365 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
3367 Vector3 paddingAddedSize = field.GetNaturalSize();
3369 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3371 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3376 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3378 ToolkitTestApplication application;
3379 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3381 TextField field = TextField::New();
3382 DALI_TEST_CHECK( field );
3383 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3384 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3385 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3386 application.GetScene().Add( field );
3388 application.SendNotification();
3389 application.Render();
3391 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3392 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
3394 // Check the enable shift selection property
3395 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
3396 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
3398 application.SendNotification();
3399 application.Render();
3404 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3406 ToolkitTestApplication application;
3407 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3409 TextField field = TextField::New();
3410 DALI_TEST_CHECK( field );
3411 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3412 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3413 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3414 application.GetScene().Add( field );
3416 application.SendNotification();
3417 application.Render();
3419 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3420 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
3422 // Check the enable grab handle property
3423 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
3424 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
3426 application.SendNotification();
3427 application.Render();
3432 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
3434 ToolkitTestApplication application;
3435 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
3437 TextField field = TextField::New();
3438 DALI_TEST_CHECK( field );
3439 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3440 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3441 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3442 application.GetScene().Add( field );
3444 application.SendNotification();
3445 application.Render();
3447 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3448 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
3450 // Check the match system language direction property
3451 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
3452 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
3454 application.SendNotification();
3455 application.Render();
3460 int utcDaliTextFieldLayoutDirectionCoverage(void)
3462 ToolkitTestApplication application;
3463 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
3465 // Creates a tap event. After creating a tap event the text field should
3466 // have the focus and add text with key events should be possible.
3467 TextField field = TextField::New();
3468 DALI_TEST_CHECK( field );
3470 application.GetScene().Add( field );
3472 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3473 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3474 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3476 // Avoid a crash when core load gl resources.
3477 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3479 // Render and notify
3480 application.SendNotification();
3481 application.Render();
3483 // init direction for coverage
3484 // Set horizontal alignment END
3485 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3487 // Create a tap event to touch the text field.
3488 TestGenerateTap( application, 150.0f, 25.0f );
3490 // Render and notify
3491 application.SendNotification();
3492 application.Render();
3494 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
3495 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
3496 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
3498 // Set horizontal alignment BEGIN
3499 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
3501 // Create a tap event to touch the text field.
3502 TestGenerateTap( application, 150.0f, 25.0f );
3504 // Render and notify
3505 application.SendNotification();
3506 application.Render();
3508 // Set horizontal alignment CENTER
3509 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
3511 // Create a tap event to touch the text field.
3512 TestGenerateTap( application, 150.0f, 25.0f );
3514 // Render and notify
3515 application.SendNotification();
3516 application.Render();
3518 // Set horizontal alignment END
3519 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3521 // Create a tap event to touch the text field.
3522 TestGenerateTap( application, 150.0f, 25.0f );
3524 // Render and notify
3525 application.SendNotification();
3526 application.Render();
3528 // Generate a Esc key event. The text field should lose the focus.
3529 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3530 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3532 // Render and notify
3533 application.SendNotification();
3534 application.Render();
3536 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
3541 int UtcDaliTextFieldGetInputMethodContext(void)
3543 ToolkitTestApplication application;
3544 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
3546 TextField field = TextField::New();
3547 DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );
3552 int UtcDaliTextFieldSelectWholeText(void)
3554 ToolkitTestApplication application;
3555 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3557 TextField textField = TextField::New();
3559 application.GetScene().Add( textField );
3561 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3562 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3563 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3565 // Avoid a crash when core load gl resources.
3566 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3568 application.SendNotification();
3569 application.Render();
3571 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
3573 DevelTextField::SelectWholeText( textField );
3575 application.SendNotification();
3576 application.Render();
3578 // Nothing should have been selected. The number of children is still 1
3579 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
3581 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3583 application.SendNotification();
3584 application.Render();
3586 DevelTextField::SelectWholeText( textField );
3588 application.SendNotification();
3589 application.Render();
3591 // Should be 2 children, the stencil and the layer
3592 DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
3594 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3595 Actor stencil = textField.GetChildAt( 0u );
3597 // The highlight actor is drawn first, so is the first actor in the list
3598 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3599 DALI_TEST_CHECK( highlight );
3604 int UtcDaliTextFieldSelectText(void)
3606 ToolkitTestApplication application;
3607 tet_infoline(" UtcDaliTextFieldSelectText ");
3609 TextField textField = TextField::New();
3611 application.GetScene().Add( textField );
3613 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3614 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3615 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3617 // Avoid a crash when core load gl resources.
3618 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3620 application.SendNotification();
3621 application.Render();
3623 DevelTextField::SelectText( textField, 0, 5 );
3625 application.SendNotification();
3626 application.Render();
3628 // Nothing is selected
3629 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3630 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3632 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3634 application.SendNotification();
3635 application.Render();
3637 // Hello is selected
3638 DevelTextField::SelectText( textField, 0, 5 );
3640 application.SendNotification();
3641 application.Render();
3643 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3644 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3646 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3647 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3649 // world is selected
3650 DevelTextField::SelectText( textField, 6, 11 );
3652 application.SendNotification();
3653 application.Render();
3655 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3656 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3658 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3659 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3664 int UtcDaliTextFieldSelectNone(void)
3666 ToolkitTestApplication application;
3667 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3669 TextField textField = TextField::New();
3671 application.GetScene().Add( textField );
3673 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3674 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3675 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3677 // Avoid a crash when core load gl resources.
3678 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3680 application.SendNotification();
3681 application.Render();
3683 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3685 application.SendNotification();
3686 application.Render();
3688 // Nothing is selected
3689 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3690 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3692 DevelTextField::SelectWholeText( textField );
3694 application.SendNotification();
3695 application.Render();
3697 // whole text is selected
3698 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3699 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3701 DevelTextField::SelectNone( textField );
3703 application.SendNotification();
3704 application.Render();
3706 // Nothing is selected
3707 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3708 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3713 int UtcDaliTextFieldSelectRange(void)
3715 ToolkitTestApplication application;
3716 tet_infoline(" UtcDaliTextFieldSelectRange ");
3718 TextField textField = TextField::New();
3720 application.GetScene().Add( textField );
3722 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3723 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3724 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3726 // Avoid a crash when core load gl resources.
3727 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3729 application.SendNotification();
3730 application.Render();
3732 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3734 application.SendNotification();
3735 application.Render();
3737 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 0);
3738 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 5);
3740 // Hello is selected
3741 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3742 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3744 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3745 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3747 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 6);
3748 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 11);
3750 // world is selected
3751 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3752 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3754 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3755 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3760 int UtcDaliTextFieldEnableEditing(void)
3762 ToolkitTestApplication application;
3763 tet_infoline(" UtcDaliTextFieldEnableEditing ");
3765 TextField textField = TextField::New();
3767 application.GetScene().Add( textField );
3769 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3770 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3771 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3773 // Avoid a crash when core load gl resources.
3774 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3776 application.SendNotification();
3777 application.Render();
3779 textField.SetKeyInputFocus();
3780 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, false );
3781 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3783 // Render and notify
3784 application.SendNotification();
3785 application.Render();
3787 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3788 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3791 textField.SetKeyInputFocus();
3792 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
3793 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3795 // Render and notify
3796 application.SendNotification();
3797 application.Render();
3799 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3800 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3805 int UtcDaliToolkitTextFieldFontSizeScale(void)
3807 ToolkitTestApplication application;
3808 tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
3810 TextField textField = TextField::New();
3811 textField.SetProperty( TextField::Property::POINT_SIZE, 30.f );
3812 textField.SetProperty( TextField::Property::TEXT, "Test" );
3813 Vector3 nonScaledSize = textField.GetNaturalSize();
3815 TextField textFieldScaled = TextField::New();
3816 textFieldScaled.SetProperty( TextField::Property::POINT_SIZE, 15.f );
3817 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3818 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3819 Vector3 scaledSize = textFieldScaled.GetNaturalSize();
3821 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3823 textField.SetProperty( TextField::Property::PIXEL_SIZE, 30.f );
3824 textField.SetProperty( TextField::Property::TEXT, "Test" );
3825 nonScaledSize = textField.GetNaturalSize();
3827 textFieldScaled.SetProperty( TextField::Property::PIXEL_SIZE, 15.f );
3828 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3829 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3830 scaledSize = textFieldScaled.GetNaturalSize();
3832 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3837 int UtcDaliTextFieldPrimaryCursorPosition(void)
3839 ToolkitTestApplication application;
3840 tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
3842 TextField textField = TextField::New();
3844 application.GetScene().Add( textField );
3846 textField.SetProperty( TextField::Property::TEXT, "ABCEF");
3847 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3848 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3849 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3851 // Avoid a crash when core load gl resources.
3852 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3854 textField.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
3855 application.SendNotification();
3856 application.Render();
3857 textField.SetKeyInputFocus();
3859 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3861 // Render and notify
3862 application.SendNotification();
3863 application.Render();
3865 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3866 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3871 // test max length when set after setting long text
3872 int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
3874 ToolkitTestApplication application;
3875 tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
3876 TextField field = TextField::New();
3877 DALI_TEST_CHECK( field );
3879 application.GetScene().Add( field );
3881 field.SetProperty(TextField::Property::TEXT, "123456789");
3883 const int maxNumberOfCharacters = 3;
3884 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
3886 field.SetKeyInputFocus();
3888 // connect to the text max lengh reached signal.
3889 ConnectionTracker* testTracker = new ConnectionTracker();
3890 bool maxLengthReachedSignal = false;
3891 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
3893 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3894 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3896 DALI_TEST_CHECK( maxLengthReachedSignal );
3898 DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "123456789", TEST_LOCATION );
3905 int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
3907 ToolkitTestApplication application;
3908 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
3910 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3911 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3912 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3914 // Create a text field
3915 TextField textField = TextField::New();
3917 //Set size to avoid automatic eliding
3918 textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3919 //Set very large font-size using point-size
3920 textField.SetProperty( TextField::Property::POINT_SIZE, 1000) ;
3921 //Specify font-family
3922 textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
3923 //Set text to check if appear or not
3924 textField.SetProperty( TextField::Property::TEXT, "A");
3926 application.GetScene().Add( textField );
3928 application.SendNotification();
3929 application.Render();
3930 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3931 Vector3 naturalSize = textField.GetNaturalSize();
3933 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3934 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3939 int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
3941 ToolkitTestApplication application;
3942 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
3944 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3945 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3946 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3948 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3949 // Create a text editor
3950 TextField textField = TextField::New();
3952 //Set size to avoid automatic eliding
3953 textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3954 textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
3955 textField.SetProperty( TextField::Property::TEXT, "A");
3957 const int numberOfCases = 6;
3958 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
3960 for (int index=0; index < numberOfCases; index++)
3962 tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
3963 textField.SetProperty( TextField::Property::POINT_SIZE, arrayCases[index]) ;
3964 application.GetScene().Add( textField );
3965 application.SendNotification();
3966 application.Render();
3967 naturalSize = textField.GetNaturalSize();
3968 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3969 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3976 int UtcDaliToolkitTextFieldEllipsisPositionProperty(void)
3978 ToolkitTestApplication application;
3979 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty ");
3980 TextField textField = TextField::New();
3982 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Default is END");
3983 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3985 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START");
3986 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
3987 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3989 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE");
3990 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
3991 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3993 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END");
3994 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
3995 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3997 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START using integer");
3998 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 1);
3999 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4001 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE using integer");
4002 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 2);
4003 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4005 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END using integer");
4006 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 0);
4007 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4009 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4010 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "START");
4011 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4013 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4014 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "MIDDLE");
4015 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4017 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4018 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "END");
4019 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4021 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4022 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "start");
4023 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4025 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4026 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "middle");
4027 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4029 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4030 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "end");
4031 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4036 int UtcDaliTextFieldCopyText(void)
4038 ToolkitTestApplication application;
4039 tet_infoline(" UtcDaliTextFieldCopyText ");
4041 TextField textField = TextField::New();
4043 std::string selectedText = "";
4044 std::string copiedText = "";
4046 application.GetScene().Add( textField );
4048 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4049 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4050 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4052 // Avoid a crash when core load gl resources.
4053 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4055 application.SendNotification();
4056 application.Render();
4058 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
4060 application.SendNotification();
4061 application.Render();
4063 // Hello is selected
4064 DevelTextField::SelectText( textField, 0, 5 );
4066 application.SendNotification();
4067 application.Render();
4069 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4070 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4072 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4073 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4076 copiedText = DevelTextField::CopyText( textField );
4077 DALI_TEST_EQUALS( "Hello", copiedText, TEST_LOCATION );
4079 // world is selected
4080 DevelTextField::SelectText( textField, 6, 11 );
4082 application.SendNotification();
4083 application.Render();
4085 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4086 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
4088 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
4089 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
4092 copiedText = DevelTextField::CopyText( textField );
4093 DALI_TEST_EQUALS( "world", copiedText, TEST_LOCATION );
4095 // "lo wo" is selected
4096 DevelTextField::SelectText( textField, 3, 8 );
4098 application.SendNotification();
4099 application.Render();
4101 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4102 DALI_TEST_EQUALS( "lo wo", selectedText, TEST_LOCATION );
4104 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 3, TEST_LOCATION );
4105 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 8, TEST_LOCATION );
4107 // "lo wo" is copied
4108 copiedText = DevelTextField::CopyText( textField );
4109 DALI_TEST_EQUALS( "lo wo", copiedText, TEST_LOCATION );
4114 int UtcDaliTextFieldCutText(void)
4116 ToolkitTestApplication application;
4117 tet_infoline(" UtcDaliTextFieldCutText ");
4119 TextField textField = TextField::New();
4121 std::string selectedText = "";
4123 application.GetScene().Add( textField );
4125 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4126 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4127 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4129 // Avoid a crash when core load gl resources.
4130 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4132 application.SendNotification();
4133 application.Render();
4135 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
4137 application.SendNotification();
4138 application.Render();
4140 // Hello is selected
4141 DevelTextField::SelectText( textField, 0, 5 );
4143 application.SendNotification();
4144 application.Render();
4146 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4147 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4149 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4150 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4153 DALI_TEST_EQUALS( "Hello", DevelTextField::CutText( textField ), TEST_LOCATION );
4155 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), " world", TEST_LOCATION );
4158 DevelTextField::SelectText( textField, 0, 2 );
4160 application.SendNotification();
4161 application.Render();
4163 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4164 DALI_TEST_EQUALS( " w", selectedText, TEST_LOCATION );
4166 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4167 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4170 DALI_TEST_EQUALS( " w", DevelTextField::CutText( textField ), TEST_LOCATION );
4172 application.SendNotification();
4173 application.Render();
4175 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "orld", TEST_LOCATION );
4177 // Test Cut from the middle
4180 DevelTextField::SelectText( textField, 1, 3 );
4182 application.SendNotification();
4183 application.Render();
4185 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4186 DALI_TEST_EQUALS( "rl", selectedText, TEST_LOCATION );
4188 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4189 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 3, TEST_LOCATION );
4192 DALI_TEST_EQUALS( "rl", DevelTextField::CutText( textField ), TEST_LOCATION );
4194 application.SendNotification();
4195 application.Render();
4197 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "od", TEST_LOCATION );
4199 // Test Cut from the end
4202 DevelTextField::SelectText( textField, 1, 2 );
4204 application.SendNotification();
4205 application.Render();
4207 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4208 DALI_TEST_EQUALS( "d", selectedText, TEST_LOCATION );
4210 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4211 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4214 DALI_TEST_EQUALS( "d", DevelTextField::CutText( textField ), TEST_LOCATION );
4216 application.SendNotification();
4217 application.Render();
4219 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "o", TEST_LOCATION );
4224 int UtcDaliTextFieldPasteText(void)
4226 ToolkitTestApplication application;
4227 tet_infoline(" UtcDaliTextFieldPasteText ");
4229 TextField textField = TextField::New();
4231 application.GetScene().Add( textField );
4233 std::string cutText = "";
4234 std::string copiedText = "";
4236 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4237 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4238 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4240 // Avoid a crash when core load gl resources.
4241 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4243 application.SendNotification();
4244 application.Render();
4246 textField.SetProperty( TextField::Property::TEXT, "Hello World" );
4248 application.SendNotification();
4249 application.Render();
4251 // Tap on the text editor
4252 TestGenerateTap( application, 3.0f, 25.0f );
4254 // Render and notify
4255 application.SendNotification();
4256 application.Render();
4258 // Select some text in the right of the current cursor position
4259 DevelTextField::SelectText( textField, 0, 3 );
4261 // Render and notify
4262 application.SendNotification();
4263 application.Render();
4265 // Cut the selected text
4266 cutText = DevelTextField::CutText(textField);
4268 // Render and notify
4269 application.SendNotification();
4270 application.Render();
4272 DALI_TEST_EQUALS( "Hel", cutText, TEST_LOCATION );
4273 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "lo World", TEST_LOCATION );
4275 DevelTextField::SelectText( textField, 0, 3 );
4277 // Render and notify
4278 application.SendNotification();
4279 application.Render();
4281 // Copy the selected text
4282 copiedText = DevelTextField::CopyText(textField);
4284 // Render and notify
4285 application.SendNotification();
4286 application.Render();
4288 DALI_TEST_EQUALS( "lo ", copiedText, TEST_LOCATION );
4289 DALI_TEST_EQUALS( "lo World", textField.GetProperty<std::string>( TextField::Property::TEXT ), TEST_LOCATION );
4291 // Move the cursor to the end of the line
4292 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4293 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4294 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4295 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4296 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4297 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4298 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4299 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4301 // Render and notify
4302 application.SendNotification();
4303 application.Render();
4305 // Paste the selected text at the current cursor position
4306 DevelTextField::PasteText(textField);
4308 // Render and notify
4309 application.SendNotification();
4310 application.Render();
4312 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "lo Worldlo ", TEST_LOCATION );
4316 int utcDaliTextFieldCursorPositionChangedSignal(void)
4318 ToolkitTestApplication application;
4319 tet_infoline(" utcDaliTextFieldCursorPositionChangedSignal");
4321 TextField field = TextField::New();
4322 DALI_TEST_CHECK( field );
4324 application.GetScene().Add( field );
4326 // connect to the selection changed signal.
4327 ConnectionTracker* testTracker = new ConnectionTracker();
4328 DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
4329 bool cursorPositionChangedSignal = false;
4330 field.ConnectSignal( testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal) );
4332 field.SetProperty( TextField::Property::TEXT, "Hello world Hello world" );
4333 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
4334 field.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4335 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4336 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4338 // Avoid a crash when core load gl resources.
4339 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4341 // Render and notify
4342 application.SendNotification();
4343 application.Render();
4345 field.SetKeyInputFocus();
4347 // Tap on the text field
4348 TestGenerateTap( application, 3.0f, 25.0f );
4350 // Render and notify
4351 application.SendNotification();
4352 application.Render();
4354 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4355 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4357 gCursorPositionChangedCallbackCalled = false;
4360 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4362 // Render and notify
4363 application.SendNotification();
4364 application.Render();
4366 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4367 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4369 gCursorPositionChangedCallbackCalled = false;
4372 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4374 // Render and notify
4375 application.SendNotification();
4376 application.Render();
4378 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4379 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4381 gCursorPositionChangedCallbackCalled = false;
4383 //delete one character
4384 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4386 // Render and notify
4387 application.SendNotification();
4388 application.Render();
4390 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4391 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4393 gCursorPositionChangedCallbackCalled = false;
4395 field.SetProperty( TextField::Property::TEXT, "Hello" );
4397 // Render and notify
4398 application.SendNotification();
4399 application.Render();
4401 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4402 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4404 gCursorPositionChangedCallbackCalled = false;
4406 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4408 // Render and notify
4409 application.SendNotification();
4410 application.Render();
4412 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4413 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4418 int utcDaliTextFieldGeometryEllipsisStart(void)
4420 ToolkitTestApplication application;
4421 tet_infoline(" utcDaliTextFieldGeometryEllipsisStart");
4423 TextField field = TextField::New();
4424 DALI_TEST_CHECK( field );
4426 application.GetScene().Add( field );
4428 field.SetProperty( TextField::Property::POINT_SIZE, 7.f );
4429 field.SetProperty( Actor::Property::SIZE, Vector2( 250.f, 50.f ) );
4430 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4431 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4432 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
4433 field.SetProperty( DevelTextField::Property::ELLIPSIS, true );
4434 field.SetProperty( DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START );
4435 field.SetProperty( TextField::Property::TEXT, "Hello World" );
4437 // Avoid a crash when core load gl resources.
4438 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4440 // Render and notify
4441 application.SendNotification();
4442 application.Render();
4444 unsigned int expectedCount = 1;
4445 unsigned int startIndex = 0;
4446 unsigned int endIndex = 10;
4448 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4449 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4451 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4452 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4454 Vector<Vector2> expectedSizes;
4455 Vector<Vector2> expectedPositions;
4457 expectedPositions.PushBack(Vector2(14, 0));
4458 expectedSizes.PushBack(Vector2(106, 25));
4460 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4465 int utcDaliTextFieldGeometryEllipsisEnd(void)
4467 ToolkitTestApplication application;
4468 tet_infoline(" utcDaliTextFieldGeometryEllipsisEnd");
4470 TextField field = TextField::New();
4471 DALI_TEST_CHECK( field );
4473 application.GetScene().Add( field );
4475 field.SetProperty( TextField::Property::POINT_SIZE, 7.f );
4476 field.SetProperty( Actor::Property::SIZE, Vector2( 250.f, 50.f ) );
4477 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4478 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4479 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
4480 field.SetProperty( DevelTextField::Property::ELLIPSIS, true );
4481 field.SetProperty( DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END );
4482 field.SetProperty( TextField::Property::TEXT, "Hello World" );
4484 // Avoid a crash when core load gl resources.
4485 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4487 // Render and notify
4488 application.SendNotification();
4489 application.Render();
4491 unsigned int expectedCount = 1;
4492 unsigned int startIndex = 0;
4493 unsigned int endIndex = 10;
4495 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4496 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4498 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4499 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4501 Vector<Vector2> expectedSizes;
4502 Vector<Vector2> expectedPositions;
4504 expectedPositions.PushBack(Vector2(-2, 0));
4505 expectedSizes.PushBack(Vector2(122, 25));
4507 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4512 int utcDaliTextFieldGeometryRTL(void)
4514 ToolkitTestApplication application;
4515 tet_infoline(" utcDaliTextFieldGeometryRTL");
4517 TextField field = TextField::New();
4518 DALI_TEST_CHECK( field );
4520 application.GetScene().Add( field );
4522 field.SetProperty( TextField::Property::POINT_SIZE, 7.f );
4523 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4524 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4525 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4526 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
4527 field.SetProperty( TextField::Property::TEXT, "السطر الاخير" );
4529 // Avoid a crash when core load gl resources.
4530 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4532 // Render and notify
4533 application.SendNotification();
4534 application.Render();
4536 unsigned int expectedCount = 1;
4537 unsigned int startIndex = 1;
4538 unsigned int endIndex = 7;
4540 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4541 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4543 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4544 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4546 Vector<Vector2> expectedSizes;
4547 Vector<Vector2> expectedPositions;
4549 expectedPositions.PushBack(Vector2(38, 0));
4550 expectedSizes.PushBack(Vector2(73, 25));
4552 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4557 int utcDaliTextFieldGeometryGlyphMiddle(void)
4559 ToolkitTestApplication application;
4560 tet_infoline(" utcDaliTextFieldGeometryGlyphMiddle");
4562 TextField field = TextField::New();
4563 DALI_TEST_CHECK( field );
4565 application.GetScene().Add( field );
4567 field.SetProperty( TextField::Property::POINT_SIZE, 7.f );
4568 field.SetProperty( Actor::Property::SIZE, Vector2( 150.f, 200.f ) );
4569 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4570 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4571 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
4572 field.SetProperty( TextField::Property::TEXT, "لا تحتوي على لا" );
4574 // Avoid a crash when core load gl resources.
4575 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4577 // Render and notify
4578 application.SendNotification();
4579 application.Render();
4581 unsigned int expectedCount = 1;
4582 unsigned int startIndex = 1;
4583 unsigned int endIndex = 13;
4585 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4586 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4588 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4589 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4591 Vector<Vector2> expectedSizes;
4592 Vector<Vector2> expectedPositions;
4594 expectedPositions.PushBack(Vector2(6, 0));
4595 expectedSizes.PushBack(Vector2(124, 25));
4597 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4602 int utcDaliTextFieldSelectionClearedSignal(void)
4604 ToolkitTestApplication application;
4605 tet_infoline(" utcDaliTextFieldSelectionClearedSignal");
4607 TextField field = TextField::New();
4608 DALI_TEST_CHECK( field );
4610 application.GetScene().Add( field );
4612 // connect to the selection changed signal.
4613 ConnectionTracker* testTracker = new ConnectionTracker();
4614 DevelTextField::SelectionClearedSignal(field).Connect(&TestSelectionClearedCallback);
4615 bool selectionClearedSignal = false;
4616 field.ConnectSignal( testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal) );
4618 field.SetProperty( TextField::Property::TEXT, "Hello\nworld\nHello world" );
4619 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
4620 field.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4621 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4622 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4624 // Avoid a crash when core load gl resources.
4625 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4627 // Render and notify
4628 application.SendNotification();
4629 application.Render();
4631 // Tap on the text editor
4632 TestGenerateTap( application, 3.0f, 25.0f );
4634 // Render and notify
4635 application.SendNotification();
4636 application.Render();
4638 // Move to second line of the text & Select some text in the right of the current cursor position
4639 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4640 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4643 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4645 // Render and notify
4646 application.SendNotification();
4647 application.Render();
4649 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4651 // Render and notify
4652 application.SendNotification();
4653 application.Render();
4655 // Tap on the text editor
4656 TestGenerateTap( application, 3.0f, 25.0f );
4658 // Render and notify
4659 application.SendNotification();
4660 application.Render();
4662 gSelectionClearedCallbackCalled = false;
4664 // Move to second line of the text & select.
4665 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4666 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4669 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4671 // Render and notify
4672 application.SendNotification();
4673 application.Render();
4675 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4677 gSelectionClearedCallbackCalled = false;
4679 // Render and notify
4680 application.SendNotification();
4681 application.Render();
4683 // Move to second line of the text & select.
4684 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4685 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4687 // replace D with selected text
4688 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4690 // Render and notify
4691 application.SendNotification();
4692 application.Render();
4694 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4696 gSelectionClearedCallbackCalled = false;
4698 // Render and notify
4699 application.SendNotification();
4700 application.Render();
4702 DevelTextField::SelectText( field ,1, 3 );
4704 // Render and notify
4705 application.SendNotification();
4706 application.Render();
4708 field.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4710 // Render and notify
4711 application.SendNotification();
4712 application.Render();
4714 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4716 gSelectionClearedCallbackCalled = false;
4718 DevelTextField::SelectText( field ,1, 3 );
4720 // Render and notify
4721 application.SendNotification();
4722 application.Render();
4725 DevelTextField::SelectNone(field);
4727 // Render and notify
4728 application.SendNotification();
4729 application.Render();
4731 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4736 int utcDaliTextFieldSelectionChangedSignal(void)
4738 ToolkitTestApplication application;
4739 tet_infoline(" utcDaliTextFieldSelectionChangedSignal");
4741 TextField field = TextField::New();
4742 DALI_TEST_CHECK( field );
4744 application.GetScene().Add( field );
4746 // connect to the selection changed signal.
4747 ConnectionTracker* testTracker = new ConnectionTracker();
4748 DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
4749 bool selectionChangedSignal = false;
4750 field.ConnectSignal( testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal) );
4752 field.SetProperty( TextField::Property::TEXT, "Hello world Hello world" );
4753 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
4754 field.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4755 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4756 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4758 // Avoid a crash when core load gl resources.
4759 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4761 // Render and notify
4762 application.SendNotification();
4763 application.Render();
4765 // Tap on the text field
4766 TestGenerateTap( application, 3.0f, 25.0f );
4768 // Render and notify
4769 application.SendNotification();
4770 application.Render();
4772 // Select some text in the right of the current cursor position
4773 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4774 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4776 // Render and notify
4777 application.SendNotification();
4778 application.Render();
4780 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4781 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4783 gSelectionChangedCallbackCalled = false;
4785 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4787 // Render and notify
4788 application.SendNotification();
4789 application.Render();
4791 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4792 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4793 DALI_TEST_EQUALS(oldSelectionEnd, 1, TEST_LOCATION);
4795 gSelectionChangedCallbackCalled = false;
4797 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4799 // Render and notify
4800 application.SendNotification();
4801 application.Render();
4803 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4804 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4805 DALI_TEST_EQUALS(oldSelectionEnd, 2, TEST_LOCATION);
4807 gSelectionChangedCallbackCalled = false;
4808 field.SetKeyInputFocus();
4810 // Render and notify
4811 application.SendNotification();
4812 application.Render();
4814 DevelTextField::SelectText( field ,0, 5 );
4816 application.SendNotification();
4817 application.Render();
4819 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4820 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4822 gSelectionChangedCallbackCalled = false;
4824 field.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4826 // Render and notify
4827 application.SendNotification();
4828 application.Render();
4830 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4831 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4832 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
4834 gSelectionChangedCallbackCalled = false;
4837 DevelTextField::SelectWholeText(field);
4839 // Render and notify
4840 application.SendNotification();
4841 application.Render();
4843 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4844 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4846 gSelectionChangedCallbackCalled = false;
4849 DevelTextField::SelectNone(field);
4851 // Render and notify
4852 application.SendNotification();
4853 application.Render();
4855 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4856 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4857 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
4862 int UtcDaliToolkitTextFieldStrikethroughGeneration(void)
4864 ToolkitTestApplication application;
4865 tet_infoline(" UtcDaliToolkitTextFieldStrikethroughGeneration");
4867 TextField textField = TextField::New();
4868 textField.SetProperty( TextField::Property::TEXT, "Test" );
4869 textField.SetProperty( Actor::Property::SIZE, Vector2( 200.0f, 100.f ) );
4870 textField.SetProperty( TextField::Property::POINT_SIZE, 10) ;
4871 textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
4873 application.GetScene().Add( textField );
4874 application.SendNotification();
4875 application.Render();
4877 Property::Map strikethroughMapSet;
4878 Property::Map strikethroughMapGet;
4880 strikethroughMapSet.Insert( "enable", true );
4881 strikethroughMapSet.Insert( "color", Color::RED );
4882 strikethroughMapSet.Insert( "height", 2.0f );
4884 // Check the strikethrough property
4885 textField.SetProperty( DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet );
4886 strikethroughMapGet = textField.GetProperty<Property::Map>( DevelTextField::Property::STRIKETHROUGH );
4887 textField.SetProperty( TextField::Property::TEXT, "Test1" );
4888 DALI_TEST_EQUALS( strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION );
4889 DALI_TEST_EQUALS( DaliTestCheckMaps( strikethroughMapGet, strikethroughMapSet ), true, TEST_LOCATION );
4891 // Render and notify
4892 application.SendNotification();
4893 application.Render();
4895 strikethroughMapSet.Clear();
4896 strikethroughMapGet.Clear();
4901 int UtcDaliToolkitTextFieldInputStrikethroughGeneration(void)
4903 ToolkitTestApplication application;
4904 tet_infoline(" UtcDaliToolkitTextFieldInputStrikethroughGeneration");
4906 TextField textField = TextField::New();
4907 textField.SetProperty( TextField::Property::TEXT, "Test" );
4908 textField.SetProperty( Actor::Property::SIZE, Vector2( 200.0f, 100.f ) );
4909 textField.SetProperty( TextField::Property::POINT_SIZE, 10) ;
4910 textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
4912 application.GetScene().Add( textField );
4913 application.SendNotification();
4914 application.Render();
4916 std::string strikethroughSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}" );
4918 // Check the strikethrough property
4919 textField.SetProperty( DevelTextField::Property::INPUT_STRIKETHROUGH, strikethroughSettings1 );
4920 textField.SetProperty( TextField::Property::TEXT, "Test1" );
4921 DALI_TEST_EQUALS( textField.GetProperty<std::string>( DevelTextField::Property::INPUT_STRIKETHROUGH ), strikethroughSettings1, TEST_LOCATION );
4923 // Render and notify
4924 application.SendNotification();
4925 application.Render();