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";
99 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
100 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
101 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
102 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
103 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
104 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
105 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
106 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
107 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
108 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
109 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
110 const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE = "enableFontSizeScale";
111 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
112 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
114 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
115 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
117 const float RENDER_FRAME_INTERVAL = 16.66f;
119 const unsigned int DEFAULT_FONT_SIZE = 1152u;
120 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
122 const int KEY_RETURN_CODE = 36;
123 const int KEY_A_CODE = 38;
124 const int KEY_D_CODE = 40;
125 const int KEY_SHIFT_MODIFIER = 257;
127 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
129 static bool gSelectionChangedCallbackCalled;
130 static uint32_t oldSelectionStart;
131 static uint32_t oldSelectionEnd;
132 static bool gSelectionClearedCallbackCalled;
133 static bool gAnchorClickedCallBackCalled;
134 static bool gAnchorClickedCallBackNotCalled;
135 static bool gTextChangedCallBackCalled;
136 static bool gMaxCharactersCallBackCalled;
137 static bool gInputFilteredAcceptedCallbackCalled;
138 static bool gInputFilteredRejectedCallbackCalled;
139 static bool gInputStyleChangedCallbackCalled;
140 static bool gCursorPositionChangedCallbackCalled;
141 static uint32_t oldCursorPos;
142 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
144 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
146 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
147 Integration::ResourcePointer resource(bitmap);
148 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
151 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
155 LoadBitmapResource( app.GetPlatform(), width, height );
157 Property::Map propertyMap;
158 propertyMap["filename"] = "image.png";
159 propertyMap["width"] = width;
160 propertyMap["height"] = height;
161 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
162 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
163 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
164 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
165 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
166 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
167 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
168 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
172 * Simulate time passed by.
174 * @note this will always process at least 1 frame (1/60 sec)
176 * @param application Test application instance
177 * @param duration Time to pass in milliseconds.
178 * @return The actual time passed in milliseconds
180 static int Wait(ToolkitTestApplication& application, int duration = 0)
184 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
186 application.SendNotification();
187 application.Render(RENDER_FRAME_INTERVAL);
188 time += RENDER_FRAME_INTERVAL;
194 Dali::Integration::Point GetPointDownInside( Vector2& pos )
196 Dali::Integration::Point point;
197 point.SetState( PointState::DOWN );
198 point.SetScreenPosition( pos );
202 Dali::Integration::Point GetPointUpInside( Vector2& pos )
204 Dali::Integration::Point point;
205 point.SetState( PointState::UP );
206 point.SetScreenPosition( pos );
210 struct CallbackFunctor
212 CallbackFunctor(bool* callbackFlag)
213 : mCallbackFlag( callbackFlag )
219 *mCallbackFlag = true;
224 static void TestSelectionClearedCallback(TextField control)
226 tet_infoline(" TestSelectionClearedCallback");
228 gSelectionClearedCallbackCalled = true;
231 static void TestSelectionChangedCallback(TextField control, uint32_t oldStart, uint32_t oldEnd)
233 tet_infoline(" TestSelectionChangedCallback");
235 gSelectionChangedCallbackCalled = true;
236 oldSelectionStart = oldStart;
237 oldSelectionEnd = oldEnd;
240 static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength)
242 tet_infoline(" TestAnchorClickedCallback");
244 gAnchorClickedCallBackNotCalled = false;
246 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
248 gAnchorClickedCallBackCalled = true;
252 static void TestCursorPositionChangedCallback( TextField control, unsigned int oldPos )
254 tet_infoline(" TestCursorPositionChangedCallback");
256 gCursorPositionChangedCallbackCalled = true;
257 oldCursorPos = oldPos;
260 static void TestTextChangedCallback( TextField control )
262 tet_infoline(" TestTextChangedCallback");
264 gTextChangedCallBackCalled = true;
267 static void TestMaxLengthReachedCallback( TextField control )
269 tet_infoline(" TestMaxLengthReachedCallback");
271 gMaxCharactersCallBackCalled = true;
274 static void TestInputFilteredCallback(TextField control, Toolkit::InputFilter::Property::Type type)
276 tet_infoline(" TestInputFilteredCallback");
278 if(type == Toolkit::InputFilter::Property::ACCEPTED)
280 gInputFilteredAcceptedCallbackCalled = true;
282 else if(type == Toolkit::InputFilter::Property::REJECTED)
284 gInputFilteredRejectedCallbackCalled = true;
288 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
290 tet_infoline(" TestInputStyleChangedCallback");
292 gInputStyleChangedCallbackCalled = true;
293 gInputStyleMask = mask;
296 // Generate a KeyEvent to send to Core.
297 Integration::KeyEvent GenerateKey( const std::string& keyName,
298 const std::string& logicalKey,
299 const std::string& keyString,
302 unsigned long timeStamp,
303 const Integration::KeyEvent::State& keyState,
304 const std::string& compose = "",
305 const std::string& deviceName = DEFAULT_DEVICE_NAME,
306 const Device::Class::Type& deviceClass = Device::Class::NONE,
307 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
309 return Integration::KeyEvent( keyName,
322 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
324 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
326 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
328 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
330 Property::Value* valueSet = NULL;
331 if ( valueGet.first.type == Property::Key::INDEX )
333 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
337 // Get Key is a string so searching Set Map for a string key
338 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
341 if( NULL != valueSet )
343 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
345 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
348 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
350 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
353 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
355 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
358 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
360 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
363 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
365 Vector2 vector2Get = valueGet.second.Get<Vector2>();
366 Vector2 vector2Set = valueSet->Get<Vector2>();
367 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
370 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
372 Vector4 vector4Get = valueGet.second.Get<Vector4>();
373 Vector4 vector4Set = valueSet->Get<Vector4>();
374 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 );
380 if ( valueGet.first.type == Property::Key::INDEX )
382 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
386 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
398 int UtcDaliToolkitTextFieldConstructorP(void)
400 ToolkitTestApplication application;
401 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
403 DALI_TEST_CHECK( !textField );
407 int UtcDaliToolkitTextFieldNewP(void)
409 ToolkitTestApplication application;
410 tet_infoline(" UtcDaliToolkitTextFieldNewP");
411 TextField textField = TextField::New();
412 DALI_TEST_CHECK( textField );
416 int UtcDaliToolkitTextFieldDownCastP(void)
418 ToolkitTestApplication application;
419 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
420 TextField textField1 = TextField::New();
421 BaseHandle object( textField1 );
423 TextField textField2 = TextField::DownCast( object );
424 DALI_TEST_CHECK( textField2 );
426 TextField textField3 = DownCast< TextField >( object );
427 DALI_TEST_CHECK( textField3 );
431 int UtcDaliToolkitTextFieldDownCastN(void)
433 ToolkitTestApplication application;
434 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
435 BaseHandle uninitializedObject;
436 TextField textField1 = TextField::DownCast( uninitializedObject );
437 DALI_TEST_CHECK( !textField1 );
439 TextField textField2 = DownCast< TextField >( uninitializedObject );
440 DALI_TEST_CHECK( !textField2 );
444 int UtcDaliToolkitTextFieldCopyConstructorP(void)
446 ToolkitTestApplication application;
447 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
448 TextField textField = TextField::New();
449 textField.SetProperty( TextField::Property::TEXT, "Test" );
451 TextField copy( textField );
452 DALI_TEST_CHECK( copy );
453 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
457 int UtcDaliTextFieldMoveConstructor(void)
459 ToolkitTestApplication application;
461 TextField textField = TextField::New();
462 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
463 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
465 TextField moved = std::move( textField );
466 DALI_TEST_CHECK( moved );
467 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
468 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
469 DALI_TEST_CHECK( !textField );
474 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
476 ToolkitTestApplication application;
477 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
478 TextField textField = TextField::New();
479 textField.SetProperty( TextField::Property::TEXT, "Test" );
481 TextField copy = textField;
482 DALI_TEST_CHECK( copy );
483 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
487 int UtcDaliTextFieldMoveAssignment(void)
489 ToolkitTestApplication application;
491 TextField textField = TextField::New();
492 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
493 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
496 moved = std::move( textField );
497 DALI_TEST_CHECK( moved );
498 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
499 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
500 DALI_TEST_CHECK( !textField );
505 int UtcDaliTextFieldNewP(void)
507 ToolkitTestApplication application;
508 tet_infoline(" UtcDaliToolkitTextFieldNewP");
509 TextField textField = TextField::New();
510 DALI_TEST_CHECK( textField );
514 // Positive test case for a method
515 int UtcDaliTextFieldGetPropertyP(void)
517 ToolkitTestApplication application;
518 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
519 TextField field = TextField::New();
520 DALI_TEST_CHECK( field );
522 // Check Property Indices are correct
523 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextField::Property::RENDERING_BACKEND );
524 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
525 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
526 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
527 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
528 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
529 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
530 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
531 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
532 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
533 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
534 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
535 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
536 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
537 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
538 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
539 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
540 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
541 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
542 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
543 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
544 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
545 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
546 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
547 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
548 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
549 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
550 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
551 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
552 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
553 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
554 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
555 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
556 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
557 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
558 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
559 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
560 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
561 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
562 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
563 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
564 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
565 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
566 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
567 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
568 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
569 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
570 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
571 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
572 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
573 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextField::Property::FONT_SIZE_SCALE );
574 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE ) == DevelTextField::Property::ENABLE_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 );
586 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
589 Property::Map imageMap;
590 imageMap[mapKey] =mapValue;
592 field.SetProperty( property , imageMap );
593 Property::Value propValue = field.GetProperty( property );
594 Property::Map* resultMap = propValue.GetMap();
596 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
604 // Positive test case for a method
605 int UtcDaliTextFieldSetPropertyP(void)
607 ToolkitTestApplication application;
608 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
609 TextField field = TextField::New();
610 DALI_TEST_CHECK( field );
611 application.GetScene().Add( field );
613 // Note - we can't check the defaults since the stylesheets are platform-specific
615 // Check the render backend property.
616 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
617 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
619 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
620 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION );
622 // Check text property.
623 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
624 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
626 // Check placeholder text properties.
627 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
628 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
630 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
631 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
633 // Check font properties.
634 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
635 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
637 Property::Map fontStyleMapSet;
638 Property::Map fontStyleMapGet;
639 Property::Value* slantValue = NULL;
641 fontStyleMapSet.Insert( "weight", "bold" );
642 fontStyleMapSet.Insert( "width", "condensed" );
643 fontStyleMapSet.Insert( "slant", "italic" );
644 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
646 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
647 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
648 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
650 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
651 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
653 field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 2.5f );
654 DALI_TEST_EQUALS( field.GetProperty<float>( DevelTextField::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
655 field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 1.0f );
657 field.SetProperty( DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, false );
658 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_FONT_SIZE_SCALE ), false, TEST_LOCATION );
659 field.SetProperty( DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, true );
662 fontStyleMapSet.Clear();
663 fontStyleMapSet.Insert( "weight", "normal" );
664 fontStyleMapSet.Insert( "slant", "oblique" );
665 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
667 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
668 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
669 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
671 fontStyleMapSet.Clear();
672 fontStyleMapSet.Insert( "slant", "roman" );
673 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
674 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
676 // Replace 'roman' for 'normal'.
677 slantValue = fontStyleMapGet.Find( "slant" );
678 if( NULL != slantValue )
680 if( "normal" == slantValue->Get<std::string>() )
682 fontStyleMapGet["slant"] = "roman";
685 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
686 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
688 fontStyleMapSet.Clear();
690 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
691 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
692 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
693 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
695 // Check that the MAX_LENGTH property can be correctly set
696 const int maxNumberOfCharacters = 20;
697 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
698 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
700 // Check exceed policy
701 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
702 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
703 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
704 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
706 // Check that the Alignment properties can be correctly set
707 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
708 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
709 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
710 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
712 // Check text's color property
713 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
714 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
716 // Check placeholder text's color property.
717 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
718 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
720 // Check cursor properties
721 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
722 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
723 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
724 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
726 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
727 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
728 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
729 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
730 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
731 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
732 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
733 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
735 // Check scroll properties.
736 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
737 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
738 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
739 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
741 // Check handle images
742 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
743 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
744 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
745 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
746 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
748 // Check handle images
749 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
750 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
751 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
752 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
753 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
754 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
756 // Check the highlight color
757 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
758 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
760 // Decoration bounding box
761 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
762 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
764 // Check the input method setting
765 Property::Map propertyMap;
766 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
767 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
768 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
769 int inputVariation = 1;
770 propertyMap["PANEL_LAYOUT"] = panelLayout;
771 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
772 propertyMap["BUTTON_ACTION"] = buttonAction;
773 propertyMap["VARIATION"] = inputVariation;
774 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
776 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
778 DALI_TEST_CHECK( value.Get( map ) );
781 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
782 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
785 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
786 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
789 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
790 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
793 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
794 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
796 // Check input color property.
797 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
798 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
800 // Check the enable markup property.
801 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
802 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
803 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
805 // Check input font properties.
806 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
807 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
809 fontStyleMapSet.Clear();
810 fontStyleMapSet.Insert( "weight", "bold" );
811 fontStyleMapSet.Insert( "width", "condensed" );
812 fontStyleMapSet.Insert( "slant", "italic" );
814 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
815 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
816 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
817 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
819 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
820 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
822 // Reset input font style.
823 fontStyleMapSet.Clear();
824 fontStyleMapSet.Insert( "weight", "normal" );
825 fontStyleMapSet.Insert( "slant", "oblique" );
827 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
828 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
829 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
830 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
832 fontStyleMapSet.Clear();
833 fontStyleMapSet.Insert( "slant", "roman" );
835 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
836 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
838 // Replace 'roman' for 'normal'.
839 slantValue = fontStyleMapGet.Find( "slant" );
840 if( NULL != slantValue )
842 if( "normal" == slantValue->Get<std::string>() )
844 fontStyleMapGet["slant"] = "roman";
847 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
848 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
850 fontStyleMapSet.Clear();
852 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
853 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
854 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
855 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
857 Property::Map underlineMapSet;
858 Property::Map underlineMapGet;
860 underlineMapSet.Insert( "enable", true );
861 underlineMapSet.Insert( "color", Color::RED );
862 underlineMapSet.Insert( "height", 1 );
864 // Check the underline property
865 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
867 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
868 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
869 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
871 // Check the input underline property
872 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
873 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
875 // Check the shadow property
876 Property::Map shadowMapSet;
877 Property::Map shadowMapGet;
879 shadowMapSet.Insert( "color", Color::GREEN );
880 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
881 shadowMapSet.Insert( "blurRadius", 3.0f );
883 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
885 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
886 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
887 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
889 // Check the input shadow property
890 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
891 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
893 // Check the emboss property
894 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
895 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
897 // Check the input emboss property
898 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
899 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
901 // Check the outline property
903 // Test string type first
904 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
905 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
906 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
908 // Then test the property map type
909 Property::Map outlineMapSet;
910 Property::Map outlineMapGet;
912 outlineMapSet["color"] = Color::RED;
913 outlineMapSet["width"] = 2.0f;
915 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
917 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
918 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
919 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
921 // Check the input outline property
922 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
923 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
925 // Check the hidden input settings property
926 Property::Map hiddenMapSet;
927 Property::Map hiddenMapGet;
928 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
929 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
930 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
931 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
932 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
934 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
935 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
936 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
938 // Check the pixel size of font
939 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
940 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
942 // Check the enable selection property
943 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
944 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
946 // Check the placeholder property with pixel size
947 Property::Map placeholderPixelSizeMapSet;
948 Property::Map placeholderPixelSizeMapGet;
949 Property::Map placeholderFontstyleMap;
950 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
951 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
952 placeholderPixelSizeMapSet["color"] = Color::BLUE;
953 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
954 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
955 placeholderPixelSizeMapSet["ellipsis"] = true;
957 placeholderFontstyleMap.Insert( "weight", "bold" );
958 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
959 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
961 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
962 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
964 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
965 Property::Map placeholderConversionMap;
966 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
967 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
968 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
969 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
970 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
971 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
973 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
975 // Check the placeholder property with point size
976 Property::Map placeholderMapSet;
977 Property::Map placeholderMapGet;
978 placeholderMapSet["text"] = "Setting Placeholder Text";
979 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
980 placeholderMapSet["color"] = Color::RED;
981 placeholderMapSet["fontFamily"] = "Arial";
982 placeholderMapSet["pointSize"] = 12.0f;
983 placeholderMapSet["ellipsis"] = false;
985 // Check the placeholder font style property
986 placeholderFontstyleMap.Clear();
988 placeholderFontstyleMap.Insert( "weight", "bold" );
989 placeholderFontstyleMap.Insert( "width", "condensed" );
990 placeholderFontstyleMap.Insert( "slant", "italic" );
991 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
992 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
994 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
995 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
997 placeholderConversionMap.Clear();
998 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
999 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
1000 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
1001 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1002 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
1003 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
1005 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1007 // Reset font style.
1008 placeholderFontstyleMap.Clear();
1009 placeholderFontstyleMap.Insert( "weight", "normal" );
1010 placeholderFontstyleMap.Insert( "slant", "oblique" );
1011 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1012 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1014 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1015 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1017 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1018 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1020 placeholderFontstyleMap.Clear();
1021 placeholderFontstyleMap.Insert( "slant", "roman" );
1022 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1023 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1025 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1027 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1029 placeholderFontstyleMap.Clear();
1030 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1031 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1033 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1034 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1035 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1037 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1039 // Check the ellipsis property
1040 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1041 field.SetProperty( TextField::Property::ELLIPSIS, true );
1042 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1044 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
1045 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1047 // Test the ENABLE_GRAB_HANDLE_POPUP property
1048 DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1049 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false );
1050 DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1052 // Check the background property
1053 field.SetProperty( DevelTextField::Property::BACKGROUND, Color::RED );
1054 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::BACKGROUND ), Color::RED, TEST_LOCATION );
1056 //Check handle color
1057 field.SetProperty( DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN );
1058 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
1060 // Check the input filter property
1061 Property::Map inputFilterMapSet;
1062 Property::Map inputFilterMapGet;
1063 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1064 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1066 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1068 inputFilterMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::INPUT_FILTER);
1069 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1072 inputFilterMapSet.Clear();
1073 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1075 application.SendNotification();
1076 application.Render();
1081 // Positive Atlas Text Renderer test
1082 int utcDaliTextFieldAtlasRenderP(void)
1084 ToolkitTestApplication application;
1085 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1086 StyleManager styleManager = StyleManager::Get();
1087 styleManager.ApplyDefaultTheme();
1088 TextField field = TextField::New();
1089 DALI_TEST_CHECK( field );
1091 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1093 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1095 application.GetScene().Add( field );
1099 // Render some text with the shared atlas backend
1100 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1101 application.SendNotification();
1102 application.Render();
1106 tet_result(TET_FAIL);
1111 // Positive test for the anchorClicked signal.
1112 int utcDaliTextFieldAnchorClicked01(void)
1114 ToolkitTestApplication application;
1115 tet_infoline(" utcDaliTextFieldAnchorClicked01");
1116 TextField field = TextField::New();
1117 DALI_TEST_CHECK(field);
1119 application.GetScene().Add(field);
1121 // connect to the anchor clicked signal.
1122 ConnectionTracker* testTracker = new ConnectionTracker();
1123 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1124 bool anchorClickedSignal = false;
1125 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1127 gAnchorClickedCallBackCalled = false;
1128 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1129 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1130 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1131 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1132 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1134 application.SendNotification();
1135 application.Render();
1136 field.SetKeyInputFocus();
1138 // Create a tap event to touch the text field.
1139 TestGenerateTap(application, 5.0f, 25.0f);
1140 application.SendNotification();
1141 application.Render();
1143 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1144 DALI_TEST_CHECK(anchorClickedSignal);
1146 gAnchorClickedCallBackNotCalled = true;
1147 // Tap the outside of anchor, callback should not be called.
1148 TestGenerateTap(application, 150.f, 100.f);
1149 application.SendNotification();
1150 application.Render();
1152 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1157 // Positive test for the anchorClicked signal.
1158 int utcDaliTextFieldAnchorClicked02(void)
1160 ToolkitTestApplication application;
1161 tet_infoline(" utcDaliTextFieldAnchorClicked02");
1162 TextField field = TextField::New();
1163 DALI_TEST_CHECK(field);
1165 application.GetScene().Add(field);
1167 // connect to the anchor clicked signal.
1168 ConnectionTracker* testTracker = new ConnectionTracker();
1169 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1170 bool anchorClickedSignal = false;
1171 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1173 gAnchorClickedCallBackCalled = false;
1174 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1175 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1176 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1177 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1178 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1180 application.SendNotification();
1181 application.Render();
1182 field.SetKeyInputFocus();
1184 // Avoid a crash when core load gl resources.
1185 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1187 // Create a tap event to touch the text field.
1188 TestGenerateTap(application, 30.0f, 25.0f, 100);
1189 application.SendNotification();
1190 application.Render();
1192 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1193 DALI_TEST_CHECK(anchorClickedSignal);
1196 // For coverage InsertTextAnchor, RemoveTextAnchor
1197 // first index insert
1198 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1199 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1200 application.SendNotification();
1201 application.Render();
1203 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1204 application.SendNotification();
1205 application.Render();
1207 gAnchorClickedCallBackCalled = false;
1208 // Create a tap event to touch the text field.
1209 TestGenerateTap(application, 30.0f, 25.0f, 700);
1210 application.SendNotification();
1211 field.SetKeyInputFocus();
1213 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1215 // last index insert
1216 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1217 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1218 application.SendNotification();
1219 application.Render();
1221 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1222 application.SendNotification();
1223 application.Render();
1225 gAnchorClickedCallBackCalled = false;
1226 // Create a tap event to touch the text field.
1227 TestGenerateTap(application, 30.0f, 25.0f, 1300);
1228 application.SendNotification();
1229 field.SetKeyInputFocus();
1231 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1234 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1235 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1236 application.SendNotification();
1237 application.Render();
1239 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1240 application.SendNotification();
1241 application.Render();
1243 gAnchorClickedCallBackCalled = false;
1244 // Create a tap event to touch the text field.
1245 TestGenerateTap(application, 30.0f, 25.0f, 1900);
1246 application.SendNotification();
1247 field.SetKeyInputFocus();
1249 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1251 // first index remove
1252 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1253 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1254 application.SendNotification();
1255 application.Render();
1257 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1258 application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1259 application.SendNotification();
1260 application.Render();
1262 gAnchorClickedCallBackCalled = false;
1263 // Create a tap event to touch the text field.
1264 TestGenerateTap(application, 30.0f, 25.0f, 2500);
1265 application.SendNotification();
1266 field.SetKeyInputFocus();
1268 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1270 // last index remove
1271 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1272 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1273 application.SendNotification();
1274 application.Render();
1276 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1277 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));
1278 application.SendNotification();
1279 application.Render();
1281 gAnchorClickedCallBackCalled = false;
1282 // Create a tap event to touch the text field.
1283 TestGenerateTap(application, 30.0f, 25.0f, 3100);
1284 application.SendNotification();
1285 application.Render();
1287 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1290 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1291 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1292 application.SendNotification();
1293 application.Render();
1295 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1296 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));
1297 application.SendNotification();
1298 application.Render();
1300 gAnchorClickedCallBackCalled = false;
1301 // Create a tap event to touch the text field.
1302 TestGenerateTap(application, 30.0f, 25.0f, 3700);
1303 application.SendNotification();
1304 application.Render();
1306 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1308 // 0 ~ 1 index remove
1309 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1310 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 0);
1311 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 1);
1312 application.SendNotification();
1313 application.Render();
1315 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1316 application.SendNotification();
1317 application.Render();
1319 gAnchorClickedCallBackCalled = false;
1320 // Create a tap event to touch the text field.
1321 TestGenerateTap(application, 30.0f, 25.0f, 4300);
1322 application.SendNotification();
1323 application.Render();
1325 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1327 // 1 ~ 3 index remove
1328 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1329 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 1);
1330 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 3);
1331 application.SendNotification();
1332 application.Render();
1334 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1335 application.SendNotification();
1336 application.Render();
1338 gAnchorClickedCallBackCalled = false;
1339 // Create a tap event to touch the text field.
1340 TestGenerateTap(application, 30.0f, 25.0f, 4900);
1341 application.SendNotification();
1342 application.Render();
1344 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1346 // 3 ~ 4 index remove
1347 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1348 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 3);
1349 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 4);
1350 application.SendNotification();
1351 application.Render();
1353 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1354 application.SendNotification();
1355 application.Render();
1357 gAnchorClickedCallBackCalled = false;
1358 // Create a tap event to touch the text field.
1359 TestGenerateTap(application, 30.0f, 25.0f, 5500);
1360 application.SendNotification();
1361 application.Render();
1363 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1365 // Remove front of anchor
1366 field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
1367 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
1368 application.SendNotification();
1369 application.Render();
1371 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1372 application.SendNotification();
1373 application.Render();
1375 // Remove whole text
1376 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1377 DevelTextField::SelectWholeText(field);
1378 application.SendNotification();
1379 application.Render();
1381 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1382 application.SendNotification();
1383 application.Render();
1385 // Remove all with backspace
1386 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1387 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
1388 application.SendNotification();
1389 application.Render();
1391 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1392 application.SendNotification();
1393 application.Render();
1395 // Remove all with delete
1396 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1397 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1398 application.SendNotification();
1399 application.Render();
1401 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));
1402 application.SendNotification();
1403 application.Render();
1408 // Positive test for the textChanged signal.
1409 int utcDaliTextFieldTextChangedP(void)
1411 ToolkitTestApplication application;
1412 tet_infoline(" utcDaliTextFieldTextChangedP");
1413 TextField field = TextField::New();
1414 DALI_TEST_CHECK( field );
1416 application.GetScene().Add( field );
1418 // connect to the text changed signal.
1419 ConnectionTracker* testTracker = new ConnectionTracker();
1420 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1421 bool textChangedSignal = false;
1422 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1424 gTextChangedCallBackCalled = false;
1425 field.SetProperty( TextField::Property::TEXT, "ABC" );
1426 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1427 DALI_TEST_CHECK( textChangedSignal );
1429 application.SendNotification();
1430 field.SetKeyInputFocus();
1432 gTextChangedCallBackCalled = false;
1433 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1434 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1437 field.SetProperty( TextField::Property::TEXT, "" );
1439 // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1440 gTextChangedCallBackCalled = false;
1441 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1442 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1444 // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1445 gTextChangedCallBackCalled = false;
1446 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1447 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1452 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1454 ToolkitTestApplication application;
1455 tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1456 TextField field = TextField::New();
1457 DALI_TEST_CHECK( field );
1460 application.GetScene().Add( field );
1462 // connect to the text changed signal.
1463 ConnectionTracker* testTracker = new ConnectionTracker();
1464 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1465 bool textChangedSignal = false;
1466 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1469 // get InputMethodContext
1471 InputMethodContext::EventData imfEvent;
1472 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext( field );
1474 field.SetKeyInputFocus();
1475 field.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
1478 gTextChangedCallBackCalled = false;
1479 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1480 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1481 application.SendNotification();
1482 application.Render();
1483 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1484 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1486 gTextChangedCallBackCalled = false;
1487 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1488 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1489 application.SendNotification();
1490 application.Render();
1491 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1492 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호"), TEST_LOCATION );
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 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1507 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1508 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1509 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1511 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1512 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1513 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1515 application.SendNotification();
1516 application.Render();
1517 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1518 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1524 // Negative test for the textChanged signal.
1525 int utcDaliTextFieldTextChangedN(void)
1527 ToolkitTestApplication application;
1528 tet_infoline(" utcDaliTextFieldTextChangedN");
1529 TextField field = TextField::New();
1530 DALI_TEST_CHECK( field );
1532 application.GetScene().Add( field );
1534 // connect to the text changed signal.
1535 ConnectionTracker* testTracker = new ConnectionTracker();
1536 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1537 bool textChangedSignal = false;
1538 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1540 gTextChangedCallBackCalled = false;
1541 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1542 application.SendNotification();
1543 application.Render();
1544 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1545 DALI_TEST_CHECK( !textChangedSignal );
1550 // Positive test for Max Characters reached signal.
1551 int utcDaliTextFieldMaxCharactersReachedP(void)
1553 ToolkitTestApplication application;
1554 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1555 TextField field = TextField::New();
1556 DALI_TEST_CHECK( field );
1558 application.GetScene().Add( field );
1560 const int maxNumberOfCharacters = 1;
1561 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1563 field.SetKeyInputFocus();
1565 // connect to the text changed signal.
1566 ConnectionTracker* testTracker = new ConnectionTracker();
1567 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1568 bool maxLengthReachedSignal = false;
1569 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1571 gMaxCharactersCallBackCalled = false;
1573 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1574 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1576 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1577 DALI_TEST_CHECK( maxLengthReachedSignal );
1582 // Negative test for Max Characters reached signal.
1583 int utcDaliTextFieldMaxCharactersReachedN(void)
1585 ToolkitTestApplication application;
1586 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1587 TextField field = TextField::New();
1588 DALI_TEST_CHECK( field );
1590 application.GetScene().Add( field );
1592 const int maxNumberOfCharacters = 3;
1593 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1595 field.SetKeyInputFocus();
1597 // connect to the text changed signal.
1598 ConnectionTracker* testTracker = new ConnectionTracker();
1599 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1600 bool maxLengthReachedSignal = false;
1601 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1603 gMaxCharactersCallBackCalled = false;
1605 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1606 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1608 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1609 DALI_TEST_CHECK( !maxLengthReachedSignal );
1611 application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1613 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1614 DALI_TEST_CHECK( !maxLengthReachedSignal );
1619 // Positive test for Input Filtered signal.
1620 int utcDaliTextFieldInputFilteredP(void)
1622 ToolkitTestApplication application;
1623 tet_infoline(" utcDaliTextFieldInputFilteredP");
1624 TextField field = TextField::New();
1625 DALI_TEST_CHECK(field);
1627 application.GetScene().Add(field);
1629 Property::Map inputFilter;
1631 // Only digit is accepted.
1632 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1634 // Set input filter to TextField.
1635 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1637 field.SetKeyInputFocus();
1639 // connect to the input filtered signal.
1640 ConnectionTracker* testTracker = new ConnectionTracker();
1641 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1642 bool inputFilteredSignal = false;
1643 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1645 gInputFilteredAcceptedCallbackCalled = false;
1647 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ));
1649 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1650 DALI_TEST_CHECK(inputFilteredSignal);
1652 // Word is rejected.
1653 inputFilter[InputFilter::Property::ACCEPTED] = "";
1654 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1656 // Set input filter to TextField.
1657 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1659 field.SetKeyInputFocus();
1661 inputFilteredSignal = false;
1662 gInputFilteredRejectedCallbackCalled = false;
1664 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1666 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1667 DALI_TEST_CHECK(inputFilteredSignal);
1672 // Negative test for Input Filtered signal.
1673 int utcDaliTextFieldInputFilteredN(void)
1675 ToolkitTestApplication application;
1676 tet_infoline(" utcDaliTextFieldInputFilteredP");
1677 TextField field = TextField::New();
1678 DALI_TEST_CHECK(field);
1680 application.GetScene().Add(field);
1682 Property::Map inputFilter;
1684 // Only word is accepted.
1685 inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
1687 // Set input filter to TextField.
1688 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1690 field.SetKeyInputFocus();
1692 // connect to the input filtered signal.
1693 ConnectionTracker* testTracker = new ConnectionTracker();
1694 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1695 bool inputFilteredSignal = false;
1696 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1698 gInputFilteredAcceptedCallbackCalled = false;
1700 // Key a, d should not be filtered.
1701 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1702 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1703 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1704 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1706 // Backspace, Delete should not be filtered.
1707 application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1708 application.ProcessEvent(GenerateKey( "Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1710 // Render and notify
1711 application.SendNotification();
1712 application.Render();
1714 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1715 DALI_TEST_CHECK(!inputFilteredSignal);
1717 // Digit is rejected.
1718 inputFilter[InputFilter::Property::ACCEPTED] = "";
1719 inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
1721 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1723 field.SetKeyInputFocus();
1725 inputFilteredSignal = false;
1726 gInputFilteredRejectedCallbackCalled = false;
1728 // Key a, d should not be filtered.
1729 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1730 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1731 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1732 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1734 // Backspace, Delete should not be filtered.
1735 application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1736 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));
1738 // Render and notify
1739 application.SendNotification();
1740 application.Render();
1742 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1743 DALI_TEST_CHECK(!inputFilteredSignal);
1748 int utcDaliTextFieldInputStyleChanged01(void)
1750 // The text-field emits signals when the input style changes. These changes of style are
1751 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1752 // can't be emitted during the size negotiation as the callbacks may update the UI.
1753 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1754 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1755 ToolkitTestApplication application;
1756 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1760 char* pathNamePtr = get_current_dir_name();
1761 const std::string pathName( pathNamePtr );
1762 free( pathNamePtr );
1764 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1765 fontClient.SetDpi( 93u, 93u );
1767 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1768 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1770 TextField field = TextField::New();
1771 DALI_TEST_CHECK( field );
1774 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1775 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1776 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1778 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1779 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1781 // connect to the text changed signal.
1782 ConnectionTracker* testTracker = new ConnectionTracker();
1783 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1784 bool inputStyleChangedSignal = false;
1785 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1787 application.GetScene().Add( field );
1789 // Render and notify
1790 application.SendNotification();
1791 application.Render();
1793 // Executes the idle callbacks added by the text control on the change of input style.
1794 application.RunIdles();
1796 gInputStyleChangedCallbackCalled = false;
1797 gInputStyleMask = TextField::InputStyle::NONE;
1798 inputStyleChangedSignal = false;
1800 // Create a tap event to touch the text field.
1801 TestGenerateTap( application, 18.0f, 25.0f );
1803 // Render and notify
1804 application.SendNotification();
1805 application.Render();
1807 // Executes the idle callbacks added by the text control on the change of input style.
1808 application.RunIdles();
1810 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1811 if( gInputStyleChangedCallbackCalled )
1813 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1815 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1816 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1818 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1819 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1821 DALI_TEST_CHECK( inputStyleChangedSignal );
1823 gInputStyleChangedCallbackCalled = false;
1824 gInputStyleMask = TextField::InputStyle::NONE;
1825 inputStyleChangedSignal = false;
1827 // Create a tap event to touch the text field.
1828 TestGenerateTap( application, 30.0f, 25.0f );
1830 // Render and notify
1831 application.SendNotification();
1832 application.Render();
1834 // Executes the idle callbacks added by the text control on the change of input style.
1835 application.RunIdles();
1837 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1838 DALI_TEST_CHECK( !inputStyleChangedSignal );
1840 gInputStyleChangedCallbackCalled = false;
1841 gInputStyleMask = TextField::InputStyle::NONE;
1842 inputStyleChangedSignal = false;
1844 // Create a tap event to touch the text field.
1845 TestGenerateTap( application, 43.0f, 25.0f );
1847 // Render and notify
1848 application.SendNotification();
1849 application.Render();
1851 // Executes the idle callbacks added by the text control on the change of input style.
1852 application.RunIdles();
1854 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1855 if( gInputStyleChangedCallbackCalled )
1857 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1859 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1860 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1862 DALI_TEST_CHECK( inputStyleChangedSignal );
1864 gInputStyleChangedCallbackCalled = false;
1865 gInputStyleMask = TextField::InputStyle::NONE;
1866 inputStyleChangedSignal = false;
1868 // Create a tap event to touch the text field.
1869 TestGenerateTap( application, 88.0f, 25.0f );
1871 // Render and notify
1872 application.SendNotification();
1873 application.Render();
1875 // Executes the idle callbacks added by the text control on the change of input style.
1876 application.RunIdles();
1878 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1879 if( gInputStyleChangedCallbackCalled )
1881 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1883 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1884 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1886 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1888 Property::Map fontStyleMapSet;
1889 fontStyleMapSet.Insert( "weight", "bold" );
1891 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1892 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1894 DALI_TEST_CHECK( inputStyleChangedSignal );
1896 gInputStyleChangedCallbackCalled = false;
1897 gInputStyleMask = TextField::InputStyle::NONE;
1898 inputStyleChangedSignal = false;
1900 // Create a tap event to touch the text field.
1901 TestGenerateTap( application, 115.0f, 25.0f );
1903 // Render and notify
1904 application.SendNotification();
1905 application.Render();
1907 // Executes the idle callbacks added by the text control on the change of input style.
1908 application.RunIdles();
1910 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1911 DALI_TEST_CHECK( !inputStyleChangedSignal );
1913 gInputStyleChangedCallbackCalled = false;
1914 gInputStyleMask = TextField::InputStyle::NONE;
1915 inputStyleChangedSignal = false;
1917 // Create a tap event to touch the text field.
1918 TestGenerateTap( application, 164.0f, 25.0f );
1920 // Render and notify
1921 application.SendNotification();
1922 application.Render();
1924 // Executes the idle callbacks added by the text control on the change of input style.
1925 application.RunIdles();
1927 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1928 if( gInputStyleChangedCallbackCalled )
1930 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1932 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1933 DALI_TEST_CHECK( style.empty() );
1935 DALI_TEST_CHECK( inputStyleChangedSignal );
1937 gInputStyleChangedCallbackCalled = false;
1938 gInputStyleMask = TextField::InputStyle::NONE;
1939 inputStyleChangedSignal = false;
1941 // Create a tap event to touch the text field.
1942 TestGenerateTap( application, 191.0f, 25.0f );
1944 // Render and notify
1945 application.SendNotification();
1946 application.Render();
1948 // Executes the idle callbacks added by the text control on the change of input style.
1949 application.RunIdles();
1951 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1952 DALI_TEST_CHECK( !inputStyleChangedSignal );
1957 int utcDaliTextFieldInputStyleChanged02(void)
1959 // The text-field emits signals when the input style changes. These changes of style are
1960 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1961 // can't be emitted during the size negotiation as the callbacks may update the UI.
1962 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1963 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1964 ToolkitTestApplication application;
1965 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1969 char* pathNamePtr = get_current_dir_name();
1970 const std::string pathName( pathNamePtr );
1971 free( pathNamePtr );
1973 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1974 fontClient.SetDpi( 93u, 93u );
1976 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1977 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1979 TextField field = TextField::New();
1980 DALI_TEST_CHECK( field );
1982 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1983 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1984 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1986 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1987 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>" );
1989 // connect to the text changed signal.
1990 ConnectionTracker* testTracker = new ConnectionTracker();
1991 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1992 bool inputStyleChangedSignal = false;
1993 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1995 application.GetScene().Add( field );
1997 // Render and notify
1998 application.SendNotification();
1999 application.Render();
2001 // Executes the idle callbacks added by the text control on the change of input style.
2002 application.RunIdles();
2004 gInputStyleChangedCallbackCalled = false;
2005 gInputStyleMask = TextField::InputStyle::NONE;
2006 inputStyleChangedSignal = false;
2008 // Create a tap event to touch the text field.
2009 TestGenerateTap( application, 53.0f, 25.0f, 100 );
2010 TestGenerateTap( application, 53.0f, 25.0f, 200 );
2012 // Render and notify
2013 application.SendNotification();
2014 application.Render();
2016 // Executes the idle callbacks added by the text control on the change of input style.
2017 application.RunIdles();
2019 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2020 if( gInputStyleChangedCallbackCalled )
2022 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2023 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
2024 TextField::InputStyle::POINT_SIZE |
2025 TextField::InputStyle::COLOR ),
2028 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2029 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
2031 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
2032 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
2034 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
2035 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2037 DALI_TEST_CHECK( inputStyleChangedSignal );
2039 gInputStyleChangedCallbackCalled = false;
2040 gInputStyleMask = TextField::InputStyle::NONE;
2041 inputStyleChangedSignal = false;
2043 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2045 // Render and notify
2046 application.SendNotification();
2047 application.Render();
2049 // Executes the idle callbacks added by the text control on the change of input style.
2050 application.RunIdles();
2052 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2053 if( gInputStyleChangedCallbackCalled )
2055 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2056 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
2059 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2060 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
2062 DALI_TEST_CHECK( inputStyleChangedSignal );
2064 gInputStyleChangedCallbackCalled = false;
2065 gInputStyleMask = TextField::InputStyle::NONE;
2066 inputStyleChangedSignal = false;
2068 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2070 // Render and notify
2071 application.SendNotification();
2072 application.Render();
2074 // Executes the idle callbacks added by the text control on the change of input style.
2075 application.RunIdles();
2077 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
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 if( gInputStyleChangedCallbackCalled )
2096 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2097 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
2100 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2101 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
2103 DALI_TEST_CHECK( inputStyleChangedSignal );
2105 gInputStyleChangedCallbackCalled = false;
2106 gInputStyleMask = TextField::InputStyle::NONE;
2107 inputStyleChangedSignal = false;
2109 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
2111 Property::Map fontStyleMapSet;
2112 fontStyleMapSet.Insert( "weight", "thin" );
2113 fontStyleMapSet.Insert( "width", "condensed" );
2114 fontStyleMapSet.Insert( "slant", "italic" );
2116 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2117 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
2119 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
2120 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
2121 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
2122 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
2124 // Render and notify
2125 application.SendNotification();
2126 application.Render();
2128 // Executes the idle callbacks added by the text control on the change of input style.
2129 application.RunIdles();
2131 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
2132 DALI_TEST_CHECK( !inputStyleChangedSignal );
2134 // Create a tap event to touch the text field.
2135 TestGenerateTap( application, 63.0f, 25.0f, 700 );
2137 // Render and notify
2138 application.SendNotification();
2139 application.Render();
2141 // Executes the idle callbacks added by the text control on the change of input style.
2142 application.RunIdles();
2144 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2145 if( gInputStyleChangedCallbackCalled )
2147 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2148 static_cast<unsigned int>( TextField::InputStyle::COLOR |
2149 TextField::InputStyle::POINT_SIZE |
2150 TextField::InputStyle::FONT_STYLE |
2151 TextField::InputStyle::UNDERLINE |
2152 TextField::InputStyle::SHADOW |
2153 TextField::InputStyle::EMBOSS |
2154 TextField::InputStyle::OUTLINE ),
2157 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2158 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
2160 DALI_TEST_CHECK( inputStyleChangedSignal );
2165 int utcDaliTextFieldEvent01(void)
2167 ToolkitTestApplication application;
2168 tet_infoline(" utcDaliTextFieldEvent01");
2170 // Creates a tap event. After creating a tap event the text field should
2171 // have the focus and add text with key events should be possible.
2173 TextField field = TextField::New();
2174 DALI_TEST_CHECK( field );
2176 application.GetScene().Add( field );
2178 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2179 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2180 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2182 // Render and notify
2183 application.SendNotification();
2184 application.Render();
2186 // Avoid a crash when core load gl resources.
2187 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2189 // Render and notify
2190 application.SendNotification();
2191 application.Render();
2193 // Add a key event but as the text field has not the focus it should do nothing.
2194 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2196 // Render and notify
2197 application.SendNotification();
2198 application.Render();
2200 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2202 // Create a tap event to touch the text field.
2203 TestGenerateTap( application, 150.0f, 25.0f );
2205 // Render and notify
2206 application.SendNotification();
2207 application.Render();
2209 // Pressing delete key should be fine even if there is no text in TextField.
2210 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 ) );
2211 // Render and notify
2212 application.SendNotification();
2213 application.Render();
2215 // Now the text field has the focus, so it can handle the key events.
2216 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2217 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2219 // Render and notify
2220 application.SendNotification();
2221 application.Render();
2223 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2225 // Create a second text field and send key events to it.
2226 TextField field2 = TextField::New();
2228 field2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2229 field2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2230 field2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2231 field2.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
2233 application.GetScene().Add( field2 );
2235 // Render and notify
2236 application.SendNotification();
2237 application.Render();
2239 // Create a tap event on the second text field.
2240 TestGenerateTap( application, 150.0f, 125.0f );
2242 // Render and notify
2243 application.SendNotification();
2244 application.Render();
2246 // The second text field has the focus. It should handle the key events.
2247 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2248 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2250 // Render and notify
2251 application.SendNotification();
2252 application.Render();
2254 // Check the text has been added to the second text field.
2255 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2260 int utcDaliTextFieldEvent02(void)
2262 ToolkitTestApplication application;
2263 tet_infoline(" utcDaliTextFieldEvent02");
2265 // Checks if the right number of actors are created.
2267 TextField field = TextField::New();
2268 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2269 DALI_TEST_CHECK( field );
2270 LoadMarkerImages(application, field);
2272 application.GetScene().Add( field );
2274 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2275 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2276 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2278 // Avoid a crash when core load gl resources.
2279 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2281 // Render and notify
2282 application.SendNotification();
2283 application.Render();
2285 // Check there are the expected number of children ( stencil ).
2286 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
2288 Actor stencil = field.GetChildAt( 0u );
2289 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2291 // Create a tap event to touch the text field.
2292 TestGenerateTap( application, 150.0f, 25.0f, 300 );
2294 // Render and notify
2295 application.SendNotification();
2296 application.Render();
2298 Actor layer = field.GetChildAt( 1u );
2299 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2300 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2302 // Now the text field has the focus, so it can handle the key events.
2303 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2304 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2306 // Render and notify
2307 application.SendNotification();
2308 application.Render();
2310 // Checks the cursor and the renderer have been created.
2311 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2312 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
2314 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
2315 DALI_TEST_CHECK( cursor );
2317 // The offscreen root actor has a container with all the actors which contain the text renderers.
2318 Actor container = stencil.GetChildAt( 0u );
2319 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2321 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2322 DALI_TEST_CHECK( renderer );
2325 // Move the cursor and check the position changes.
2326 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2327 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2329 // Render and notify
2330 application.SendNotification();
2331 application.Render();
2333 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2334 DALI_TEST_CHECK( position2.x < position1.x );
2336 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2338 // Render and notify
2339 application.SendNotification();
2340 application.Render();
2342 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2343 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
2346 // Move the cursor to the first position.
2347 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2348 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2350 // Render and notify
2351 application.SendNotification();
2352 application.Render();
2354 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2356 // Send some taps and check the cursor positions.
2358 // Try to tap at the beginning.
2359 TestGenerateTap( application, 1.0f, 25.0f, 900 );
2361 // Render and notify
2362 application.SendNotification();
2363 application.Render();
2365 // Cursor position should be the same than position1.
2366 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2368 DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
2370 // Tap away from the start position.
2371 TestGenerateTap( application, 16.0f, 25.0f, 1500 );
2373 // Render and notify
2374 application.SendNotification();
2375 application.Render();
2377 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2379 DALI_TEST_CHECK( position6.x > position5.x );
2381 // Remove all the text.
2382 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2383 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2384 field.SetProperty( TextField::Property::TEXT, "" );
2386 // Render and notify
2387 application.SendNotification();
2388 application.Render();
2390 // Cursor position should be the same than position2.
2391 Vector3 position7 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2393 DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
2395 // Should not be a renderer.
2396 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2398 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2399 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2400 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
2402 application.SendNotification();
2403 application.Render();
2405 // There are renderer and decorator layer
2406 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
2411 int utcDaliTextFieldEvent03(void)
2413 ToolkitTestApplication application;
2414 tet_infoline(" utcDaliTextFieldEvent03");
2416 // Checks if the highlight actor is created.
2418 TextField field = TextField::New();
2419 DALI_TEST_CHECK( field );
2421 application.GetScene().Add( field );
2423 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2424 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2425 field.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
2426 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2427 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2429 // Avoid a crash when core load gl resources.
2430 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2431 LoadMarkerImages(application, field);
2433 // Render and notify
2434 application.SendNotification();
2435 application.Render();
2437 // Tap first to get the focus.
2438 TestGenerateTap( application, 3.0f, 25.0f );
2440 // Render and notify
2441 application.SendNotification();
2442 application.Render();
2444 // Double tap to select a word.
2445 TestGenerateTap( application, 3.0f, 25.0f );
2447 // Render and notify
2448 application.SendNotification();
2449 application.Render();
2451 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2452 Actor stencil = field.GetChildAt( 0u );
2454 // The highlight actor is drawn first, so is the first actor in the list
2455 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2456 DALI_TEST_CHECK( highlight );
2458 // The offscreen root actor has a container with all the actors which contain the text renderers.
2459 Actor container = stencil.GetChildAt( 1u );
2460 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2462 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2463 DALI_TEST_CHECK( renderer );
2469 int utcDaliTextFieldEvent04(void)
2471 ToolkitTestApplication application;
2472 tet_infoline(" utcDaliTextFieldEvent04");
2474 // Checks if the highlight actor is created.
2476 TextField field = TextField::New();
2477 DALI_TEST_CHECK( field );
2478 application.GetScene().Add( field );
2479 LoadMarkerImages(application, field);
2480 // Render and notify
2481 application.SendNotification();
2482 application.Render();
2484 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2485 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2486 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2487 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2488 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2490 // Avoid a crash when core load gl resources.
2491 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2492 // Render and notify
2493 application.SendNotification();
2494 application.Render();
2496 // Create a tap event to touch the text field.
2497 TestGenerateTap( application, 150.0f, 25.0f );
2498 // Render and notify
2499 application.SendNotification();
2500 application.Render();
2503 // Tap first to get the focus.
2504 TestGenerateTap( application, 1.0f, 25.0f );
2506 // Render and notify
2507 application.SendNotification();
2508 application.Render();
2510 // Double tap to select a word.
2511 TestGenerateTap( application, 1.0f, 25.0f );
2513 // Render and notify
2514 application.SendNotification();
2515 application.Render();
2518 TestGenerateTap( application, 0.0f, 40.0f );
2522 int utcDaliTextFieldEvent05(void)
2524 ToolkitTestApplication application;
2525 tet_infoline(" utcDaliTextFieldEvent05");
2527 // Checks dragging of cursor/grab handle
2529 TextField field = TextField::New();
2530 DALI_TEST_CHECK( field );
2531 application.GetScene().Add( field );
2532 LoadMarkerImages(application, field);
2533 // Render and notify
2534 application.SendNotification();
2535 application.Render();
2537 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2538 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2539 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2540 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2541 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2543 // Avoid a crash when core load gl resources.
2544 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2545 // Render and notify
2546 application.SendNotification();
2547 application.Render();
2549 // Create a tap event to touch the text field.
2550 TestGenerateTap( application, 150.0f, 25.0f );
2551 // Render and notify
2552 application.SendNotification();
2553 application.Render();
2555 // Tap first to get the focus.
2556 TestGenerateTap( application, 1.0f, 25.0f );
2558 // Render and notify
2559 application.SendNotification();
2560 application.Render();
2562 // Double tap to select a word.
2563 TestGenerateTap( application, 1.0f, 25.0f );
2565 // Render and notify
2566 application.SendNotification();
2567 application.Render();
2569 Actor stencil = field.GetChildAt( 1u );
2573 int utcDaliTextFieldEvent06(void)
2575 ToolkitTestApplication application;
2576 tet_infoline(" utcDaliTextFieldEvent06");
2578 // Checks Longpress when in edit mode
2580 TextField field = TextField::New();
2581 DALI_TEST_CHECK( field );
2582 application.GetScene().Add( field );
2583 LoadMarkerImages(application, field);
2584 // Render and notify
2585 application.SendNotification();
2586 application.Render();
2588 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2589 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2590 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2591 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2592 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2594 // Avoid a crash when core load gl resources.
2595 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2596 // Render and notify
2597 application.SendNotification();
2598 application.Render();
2600 // Create a tap event to touch the text field.
2601 TestGenerateTap( application, 150.0f, 25.0f );
2602 // Render and notify
2603 application.SendNotification();
2604 application.Render();
2607 // Tap first to get the focus.
2608 TestGenerateTap( application, 1.0f, 25.0f );
2610 // Render and notify
2611 application.SendNotification();
2612 application.Render();
2615 TestGenerateLongPress(application, 1.0f, 25.0f);
2617 // Render and notify
2618 application.SendNotification();
2619 application.Render();
2624 int utcDaliTextFieldEvent07(void)
2626 ToolkitTestApplication application;
2627 tet_infoline(" utcDaliTextFieldEvent07");
2629 // Checks Longpress to start edit mode
2631 TextField field = TextField::New();
2632 DALI_TEST_CHECK( field );
2633 application.GetScene().Add( field );
2634 LoadMarkerImages(application, field);
2635 // Render and notify
2636 application.SendNotification();
2637 application.Render();
2639 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2640 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2641 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2642 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2643 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2644 Property::Map propertyMap;
2645 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2646 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2648 // Avoid a crash when core load gl resources.
2649 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2650 // Render and notify
2651 application.SendNotification();
2652 application.Render();
2655 TestGenerateLongPress(application, 1.0f, 25.0f);
2657 // Render and notify
2658 application.SendNotification();
2659 application.Render();
2664 int utcDaliTextFieldEvent08(void)
2666 ToolkitTestApplication application;
2667 tet_infoline(" utcDaliTextFieldEvent08");
2669 Dali::Clipboard clipboard = Clipboard::Get();
2670 clipboard.SetItem("testTextFieldEvent");
2672 // Checks Longpress when only place holder text
2674 TextField field = TextField::New();
2675 DALI_TEST_CHECK( field );
2676 application.GetScene().Add( field );
2677 LoadMarkerImages(application, field);
2678 // Render and notify
2679 application.SendNotification();
2680 application.Render();
2682 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2683 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2684 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2685 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2686 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2688 // Avoid a crash when core load gl resources.
2689 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2690 // Render and notify
2691 application.SendNotification();
2692 application.Render();
2695 TestGenerateLongPress( application, 1.0f, 25.0f, 20 );
2697 // Render and notify
2698 application.SendNotification();
2699 application.Render();
2701 Wait(application, 500);
2703 TestEndLongPress( application, 1.0f, 25.0f, 520 );
2706 TestGenerateLongPress( application, 1.0f, 25.0f, 600 );
2708 // Render and notify
2709 application.Render();
2711 Wait(application, 500);
2713 Integration::Scene stage = application.GetScene();
2714 Layer layer = stage.GetRootLayer();
2715 Actor actor = layer.FindChildByName("optionPaste");
2719 Vector3 worldPosition = actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION );
2720 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2721 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2723 Dali::Integration::TouchEvent event;
2724 event = Dali::Integration::TouchEvent();
2725 event.AddPoint( GetPointDownInside( position ) );
2726 application.ProcessEvent( event );
2728 event = Dali::Integration::TouchEvent();
2729 event.AddPoint( GetPointUpInside( position ) );
2730 application.ProcessEvent( event );
2732 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2737 int utcDaliTextFieldEvent09(void)
2739 ToolkitTestApplication application;
2740 tet_infoline(" utcDaliTextFieldEvent09");
2742 TextField field = TextField::New();
2743 DALI_TEST_CHECK( field );
2744 application.GetScene().Add( field );
2745 LoadMarkerImages(application, field);
2746 // Render and notify
2747 application.SendNotification();
2748 application.Render();
2750 field.SetProperty( TextField::Property::TEXT, "Hello" );
2751 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2752 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2753 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2754 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2756 // Avoid a crash when core load gl resources.
2757 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2759 // Create a tap event to touch the text field.
2760 TestGenerateTap( application, 150.0f, 25.0f );
2761 application.SendNotification();
2762 application.Render();
2765 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2766 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2767 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2768 application.SendNotification();
2769 application.Render();
2771 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2772 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2773 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2774 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2775 application.SendNotification();
2776 application.Render();
2778 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2779 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2780 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2781 for( unsigned int index = 0u; index < 5u; ++index )
2783 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2784 application.SendNotification();
2785 application.Render();
2788 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2789 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2790 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2791 for( unsigned int index = 0u; index < 5u; ++index )
2793 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2794 application.SendNotification();
2795 application.Render();
2798 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2799 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2800 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2801 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2802 application.SendNotification();
2803 application.Render();
2804 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2805 application.SendNotification();
2806 application.Render();
2808 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2809 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
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();
2814 Property::Map mapGet;
2815 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2816 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2817 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2822 int utcDaliTextFieldStyleWhilstSelected(void)
2824 ToolkitTestApplication application;
2825 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2827 // Change font and styles whilst text is selected whilst word selected
2829 TextField field = TextField::New();
2830 DALI_TEST_CHECK( field );
2831 application.GetScene().Add( field );
2832 LoadMarkerImages(application, field);
2833 // Render and notify
2834 application.SendNotification();
2835 application.Render();
2837 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2838 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2839 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2840 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2841 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2843 // Avoid a crash when core load gl resources.
2844 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2845 // Render and notify
2846 application.SendNotification();
2847 application.Render();
2849 // Create a tap event to touch the text field.
2850 TestGenerateTap( application, 150.0f, 25.0f );
2851 // Render and notify
2852 application.SendNotification();
2853 application.Render();
2856 // Tap first to get the focus.
2857 TestGenerateTap( application, 1.0f, 25.0f );
2859 // Render and notify
2860 application.SendNotification();
2861 application.Render();
2863 // Double tap to select a word.
2864 TestGenerateTap( application, 1.0f, 25.0f );
2866 // Render and notify
2867 application.SendNotification();
2868 application.Render();
2870 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2871 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2873 Property::Map fontStyleMapSet;
2874 Property::Map fontStyleMapGet;
2876 fontStyleMapSet.Insert( "weight", "bold" );
2877 fontStyleMapSet.Insert( "slant", "italic" );
2878 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2880 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2881 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2882 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2884 fontStyleMapSet.Clear();
2885 fontStyleMapSet.Insert( "width", "expanded" );
2886 fontStyleMapSet.Insert( "slant", "italic" );
2887 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2889 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2890 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2891 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2893 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2894 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2896 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2897 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2899 fontStyleMapSet.Clear();
2900 fontStyleMapSet.Insert( "weight", "bold" );
2901 fontStyleMapSet.Insert( "slant", "italic" );
2903 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2905 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2906 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2907 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2909 fontStyleMapSet.Clear();
2910 fontStyleMapSet.Insert( "width", "expanded" );
2912 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2914 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2915 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2916 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2918 // Press Escape to increase coverage
2919 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2920 application.SendNotification();
2921 application.Render();
2923 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2928 int utcDaliTextFieldEscKeyLoseFocus(void)
2930 ToolkitTestApplication application;
2931 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2933 // Creates a tap event. After creating a tap event the text field should
2934 // have the focus and add text with key events should be possible.
2936 TextField field = TextField::New();
2937 DALI_TEST_CHECK( field );
2939 application.GetScene().Add( field );
2941 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2942 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2943 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2945 // Avoid a crash when core load gl resources.
2946 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2948 // Render and notify
2949 application.SendNotification();
2950 application.Render();
2952 // Add a key event but as the text field has not the focus it should do nothing.
2953 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2954 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2956 // Render and notify
2957 application.SendNotification();
2958 application.Render();
2960 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2962 // Create a tap event to touch the text field.
2963 TestGenerateTap( application, 150.0f, 25.0f );
2965 // Render and notify
2966 application.SendNotification();
2967 application.Render();
2969 // Now the text field has the focus, so it can handle the key events.
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 ) );
2972 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2973 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2975 // Render and notify
2976 application.SendNotification();
2977 application.Render();
2979 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2981 // Generate a Esc key event. The text field should lose the focus.
2982 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2983 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2985 // Render and notify
2986 application.SendNotification();
2987 application.Render();
2989 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2991 // No more text should be introduced
2992 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2993 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2995 // Render and notify
2996 application.SendNotification();
2997 application.Render();
2999 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
3004 int utcDaliTextFieldSomeSpecialKeys(void)
3006 ToolkitTestApplication application;
3007 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
3009 // Checks some special keys when the text is selected.
3011 TextField field = TextField::New();
3012 DALI_TEST_CHECK( field );
3013 application.GetScene().Add( field );
3014 LoadMarkerImages(application, field);
3015 // Render and notify
3016 application.SendNotification();
3017 application.Render();
3019 const std::string longText( "This is a long text for the size of the text-field." );
3021 field.SetProperty( TextField::Property::TEXT, longText );
3022 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
3023 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3024 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3025 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3027 // Avoid a crash when core load gl resources.
3028 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3029 // Render and notify
3030 application.SendNotification();
3031 application.Render();
3033 // Create a tap event to touch the text field.
3034 TestGenerateTap( application, 150.0f, 25.0f );
3036 // Render and notify
3037 application.SendNotification();
3038 application.Render();
3040 // Tap first to get the focus.
3041 TestGenerateTap( application, 1.0f, 25.0f );
3043 // Render and notify
3044 application.SendNotification();
3045 application.Render();
3047 // Double tap to select a word.
3048 TestGenerateTap( application, 1.0f, 25.0f );
3050 // Render and notify
3051 application.SendNotification();
3052 application.Render();
3054 // Generate a Esc key event. The text field should lose the focus.
3055 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3056 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3058 // Render and notify
3059 application.SendNotification();
3060 application.Render();
3062 // Generate a Esc key event. The text field should lose the focus.
3063 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3064 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3066 // Render and notify
3067 application.SendNotification();
3068 application.Render();
3070 // Generate a Esc key event. The text field should lose the focus.
3071 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3072 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3074 // Render and notify
3075 application.SendNotification();
3076 application.Render();
3078 // The text shouldn't be deleted.
3079 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
3084 int utcDaliTextFieldSizeUpdate(void)
3086 ToolkitTestApplication application;
3087 tet_infoline("utcDaliTextFieldSizeUpdate");
3089 // Checks some special keys when the text is selected.
3090 TextField field = TextField::New();
3091 DALI_TEST_CHECK( field );
3092 application.GetScene().Add( field );
3094 float previousHeight = 0.0f;
3095 float currentHeight = 0.0f;
3096 const float fieldWidth = 1920.0f;
3099 // "ㅁ" is bigger then "ኢ"
3100 field.SetProperty( Actor::Property::SIZE, Vector2( fieldWidth ,10.0f ) );
3101 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
3102 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
3104 field.SetProperty( TextField::Property::TEXT, "ኢ");
3105 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3106 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3108 field.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
3109 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
3111 application.SendNotification();
3112 application.Render();
3114 previousHeight = field.GetHeightForWidth( fieldWidth );
3115 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
3117 // Add another script characters ( glyph height is defferent )
3118 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3119 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3121 application.SendNotification();
3122 application.Render();
3124 currentHeight = field.GetHeightForWidth( fieldWidth );
3125 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
3126 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
3131 int utcDaliTextFieldExtremlyLargePointSize(void)
3133 ToolkitTestApplication application;
3134 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
3136 TextField field = TextField::New();
3138 field.SetProperty( TextField::Property::TEXT, "Text" );
3139 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3140 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3141 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3142 application.GetScene().Add( field );
3146 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
3147 application.SendNotification();
3148 DALI_TEST_CHECK( field );
3152 tet_result(TET_FAIL);
3157 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
3159 ToolkitTestApplication application;
3160 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
3161 TextField field = TextField::New();
3162 DALI_TEST_CHECK( field );
3163 application.GetScene().Add( field );
3165 Property::Map fontStyleMapGet;
3167 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
3169 Property::Value* weightValue = NULL;
3170 Property::Value* widthValue = NULL;
3171 Property::Value* slantValue = NULL;
3172 weightValue = fontStyleMapGet.Find( "weight" );
3173 widthValue = fontStyleMapGet.Find( "width" );
3174 slantValue = fontStyleMapGet.Find( "slant" );
3175 DALI_TEST_CHECK( !weightValue );
3176 DALI_TEST_CHECK( !widthValue );
3177 DALI_TEST_CHECK( !slantValue );
3182 int UtcDaliTextFieldSettingPlaceholder(void)
3184 ToolkitTestApplication application;
3185 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
3187 TextField field = TextField::New();
3188 DALI_TEST_CHECK( field );
3189 application.GetScene().Add( field );
3191 // Check the placeholder property with pixel size
3192 Property::Map placeholderPixelSizeMapSet;
3193 Property::Map placeholderPixelSizeMapGet;
3194 Property::Map placeholderFontstyleMap;
3195 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
3196 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
3197 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
3198 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
3199 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
3200 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
3202 placeholderFontstyleMap.Insert( "weight", "bold" );
3203 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3204 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
3206 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3207 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
3208 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
3210 // Check the placeholder property with point size
3211 Property::Map placeholderMapSet;
3212 Property::Map placeholderMapGet;
3213 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
3214 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
3215 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
3216 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
3217 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
3218 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
3220 // Check the placeholder font style property
3221 placeholderFontstyleMap.Clear();
3223 placeholderFontstyleMap.Insert( "weight", "bold" );
3224 placeholderFontstyleMap.Insert( "width", "condensed" );
3225 placeholderFontstyleMap.Insert( "slant", "italic" );
3226 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3227 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3229 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3230 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3231 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3233 // Reset font style.
3234 placeholderFontstyleMap.Clear();
3235 placeholderFontstyleMap.Insert( "weight", "normal" );
3236 placeholderFontstyleMap.Insert( "slant", "oblique" );
3237 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3238 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3240 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3241 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3242 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3244 placeholderFontstyleMap.Clear();
3245 placeholderFontstyleMap.Insert( "slant", "roman" );
3246 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3247 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3249 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3251 placeholderFontstyleMap.Clear();
3252 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3254 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3255 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3256 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3257 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3262 int UtcDaliTextFieldPlaceholderCoverage(void)
3264 ToolkitTestApplication application;
3265 tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
3267 // mPlaceholderFont is created only once, so create a new control for coverage.
3268 TextField fieldForCoverage = TextField::New();
3269 DALI_TEST_CHECK(fieldForCoverage);
3270 application.GetScene().Add(fieldForCoverage);
3272 // for SetPlaceholderFontFamily() coverage.
3273 Property::Map fontFamilyMap;
3274 fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3275 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
3277 // mPlaceholderFont is created only once, so create a new control for coverage.
3278 fieldForCoverage = TextField::New();
3279 DALI_TEST_CHECK(fieldForCoverage);
3280 application.GetScene().Add(fieldForCoverage);
3282 // for SetPlaceholderTextFontSize coverage.
3283 Property::Map fontSizeMap;
3284 fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3285 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
3287 // mPlaceholderFont is created only once, so create a new control for coverage.
3288 fieldForCoverage = TextField::New();
3289 DALI_TEST_CHECK(fieldForCoverage);
3290 application.GetScene().Add(fieldForCoverage);
3292 // for SetPlaceholderTextFontWeight coverage.
3293 Property::Map fontStyleWeightMap;
3294 Property::Map fontStyleWeightPropertyMap;
3295 fontStyleWeightPropertyMap.Insert("weight", "bold");
3296 fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
3297 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
3299 // mPlaceholderFont is created only once, so create a new control for coverage.
3300 fieldForCoverage = TextField::New();
3301 DALI_TEST_CHECK(fieldForCoverage);
3302 application.GetScene().Add(fieldForCoverage);
3304 // for SetPlaceholderTextFontWidth coverage.
3305 Property::Map fontStyleWidthMap;
3306 Property::Map fontStyleWidthPropertyMap;
3307 fontStyleWidthPropertyMap.Insert("width", "expanded");
3308 fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
3309 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
3311 // mPlaceholderFont is created only once, so create a new control for coverage.
3312 fieldForCoverage = TextField::New();
3313 DALI_TEST_CHECK(fieldForCoverage);
3314 application.GetScene().Add(fieldForCoverage);
3316 // for SetPlaceholderTextFontSlant coverage.
3317 Property::Map fontStyleSlantMap;
3318 Property::Map fontStyleSlantPropertyMap;
3319 fontStyleSlantPropertyMap.Insert("slant", "italic");
3320 fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
3321 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
3326 int UtcDaliTextFieldSetPaddingProperty(void)
3328 ToolkitTestApplication application;
3329 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3331 TextField field = TextField::New();
3332 DALI_TEST_CHECK( field );
3333 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3334 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3335 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3336 application.GetScene().Add( field );
3338 application.SendNotification();
3339 application.Render();
3341 Vector3 originalSize = field.GetNaturalSize();
3343 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
3345 application.SendNotification();
3346 application.Render();
3348 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
3350 Vector3 paddingAddedSize = field.GetNaturalSize();
3352 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3354 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3359 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3361 ToolkitTestApplication application;
3362 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3364 TextField field = TextField::New();
3365 DALI_TEST_CHECK( field );
3366 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3367 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3368 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3369 application.GetScene().Add( field );
3371 application.SendNotification();
3372 application.Render();
3374 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3375 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
3377 // Check the enable shift selection property
3378 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
3379 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
3381 application.SendNotification();
3382 application.Render();
3387 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3389 ToolkitTestApplication application;
3390 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3392 TextField field = TextField::New();
3393 DALI_TEST_CHECK( field );
3394 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3395 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3396 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3397 application.GetScene().Add( field );
3399 application.SendNotification();
3400 application.Render();
3402 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3403 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
3405 // Check the enable grab handle property
3406 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
3407 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
3409 application.SendNotification();
3410 application.Render();
3415 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
3417 ToolkitTestApplication application;
3418 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
3420 TextField field = TextField::New();
3421 DALI_TEST_CHECK( field );
3422 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3423 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3424 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3425 application.GetScene().Add( field );
3427 application.SendNotification();
3428 application.Render();
3430 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3431 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
3433 // Check the match system language direction property
3434 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
3435 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
3437 application.SendNotification();
3438 application.Render();
3443 int utcDaliTextFieldLayoutDirectionCoverage(void)
3445 ToolkitTestApplication application;
3446 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
3448 // Creates a tap event. After creating a tap event the text field should
3449 // have the focus and add text with key events should be possible.
3450 TextField field = TextField::New();
3451 DALI_TEST_CHECK( field );
3453 application.GetScene().Add( field );
3455 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3456 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3457 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3459 // Avoid a crash when core load gl resources.
3460 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3462 // Render and notify
3463 application.SendNotification();
3464 application.Render();
3466 // init direction for coverage
3467 // Set horizontal alignment END
3468 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3470 // Create a tap event to touch the text field.
3471 TestGenerateTap( application, 150.0f, 25.0f );
3473 // Render and notify
3474 application.SendNotification();
3475 application.Render();
3477 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
3478 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
3479 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
3481 // Set horizontal alignment BEGIN
3482 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
3484 // Create a tap event to touch the text field.
3485 TestGenerateTap( application, 150.0f, 25.0f );
3487 // Render and notify
3488 application.SendNotification();
3489 application.Render();
3491 // Set horizontal alignment CENTER
3492 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
3494 // Create a tap event to touch the text field.
3495 TestGenerateTap( application, 150.0f, 25.0f );
3497 // Render and notify
3498 application.SendNotification();
3499 application.Render();
3501 // Set horizontal alignment END
3502 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3504 // Create a tap event to touch the text field.
3505 TestGenerateTap( application, 150.0f, 25.0f );
3507 // Render and notify
3508 application.SendNotification();
3509 application.Render();
3511 // Generate a Esc key event. The text field should lose the focus.
3512 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3513 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3515 // Render and notify
3516 application.SendNotification();
3517 application.Render();
3519 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
3524 int UtcDaliTextFieldGetInputMethodContext(void)
3526 ToolkitTestApplication application;
3527 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
3529 TextField field = TextField::New();
3530 DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );
3535 int UtcDaliTextFieldSelectWholeText(void)
3537 ToolkitTestApplication application;
3538 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3540 TextField textField = TextField::New();
3542 application.GetScene().Add( textField );
3544 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3545 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3546 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3548 // Avoid a crash when core load gl resources.
3549 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3551 application.SendNotification();
3552 application.Render();
3554 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
3556 DevelTextField::SelectWholeText( textField );
3558 application.SendNotification();
3559 application.Render();
3561 // Nothing should have been selected. The number of children is still 1
3562 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
3564 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3566 application.SendNotification();
3567 application.Render();
3569 DevelTextField::SelectWholeText( textField );
3571 application.SendNotification();
3572 application.Render();
3574 // Even if resize, selection should remain.
3575 textField.SetProperty( Actor::Property::SIZE, Vector2( 150.f, 50.f ) );
3577 application.SendNotification();
3578 application.Render();
3580 // Should be 2 children, the stencil and the layer
3581 DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
3583 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3584 Actor stencil = textField.GetChildAt( 0u );
3586 // The highlight actor is drawn first, so is the first actor in the list
3587 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3588 DALI_TEST_CHECK( highlight );
3593 int UtcDaliTextFieldSelectText(void)
3595 ToolkitTestApplication application;
3596 tet_infoline(" UtcDaliTextFieldSelectText ");
3598 TextField textField = TextField::New();
3600 application.GetScene().Add( textField );
3602 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3603 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3604 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3606 // Avoid a crash when core load gl resources.
3607 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3609 application.SendNotification();
3610 application.Render();
3612 DevelTextField::SelectText( textField, 0, 5 );
3614 application.SendNotification();
3615 application.Render();
3617 // Nothing is selected
3618 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3619 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3621 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3623 application.SendNotification();
3624 application.Render();
3626 // Hello is selected
3627 DevelTextField::SelectText( textField, 0, 5 );
3629 application.SendNotification();
3630 application.Render();
3632 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3633 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3635 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3636 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3638 // world is selected
3639 DevelTextField::SelectText( textField, 6, 11 );
3641 application.SendNotification();
3642 application.Render();
3644 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3645 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3647 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3648 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3653 int UtcDaliTextFieldSelectNone(void)
3655 ToolkitTestApplication application;
3656 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3658 TextField textField = TextField::New();
3660 application.GetScene().Add( textField );
3662 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3663 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3664 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3666 // Avoid a crash when core load gl resources.
3667 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3669 application.SendNotification();
3670 application.Render();
3672 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3674 application.SendNotification();
3675 application.Render();
3677 // Nothing is selected
3678 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3679 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3681 DevelTextField::SelectWholeText( textField );
3683 application.SendNotification();
3684 application.Render();
3686 // whole text is selected
3687 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3688 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3690 DevelTextField::SelectNone( textField );
3692 application.SendNotification();
3693 application.Render();
3695 // Nothing is selected
3696 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3697 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3702 int UtcDaliTextFieldSelectRange(void)
3704 ToolkitTestApplication application;
3705 tet_infoline(" UtcDaliTextFieldSelectRange ");
3707 TextField textField = TextField::New();
3709 application.GetScene().Add( textField );
3711 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3712 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3713 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3715 // Avoid a crash when core load gl resources.
3716 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3718 application.SendNotification();
3719 application.Render();
3721 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3723 application.SendNotification();
3724 application.Render();
3726 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 0);
3727 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 5);
3729 // Hello is selected
3730 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3731 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3733 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3734 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3736 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 6);
3737 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 11);
3739 // world is selected
3740 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3741 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3743 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3744 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3749 int UtcDaliTextFieldEnableEditing(void)
3751 ToolkitTestApplication application;
3752 tet_infoline(" UtcDaliTextFieldEnableEditing ");
3754 TextField textField = TextField::New();
3756 application.GetScene().Add( textField );
3758 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3759 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3760 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3762 // Avoid a crash when core load gl resources.
3763 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3765 application.SendNotification();
3766 application.Render();
3768 textField.SetKeyInputFocus();
3769 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, false );
3770 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3772 // Render and notify
3773 application.SendNotification();
3774 application.Render();
3776 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3777 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3780 textField.SetKeyInputFocus();
3781 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
3782 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3784 // Render and notify
3785 application.SendNotification();
3786 application.Render();
3788 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3789 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3794 int UtcDaliToolkitTextFieldFontSizeScale(void)
3796 ToolkitTestApplication application;
3797 tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
3799 TextField textField = TextField::New();
3800 textField.SetProperty( TextField::Property::POINT_SIZE, 30.f );
3801 textField.SetProperty( TextField::Property::TEXT, "Test" );
3802 Vector3 nonScaledSize = textField.GetNaturalSize();
3804 TextField textFieldScaled = TextField::New();
3805 textFieldScaled.SetProperty( TextField::Property::POINT_SIZE, 15.f );
3806 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3807 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3808 Vector3 scaledSize = textFieldScaled.GetNaturalSize();
3810 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3812 textField.SetProperty( TextField::Property::PIXEL_SIZE, 30.f );
3813 textField.SetProperty( TextField::Property::TEXT, "Test" );
3814 nonScaledSize = textField.GetNaturalSize();
3816 textFieldScaled.SetProperty( TextField::Property::PIXEL_SIZE, 15.f );
3817 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3818 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3819 scaledSize = textFieldScaled.GetNaturalSize();
3821 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3826 int UtcDaliTextFieldPrimaryCursorPosition(void)
3828 ToolkitTestApplication application;
3829 tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
3831 TextField textField = TextField::New();
3833 application.GetScene().Add( textField );
3835 textField.SetProperty( TextField::Property::TEXT, "ABCEF");
3836 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3837 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3838 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3840 // Avoid a crash when core load gl resources.
3841 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3843 textField.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
3844 application.SendNotification();
3845 application.Render();
3846 textField.SetKeyInputFocus();
3848 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3850 // Render and notify
3851 application.SendNotification();
3852 application.Render();
3854 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3855 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3860 // test max length when set after setting long text
3861 int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
3863 ToolkitTestApplication application;
3864 tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
3865 TextField field = TextField::New();
3866 DALI_TEST_CHECK( field );
3868 application.GetScene().Add( field );
3870 field.SetProperty(TextField::Property::TEXT, "123456789");
3872 const int maxNumberOfCharacters = 3;
3873 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
3875 field.SetKeyInputFocus();
3877 // connect to the text max lengh reached signal.
3878 ConnectionTracker* testTracker = new ConnectionTracker();
3879 bool maxLengthReachedSignal = false;
3880 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
3882 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3883 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3885 DALI_TEST_CHECK( maxLengthReachedSignal );
3887 DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "123456789", TEST_LOCATION );
3894 int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
3896 ToolkitTestApplication application;
3897 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
3899 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3900 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3901 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3903 // Create a text field
3904 TextField textField = TextField::New();
3906 //Set size to avoid automatic eliding
3907 textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3908 //Set very large font-size using point-size
3909 textField.SetProperty( TextField::Property::POINT_SIZE, 1000) ;
3910 //Specify font-family
3911 textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
3912 //Set text to check if appear or not
3913 textField.SetProperty( TextField::Property::TEXT, "A");
3915 application.GetScene().Add( textField );
3917 application.SendNotification();
3918 application.Render();
3919 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3920 Vector3 naturalSize = textField.GetNaturalSize();
3922 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3923 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3928 int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
3930 ToolkitTestApplication application;
3931 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
3933 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3934 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3935 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3937 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3938 // Create a text editor
3939 TextField textField = TextField::New();
3941 //Set size to avoid automatic eliding
3942 textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3943 textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
3944 textField.SetProperty( TextField::Property::TEXT, "A");
3946 const int numberOfCases = 6;
3947 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
3949 for (int index=0; index < numberOfCases; index++)
3951 tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
3952 textField.SetProperty( TextField::Property::POINT_SIZE, arrayCases[index]) ;
3953 application.GetScene().Add( textField );
3954 application.SendNotification();
3955 application.Render();
3956 naturalSize = textField.GetNaturalSize();
3957 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3958 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3965 int UtcDaliToolkitTextFieldEllipsisPositionProperty(void)
3967 ToolkitTestApplication application;
3968 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty ");
3969 TextField textField = TextField::New();
3971 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Default is END");
3972 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3974 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START");
3975 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
3976 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3978 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE");
3979 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
3980 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3982 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END");
3983 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
3984 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3986 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START using integer");
3987 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 1);
3988 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3990 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE using integer");
3991 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 2);
3992 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3994 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END using integer");
3995 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 0);
3996 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3998 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
3999 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "START");
4000 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4002 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4003 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "MIDDLE");
4004 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4006 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4007 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "END");
4008 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4010 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4011 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "start");
4012 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4014 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4015 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "middle");
4016 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4018 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4019 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "end");
4020 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4025 int UtcDaliTextFieldCopyText(void)
4027 ToolkitTestApplication application;
4028 tet_infoline(" UtcDaliTextFieldCopyText ");
4030 TextField textField = TextField::New();
4032 std::string selectedText = "";
4033 std::string copiedText = "";
4035 application.GetScene().Add( textField );
4037 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4038 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4039 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4041 // Avoid a crash when core load gl resources.
4042 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4044 application.SendNotification();
4045 application.Render();
4047 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
4049 application.SendNotification();
4050 application.Render();
4052 // Hello is selected
4053 DevelTextField::SelectText( textField, 0, 5 );
4055 application.SendNotification();
4056 application.Render();
4058 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4059 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4061 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4062 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4065 copiedText = DevelTextField::CopyText( textField );
4066 DALI_TEST_EQUALS( "Hello", copiedText, TEST_LOCATION );
4068 // world is selected
4069 DevelTextField::SelectText( textField, 6, 11 );
4071 application.SendNotification();
4072 application.Render();
4074 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4075 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
4077 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
4078 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
4081 copiedText = DevelTextField::CopyText( textField );
4082 DALI_TEST_EQUALS( "world", copiedText, TEST_LOCATION );
4084 // "lo wo" is selected
4085 DevelTextField::SelectText( textField, 3, 8 );
4087 application.SendNotification();
4088 application.Render();
4090 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4091 DALI_TEST_EQUALS( "lo wo", selectedText, TEST_LOCATION );
4093 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 3, TEST_LOCATION );
4094 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 8, TEST_LOCATION );
4096 // "lo wo" is copied
4097 copiedText = DevelTextField::CopyText( textField );
4098 DALI_TEST_EQUALS( "lo wo", copiedText, TEST_LOCATION );
4103 int UtcDaliTextFieldCutText(void)
4105 ToolkitTestApplication application;
4106 tet_infoline(" UtcDaliTextFieldCutText ");
4108 TextField textField = TextField::New();
4110 std::string selectedText = "";
4112 application.GetScene().Add( textField );
4114 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4115 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4116 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4118 // Avoid a crash when core load gl resources.
4119 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4121 application.SendNotification();
4122 application.Render();
4124 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
4126 application.SendNotification();
4127 application.Render();
4129 // Hello is selected
4130 DevelTextField::SelectText( textField, 0, 5 );
4132 application.SendNotification();
4133 application.Render();
4135 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4136 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4138 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4139 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4142 DALI_TEST_EQUALS( "Hello", DevelTextField::CutText( textField ), TEST_LOCATION );
4144 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), " world", TEST_LOCATION );
4147 DevelTextField::SelectText( textField, 0, 2 );
4149 application.SendNotification();
4150 application.Render();
4152 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4153 DALI_TEST_EQUALS( " w", selectedText, TEST_LOCATION );
4155 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4156 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4159 DALI_TEST_EQUALS( " w", DevelTextField::CutText( textField ), TEST_LOCATION );
4161 application.SendNotification();
4162 application.Render();
4164 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "orld", TEST_LOCATION );
4166 // Test Cut from the middle
4169 DevelTextField::SelectText( textField, 1, 3 );
4171 application.SendNotification();
4172 application.Render();
4174 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4175 DALI_TEST_EQUALS( "rl", selectedText, TEST_LOCATION );
4177 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4178 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 3, TEST_LOCATION );
4181 DALI_TEST_EQUALS( "rl", DevelTextField::CutText( textField ), TEST_LOCATION );
4183 application.SendNotification();
4184 application.Render();
4186 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "od", TEST_LOCATION );
4188 // Test Cut from the end
4191 DevelTextField::SelectText( textField, 1, 2 );
4193 application.SendNotification();
4194 application.Render();
4196 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4197 DALI_TEST_EQUALS( "d", selectedText, TEST_LOCATION );
4199 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4200 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4203 DALI_TEST_EQUALS( "d", DevelTextField::CutText( textField ), TEST_LOCATION );
4205 application.SendNotification();
4206 application.Render();
4208 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "o", TEST_LOCATION );
4213 int UtcDaliTextFieldPasteText(void)
4215 ToolkitTestApplication application;
4216 tet_infoline(" UtcDaliTextFieldPasteText ");
4218 TextField textField = TextField::New();
4220 application.GetScene().Add( textField );
4222 std::string cutText = "";
4223 std::string copiedText = "";
4225 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4226 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4227 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4229 // Avoid a crash when core load gl resources.
4230 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4232 application.SendNotification();
4233 application.Render();
4235 textField.SetProperty( TextField::Property::TEXT, "Hello World" );
4237 application.SendNotification();
4238 application.Render();
4240 // Tap on the text editor
4241 TestGenerateTap( application, 3.0f, 25.0f );
4243 // Render and notify
4244 application.SendNotification();
4245 application.Render();
4247 // Select some text in the right of the current cursor position
4248 DevelTextField::SelectText( textField, 0, 3 );
4250 // Render and notify
4251 application.SendNotification();
4252 application.Render();
4254 // Cut the selected text
4255 cutText = DevelTextField::CutText(textField);
4257 // Render and notify
4258 application.SendNotification();
4259 application.Render();
4261 DALI_TEST_EQUALS( "Hel", cutText, TEST_LOCATION );
4262 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "lo World", TEST_LOCATION );
4264 DevelTextField::SelectText( textField, 0, 3 );
4266 // Render and notify
4267 application.SendNotification();
4268 application.Render();
4270 // Copy the selected text
4271 copiedText = DevelTextField::CopyText(textField);
4273 // Render and notify
4274 application.SendNotification();
4275 application.Render();
4277 DALI_TEST_EQUALS( "lo ", copiedText, TEST_LOCATION );
4278 DALI_TEST_EQUALS( "lo World", textField.GetProperty<std::string>( TextField::Property::TEXT ), TEST_LOCATION );
4280 // Move the cursor to the end of the line
4281 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4282 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4283 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4284 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4285 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4286 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4287 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4288 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4290 // Render and notify
4291 application.SendNotification();
4292 application.Render();
4294 // Paste the selected text at the current cursor position
4295 DevelTextField::PasteText(textField);
4297 // Render and notify
4298 application.SendNotification();
4299 application.Render();
4301 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "lo Worldlo ", TEST_LOCATION );
4305 int utcDaliTextFieldCursorPositionChangedSignal(void)
4307 ToolkitTestApplication application;
4308 tet_infoline(" utcDaliTextFieldCursorPositionChangedSignal");
4310 TextField field = TextField::New();
4311 DALI_TEST_CHECK( field );
4313 application.GetScene().Add( field );
4315 // connect to the selection changed signal.
4316 ConnectionTracker* testTracker = new ConnectionTracker();
4317 DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
4318 bool cursorPositionChangedSignal = false;
4319 field.ConnectSignal( testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal) );
4321 field.SetProperty( TextField::Property::TEXT, "Hello world Hello world" );
4322 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
4323 field.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4324 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4325 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4327 // Avoid a crash when core load gl resources.
4328 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4330 // Render and notify
4331 application.SendNotification();
4332 application.Render();
4334 field.SetKeyInputFocus();
4336 // Tap on the text field
4337 TestGenerateTap( application, 3.0f, 25.0f );
4339 // Render and notify
4340 application.SendNotification();
4341 application.Render();
4343 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4344 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4346 gCursorPositionChangedCallbackCalled = false;
4349 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4351 // Render and notify
4352 application.SendNotification();
4353 application.Render();
4355 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4356 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4358 gCursorPositionChangedCallbackCalled = false;
4361 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4363 // Render and notify
4364 application.SendNotification();
4365 application.Render();
4367 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4368 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4370 gCursorPositionChangedCallbackCalled = false;
4372 //delete one character
4373 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4375 // Render and notify
4376 application.SendNotification();
4377 application.Render();
4379 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4380 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4382 gCursorPositionChangedCallbackCalled = false;
4384 field.SetProperty( TextField::Property::TEXT, "Hello" );
4386 // Render and notify
4387 application.SendNotification();
4388 application.Render();
4390 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4391 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4393 gCursorPositionChangedCallbackCalled = false;
4395 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4397 // Render and notify
4398 application.SendNotification();
4399 application.Render();
4401 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4402 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4407 int utcDaliTextFieldGeometryEllipsisStart(void)
4409 ToolkitTestApplication application;
4410 tet_infoline(" utcDaliTextFieldGeometryEllipsisStart");
4412 TextField field = TextField::New();
4413 DALI_TEST_CHECK( field );
4415 application.GetScene().Add( field );
4417 field.SetProperty( TextField::Property::POINT_SIZE, 7.f );
4418 field.SetProperty( Actor::Property::SIZE, Vector2( 250.f, 50.f ) );
4419 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4420 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4421 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
4422 field.SetProperty( DevelTextField::Property::ELLIPSIS, true );
4423 field.SetProperty( DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START );
4424 field.SetProperty( TextField::Property::TEXT, "Hello World" );
4426 // Avoid a crash when core load gl resources.
4427 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4429 // Render and notify
4430 application.SendNotification();
4431 application.Render();
4433 unsigned int expectedCount = 1;
4434 unsigned int startIndex = 0;
4435 unsigned int endIndex = 10;
4437 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4438 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4440 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4441 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4443 Vector<Vector2> expectedSizes;
4444 Vector<Vector2> expectedPositions;
4446 expectedPositions.PushBack(Vector2(14, 0));
4447 expectedSizes.PushBack(Vector2(106, 25));
4449 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4454 int utcDaliTextFieldGeometryEllipsisEnd(void)
4456 ToolkitTestApplication application;
4457 tet_infoline(" utcDaliTextFieldGeometryEllipsisEnd");
4459 TextField field = TextField::New();
4460 DALI_TEST_CHECK( field );
4462 application.GetScene().Add( field );
4464 field.SetProperty( TextField::Property::POINT_SIZE, 7.f );
4465 field.SetProperty( Actor::Property::SIZE, Vector2( 250.f, 50.f ) );
4466 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4467 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4468 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
4469 field.SetProperty( DevelTextField::Property::ELLIPSIS, true );
4470 field.SetProperty( DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END );
4471 field.SetProperty( TextField::Property::TEXT, "Hello World" );
4473 // Avoid a crash when core load gl resources.
4474 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4476 // Render and notify
4477 application.SendNotification();
4478 application.Render();
4480 unsigned int expectedCount = 1;
4481 unsigned int startIndex = 0;
4482 unsigned int endIndex = 10;
4484 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4485 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4487 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4488 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4490 Vector<Vector2> expectedSizes;
4491 Vector<Vector2> expectedPositions;
4493 expectedPositions.PushBack(Vector2(-2, 0));
4494 expectedSizes.PushBack(Vector2(122, 25));
4496 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4501 int utcDaliTextFieldGeometryRTL(void)
4503 ToolkitTestApplication application;
4504 tet_infoline(" utcDaliTextFieldGeometryRTL");
4506 TextField field = TextField::New();
4507 DALI_TEST_CHECK( field );
4509 application.GetScene().Add( field );
4511 field.SetProperty( TextField::Property::POINT_SIZE, 7.f );
4512 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4513 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4514 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4515 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
4516 field.SetProperty( TextField::Property::TEXT, "السطر الاخير" );
4518 // Avoid a crash when core load gl resources.
4519 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4521 // Render and notify
4522 application.SendNotification();
4523 application.Render();
4525 unsigned int expectedCount = 1;
4526 unsigned int startIndex = 1;
4527 unsigned int endIndex = 7;
4529 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4530 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4532 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4533 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4535 Vector<Vector2> expectedSizes;
4536 Vector<Vector2> expectedPositions;
4538 expectedPositions.PushBack(Vector2(38, 0));
4539 expectedSizes.PushBack(Vector2(73, 25));
4541 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4546 int utcDaliTextFieldGeometryGlyphMiddle(void)
4548 ToolkitTestApplication application;
4549 tet_infoline(" utcDaliTextFieldGeometryGlyphMiddle");
4551 TextField field = TextField::New();
4552 DALI_TEST_CHECK( field );
4554 application.GetScene().Add( field );
4556 field.SetProperty( TextField::Property::POINT_SIZE, 7.f );
4557 field.SetProperty( Actor::Property::SIZE, Vector2( 150.f, 200.f ) );
4558 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4559 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4560 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
4561 field.SetProperty( TextField::Property::TEXT, "لا تحتوي على لا" );
4563 // Avoid a crash when core load gl resources.
4564 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4566 // Render and notify
4567 application.SendNotification();
4568 application.Render();
4570 unsigned int expectedCount = 1;
4571 unsigned int startIndex = 1;
4572 unsigned int endIndex = 13;
4574 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4575 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4577 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4578 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4580 Vector<Vector2> expectedSizes;
4581 Vector<Vector2> expectedPositions;
4583 expectedPositions.PushBack(Vector2(6, 0));
4584 expectedSizes.PushBack(Vector2(124, 25));
4586 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4591 int utcDaliTextFieldSelectionClearedSignal(void)
4593 ToolkitTestApplication application;
4594 tet_infoline(" utcDaliTextFieldSelectionClearedSignal");
4596 TextField field = TextField::New();
4597 DALI_TEST_CHECK( field );
4599 application.GetScene().Add( field );
4601 // connect to the selection changed signal.
4602 ConnectionTracker* testTracker = new ConnectionTracker();
4603 DevelTextField::SelectionClearedSignal(field).Connect(&TestSelectionClearedCallback);
4604 bool selectionClearedSignal = false;
4605 field.ConnectSignal( testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal) );
4607 field.SetProperty( TextField::Property::TEXT, "Hello\nworld\nHello world" );
4608 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
4609 field.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4610 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4611 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4613 // Avoid a crash when core load gl resources.
4614 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4616 // Render and notify
4617 application.SendNotification();
4618 application.Render();
4620 // Tap on the text editor
4621 TestGenerateTap( application, 3.0f, 25.0f );
4623 // Render and notify
4624 application.SendNotification();
4625 application.Render();
4627 // Move to second line of the text & Select some text in the right of the current cursor position
4628 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4629 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4632 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4634 // Render and notify
4635 application.SendNotification();
4636 application.Render();
4638 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4640 // Render and notify
4641 application.SendNotification();
4642 application.Render();
4644 // Tap on the text editor
4645 TestGenerateTap( application, 3.0f, 25.0f );
4647 // Render and notify
4648 application.SendNotification();
4649 application.Render();
4651 gSelectionClearedCallbackCalled = false;
4653 // Move to second line of the text & select.
4654 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4655 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4658 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4660 // Render and notify
4661 application.SendNotification();
4662 application.Render();
4664 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4666 gSelectionClearedCallbackCalled = false;
4668 // Render and notify
4669 application.SendNotification();
4670 application.Render();
4672 // Move to second line of the text & select.
4673 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4674 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4676 // replace D with selected text
4677 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4679 // Render and notify
4680 application.SendNotification();
4681 application.Render();
4683 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4685 gSelectionClearedCallbackCalled = false;
4687 // Render and notify
4688 application.SendNotification();
4689 application.Render();
4691 DevelTextField::SelectText( field ,1, 3 );
4693 // Render and notify
4694 application.SendNotification();
4695 application.Render();
4697 field.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4699 // Render and notify
4700 application.SendNotification();
4701 application.Render();
4703 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4705 gSelectionClearedCallbackCalled = false;
4707 DevelTextField::SelectText( field ,1, 3 );
4709 // Render and notify
4710 application.SendNotification();
4711 application.Render();
4714 DevelTextField::SelectNone(field);
4716 // Render and notify
4717 application.SendNotification();
4718 application.Render();
4720 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4725 int utcDaliTextFieldSelectionChangedSignal(void)
4727 ToolkitTestApplication application;
4728 tet_infoline(" utcDaliTextFieldSelectionChangedSignal");
4730 TextField field = TextField::New();
4731 DALI_TEST_CHECK( field );
4733 application.GetScene().Add( field );
4735 // connect to the selection changed signal.
4736 ConnectionTracker* testTracker = new ConnectionTracker();
4737 DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
4738 bool selectionChangedSignal = false;
4739 field.ConnectSignal( testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal) );
4741 field.SetProperty( TextField::Property::TEXT, "Hello world Hello world" );
4742 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
4743 field.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4744 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4745 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4747 // Avoid a crash when core load gl resources.
4748 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4750 // Render and notify
4751 application.SendNotification();
4752 application.Render();
4754 // Tap on the text field
4755 TestGenerateTap( application, 3.0f, 25.0f );
4757 // Render and notify
4758 application.SendNotification();
4759 application.Render();
4761 // Select some text in the right of the current cursor position
4762 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4763 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4765 // Render and notify
4766 application.SendNotification();
4767 application.Render();
4769 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4770 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4772 gSelectionChangedCallbackCalled = false;
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, 0, TEST_LOCATION);
4782 DALI_TEST_EQUALS(oldSelectionEnd, 1, TEST_LOCATION);
4784 gSelectionChangedCallbackCalled = false;
4786 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4788 // Render and notify
4789 application.SendNotification();
4790 application.Render();
4792 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4793 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4794 DALI_TEST_EQUALS(oldSelectionEnd, 2, TEST_LOCATION);
4796 gSelectionChangedCallbackCalled = false;
4797 field.SetKeyInputFocus();
4799 // Render and notify
4800 application.SendNotification();
4801 application.Render();
4803 DevelTextField::SelectText( field ,0, 5 );
4805 application.SendNotification();
4806 application.Render();
4808 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4809 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4811 gSelectionChangedCallbackCalled = false;
4813 field.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4815 // Render and notify
4816 application.SendNotification();
4817 application.Render();
4819 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4820 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4821 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
4823 gSelectionChangedCallbackCalled = false;
4826 DevelTextField::SelectWholeText(field);
4828 // Render and notify
4829 application.SendNotification();
4830 application.Render();
4832 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4833 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4835 gSelectionChangedCallbackCalled = false;
4838 DevelTextField::SelectNone(field);
4840 // Render and notify
4841 application.SendNotification();
4842 application.Render();
4844 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4845 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4846 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);