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_GRAB_HANDLE_COLOR = "grabHandleColor";
111 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
113 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
114 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
116 const float RENDER_FRAME_INTERVAL = 16.66f;
118 const unsigned int DEFAULT_FONT_SIZE = 1152u;
119 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
121 const int KEY_RETURN_CODE = 36;
122 const int KEY_A_CODE = 38;
123 const int KEY_D_CODE = 40;
124 const int KEY_SHIFT_MODIFIER = 257;
126 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
128 static bool gSelectionChangedCallbackCalled;
129 static uint32_t oldSelectionStart;
130 static uint32_t oldSelectionEnd;
131 static bool gSelectionClearedCallbackCalled;
132 static bool gAnchorClickedCallBackCalled;
133 static bool gAnchorClickedCallBackNotCalled;
134 static bool gTextChangedCallBackCalled;
135 static bool gMaxCharactersCallBackCalled;
136 static bool gInputFilteredAcceptedCallbackCalled;
137 static bool gInputFilteredRejectedCallbackCalled;
138 static bool gInputStyleChangedCallbackCalled;
139 static bool gCursorPositionChangedCallbackCalled;
140 static uint32_t oldCursorPos;
141 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
143 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
145 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
146 Integration::ResourcePointer resource(bitmap);
147 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
150 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
154 LoadBitmapResource( app.GetPlatform(), width, height );
156 Property::Map propertyMap;
157 propertyMap["filename"] = "image.png";
158 propertyMap["width"] = width;
159 propertyMap["height"] = height;
160 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
161 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
162 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
163 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
164 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
165 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
166 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
167 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
171 * Simulate time passed by.
173 * @note this will always process at least 1 frame (1/60 sec)
175 * @param application Test application instance
176 * @param duration Time to pass in milliseconds.
177 * @return The actual time passed in milliseconds
179 static int Wait(ToolkitTestApplication& application, int duration = 0)
183 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
185 application.SendNotification();
186 application.Render(RENDER_FRAME_INTERVAL);
187 time += RENDER_FRAME_INTERVAL;
193 Dali::Integration::Point GetPointDownInside( Vector2& pos )
195 Dali::Integration::Point point;
196 point.SetState( PointState::DOWN );
197 point.SetScreenPosition( pos );
201 Dali::Integration::Point GetPointUpInside( Vector2& pos )
203 Dali::Integration::Point point;
204 point.SetState( PointState::UP );
205 point.SetScreenPosition( pos );
209 struct CallbackFunctor
211 CallbackFunctor(bool* callbackFlag)
212 : mCallbackFlag( callbackFlag )
218 *mCallbackFlag = true;
223 static void TestSelectionClearedCallback(TextField control)
225 tet_infoline(" TestSelectionClearedCallback");
227 gSelectionClearedCallbackCalled = true;
230 static void TestSelectionChangedCallback(TextField control, uint32_t oldStart, uint32_t oldEnd)
232 tet_infoline(" TestSelectionChangedCallback");
234 gSelectionChangedCallbackCalled = true;
235 oldSelectionStart = oldStart;
236 oldSelectionEnd = oldEnd;
239 static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength)
241 tet_infoline(" TestAnchorClickedCallback");
243 gAnchorClickedCallBackNotCalled = false;
245 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
247 gAnchorClickedCallBackCalled = true;
251 static void TestCursorPositionChangedCallback( TextField control, unsigned int oldPos )
253 tet_infoline(" TestCursorPositionChangedCallback");
255 gCursorPositionChangedCallbackCalled = true;
256 oldCursorPos = oldPos;
259 static void TestTextChangedCallback( TextField control )
261 tet_infoline(" TestTextChangedCallback");
263 gTextChangedCallBackCalled = true;
266 static void TestMaxLengthReachedCallback( TextField control )
268 tet_infoline(" TestMaxLengthReachedCallback");
270 gMaxCharactersCallBackCalled = true;
273 static void TestInputFilteredCallback(TextField control, Toolkit::InputFilter::Property::Type type)
275 tet_infoline(" TestInputFilteredCallback");
277 if(type == Toolkit::InputFilter::Property::ACCEPTED)
279 gInputFilteredAcceptedCallbackCalled = true;
281 else if(type == Toolkit::InputFilter::Property::REJECTED)
283 gInputFilteredRejectedCallbackCalled = true;
287 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
289 tet_infoline(" TestInputStyleChangedCallback");
291 gInputStyleChangedCallbackCalled = true;
292 gInputStyleMask = mask;
295 // Generate a KeyEvent to send to Core.
296 Integration::KeyEvent GenerateKey( const std::string& keyName,
297 const std::string& logicalKey,
298 const std::string& keyString,
301 unsigned long timeStamp,
302 const Integration::KeyEvent::State& keyState,
303 const std::string& compose = "",
304 const std::string& deviceName = DEFAULT_DEVICE_NAME,
305 const Device::Class::Type& deviceClass = Device::Class::NONE,
306 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
308 return Integration::KeyEvent( keyName,
321 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
323 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
325 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
327 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
329 Property::Value* valueSet = NULL;
330 if ( valueGet.first.type == Property::Key::INDEX )
332 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
336 // Get Key is a string so searching Set Map for a string key
337 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
340 if( NULL != valueSet )
342 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
344 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
347 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
349 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
352 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
354 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
357 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
359 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
362 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
364 Vector2 vector2Get = valueGet.second.Get<Vector2>();
365 Vector2 vector2Set = valueSet->Get<Vector2>();
366 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
369 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
371 Vector4 vector4Get = valueGet.second.Get<Vector4>();
372 Vector4 vector4Set = valueSet->Get<Vector4>();
373 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 );
379 if ( valueGet.first.type == Property::Key::INDEX )
381 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
385 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
397 int UtcDaliToolkitTextFieldConstructorP(void)
399 ToolkitTestApplication application;
400 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
402 DALI_TEST_CHECK( !textField );
406 int UtcDaliToolkitTextFieldNewP(void)
408 ToolkitTestApplication application;
409 tet_infoline(" UtcDaliToolkitTextFieldNewP");
410 TextField textField = TextField::New();
411 DALI_TEST_CHECK( textField );
415 int UtcDaliToolkitTextFieldDownCastP(void)
417 ToolkitTestApplication application;
418 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
419 TextField textField1 = TextField::New();
420 BaseHandle object( textField1 );
422 TextField textField2 = TextField::DownCast( object );
423 DALI_TEST_CHECK( textField2 );
425 TextField textField3 = DownCast< TextField >( object );
426 DALI_TEST_CHECK( textField3 );
430 int UtcDaliToolkitTextFieldDownCastN(void)
432 ToolkitTestApplication application;
433 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
434 BaseHandle uninitializedObject;
435 TextField textField1 = TextField::DownCast( uninitializedObject );
436 DALI_TEST_CHECK( !textField1 );
438 TextField textField2 = DownCast< TextField >( uninitializedObject );
439 DALI_TEST_CHECK( !textField2 );
443 int UtcDaliToolkitTextFieldCopyConstructorP(void)
445 ToolkitTestApplication application;
446 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
447 TextField textField = TextField::New();
448 textField.SetProperty( TextField::Property::TEXT, "Test" );
450 TextField copy( textField );
451 DALI_TEST_CHECK( copy );
452 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
456 int UtcDaliTextFieldMoveConstructor(void)
458 ToolkitTestApplication application;
460 TextField textField = TextField::New();
461 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
462 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
464 TextField moved = std::move( textField );
465 DALI_TEST_CHECK( moved );
466 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
467 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
468 DALI_TEST_CHECK( !textField );
473 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
475 ToolkitTestApplication application;
476 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
477 TextField textField = TextField::New();
478 textField.SetProperty( TextField::Property::TEXT, "Test" );
480 TextField copy = textField;
481 DALI_TEST_CHECK( copy );
482 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
486 int UtcDaliTextFieldMoveAssignment(void)
488 ToolkitTestApplication application;
490 TextField textField = TextField::New();
491 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
492 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
495 moved = std::move( textField );
496 DALI_TEST_CHECK( moved );
497 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
498 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
499 DALI_TEST_CHECK( !textField );
504 int UtcDaliTextFieldNewP(void)
506 ToolkitTestApplication application;
507 tet_infoline(" UtcDaliToolkitTextFieldNewP");
508 TextField textField = TextField::New();
509 DALI_TEST_CHECK( textField );
513 // Positive test case for a method
514 int UtcDaliTextFieldGetPropertyP(void)
516 ToolkitTestApplication application;
517 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
518 TextField field = TextField::New();
519 DALI_TEST_CHECK( field );
521 // Check Property Indices are correct
522 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextField::Property::RENDERING_BACKEND );
523 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
524 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
525 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
526 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
527 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
528 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
529 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
530 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
531 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
532 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
533 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
534 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
535 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
536 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
537 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
538 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
539 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
540 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
541 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
542 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
543 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
544 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
545 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
546 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
547 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
548 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
549 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
550 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
551 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
552 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
553 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
554 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
555 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
556 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
557 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
558 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
559 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
560 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
561 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
562 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
563 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
564 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
565 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
566 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
567 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
568 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
569 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
570 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
571 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
572 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextField::Property::FONT_SIZE_SCALE );
573 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
574 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
575 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
576 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP );
577 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextField::Property::BACKGROUND );
578 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextField::Property::GRAB_HANDLE_COLOR );
579 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FILTER ) == DevelTextField::Property::INPUT_FILTER );
584 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
587 Property::Map imageMap;
588 imageMap[mapKey] =mapValue;
590 field.SetProperty( property , imageMap );
591 Property::Value propValue = field.GetProperty( property );
592 Property::Map* resultMap = propValue.GetMap();
594 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
602 // Positive test case for a method
603 int UtcDaliTextFieldSetPropertyP(void)
605 ToolkitTestApplication application;
606 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
607 TextField field = TextField::New();
608 DALI_TEST_CHECK( field );
609 application.GetScene().Add( field );
611 // Note - we can't check the defaults since the stylesheets are platform-specific
613 // Check the render backend property.
614 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
615 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
617 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
618 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION );
620 // Check text property.
621 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
622 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
624 // Check placeholder text properties.
625 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
626 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
628 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
629 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
631 // Check font properties.
632 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
633 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
635 Property::Map fontStyleMapSet;
636 Property::Map fontStyleMapGet;
637 Property::Value* slantValue = NULL;
639 fontStyleMapSet.Insert( "weight", "bold" );
640 fontStyleMapSet.Insert( "width", "condensed" );
641 fontStyleMapSet.Insert( "slant", "italic" );
642 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
644 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
645 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
646 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
648 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
649 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
651 field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 2.5f );
652 DALI_TEST_EQUALS( field.GetProperty<float>( DevelTextField::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
653 field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 1.0f );
656 fontStyleMapSet.Clear();
657 fontStyleMapSet.Insert( "weight", "normal" );
658 fontStyleMapSet.Insert( "slant", "oblique" );
659 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
661 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
662 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
663 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
665 fontStyleMapSet.Clear();
666 fontStyleMapSet.Insert( "slant", "roman" );
667 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
668 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
670 // Replace 'roman' for 'normal'.
671 slantValue = fontStyleMapGet.Find( "slant" );
672 if( NULL != slantValue )
674 if( "normal" == slantValue->Get<std::string>() )
676 fontStyleMapGet["slant"] = "roman";
679 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
680 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
682 fontStyleMapSet.Clear();
684 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
685 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
686 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
687 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
689 // Check that the MAX_LENGTH property can be correctly set
690 const int maxNumberOfCharacters = 20;
691 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
692 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
694 // Check exceed policy
695 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
696 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
697 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
698 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
700 // Check that the Alignment properties can be correctly set
701 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
702 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
703 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
704 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
706 // Check text's color property
707 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
708 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
710 // Check placeholder text's color property.
711 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
712 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
714 // Check cursor properties
715 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
716 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
717 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
718 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
720 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
721 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
722 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
723 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
724 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
725 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
726 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
727 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
729 // Check scroll properties.
730 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
731 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
732 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
733 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
735 // Check handle images
736 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
737 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
738 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
739 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
740 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
742 // Check handle images
743 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
744 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
745 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
746 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
747 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
748 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
750 // Check the highlight color
751 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
752 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
754 // Decoration bounding box
755 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
756 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
758 // Check the input method setting
759 Property::Map propertyMap;
760 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
761 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
762 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
763 int inputVariation = 1;
764 propertyMap["PANEL_LAYOUT"] = panelLayout;
765 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
766 propertyMap["BUTTON_ACTION"] = buttonAction;
767 propertyMap["VARIATION"] = inputVariation;
768 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
770 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
772 DALI_TEST_CHECK( value.Get( map ) );
775 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
776 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
779 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
780 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
783 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
784 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
787 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
788 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
790 // Check input color property.
791 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
792 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
794 // Check the enable markup property.
795 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
796 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
797 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
799 // Check input font properties.
800 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
801 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
803 fontStyleMapSet.Clear();
804 fontStyleMapSet.Insert( "weight", "bold" );
805 fontStyleMapSet.Insert( "width", "condensed" );
806 fontStyleMapSet.Insert( "slant", "italic" );
808 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
809 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
810 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
811 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
813 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
814 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
816 // Reset input font style.
817 fontStyleMapSet.Clear();
818 fontStyleMapSet.Insert( "weight", "normal" );
819 fontStyleMapSet.Insert( "slant", "oblique" );
821 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
822 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
823 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
824 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
826 fontStyleMapSet.Clear();
827 fontStyleMapSet.Insert( "slant", "roman" );
829 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
830 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
832 // Replace 'roman' for 'normal'.
833 slantValue = fontStyleMapGet.Find( "slant" );
834 if( NULL != slantValue )
836 if( "normal" == slantValue->Get<std::string>() )
838 fontStyleMapGet["slant"] = "roman";
841 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
842 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
844 fontStyleMapSet.Clear();
846 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
847 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
848 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
849 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
851 Property::Map underlineMapSet;
852 Property::Map underlineMapGet;
854 underlineMapSet.Insert( "enable", true );
855 underlineMapSet.Insert( "color", Color::RED );
856 underlineMapSet.Insert( "height", 1 );
858 // Check the underline property
859 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
861 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
862 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
863 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
865 // Check the input underline property
866 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
867 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
869 // Check the shadow property
870 Property::Map shadowMapSet;
871 Property::Map shadowMapGet;
873 shadowMapSet.Insert( "color", Color::GREEN );
874 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
875 shadowMapSet.Insert( "blurRadius", 3.0f );
877 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
879 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
880 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
881 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
883 // Check the input shadow property
884 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
885 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
887 // Check the emboss property
888 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
889 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
891 // Check the input emboss property
892 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
893 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
895 // Check the outline property
897 // Test string type first
898 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
899 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
900 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
902 // Then test the property map type
903 Property::Map outlineMapSet;
904 Property::Map outlineMapGet;
906 outlineMapSet["color"] = Color::RED;
907 outlineMapSet["width"] = 2.0f;
909 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
911 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
912 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
913 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
915 // Check the input outline property
916 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
917 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
919 // Check the hidden input settings property
920 Property::Map hiddenMapSet;
921 Property::Map hiddenMapGet;
922 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
923 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
924 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
925 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
926 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
928 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
929 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
930 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
932 // Check the pixel size of font
933 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
934 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
936 // Check the enable selection property
937 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
938 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
940 // Check the placeholder property with pixel size
941 Property::Map placeholderPixelSizeMapSet;
942 Property::Map placeholderPixelSizeMapGet;
943 Property::Map placeholderFontstyleMap;
944 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
945 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
946 placeholderPixelSizeMapSet["color"] = Color::BLUE;
947 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
948 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
949 placeholderPixelSizeMapSet["ellipsis"] = true;
951 placeholderFontstyleMap.Insert( "weight", "bold" );
952 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
953 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
955 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
956 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
958 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
959 Property::Map placeholderConversionMap;
960 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
961 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
962 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
963 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
964 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
965 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
967 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
969 // Check the placeholder property with point size
970 Property::Map placeholderMapSet;
971 Property::Map placeholderMapGet;
972 placeholderMapSet["text"] = "Setting Placeholder Text";
973 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
974 placeholderMapSet["color"] = Color::RED;
975 placeholderMapSet["fontFamily"] = "Arial";
976 placeholderMapSet["pointSize"] = 12.0f;
977 placeholderMapSet["ellipsis"] = false;
979 // Check the placeholder font style property
980 placeholderFontstyleMap.Clear();
982 placeholderFontstyleMap.Insert( "weight", "bold" );
983 placeholderFontstyleMap.Insert( "width", "condensed" );
984 placeholderFontstyleMap.Insert( "slant", "italic" );
985 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
986 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
988 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
989 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
991 placeholderConversionMap.Clear();
992 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
993 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
994 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
995 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
996 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
997 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
999 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1001 // Reset font style.
1002 placeholderFontstyleMap.Clear();
1003 placeholderFontstyleMap.Insert( "weight", "normal" );
1004 placeholderFontstyleMap.Insert( "slant", "oblique" );
1005 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1006 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1008 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1009 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1011 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1012 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1014 placeholderFontstyleMap.Clear();
1015 placeholderFontstyleMap.Insert( "slant", "roman" );
1016 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1017 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1019 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1021 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1023 placeholderFontstyleMap.Clear();
1024 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1025 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1027 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1028 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1029 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1031 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1033 // Check the ellipsis property
1034 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1035 field.SetProperty( TextField::Property::ELLIPSIS, true );
1036 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1038 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
1039 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1041 // Test the ENABLE_GRAB_HANDLE_POPUP property
1042 DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1043 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false );
1044 DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1046 // Check the background property
1047 field.SetProperty( DevelTextField::Property::BACKGROUND, Color::RED );
1048 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::BACKGROUND ), Color::RED, TEST_LOCATION );
1050 //Check handle color
1051 field.SetProperty( DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN );
1052 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
1054 // Check the input filter property
1055 Property::Map inputFilterMapSet;
1056 Property::Map inputFilterMapGet;
1057 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1058 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1060 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1062 inputFilterMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::INPUT_FILTER);
1063 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1066 inputFilterMapSet.Clear();
1067 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1069 application.SendNotification();
1070 application.Render();
1075 // Positive Atlas Text Renderer test
1076 int utcDaliTextFieldAtlasRenderP(void)
1078 ToolkitTestApplication application;
1079 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1080 StyleManager styleManager = StyleManager::Get();
1081 styleManager.ApplyDefaultTheme();
1082 TextField field = TextField::New();
1083 DALI_TEST_CHECK( field );
1085 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1087 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1089 application.GetScene().Add( field );
1093 // Render some text with the shared atlas backend
1094 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1095 application.SendNotification();
1096 application.Render();
1100 tet_result(TET_FAIL);
1105 // Positive test for the anchorClicked signal.
1106 int utcDaliTextFieldAnchorClicked01(void)
1108 ToolkitTestApplication application;
1109 tet_infoline(" utcDaliTextFieldAnchorClicked01");
1110 TextField field = TextField::New();
1111 DALI_TEST_CHECK(field);
1113 application.GetScene().Add(field);
1115 // connect to the anchor clicked signal.
1116 ConnectionTracker* testTracker = new ConnectionTracker();
1117 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1118 bool anchorClickedSignal = false;
1119 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1121 gAnchorClickedCallBackCalled = false;
1122 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1123 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1124 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1125 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1126 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1128 application.SendNotification();
1129 application.Render();
1130 field.SetKeyInputFocus();
1132 // Create a tap event to touch the text field.
1133 TestGenerateTap(application, 5.0f, 25.0f);
1134 application.SendNotification();
1135 application.Render();
1137 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1138 DALI_TEST_CHECK(anchorClickedSignal);
1140 gAnchorClickedCallBackNotCalled = true;
1141 // Tap the outside of anchor, callback should not be called.
1142 TestGenerateTap(application, 150.f, 100.f);
1143 application.SendNotification();
1144 application.Render();
1146 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1151 // Positive test for the anchorClicked signal.
1152 int utcDaliTextFieldAnchorClicked02(void)
1154 ToolkitTestApplication application;
1155 tet_infoline(" utcDaliTextFieldAnchorClicked02");
1156 TextField field = TextField::New();
1157 DALI_TEST_CHECK(field);
1159 application.GetScene().Add(field);
1161 // connect to the anchor clicked signal.
1162 ConnectionTracker* testTracker = new ConnectionTracker();
1163 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1164 bool anchorClickedSignal = false;
1165 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1167 gAnchorClickedCallBackCalled = false;
1168 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1169 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1170 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1171 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1172 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1174 application.SendNotification();
1175 application.Render();
1176 field.SetKeyInputFocus();
1178 // Avoid a crash when core load gl resources.
1179 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1181 // Create a tap event to touch the text field.
1182 TestGenerateTap(application, 30.0f, 25.0f, 100);
1183 application.SendNotification();
1184 application.Render();
1186 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1187 DALI_TEST_CHECK(anchorClickedSignal);
1190 // For coverage InsertTextAnchor, RemoveTextAnchor
1191 // first index insert
1192 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1193 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1194 application.SendNotification();
1195 application.Render();
1197 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1198 application.SendNotification();
1199 application.Render();
1201 gAnchorClickedCallBackCalled = false;
1202 // Create a tap event to touch the text field.
1203 TestGenerateTap(application, 30.0f, 25.0f, 700);
1204 application.SendNotification();
1205 field.SetKeyInputFocus();
1207 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1209 // last index insert
1210 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1211 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1212 application.SendNotification();
1213 application.Render();
1215 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1216 application.SendNotification();
1217 application.Render();
1219 gAnchorClickedCallBackCalled = false;
1220 // Create a tap event to touch the text field.
1221 TestGenerateTap(application, 30.0f, 25.0f, 1300);
1222 application.SendNotification();
1223 field.SetKeyInputFocus();
1225 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1228 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1229 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1230 application.SendNotification();
1231 application.Render();
1233 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1234 application.SendNotification();
1235 application.Render();
1237 gAnchorClickedCallBackCalled = false;
1238 // Create a tap event to touch the text field.
1239 TestGenerateTap(application, 30.0f, 25.0f, 1900);
1240 application.SendNotification();
1241 field.SetKeyInputFocus();
1243 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1245 // first index remove
1246 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1247 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1248 application.SendNotification();
1249 application.Render();
1251 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1252 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));
1253 application.SendNotification();
1254 application.Render();
1256 gAnchorClickedCallBackCalled = false;
1257 // Create a tap event to touch the text field.
1258 TestGenerateTap(application, 30.0f, 25.0f, 2500);
1259 application.SendNotification();
1260 field.SetKeyInputFocus();
1262 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1264 // last index remove
1265 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1266 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1267 application.SendNotification();
1268 application.Render();
1270 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1271 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));
1272 application.SendNotification();
1273 application.Render();
1275 gAnchorClickedCallBackCalled = false;
1276 // Create a tap event to touch the text field.
1277 TestGenerateTap(application, 30.0f, 25.0f, 3100);
1278 application.SendNotification();
1279 application.Render();
1281 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1284 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1285 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1286 application.SendNotification();
1287 application.Render();
1289 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1290 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));
1291 application.SendNotification();
1292 application.Render();
1294 gAnchorClickedCallBackCalled = false;
1295 // Create a tap event to touch the text field.
1296 TestGenerateTap(application, 30.0f, 25.0f, 3700);
1297 application.SendNotification();
1298 application.Render();
1300 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1302 // 0 ~ 1 index remove
1303 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1304 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 0);
1305 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 1);
1306 application.SendNotification();
1307 application.Render();
1309 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1310 application.SendNotification();
1311 application.Render();
1313 gAnchorClickedCallBackCalled = false;
1314 // Create a tap event to touch the text field.
1315 TestGenerateTap(application, 30.0f, 25.0f, 4300);
1316 application.SendNotification();
1317 application.Render();
1319 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1321 // 1 ~ 3 index remove
1322 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1323 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 1);
1324 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 3);
1325 application.SendNotification();
1326 application.Render();
1328 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1329 application.SendNotification();
1330 application.Render();
1332 gAnchorClickedCallBackCalled = false;
1333 // Create a tap event to touch the text field.
1334 TestGenerateTap(application, 30.0f, 25.0f, 4900);
1335 application.SendNotification();
1336 application.Render();
1338 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1340 // 3 ~ 4 index remove
1341 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1342 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 3);
1343 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 4);
1344 application.SendNotification();
1345 application.Render();
1347 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1348 application.SendNotification();
1349 application.Render();
1351 gAnchorClickedCallBackCalled = false;
1352 // Create a tap event to touch the text field.
1353 TestGenerateTap(application, 30.0f, 25.0f, 5500);
1354 application.SendNotification();
1355 application.Render();
1357 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1359 // Remove front of anchor
1360 field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
1361 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
1362 application.SendNotification();
1363 application.Render();
1365 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1366 application.SendNotification();
1367 application.Render();
1369 // Remove whole text
1370 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1371 DevelTextField::SelectWholeText(field);
1372 application.SendNotification();
1373 application.Render();
1375 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1376 application.SendNotification();
1377 application.Render();
1379 // Remove all with backspace
1380 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1381 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
1382 application.SendNotification();
1383 application.Render();
1385 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1386 application.SendNotification();
1387 application.Render();
1389 // Remove all with delete
1390 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1391 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1392 application.SendNotification();
1393 application.Render();
1395 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));
1396 application.SendNotification();
1397 application.Render();
1402 // Positive test for the textChanged signal.
1403 int utcDaliTextFieldTextChangedP(void)
1405 ToolkitTestApplication application;
1406 tet_infoline(" utcDaliTextFieldTextChangedP");
1407 TextField field = TextField::New();
1408 DALI_TEST_CHECK( field );
1410 application.GetScene().Add( field );
1412 // connect to the text changed signal.
1413 ConnectionTracker* testTracker = new ConnectionTracker();
1414 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1415 bool textChangedSignal = false;
1416 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1418 gTextChangedCallBackCalled = false;
1419 field.SetProperty( TextField::Property::TEXT, "ABC" );
1420 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1421 DALI_TEST_CHECK( textChangedSignal );
1423 application.SendNotification();
1424 field.SetKeyInputFocus();
1426 gTextChangedCallBackCalled = false;
1427 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1428 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1431 field.SetProperty( TextField::Property::TEXT, "" );
1433 // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1434 gTextChangedCallBackCalled = false;
1435 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1436 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1438 // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1439 gTextChangedCallBackCalled = false;
1440 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1441 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1446 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1448 ToolkitTestApplication application;
1449 tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1450 TextField field = TextField::New();
1451 DALI_TEST_CHECK( field );
1454 application.GetScene().Add( field );
1456 // connect to the text changed signal.
1457 ConnectionTracker* testTracker = new ConnectionTracker();
1458 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1459 bool textChangedSignal = false;
1460 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1463 // get InputMethodContext
1465 InputMethodContext::EventData imfEvent;
1466 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext( field );
1468 field.SetKeyInputFocus();
1469 field.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
1472 gTextChangedCallBackCalled = false;
1473 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1474 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1475 application.SendNotification();
1476 application.Render();
1477 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1478 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1480 gTextChangedCallBackCalled = false;
1481 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1482 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1483 application.SendNotification();
1484 application.Render();
1485 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1486 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호"), TEST_LOCATION );
1488 gTextChangedCallBackCalled = false;
1489 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1490 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1491 application.SendNotification();
1492 application.Render();
1493 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1494 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1496 gTextChangedCallBackCalled = false;
1497 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1498 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1499 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1501 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1502 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1503 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1505 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1506 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1507 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1509 application.SendNotification();
1510 application.Render();
1511 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1512 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1518 // Negative test for the textChanged signal.
1519 int utcDaliTextFieldTextChangedN(void)
1521 ToolkitTestApplication application;
1522 tet_infoline(" utcDaliTextFieldTextChangedN");
1523 TextField field = TextField::New();
1524 DALI_TEST_CHECK( field );
1526 application.GetScene().Add( field );
1528 // connect to the text changed signal.
1529 ConnectionTracker* testTracker = new ConnectionTracker();
1530 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1531 bool textChangedSignal = false;
1532 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1534 gTextChangedCallBackCalled = false;
1535 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1536 application.SendNotification();
1537 application.Render();
1538 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1539 DALI_TEST_CHECK( !textChangedSignal );
1544 // Positive test for Max Characters reached signal.
1545 int utcDaliTextFieldMaxCharactersReachedP(void)
1547 ToolkitTestApplication application;
1548 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1549 TextField field = TextField::New();
1550 DALI_TEST_CHECK( field );
1552 application.GetScene().Add( field );
1554 const int maxNumberOfCharacters = 1;
1555 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1557 field.SetKeyInputFocus();
1559 // connect to the text changed signal.
1560 ConnectionTracker* testTracker = new ConnectionTracker();
1561 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1562 bool maxLengthReachedSignal = false;
1563 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1565 gMaxCharactersCallBackCalled = false;
1567 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1568 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1570 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1571 DALI_TEST_CHECK( maxLengthReachedSignal );
1576 // Negative test for Max Characters reached signal.
1577 int utcDaliTextFieldMaxCharactersReachedN(void)
1579 ToolkitTestApplication application;
1580 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1581 TextField field = TextField::New();
1582 DALI_TEST_CHECK( field );
1584 application.GetScene().Add( field );
1586 const int maxNumberOfCharacters = 3;
1587 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1589 field.SetKeyInputFocus();
1591 // connect to the text changed signal.
1592 ConnectionTracker* testTracker = new ConnectionTracker();
1593 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1594 bool maxLengthReachedSignal = false;
1595 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1597 gMaxCharactersCallBackCalled = false;
1599 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1600 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1602 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1603 DALI_TEST_CHECK( !maxLengthReachedSignal );
1605 application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1607 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1608 DALI_TEST_CHECK( !maxLengthReachedSignal );
1613 // Positive test for Input Filtered signal.
1614 int utcDaliTextFieldInputFilteredP(void)
1616 ToolkitTestApplication application;
1617 tet_infoline(" utcDaliTextFieldInputFilteredP");
1618 TextField field = TextField::New();
1619 DALI_TEST_CHECK(field);
1621 application.GetScene().Add(field);
1623 Property::Map inputFilter;
1625 // Only digit is accepted.
1626 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1628 // Set input filter to TextField.
1629 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1631 field.SetKeyInputFocus();
1633 // connect to the input filtered signal.
1634 ConnectionTracker* testTracker = new ConnectionTracker();
1635 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1636 bool inputFilteredSignal = false;
1637 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1639 gInputFilteredAcceptedCallbackCalled = false;
1641 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ));
1643 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1644 DALI_TEST_CHECK(inputFilteredSignal);
1646 // Word is rejected.
1647 inputFilter[InputFilter::Property::ACCEPTED] = "";
1648 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1650 // Set input filter to TextField.
1651 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1653 field.SetKeyInputFocus();
1655 inputFilteredSignal = false;
1656 gInputFilteredRejectedCallbackCalled = false;
1658 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1660 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1661 DALI_TEST_CHECK(inputFilteredSignal);
1666 // Negative test for Input Filtered signal.
1667 int utcDaliTextFieldInputFilteredN(void)
1669 ToolkitTestApplication application;
1670 tet_infoline(" utcDaliTextFieldInputFilteredP");
1671 TextField field = TextField::New();
1672 DALI_TEST_CHECK(field);
1674 application.GetScene().Add(field);
1676 Property::Map inputFilter;
1678 // Only word is accepted.
1679 inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
1681 // Set input filter to TextField.
1682 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1684 field.SetKeyInputFocus();
1686 // connect to the input filtered signal.
1687 ConnectionTracker* testTracker = new ConnectionTracker();
1688 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1689 bool inputFilteredSignal = false;
1690 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1692 gInputFilteredAcceptedCallbackCalled = false;
1694 // Key a, d should not be filtered.
1695 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1696 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1697 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1698 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1700 // Backspace, Delete should not be filtered.
1701 application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1702 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));
1704 // Render and notify
1705 application.SendNotification();
1706 application.Render();
1708 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1709 DALI_TEST_CHECK(!inputFilteredSignal);
1711 // Digit is rejected.
1712 inputFilter[InputFilter::Property::ACCEPTED] = "";
1713 inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
1715 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1717 field.SetKeyInputFocus();
1719 inputFilteredSignal = false;
1720 gInputFilteredRejectedCallbackCalled = false;
1722 // Key a, d should not be filtered.
1723 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1724 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1725 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1726 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1728 // Backspace, Delete should not be filtered.
1729 application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1730 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));
1732 // Render and notify
1733 application.SendNotification();
1734 application.Render();
1736 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1737 DALI_TEST_CHECK(!inputFilteredSignal);
1742 int utcDaliTextFieldInputStyleChanged01(void)
1744 // The text-field emits signals when the input style changes. These changes of style are
1745 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1746 // can't be emitted during the size negotiation as the callbacks may update the UI.
1747 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1748 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1749 ToolkitTestApplication application;
1750 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1754 char* pathNamePtr = get_current_dir_name();
1755 const std::string pathName( pathNamePtr );
1756 free( pathNamePtr );
1758 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1759 fontClient.SetDpi( 93u, 93u );
1761 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1762 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1764 TextField field = TextField::New();
1765 DALI_TEST_CHECK( field );
1768 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1769 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1770 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1772 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1773 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1775 // connect to the text changed signal.
1776 ConnectionTracker* testTracker = new ConnectionTracker();
1777 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1778 bool inputStyleChangedSignal = false;
1779 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1781 application.GetScene().Add( field );
1783 // Render and notify
1784 application.SendNotification();
1785 application.Render();
1787 // Executes the idle callbacks added by the text control on the change of input style.
1788 application.RunIdles();
1790 gInputStyleChangedCallbackCalled = false;
1791 gInputStyleMask = TextField::InputStyle::NONE;
1792 inputStyleChangedSignal = false;
1794 // Create a tap event to touch the text field.
1795 TestGenerateTap( application, 18.0f, 25.0f );
1797 // Render and notify
1798 application.SendNotification();
1799 application.Render();
1801 // Executes the idle callbacks added by the text control on the change of input style.
1802 application.RunIdles();
1804 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1805 if( gInputStyleChangedCallbackCalled )
1807 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1809 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1810 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1812 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1813 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1815 DALI_TEST_CHECK( inputStyleChangedSignal );
1817 gInputStyleChangedCallbackCalled = false;
1818 gInputStyleMask = TextField::InputStyle::NONE;
1819 inputStyleChangedSignal = false;
1821 // Create a tap event to touch the text field.
1822 TestGenerateTap( application, 30.0f, 25.0f );
1824 // Render and notify
1825 application.SendNotification();
1826 application.Render();
1828 // Executes the idle callbacks added by the text control on the change of input style.
1829 application.RunIdles();
1831 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1832 DALI_TEST_CHECK( !inputStyleChangedSignal );
1834 gInputStyleChangedCallbackCalled = false;
1835 gInputStyleMask = TextField::InputStyle::NONE;
1836 inputStyleChangedSignal = false;
1838 // Create a tap event to touch the text field.
1839 TestGenerateTap( application, 43.0f, 25.0f );
1841 // Render and notify
1842 application.SendNotification();
1843 application.Render();
1845 // Executes the idle callbacks added by the text control on the change of input style.
1846 application.RunIdles();
1848 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1849 if( gInputStyleChangedCallbackCalled )
1851 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1853 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1854 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1856 DALI_TEST_CHECK( inputStyleChangedSignal );
1858 gInputStyleChangedCallbackCalled = false;
1859 gInputStyleMask = TextField::InputStyle::NONE;
1860 inputStyleChangedSignal = false;
1862 // Create a tap event to touch the text field.
1863 TestGenerateTap( application, 88.0f, 25.0f );
1865 // Render and notify
1866 application.SendNotification();
1867 application.Render();
1869 // Executes the idle callbacks added by the text control on the change of input style.
1870 application.RunIdles();
1872 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1873 if( gInputStyleChangedCallbackCalled )
1875 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1877 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1878 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1880 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1882 Property::Map fontStyleMapSet;
1883 fontStyleMapSet.Insert( "weight", "bold" );
1885 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1886 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1888 DALI_TEST_CHECK( inputStyleChangedSignal );
1890 gInputStyleChangedCallbackCalled = false;
1891 gInputStyleMask = TextField::InputStyle::NONE;
1892 inputStyleChangedSignal = false;
1894 // Create a tap event to touch the text field.
1895 TestGenerateTap( application, 115.0f, 25.0f );
1897 // Render and notify
1898 application.SendNotification();
1899 application.Render();
1901 // Executes the idle callbacks added by the text control on the change of input style.
1902 application.RunIdles();
1904 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1905 DALI_TEST_CHECK( !inputStyleChangedSignal );
1907 gInputStyleChangedCallbackCalled = false;
1908 gInputStyleMask = TextField::InputStyle::NONE;
1909 inputStyleChangedSignal = false;
1911 // Create a tap event to touch the text field.
1912 TestGenerateTap( application, 164.0f, 25.0f );
1914 // Render and notify
1915 application.SendNotification();
1916 application.Render();
1918 // Executes the idle callbacks added by the text control on the change of input style.
1919 application.RunIdles();
1921 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1922 if( gInputStyleChangedCallbackCalled )
1924 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1926 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1927 DALI_TEST_CHECK( style.empty() );
1929 DALI_TEST_CHECK( inputStyleChangedSignal );
1931 gInputStyleChangedCallbackCalled = false;
1932 gInputStyleMask = TextField::InputStyle::NONE;
1933 inputStyleChangedSignal = false;
1935 // Create a tap event to touch the text field.
1936 TestGenerateTap( application, 191.0f, 25.0f );
1938 // Render and notify
1939 application.SendNotification();
1940 application.Render();
1942 // Executes the idle callbacks added by the text control on the change of input style.
1943 application.RunIdles();
1945 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1946 DALI_TEST_CHECK( !inputStyleChangedSignal );
1951 int utcDaliTextFieldInputStyleChanged02(void)
1953 // The text-field emits signals when the input style changes. These changes of style are
1954 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1955 // can't be emitted during the size negotiation as the callbacks may update the UI.
1956 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1957 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1958 ToolkitTestApplication application;
1959 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1963 char* pathNamePtr = get_current_dir_name();
1964 const std::string pathName( pathNamePtr );
1965 free( pathNamePtr );
1967 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1968 fontClient.SetDpi( 93u, 93u );
1970 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1971 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1973 TextField field = TextField::New();
1974 DALI_TEST_CHECK( field );
1976 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1977 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1978 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1980 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1981 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>" );
1983 // connect to the text changed signal.
1984 ConnectionTracker* testTracker = new ConnectionTracker();
1985 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1986 bool inputStyleChangedSignal = false;
1987 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1989 application.GetScene().Add( field );
1991 // Render and notify
1992 application.SendNotification();
1993 application.Render();
1995 // Executes the idle callbacks added by the text control on the change of input style.
1996 application.RunIdles();
1998 gInputStyleChangedCallbackCalled = false;
1999 gInputStyleMask = TextField::InputStyle::NONE;
2000 inputStyleChangedSignal = false;
2002 // Create a tap event to touch the text field.
2003 TestGenerateTap( application, 53.0f, 25.0f, 100 );
2004 TestGenerateTap( application, 53.0f, 25.0f, 200 );
2006 // Render and notify
2007 application.SendNotification();
2008 application.Render();
2010 // Executes the idle callbacks added by the text control on the change of input style.
2011 application.RunIdles();
2013 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2014 if( gInputStyleChangedCallbackCalled )
2016 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2017 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
2018 TextField::InputStyle::POINT_SIZE |
2019 TextField::InputStyle::COLOR ),
2022 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2023 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
2025 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
2026 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
2028 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
2029 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2031 DALI_TEST_CHECK( inputStyleChangedSignal );
2033 gInputStyleChangedCallbackCalled = false;
2034 gInputStyleMask = TextField::InputStyle::NONE;
2035 inputStyleChangedSignal = false;
2037 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2039 // Render and notify
2040 application.SendNotification();
2041 application.Render();
2043 // Executes the idle callbacks added by the text control on the change of input style.
2044 application.RunIdles();
2046 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2047 if( gInputStyleChangedCallbackCalled )
2049 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2050 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
2053 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2054 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
2056 DALI_TEST_CHECK( inputStyleChangedSignal );
2058 gInputStyleChangedCallbackCalled = false;
2059 gInputStyleMask = TextField::InputStyle::NONE;
2060 inputStyleChangedSignal = false;
2062 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2064 // Render and notify
2065 application.SendNotification();
2066 application.Render();
2068 // Executes the idle callbacks added by the text control on the change of input style.
2069 application.RunIdles();
2071 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
2072 DALI_TEST_CHECK( !inputStyleChangedSignal );
2074 gInputStyleChangedCallbackCalled = false;
2075 gInputStyleMask = TextField::InputStyle::NONE;
2076 inputStyleChangedSignal = false;
2078 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2080 // Render and notify
2081 application.SendNotification();
2082 application.Render();
2084 // Executes the idle callbacks added by the text control on the change of input style.
2085 application.RunIdles();
2087 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2088 if( gInputStyleChangedCallbackCalled )
2090 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2091 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
2094 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2095 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
2097 DALI_TEST_CHECK( inputStyleChangedSignal );
2099 gInputStyleChangedCallbackCalled = false;
2100 gInputStyleMask = TextField::InputStyle::NONE;
2101 inputStyleChangedSignal = false;
2103 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
2105 Property::Map fontStyleMapSet;
2106 fontStyleMapSet.Insert( "weight", "thin" );
2107 fontStyleMapSet.Insert( "width", "condensed" );
2108 fontStyleMapSet.Insert( "slant", "italic" );
2110 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2111 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
2113 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
2114 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
2115 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
2116 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
2118 // Render and notify
2119 application.SendNotification();
2120 application.Render();
2122 // Executes the idle callbacks added by the text control on the change of input style.
2123 application.RunIdles();
2125 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
2126 DALI_TEST_CHECK( !inputStyleChangedSignal );
2128 // Create a tap event to touch the text field.
2129 TestGenerateTap( application, 63.0f, 25.0f, 700 );
2131 // Render and notify
2132 application.SendNotification();
2133 application.Render();
2135 // Executes the idle callbacks added by the text control on the change of input style.
2136 application.RunIdles();
2138 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2139 if( gInputStyleChangedCallbackCalled )
2141 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2142 static_cast<unsigned int>( TextField::InputStyle::COLOR |
2143 TextField::InputStyle::POINT_SIZE |
2144 TextField::InputStyle::FONT_STYLE |
2145 TextField::InputStyle::UNDERLINE |
2146 TextField::InputStyle::SHADOW |
2147 TextField::InputStyle::EMBOSS |
2148 TextField::InputStyle::OUTLINE ),
2151 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2152 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
2154 DALI_TEST_CHECK( inputStyleChangedSignal );
2159 int utcDaliTextFieldEvent01(void)
2161 ToolkitTestApplication application;
2162 tet_infoline(" utcDaliTextFieldEvent01");
2164 // Creates a tap event. After creating a tap event the text field should
2165 // have the focus and add text with key events should be possible.
2167 TextField field = TextField::New();
2168 DALI_TEST_CHECK( field );
2170 application.GetScene().Add( field );
2172 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2173 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2174 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2176 // Render and notify
2177 application.SendNotification();
2178 application.Render();
2180 // Avoid a crash when core load gl resources.
2181 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2183 // Render and notify
2184 application.SendNotification();
2185 application.Render();
2187 // Add a key event but as the text field has not the focus it should do nothing.
2188 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2190 // Render and notify
2191 application.SendNotification();
2192 application.Render();
2194 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2196 // Create a tap event to touch the text field.
2197 TestGenerateTap( application, 150.0f, 25.0f );
2199 // Render and notify
2200 application.SendNotification();
2201 application.Render();
2203 // Pressing delete key should be fine even if there is no text in TextField.
2204 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 ) );
2205 // Render and notify
2206 application.SendNotification();
2207 application.Render();
2209 // Now the text field has the focus, so it can handle the key events.
2210 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2211 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2213 // Render and notify
2214 application.SendNotification();
2215 application.Render();
2217 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2219 // Create a second text field and send key events to it.
2220 TextField field2 = TextField::New();
2222 field2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2223 field2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2224 field2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2225 field2.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
2227 application.GetScene().Add( field2 );
2229 // Render and notify
2230 application.SendNotification();
2231 application.Render();
2233 // Create a tap event on the second text field.
2234 TestGenerateTap( application, 150.0f, 125.0f );
2236 // Render and notify
2237 application.SendNotification();
2238 application.Render();
2240 // The second text field has the focus. It should handle the key events.
2241 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2242 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2244 // Render and notify
2245 application.SendNotification();
2246 application.Render();
2248 // Check the text has been added to the second text field.
2249 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2254 int utcDaliTextFieldEvent02(void)
2256 ToolkitTestApplication application;
2257 tet_infoline(" utcDaliTextFieldEvent02");
2259 // Checks if the right number of actors are created.
2261 TextField field = TextField::New();
2262 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2263 DALI_TEST_CHECK( field );
2264 LoadMarkerImages(application, field);
2266 application.GetScene().Add( field );
2268 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2269 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2270 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2272 // Avoid a crash when core load gl resources.
2273 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2275 // Render and notify
2276 application.SendNotification();
2277 application.Render();
2279 // Check there are the expected number of children ( stencil ).
2280 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
2282 Actor stencil = field.GetChildAt( 0u );
2283 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2285 // Create a tap event to touch the text field.
2286 TestGenerateTap( application, 150.0f, 25.0f, 300 );
2288 // Render and notify
2289 application.SendNotification();
2290 application.Render();
2292 Actor layer = field.GetChildAt( 1u );
2293 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2294 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2296 // Now the text field has the focus, so it can handle the key events.
2297 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2298 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2300 // Render and notify
2301 application.SendNotification();
2302 application.Render();
2304 // Checks the cursor and the renderer have been created.
2305 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2306 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
2308 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
2309 DALI_TEST_CHECK( cursor );
2311 // The offscreen root actor has a container with all the actors which contain the text renderers.
2312 Actor container = stencil.GetChildAt( 0u );
2313 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2315 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2316 DALI_TEST_CHECK( renderer );
2319 // Move the cursor and check the position changes.
2320 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2321 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2323 // Render and notify
2324 application.SendNotification();
2325 application.Render();
2327 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2328 DALI_TEST_CHECK( position2.x < position1.x );
2330 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2332 // Render and notify
2333 application.SendNotification();
2334 application.Render();
2336 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2337 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
2340 // Move the cursor to the first position.
2341 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2342 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2344 // Render and notify
2345 application.SendNotification();
2346 application.Render();
2348 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2350 // Send some taps and check the cursor positions.
2352 // Try to tap at the beginning.
2353 TestGenerateTap( application, 1.0f, 25.0f, 900 );
2355 // Render and notify
2356 application.SendNotification();
2357 application.Render();
2359 // Cursor position should be the same than position1.
2360 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2362 DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
2364 // Tap away from the start position.
2365 TestGenerateTap( application, 16.0f, 25.0f, 1500 );
2367 // Render and notify
2368 application.SendNotification();
2369 application.Render();
2371 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2373 DALI_TEST_CHECK( position6.x > position5.x );
2375 // Remove all the text.
2376 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2377 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2378 field.SetProperty( TextField::Property::TEXT, "" );
2380 // Render and notify
2381 application.SendNotification();
2382 application.Render();
2384 // Cursor position should be the same than position2.
2385 Vector3 position7 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2387 DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
2389 // Should not be a renderer.
2390 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2392 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2393 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2394 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
2396 application.SendNotification();
2397 application.Render();
2399 // There are renderer and decorator layer
2400 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
2405 int utcDaliTextFieldEvent03(void)
2407 ToolkitTestApplication application;
2408 tet_infoline(" utcDaliTextFieldEvent03");
2410 // Checks if the highlight actor is created.
2412 TextField field = TextField::New();
2413 DALI_TEST_CHECK( field );
2415 application.GetScene().Add( field );
2417 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2418 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2419 field.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
2420 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2421 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2423 // Avoid a crash when core load gl resources.
2424 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2425 LoadMarkerImages(application, field);
2427 // Render and notify
2428 application.SendNotification();
2429 application.Render();
2431 // Tap first to get the focus.
2432 TestGenerateTap( application, 3.0f, 25.0f );
2434 // Render and notify
2435 application.SendNotification();
2436 application.Render();
2438 // Double tap to select a word.
2439 TestGenerateTap( application, 3.0f, 25.0f );
2441 // Render and notify
2442 application.SendNotification();
2443 application.Render();
2445 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2446 Actor stencil = field.GetChildAt( 0u );
2448 // The highlight actor is drawn first, so is the first actor in the list
2449 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2450 DALI_TEST_CHECK( highlight );
2452 // The offscreen root actor has a container with all the actors which contain the text renderers.
2453 Actor container = stencil.GetChildAt( 1u );
2454 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2456 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2457 DALI_TEST_CHECK( renderer );
2463 int utcDaliTextFieldEvent04(void)
2465 ToolkitTestApplication application;
2466 tet_infoline(" utcDaliTextFieldEvent04");
2468 // Checks if the highlight actor is created.
2470 TextField field = TextField::New();
2471 DALI_TEST_CHECK( field );
2472 application.GetScene().Add( field );
2473 LoadMarkerImages(application, field);
2474 // Render and notify
2475 application.SendNotification();
2476 application.Render();
2478 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2479 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2480 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2481 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2482 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2484 // Avoid a crash when core load gl resources.
2485 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2486 // Render and notify
2487 application.SendNotification();
2488 application.Render();
2490 // Create a tap event to touch the text field.
2491 TestGenerateTap( application, 150.0f, 25.0f );
2492 // Render and notify
2493 application.SendNotification();
2494 application.Render();
2497 // Tap first to get the focus.
2498 TestGenerateTap( application, 1.0f, 25.0f );
2500 // Render and notify
2501 application.SendNotification();
2502 application.Render();
2504 // Double tap to select a word.
2505 TestGenerateTap( application, 1.0f, 25.0f );
2507 // Render and notify
2508 application.SendNotification();
2509 application.Render();
2512 TestGenerateTap( application, 0.0f, 40.0f );
2516 int utcDaliTextFieldEvent05(void)
2518 ToolkitTestApplication application;
2519 tet_infoline(" utcDaliTextFieldEvent05");
2521 // Checks dragging of cursor/grab handle
2523 TextField field = TextField::New();
2524 DALI_TEST_CHECK( field );
2525 application.GetScene().Add( field );
2526 LoadMarkerImages(application, field);
2527 // Render and notify
2528 application.SendNotification();
2529 application.Render();
2531 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2532 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2533 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2534 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2535 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2537 // Avoid a crash when core load gl resources.
2538 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2539 // Render and notify
2540 application.SendNotification();
2541 application.Render();
2543 // Create a tap event to touch the text field.
2544 TestGenerateTap( application, 150.0f, 25.0f );
2545 // Render and notify
2546 application.SendNotification();
2547 application.Render();
2549 // Tap first to get the focus.
2550 TestGenerateTap( application, 1.0f, 25.0f );
2552 // Render and notify
2553 application.SendNotification();
2554 application.Render();
2556 // Double tap to select a word.
2557 TestGenerateTap( application, 1.0f, 25.0f );
2559 // Render and notify
2560 application.SendNotification();
2561 application.Render();
2563 Actor stencil = field.GetChildAt( 1u );
2567 int utcDaliTextFieldEvent06(void)
2569 ToolkitTestApplication application;
2570 tet_infoline(" utcDaliTextFieldEvent06");
2572 // Checks Longpress when in edit mode
2574 TextField field = TextField::New();
2575 DALI_TEST_CHECK( field );
2576 application.GetScene().Add( field );
2577 LoadMarkerImages(application, field);
2578 // Render and notify
2579 application.SendNotification();
2580 application.Render();
2582 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2583 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2584 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2585 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2586 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2588 // Avoid a crash when core load gl resources.
2589 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2590 // Render and notify
2591 application.SendNotification();
2592 application.Render();
2594 // Create a tap event to touch the text field.
2595 TestGenerateTap( application, 150.0f, 25.0f );
2596 // Render and notify
2597 application.SendNotification();
2598 application.Render();
2601 // Tap first to get the focus.
2602 TestGenerateTap( application, 1.0f, 25.0f );
2604 // Render and notify
2605 application.SendNotification();
2606 application.Render();
2609 TestGenerateLongPress(application, 1.0f, 25.0f);
2611 // Render and notify
2612 application.SendNotification();
2613 application.Render();
2618 int utcDaliTextFieldEvent07(void)
2620 ToolkitTestApplication application;
2621 tet_infoline(" utcDaliTextFieldEvent07");
2623 // Checks Longpress to start edit mode
2625 TextField field = TextField::New();
2626 DALI_TEST_CHECK( field );
2627 application.GetScene().Add( field );
2628 LoadMarkerImages(application, field);
2629 // Render and notify
2630 application.SendNotification();
2631 application.Render();
2633 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2634 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2635 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2636 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2637 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2638 Property::Map propertyMap;
2639 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2640 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2642 // Avoid a crash when core load gl resources.
2643 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2644 // Render and notify
2645 application.SendNotification();
2646 application.Render();
2649 TestGenerateLongPress(application, 1.0f, 25.0f);
2651 // Render and notify
2652 application.SendNotification();
2653 application.Render();
2658 int utcDaliTextFieldEvent08(void)
2660 ToolkitTestApplication application;
2661 tet_infoline(" utcDaliTextFieldEvent08");
2663 Dali::Clipboard clipboard = Clipboard::Get();
2664 clipboard.SetItem("testTextFieldEvent");
2666 // Checks Longpress when only place holder text
2668 TextField field = TextField::New();
2669 DALI_TEST_CHECK( field );
2670 application.GetScene().Add( field );
2671 LoadMarkerImages(application, field);
2672 // Render and notify
2673 application.SendNotification();
2674 application.Render();
2676 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2677 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2678 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2679 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2680 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2682 // Avoid a crash when core load gl resources.
2683 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2684 // Render and notify
2685 application.SendNotification();
2686 application.Render();
2689 TestGenerateLongPress( application, 1.0f, 25.0f, 20 );
2691 // Render and notify
2692 application.SendNotification();
2693 application.Render();
2695 Wait(application, 500);
2697 TestEndLongPress( application, 1.0f, 25.0f, 520 );
2700 TestGenerateLongPress( application, 1.0f, 25.0f, 600 );
2702 // Render and notify
2703 application.Render();
2705 Wait(application, 500);
2707 Integration::Scene stage = application.GetScene();
2708 Layer layer = stage.GetRootLayer();
2709 Actor actor = layer.FindChildByName("optionPaste");
2713 Vector3 worldPosition = actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION );
2714 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2715 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2717 Dali::Integration::TouchEvent event;
2718 event = Dali::Integration::TouchEvent();
2719 event.AddPoint( GetPointDownInside( position ) );
2720 application.ProcessEvent( event );
2722 event = Dali::Integration::TouchEvent();
2723 event.AddPoint( GetPointUpInside( position ) );
2724 application.ProcessEvent( event );
2726 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2731 int utcDaliTextFieldEvent09(void)
2733 ToolkitTestApplication application;
2734 tet_infoline(" utcDaliTextFieldEvent09");
2736 TextField field = TextField::New();
2737 DALI_TEST_CHECK( field );
2738 application.GetScene().Add( field );
2739 LoadMarkerImages(application, field);
2740 // Render and notify
2741 application.SendNotification();
2742 application.Render();
2744 field.SetProperty( TextField::Property::TEXT, "Hello" );
2745 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2746 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2747 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2748 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2750 // Avoid a crash when core load gl resources.
2751 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2753 // Create a tap event to touch the text field.
2754 TestGenerateTap( application, 150.0f, 25.0f );
2755 application.SendNotification();
2756 application.Render();
2759 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2760 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2761 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2762 application.SendNotification();
2763 application.Render();
2765 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2766 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2767 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2768 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2769 application.SendNotification();
2770 application.Render();
2772 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2773 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2774 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2775 for( unsigned int index = 0u; index < 5u; ++index )
2777 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2778 application.SendNotification();
2779 application.Render();
2782 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2783 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2784 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2785 for( unsigned int index = 0u; index < 5u; ++index )
2787 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2788 application.SendNotification();
2789 application.Render();
2792 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2793 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2794 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2795 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2796 application.SendNotification();
2797 application.Render();
2798 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2799 application.SendNotification();
2800 application.Render();
2802 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2803 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
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 Property::Map mapGet;
2809 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2810 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2811 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2816 int utcDaliTextFieldStyleWhilstSelected(void)
2818 ToolkitTestApplication application;
2819 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2821 // Change font and styles whilst text is selected whilst word selected
2823 TextField field = TextField::New();
2824 DALI_TEST_CHECK( field );
2825 application.GetScene().Add( field );
2826 LoadMarkerImages(application, field);
2827 // Render and notify
2828 application.SendNotification();
2829 application.Render();
2831 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2832 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2833 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2834 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2835 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2837 // Avoid a crash when core load gl resources.
2838 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2839 // Render and notify
2840 application.SendNotification();
2841 application.Render();
2843 // Create a tap event to touch the text field.
2844 TestGenerateTap( application, 150.0f, 25.0f );
2845 // Render and notify
2846 application.SendNotification();
2847 application.Render();
2850 // Tap first to get the focus.
2851 TestGenerateTap( application, 1.0f, 25.0f );
2853 // Render and notify
2854 application.SendNotification();
2855 application.Render();
2857 // Double tap to select a word.
2858 TestGenerateTap( application, 1.0f, 25.0f );
2860 // Render and notify
2861 application.SendNotification();
2862 application.Render();
2864 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2865 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2867 Property::Map fontStyleMapSet;
2868 Property::Map fontStyleMapGet;
2870 fontStyleMapSet.Insert( "weight", "bold" );
2871 fontStyleMapSet.Insert( "slant", "italic" );
2872 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2874 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2875 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2876 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2878 fontStyleMapSet.Clear();
2879 fontStyleMapSet.Insert( "width", "expanded" );
2880 fontStyleMapSet.Insert( "slant", "italic" );
2881 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2883 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2884 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2885 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2887 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2888 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2890 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2891 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2893 fontStyleMapSet.Clear();
2894 fontStyleMapSet.Insert( "weight", "bold" );
2895 fontStyleMapSet.Insert( "slant", "italic" );
2897 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2899 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2900 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2901 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2903 fontStyleMapSet.Clear();
2904 fontStyleMapSet.Insert( "width", "expanded" );
2906 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2908 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2909 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2910 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2912 // Press Escape to increase coverage
2913 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2914 application.SendNotification();
2915 application.Render();
2917 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2922 int utcDaliTextFieldEscKeyLoseFocus(void)
2924 ToolkitTestApplication application;
2925 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2927 // Creates a tap event. After creating a tap event the text field should
2928 // have the focus and add text with key events should be possible.
2930 TextField field = TextField::New();
2931 DALI_TEST_CHECK( field );
2933 application.GetScene().Add( field );
2935 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2936 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2937 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2939 // Avoid a crash when core load gl resources.
2940 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2942 // Render and notify
2943 application.SendNotification();
2944 application.Render();
2946 // Add a key event but as the text field has not the focus it should do nothing.
2947 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2948 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2950 // Render and notify
2951 application.SendNotification();
2952 application.Render();
2954 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2956 // Create a tap event to touch the text field.
2957 TestGenerateTap( application, 150.0f, 25.0f );
2959 // Render and notify
2960 application.SendNotification();
2961 application.Render();
2963 // Now the text field has the focus, so it can handle the key events.
2964 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2965 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2966 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2967 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2969 // Render and notify
2970 application.SendNotification();
2971 application.Render();
2973 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2975 // Generate a Esc key event. The text field should lose the focus.
2976 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2977 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2979 // Render and notify
2980 application.SendNotification();
2981 application.Render();
2983 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2985 // No more text should be introduced
2986 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2987 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2989 // Render and notify
2990 application.SendNotification();
2991 application.Render();
2993 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2998 int utcDaliTextFieldSomeSpecialKeys(void)
3000 ToolkitTestApplication application;
3001 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
3003 // Checks some special keys when the text is selected.
3005 TextField field = TextField::New();
3006 DALI_TEST_CHECK( field );
3007 application.GetScene().Add( field );
3008 LoadMarkerImages(application, field);
3009 // Render and notify
3010 application.SendNotification();
3011 application.Render();
3013 const std::string longText( "This is a long text for the size of the text-field." );
3015 field.SetProperty( TextField::Property::TEXT, longText );
3016 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
3017 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3018 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3019 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3021 // Avoid a crash when core load gl resources.
3022 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3023 // Render and notify
3024 application.SendNotification();
3025 application.Render();
3027 // Create a tap event to touch the text field.
3028 TestGenerateTap( application, 150.0f, 25.0f );
3030 // Render and notify
3031 application.SendNotification();
3032 application.Render();
3034 // Tap first to get the focus.
3035 TestGenerateTap( application, 1.0f, 25.0f );
3037 // Render and notify
3038 application.SendNotification();
3039 application.Render();
3041 // Double tap to select a word.
3042 TestGenerateTap( application, 1.0f, 25.0f );
3044 // Render and notify
3045 application.SendNotification();
3046 application.Render();
3048 // Generate a Esc key event. The text field should lose the focus.
3049 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3050 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3052 // Render and notify
3053 application.SendNotification();
3054 application.Render();
3056 // Generate a Esc key event. The text field should lose the focus.
3057 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3058 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3060 // Render and notify
3061 application.SendNotification();
3062 application.Render();
3064 // Generate a Esc key event. The text field should lose the focus.
3065 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3066 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3068 // Render and notify
3069 application.SendNotification();
3070 application.Render();
3072 // The text shouldn't be deleted.
3073 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
3078 int utcDaliTextFieldSizeUpdate(void)
3080 ToolkitTestApplication application;
3081 tet_infoline("utcDaliTextFieldSizeUpdate");
3083 // Checks some special keys when the text is selected.
3084 TextField field = TextField::New();
3085 DALI_TEST_CHECK( field );
3086 application.GetScene().Add( field );
3088 float previousHeight = 0.0f;
3089 float currentHeight = 0.0f;
3090 const float fieldWidth = 1920.0f;
3093 // "ㅁ" is bigger then "ኢ"
3094 field.SetProperty( Actor::Property::SIZE, Vector2( fieldWidth ,10.0f ) );
3095 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
3096 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
3098 field.SetProperty( TextField::Property::TEXT, "ኢ");
3099 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3100 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3102 field.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
3103 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
3105 application.SendNotification();
3106 application.Render();
3108 previousHeight = field.GetHeightForWidth( fieldWidth );
3109 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
3111 // Add another script characters ( glyph height is defferent )
3112 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3113 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3115 application.SendNotification();
3116 application.Render();
3118 currentHeight = field.GetHeightForWidth( fieldWidth );
3119 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
3120 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
3125 int utcDaliTextFieldExtremlyLargePointSize(void)
3127 ToolkitTestApplication application;
3128 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
3130 TextField field = TextField::New();
3132 field.SetProperty( TextField::Property::TEXT, "Text" );
3133 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3134 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3135 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3136 application.GetScene().Add( field );
3140 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
3141 application.SendNotification();
3142 DALI_TEST_CHECK( field );
3146 tet_result(TET_FAIL);
3151 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
3153 ToolkitTestApplication application;
3154 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
3155 TextField field = TextField::New();
3156 DALI_TEST_CHECK( field );
3157 application.GetScene().Add( field );
3159 Property::Map fontStyleMapGet;
3161 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
3163 Property::Value* weightValue = NULL;
3164 Property::Value* widthValue = NULL;
3165 Property::Value* slantValue = NULL;
3166 weightValue = fontStyleMapGet.Find( "weight" );
3167 widthValue = fontStyleMapGet.Find( "width" );
3168 slantValue = fontStyleMapGet.Find( "slant" );
3169 DALI_TEST_CHECK( !weightValue );
3170 DALI_TEST_CHECK( !widthValue );
3171 DALI_TEST_CHECK( !slantValue );
3176 int UtcDaliTextFieldSettingPlaceholder(void)
3178 ToolkitTestApplication application;
3179 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
3181 TextField field = TextField::New();
3182 DALI_TEST_CHECK( field );
3183 application.GetScene().Add( field );
3185 // Check the placeholder property with pixel size
3186 Property::Map placeholderPixelSizeMapSet;
3187 Property::Map placeholderPixelSizeMapGet;
3188 Property::Map placeholderFontstyleMap;
3189 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
3190 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
3191 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
3192 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
3193 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
3194 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
3196 placeholderFontstyleMap.Insert( "weight", "bold" );
3197 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3198 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
3200 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3201 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
3202 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
3204 // Check the placeholder property with point size
3205 Property::Map placeholderMapSet;
3206 Property::Map placeholderMapGet;
3207 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
3208 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
3209 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
3210 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
3211 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
3212 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
3214 // Check the placeholder font style property
3215 placeholderFontstyleMap.Clear();
3217 placeholderFontstyleMap.Insert( "weight", "bold" );
3218 placeholderFontstyleMap.Insert( "width", "condensed" );
3219 placeholderFontstyleMap.Insert( "slant", "italic" );
3220 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3221 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3223 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3224 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3225 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3227 // Reset font style.
3228 placeholderFontstyleMap.Clear();
3229 placeholderFontstyleMap.Insert( "weight", "normal" );
3230 placeholderFontstyleMap.Insert( "slant", "oblique" );
3231 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3232 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3234 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3235 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3236 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3238 placeholderFontstyleMap.Clear();
3239 placeholderFontstyleMap.Insert( "slant", "roman" );
3240 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3241 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3243 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3245 placeholderFontstyleMap.Clear();
3246 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3248 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3249 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3250 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3251 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3256 int UtcDaliTextFieldPlaceholderCoverage(void)
3258 ToolkitTestApplication application;
3259 tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
3261 // mPlaceholderFont is created only once, so create a new control for coverage.
3262 TextField fieldForCoverage = TextField::New();
3263 DALI_TEST_CHECK(fieldForCoverage);
3264 application.GetScene().Add(fieldForCoverage);
3266 // for SetPlaceholderFontFamily() coverage.
3267 Property::Map fontFamilyMap;
3268 fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3269 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
3271 // mPlaceholderFont is created only once, so create a new control for coverage.
3272 fieldForCoverage = TextField::New();
3273 DALI_TEST_CHECK(fieldForCoverage);
3274 application.GetScene().Add(fieldForCoverage);
3276 // for SetPlaceholderTextFontSize coverage.
3277 Property::Map fontSizeMap;
3278 fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3279 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
3281 // mPlaceholderFont is created only once, so create a new control for coverage.
3282 fieldForCoverage = TextField::New();
3283 DALI_TEST_CHECK(fieldForCoverage);
3284 application.GetScene().Add(fieldForCoverage);
3286 // for SetPlaceholderTextFontWeight coverage.
3287 Property::Map fontStyleWeightMap;
3288 Property::Map fontStyleWeightPropertyMap;
3289 fontStyleWeightPropertyMap.Insert("weight", "bold");
3290 fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
3291 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
3293 // mPlaceholderFont is created only once, so create a new control for coverage.
3294 fieldForCoverage = TextField::New();
3295 DALI_TEST_CHECK(fieldForCoverage);
3296 application.GetScene().Add(fieldForCoverage);
3298 // for SetPlaceholderTextFontWidth coverage.
3299 Property::Map fontStyleWidthMap;
3300 Property::Map fontStyleWidthPropertyMap;
3301 fontStyleWidthPropertyMap.Insert("width", "expanded");
3302 fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
3303 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
3305 // mPlaceholderFont is created only once, so create a new control for coverage.
3306 fieldForCoverage = TextField::New();
3307 DALI_TEST_CHECK(fieldForCoverage);
3308 application.GetScene().Add(fieldForCoverage);
3310 // for SetPlaceholderTextFontSlant coverage.
3311 Property::Map fontStyleSlantMap;
3312 Property::Map fontStyleSlantPropertyMap;
3313 fontStyleSlantPropertyMap.Insert("slant", "italic");
3314 fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
3315 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
3320 int UtcDaliTextFieldSetPaddingProperty(void)
3322 ToolkitTestApplication application;
3323 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3325 TextField field = TextField::New();
3326 DALI_TEST_CHECK( field );
3327 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3328 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3329 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3330 application.GetScene().Add( field );
3332 application.SendNotification();
3333 application.Render();
3335 Vector3 originalSize = field.GetNaturalSize();
3337 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
3339 application.SendNotification();
3340 application.Render();
3342 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
3344 Vector3 paddingAddedSize = field.GetNaturalSize();
3346 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3348 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3353 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3355 ToolkitTestApplication application;
3356 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3358 TextField field = TextField::New();
3359 DALI_TEST_CHECK( field );
3360 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3361 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3362 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3363 application.GetScene().Add( field );
3365 application.SendNotification();
3366 application.Render();
3368 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3369 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
3371 // Check the enable shift selection property
3372 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
3373 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
3375 application.SendNotification();
3376 application.Render();
3381 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3383 ToolkitTestApplication application;
3384 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3386 TextField field = TextField::New();
3387 DALI_TEST_CHECK( field );
3388 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3389 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3390 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3391 application.GetScene().Add( field );
3393 application.SendNotification();
3394 application.Render();
3396 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3397 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
3399 // Check the enable grab handle property
3400 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
3401 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
3403 application.SendNotification();
3404 application.Render();
3409 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
3411 ToolkitTestApplication application;
3412 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
3414 TextField field = TextField::New();
3415 DALI_TEST_CHECK( field );
3416 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3417 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3418 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3419 application.GetScene().Add( field );
3421 application.SendNotification();
3422 application.Render();
3424 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3425 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
3427 // Check the match system language direction property
3428 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
3429 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
3431 application.SendNotification();
3432 application.Render();
3437 int utcDaliTextFieldLayoutDirectionCoverage(void)
3439 ToolkitTestApplication application;
3440 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
3442 // Creates a tap event. After creating a tap event the text field should
3443 // have the focus and add text with key events should be possible.
3444 TextField field = TextField::New();
3445 DALI_TEST_CHECK( field );
3447 application.GetScene().Add( field );
3449 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3450 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3451 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3453 // Avoid a crash when core load gl resources.
3454 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3456 // Render and notify
3457 application.SendNotification();
3458 application.Render();
3460 // init direction for coverage
3461 // Set horizontal alignment END
3462 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3464 // Create a tap event to touch the text field.
3465 TestGenerateTap( application, 150.0f, 25.0f );
3467 // Render and notify
3468 application.SendNotification();
3469 application.Render();
3471 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
3472 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
3473 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
3475 // Set horizontal alignment BEGIN
3476 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
3478 // Create a tap event to touch the text field.
3479 TestGenerateTap( application, 150.0f, 25.0f );
3481 // Render and notify
3482 application.SendNotification();
3483 application.Render();
3485 // Set horizontal alignment CENTER
3486 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
3488 // Create a tap event to touch the text field.
3489 TestGenerateTap( application, 150.0f, 25.0f );
3491 // Render and notify
3492 application.SendNotification();
3493 application.Render();
3495 // Set horizontal alignment END
3496 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3498 // Create a tap event to touch the text field.
3499 TestGenerateTap( application, 150.0f, 25.0f );
3501 // Render and notify
3502 application.SendNotification();
3503 application.Render();
3505 // Generate a Esc key event. The text field should lose the focus.
3506 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3507 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3509 // Render and notify
3510 application.SendNotification();
3511 application.Render();
3513 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
3518 int UtcDaliTextFieldGetInputMethodContext(void)
3520 ToolkitTestApplication application;
3521 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
3523 TextField field = TextField::New();
3524 DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );
3529 int UtcDaliTextFieldSelectWholeText(void)
3531 ToolkitTestApplication application;
3532 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3534 TextField textField = TextField::New();
3536 application.GetScene().Add( textField );
3538 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3539 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3540 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3542 // Avoid a crash when core load gl resources.
3543 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3545 application.SendNotification();
3546 application.Render();
3548 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
3550 DevelTextField::SelectWholeText( textField );
3552 application.SendNotification();
3553 application.Render();
3555 // Nothing should have been selected. The number of children is still 1
3556 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
3558 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3560 application.SendNotification();
3561 application.Render();
3563 DevelTextField::SelectWholeText( textField );
3565 application.SendNotification();
3566 application.Render();
3568 // Should be 2 children, the stencil and the layer
3569 DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
3571 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3572 Actor stencil = textField.GetChildAt( 0u );
3574 // The highlight actor is drawn first, so is the first actor in the list
3575 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3576 DALI_TEST_CHECK( highlight );
3581 int UtcDaliTextFieldSelectText(void)
3583 ToolkitTestApplication application;
3584 tet_infoline(" UtcDaliTextFieldSelectText ");
3586 TextField textField = TextField::New();
3588 application.GetScene().Add( textField );
3590 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3591 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3592 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3594 // Avoid a crash when core load gl resources.
3595 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3597 application.SendNotification();
3598 application.Render();
3600 DevelTextField::SelectText( textField, 0, 5 );
3602 application.SendNotification();
3603 application.Render();
3605 // Nothing is selected
3606 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3607 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3609 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3611 application.SendNotification();
3612 application.Render();
3614 // Hello is selected
3615 DevelTextField::SelectText( textField, 0, 5 );
3617 application.SendNotification();
3618 application.Render();
3620 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3621 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3623 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3624 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3626 // world is selected
3627 DevelTextField::SelectText( textField, 6, 11 );
3629 application.SendNotification();
3630 application.Render();
3632 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3633 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3635 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3636 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3641 int UtcDaliTextFieldSelectNone(void)
3643 ToolkitTestApplication application;
3644 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3646 TextField textField = TextField::New();
3648 application.GetScene().Add( textField );
3650 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3651 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3652 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3654 // Avoid a crash when core load gl resources.
3655 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3657 application.SendNotification();
3658 application.Render();
3660 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3662 application.SendNotification();
3663 application.Render();
3665 // Nothing is selected
3666 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3667 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3669 DevelTextField::SelectWholeText( textField );
3671 application.SendNotification();
3672 application.Render();
3674 // whole text is selected
3675 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3676 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3678 DevelTextField::SelectNone( textField );
3680 application.SendNotification();
3681 application.Render();
3683 // Nothing is selected
3684 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3685 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3690 int UtcDaliTextFieldSelectRange(void)
3692 ToolkitTestApplication application;
3693 tet_infoline(" UtcDaliTextFieldSelectRange ");
3695 TextField textField = TextField::New();
3697 application.GetScene().Add( textField );
3699 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3700 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3701 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3703 // Avoid a crash when core load gl resources.
3704 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3706 application.SendNotification();
3707 application.Render();
3709 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3711 application.SendNotification();
3712 application.Render();
3714 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 0);
3715 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 5);
3717 // Hello is selected
3718 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3719 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3721 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3722 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3724 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 6);
3725 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 11);
3727 // world is selected
3728 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3729 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3731 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3732 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3737 int UtcDaliTextFieldEnableEditing(void)
3739 ToolkitTestApplication application;
3740 tet_infoline(" UtcDaliTextFieldEnableEditing ");
3742 TextField textField = TextField::New();
3744 application.GetScene().Add( textField );
3746 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3747 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3748 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3750 // Avoid a crash when core load gl resources.
3751 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3753 application.SendNotification();
3754 application.Render();
3756 textField.SetKeyInputFocus();
3757 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, false );
3758 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3760 // Render and notify
3761 application.SendNotification();
3762 application.Render();
3764 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3765 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3768 textField.SetKeyInputFocus();
3769 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
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>(), "D", TEST_LOCATION );
3777 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3782 int UtcDaliToolkitTextFieldFontSizeScale(void)
3784 ToolkitTestApplication application;
3785 tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
3787 TextField textField = TextField::New();
3788 textField.SetProperty( TextField::Property::POINT_SIZE, 30.f );
3789 textField.SetProperty( TextField::Property::TEXT, "Test" );
3790 Vector3 nonScaledSize = textField.GetNaturalSize();
3792 TextField textFieldScaled = TextField::New();
3793 textFieldScaled.SetProperty( TextField::Property::POINT_SIZE, 15.f );
3794 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3795 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3796 Vector3 scaledSize = textFieldScaled.GetNaturalSize();
3798 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3800 textField.SetProperty( TextField::Property::PIXEL_SIZE, 30.f );
3801 textField.SetProperty( TextField::Property::TEXT, "Test" );
3802 nonScaledSize = textField.GetNaturalSize();
3804 textFieldScaled.SetProperty( TextField::Property::PIXEL_SIZE, 15.f );
3805 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3806 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3807 scaledSize = textFieldScaled.GetNaturalSize();
3809 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3814 int UtcDaliTextFieldPrimaryCursorPosition(void)
3816 ToolkitTestApplication application;
3817 tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
3819 TextField textField = TextField::New();
3821 application.GetScene().Add( textField );
3823 textField.SetProperty( TextField::Property::TEXT, "ABCEF");
3824 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3825 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3826 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3828 // Avoid a crash when core load gl resources.
3829 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3831 textField.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
3832 application.SendNotification();
3833 application.Render();
3834 textField.SetKeyInputFocus();
3836 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3838 // Render and notify
3839 application.SendNotification();
3840 application.Render();
3842 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3843 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3848 // test max length when set after setting long text
3849 int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
3851 ToolkitTestApplication application;
3852 tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
3853 TextField field = TextField::New();
3854 DALI_TEST_CHECK( field );
3856 application.GetScene().Add( field );
3858 field.SetProperty(TextField::Property::TEXT, "123456789");
3860 const int maxNumberOfCharacters = 3;
3861 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
3863 field.SetKeyInputFocus();
3865 // connect to the text max lengh reached signal.
3866 ConnectionTracker* testTracker = new ConnectionTracker();
3867 bool maxLengthReachedSignal = false;
3868 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
3870 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3871 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3873 DALI_TEST_CHECK( maxLengthReachedSignal );
3875 DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "123456789", TEST_LOCATION );
3882 int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
3884 ToolkitTestApplication application;
3885 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
3887 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3888 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3889 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3891 // Create a text field
3892 TextField textField = TextField::New();
3894 //Set size to avoid automatic eliding
3895 textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3896 //Set very large font-size using point-size
3897 textField.SetProperty( TextField::Property::POINT_SIZE, 1000) ;
3898 //Specify font-family
3899 textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
3900 //Set text to check if appear or not
3901 textField.SetProperty( TextField::Property::TEXT, "A");
3903 application.GetScene().Add( textField );
3905 application.SendNotification();
3906 application.Render();
3907 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3908 Vector3 naturalSize = textField.GetNaturalSize();
3910 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3911 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3916 int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
3918 ToolkitTestApplication application;
3919 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
3921 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3922 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3923 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3925 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3926 // Create a text editor
3927 TextField textField = TextField::New();
3929 //Set size to avoid automatic eliding
3930 textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3931 textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
3932 textField.SetProperty( TextField::Property::TEXT, "A");
3934 const int numberOfCases = 6;
3935 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
3937 for (int index=0; index < numberOfCases; index++)
3939 tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
3940 textField.SetProperty( TextField::Property::POINT_SIZE, arrayCases[index]) ;
3941 application.GetScene().Add( textField );
3942 application.SendNotification();
3943 application.Render();
3944 naturalSize = textField.GetNaturalSize();
3945 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3946 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3953 int UtcDaliToolkitTextFieldEllipsisPositionProperty(void)
3955 ToolkitTestApplication application;
3956 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty ");
3957 TextField textField = TextField::New();
3959 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Default is END");
3960 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3962 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START");
3963 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
3964 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3966 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE");
3967 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
3968 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3970 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END");
3971 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::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 using integer");
3975 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 1);
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 using integer");
3979 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 2);
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 using integer");
3983 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 0);
3984 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3986 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
3987 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "START");
3988 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3990 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
3991 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "MIDDLE");
3992 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3994 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
3995 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "END");
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 - lowercase");
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 - lowercase");
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 - lowercase");
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 );
4013 int UtcDaliTextFieldCopyText(void)
4015 ToolkitTestApplication application;
4016 tet_infoline(" UtcDaliTextFieldCopyText ");
4018 TextField textField = TextField::New();
4020 std::string selectedText = "";
4021 std::string copiedText = "";
4023 application.GetScene().Add( textField );
4025 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4026 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4027 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4029 // Avoid a crash when core load gl resources.
4030 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4032 application.SendNotification();
4033 application.Render();
4035 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
4037 application.SendNotification();
4038 application.Render();
4040 // Hello is selected
4041 DevelTextField::SelectText( textField, 0, 5 );
4043 application.SendNotification();
4044 application.Render();
4046 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4047 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4049 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4050 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4053 copiedText = DevelTextField::CopyText( textField );
4054 DALI_TEST_EQUALS( "Hello", copiedText, TEST_LOCATION );
4056 // world is selected
4057 DevelTextField::SelectText( textField, 6, 11 );
4059 application.SendNotification();
4060 application.Render();
4062 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4063 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
4065 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
4066 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
4069 copiedText = DevelTextField::CopyText( textField );
4070 DALI_TEST_EQUALS( "world", copiedText, TEST_LOCATION );
4072 // "lo wo" is selected
4073 DevelTextField::SelectText( textField, 3, 8 );
4075 application.SendNotification();
4076 application.Render();
4078 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4079 DALI_TEST_EQUALS( "lo wo", selectedText, TEST_LOCATION );
4081 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 3, TEST_LOCATION );
4082 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 8, TEST_LOCATION );
4084 // "lo wo" is copied
4085 copiedText = DevelTextField::CopyText( textField );
4086 DALI_TEST_EQUALS( "lo wo", copiedText, TEST_LOCATION );
4091 int UtcDaliTextFieldCutText(void)
4093 ToolkitTestApplication application;
4094 tet_infoline(" UtcDaliTextFieldCutText ");
4096 TextField textField = TextField::New();
4098 std::string selectedText = "";
4100 application.GetScene().Add( textField );
4102 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4103 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4104 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4106 // Avoid a crash when core load gl resources.
4107 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4109 application.SendNotification();
4110 application.Render();
4112 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
4114 application.SendNotification();
4115 application.Render();
4117 // Hello is selected
4118 DevelTextField::SelectText( textField, 0, 5 );
4120 application.SendNotification();
4121 application.Render();
4123 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4124 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4126 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4127 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4130 DALI_TEST_EQUALS( "Hello", DevelTextField::CutText( textField ), TEST_LOCATION );
4132 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), " world", TEST_LOCATION );
4135 DevelTextField::SelectText( textField, 0, 2 );
4137 application.SendNotification();
4138 application.Render();
4140 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4141 DALI_TEST_EQUALS( " w", selectedText, TEST_LOCATION );
4143 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4144 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4147 DALI_TEST_EQUALS( " w", DevelTextField::CutText( textField ), TEST_LOCATION );
4149 application.SendNotification();
4150 application.Render();
4152 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "orld", TEST_LOCATION );
4154 // Test Cut from the middle
4157 DevelTextField::SelectText( textField, 1, 3 );
4159 application.SendNotification();
4160 application.Render();
4162 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4163 DALI_TEST_EQUALS( "rl", selectedText, TEST_LOCATION );
4165 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4166 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 3, TEST_LOCATION );
4169 DALI_TEST_EQUALS( "rl", DevelTextField::CutText( textField ), TEST_LOCATION );
4171 application.SendNotification();
4172 application.Render();
4174 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "od", TEST_LOCATION );
4176 // Test Cut from the end
4179 DevelTextField::SelectText( textField, 1, 2 );
4181 application.SendNotification();
4182 application.Render();
4184 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4185 DALI_TEST_EQUALS( "d", selectedText, TEST_LOCATION );
4187 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4188 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4191 DALI_TEST_EQUALS( "d", DevelTextField::CutText( textField ), TEST_LOCATION );
4193 application.SendNotification();
4194 application.Render();
4196 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "o", TEST_LOCATION );
4201 int UtcDaliTextFieldPasteText(void)
4203 ToolkitTestApplication application;
4204 tet_infoline(" UtcDaliTextFieldPasteText ");
4206 TextField textField = TextField::New();
4208 application.GetScene().Add( textField );
4210 std::string cutText = "";
4211 std::string copiedText = "";
4213 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4214 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4215 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4217 // Avoid a crash when core load gl resources.
4218 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4220 application.SendNotification();
4221 application.Render();
4223 textField.SetProperty( TextField::Property::TEXT, "Hello World" );
4225 application.SendNotification();
4226 application.Render();
4228 // Tap on the text editor
4229 TestGenerateTap( application, 3.0f, 25.0f );
4231 // Render and notify
4232 application.SendNotification();
4233 application.Render();
4235 // Select some text in the right of the current cursor position
4236 DevelTextField::SelectText( textField, 0, 3 );
4238 // Render and notify
4239 application.SendNotification();
4240 application.Render();
4242 // Cut the selected text
4243 cutText = DevelTextField::CutText(textField);
4245 // Render and notify
4246 application.SendNotification();
4247 application.Render();
4249 DALI_TEST_EQUALS( "Hel", cutText, TEST_LOCATION );
4250 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "lo World", TEST_LOCATION );
4252 DevelTextField::SelectText( textField, 0, 3 );
4254 // Render and notify
4255 application.SendNotification();
4256 application.Render();
4258 // Copy the selected text
4259 copiedText = DevelTextField::CopyText(textField);
4261 // Render and notify
4262 application.SendNotification();
4263 application.Render();
4265 DALI_TEST_EQUALS( "lo ", copiedText, TEST_LOCATION );
4266 DALI_TEST_EQUALS( "lo World", textField.GetProperty<std::string>( TextField::Property::TEXT ), TEST_LOCATION );
4268 // Move the cursor to the end of the line
4269 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4270 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4271 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4272 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4273 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4274 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4275 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4276 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4278 // Render and notify
4279 application.SendNotification();
4280 application.Render();
4282 // Paste the selected text at the current cursor position
4283 DevelTextField::PasteText(textField);
4285 // Render and notify
4286 application.SendNotification();
4287 application.Render();
4289 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "lo Worldlo ", TEST_LOCATION );
4293 int utcDaliTextFieldCursorPositionChangedSignal(void)
4295 ToolkitTestApplication application;
4296 tet_infoline(" utcDaliTextFieldCursorPositionChangedSignal");
4298 TextField field = TextField::New();
4299 DALI_TEST_CHECK( field );
4301 application.GetScene().Add( field );
4303 // connect to the selection changed signal.
4304 ConnectionTracker* testTracker = new ConnectionTracker();
4305 DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
4306 bool cursorPositionChangedSignal = false;
4307 field.ConnectSignal( testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal) );
4309 field.SetProperty( TextField::Property::TEXT, "Hello world Hello world" );
4310 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
4311 field.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4312 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4313 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4315 // Avoid a crash when core load gl resources.
4316 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4318 // Render and notify
4319 application.SendNotification();
4320 application.Render();
4322 field.SetKeyInputFocus();
4324 // Tap on the text field
4325 TestGenerateTap( application, 3.0f, 25.0f );
4327 // Render and notify
4328 application.SendNotification();
4329 application.Render();
4331 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4332 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4334 gCursorPositionChangedCallbackCalled = false;
4337 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4339 // Render and notify
4340 application.SendNotification();
4341 application.Render();
4343 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4344 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4346 gCursorPositionChangedCallbackCalled = false;
4349 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", 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, 16, TEST_LOCATION);
4358 gCursorPositionChangedCallbackCalled = false;
4360 //delete one character
4361 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", 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, 17, TEST_LOCATION);
4370 gCursorPositionChangedCallbackCalled = false;
4372 field.SetProperty( TextField::Property::TEXT, "Hello" );
4374 // Render and notify
4375 application.SendNotification();
4376 application.Render();
4378 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4379 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4381 gCursorPositionChangedCallbackCalled = false;
4383 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4385 // Render and notify
4386 application.SendNotification();
4387 application.Render();
4389 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4390 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4395 int utcDaliTextFieldGeometryEllipsisStart(void)
4397 ToolkitTestApplication application;
4398 tet_infoline(" utcDaliTextFieldGeometryEllipsisStart");
4400 TextField field = TextField::New();
4401 DALI_TEST_CHECK( field );
4403 application.GetScene().Add( field );
4405 field.SetProperty( TextField::Property::POINT_SIZE, 7.f );
4406 field.SetProperty( Actor::Property::SIZE, Vector2( 250.f, 50.f ) );
4407 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4408 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4409 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
4410 field.SetProperty( DevelTextField::Property::ELLIPSIS, true );
4411 field.SetProperty( DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START );
4412 field.SetProperty( TextField::Property::TEXT, "Hello World" );
4414 // Avoid a crash when core load gl resources.
4415 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4417 // Render and notify
4418 application.SendNotification();
4419 application.Render();
4421 unsigned int expectedCount = 1;
4422 unsigned int startIndex = 0;
4423 unsigned int endIndex = 10;
4425 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4426 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4428 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4429 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4431 Vector<Vector2> expectedSizes;
4432 Vector<Vector2> expectedPositions;
4434 expectedPositions.PushBack(Vector2(14, 0));
4435 expectedSizes.PushBack(Vector2(106, 25));
4437 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4442 int utcDaliTextFieldGeometryEllipsisEnd(void)
4444 ToolkitTestApplication application;
4445 tet_infoline(" utcDaliTextFieldGeometryEllipsisEnd");
4447 TextField field = TextField::New();
4448 DALI_TEST_CHECK( field );
4450 application.GetScene().Add( field );
4452 field.SetProperty( TextField::Property::POINT_SIZE, 7.f );
4453 field.SetProperty( Actor::Property::SIZE, Vector2( 250.f, 50.f ) );
4454 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4455 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4456 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
4457 field.SetProperty( DevelTextField::Property::ELLIPSIS, true );
4458 field.SetProperty( DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END );
4459 field.SetProperty( TextField::Property::TEXT, "Hello World" );
4461 // Avoid a crash when core load gl resources.
4462 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4464 // Render and notify
4465 application.SendNotification();
4466 application.Render();
4468 unsigned int expectedCount = 1;
4469 unsigned int startIndex = 0;
4470 unsigned int endIndex = 10;
4472 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4473 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4475 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4476 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4478 Vector<Vector2> expectedSizes;
4479 Vector<Vector2> expectedPositions;
4481 expectedPositions.PushBack(Vector2(-2, 0));
4482 expectedSizes.PushBack(Vector2(122, 25));
4484 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4489 int utcDaliTextFieldGeometryRTL(void)
4491 ToolkitTestApplication application;
4492 tet_infoline(" utcDaliTextFieldGeometryRTL");
4494 TextField field = TextField::New();
4495 DALI_TEST_CHECK( field );
4497 application.GetScene().Add( field );
4499 field.SetProperty( TextField::Property::POINT_SIZE, 7.f );
4500 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4501 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4502 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4503 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
4504 field.SetProperty( TextField::Property::TEXT, "السطر الاخير" );
4506 // Avoid a crash when core load gl resources.
4507 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4509 // Render and notify
4510 application.SendNotification();
4511 application.Render();
4513 unsigned int expectedCount = 1;
4514 unsigned int startIndex = 1;
4515 unsigned int endIndex = 7;
4517 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4518 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4520 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4521 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4523 Vector<Vector2> expectedSizes;
4524 Vector<Vector2> expectedPositions;
4526 expectedPositions.PushBack(Vector2(38, 0));
4527 expectedSizes.PushBack(Vector2(73, 25));
4529 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4534 int utcDaliTextFieldGeometryGlyphMiddle(void)
4536 ToolkitTestApplication application;
4537 tet_infoline(" utcDaliTextFieldGeometryGlyphMiddle");
4539 TextField field = TextField::New();
4540 DALI_TEST_CHECK( field );
4542 application.GetScene().Add( field );
4544 field.SetProperty( TextField::Property::POINT_SIZE, 7.f );
4545 field.SetProperty( Actor::Property::SIZE, Vector2( 150.f, 200.f ) );
4546 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4547 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4548 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
4549 field.SetProperty( TextField::Property::TEXT, "لا تحتوي على لا" );
4551 // Avoid a crash when core load gl resources.
4552 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4554 // Render and notify
4555 application.SendNotification();
4556 application.Render();
4558 unsigned int expectedCount = 1;
4559 unsigned int startIndex = 1;
4560 unsigned int endIndex = 13;
4562 Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
4563 Vector<Vector2> sizeList = DevelTextField::GetTextSize(field, startIndex, endIndex);
4565 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4566 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4568 Vector<Vector2> expectedSizes;
4569 Vector<Vector2> expectedPositions;
4571 expectedPositions.PushBack(Vector2(6, 0));
4572 expectedSizes.PushBack(Vector2(124, 25));
4574 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4579 int utcDaliTextFieldSelectionClearedSignal(void)
4581 ToolkitTestApplication application;
4582 tet_infoline(" utcDaliTextFieldSelectionClearedSignal");
4584 TextField field = TextField::New();
4585 DALI_TEST_CHECK( field );
4587 application.GetScene().Add( field );
4589 // connect to the selection changed signal.
4590 ConnectionTracker* testTracker = new ConnectionTracker();
4591 DevelTextField::SelectionClearedSignal(field).Connect(&TestSelectionClearedCallback);
4592 bool selectionClearedSignal = false;
4593 field.ConnectSignal( testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal) );
4595 field.SetProperty( TextField::Property::TEXT, "Hello\nworld\nHello world" );
4596 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
4597 field.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4598 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4599 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4601 // Avoid a crash when core load gl resources.
4602 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4604 // Render and notify
4605 application.SendNotification();
4606 application.Render();
4608 // Tap on the text editor
4609 TestGenerateTap( application, 3.0f, 25.0f );
4611 // Render and notify
4612 application.SendNotification();
4613 application.Render();
4615 // Move to second line of the text & Select some text in the right of the current cursor position
4616 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4617 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4620 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4622 // Render and notify
4623 application.SendNotification();
4624 application.Render();
4626 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4628 // Render and notify
4629 application.SendNotification();
4630 application.Render();
4632 // Tap on the text editor
4633 TestGenerateTap( application, 3.0f, 25.0f );
4635 // Render and notify
4636 application.SendNotification();
4637 application.Render();
4639 gSelectionClearedCallbackCalled = false;
4641 // Move to second line of the text & select.
4642 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4643 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4646 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4648 // Render and notify
4649 application.SendNotification();
4650 application.Render();
4652 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4654 gSelectionClearedCallbackCalled = false;
4656 // Render and notify
4657 application.SendNotification();
4658 application.Render();
4660 // Move to second line of the text & select.
4661 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4662 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4664 // replace D with selected text
4665 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4667 // Render and notify
4668 application.SendNotification();
4669 application.Render();
4671 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4673 gSelectionClearedCallbackCalled = false;
4675 // Render and notify
4676 application.SendNotification();
4677 application.Render();
4679 DevelTextField::SelectText( field ,1, 3 );
4681 // Render and notify
4682 application.SendNotification();
4683 application.Render();
4685 field.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4687 // Render and notify
4688 application.SendNotification();
4689 application.Render();
4691 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4693 gSelectionClearedCallbackCalled = false;
4695 DevelTextField::SelectText( field ,1, 3 );
4697 // Render and notify
4698 application.SendNotification();
4699 application.Render();
4702 DevelTextField::SelectNone(field);
4704 // Render and notify
4705 application.SendNotification();
4706 application.Render();
4708 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4713 int utcDaliTextFieldSelectionChangedSignal(void)
4715 ToolkitTestApplication application;
4716 tet_infoline(" utcDaliTextFieldSelectionChangedSignal");
4718 TextField field = TextField::New();
4719 DALI_TEST_CHECK( field );
4721 application.GetScene().Add( field );
4723 // connect to the selection changed signal.
4724 ConnectionTracker* testTracker = new ConnectionTracker();
4725 DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
4726 bool selectionChangedSignal = false;
4727 field.ConnectSignal( testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal) );
4729 field.SetProperty( TextField::Property::TEXT, "Hello world Hello world" );
4730 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
4731 field.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4732 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4733 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4735 // Avoid a crash when core load gl resources.
4736 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4738 // Render and notify
4739 application.SendNotification();
4740 application.Render();
4742 // Tap on the text field
4743 TestGenerateTap( application, 3.0f, 25.0f );
4745 // Render and notify
4746 application.SendNotification();
4747 application.Render();
4749 // Select some text in the right of the current cursor position
4750 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4751 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4753 // Render and notify
4754 application.SendNotification();
4755 application.Render();
4757 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4758 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4760 gSelectionChangedCallbackCalled = false;
4762 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4764 // Render and notify
4765 application.SendNotification();
4766 application.Render();
4768 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4769 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4770 DALI_TEST_EQUALS(oldSelectionEnd, 1, TEST_LOCATION);
4772 gSelectionChangedCallbackCalled = false;
4774 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", 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, 2, TEST_LOCATION);
4784 gSelectionChangedCallbackCalled = false;
4785 field.SetKeyInputFocus();
4787 // Render and notify
4788 application.SendNotification();
4789 application.Render();
4791 DevelTextField::SelectText( field ,0, 5 );
4793 application.SendNotification();
4794 application.Render();
4796 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4797 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4799 gSelectionChangedCallbackCalled = false;
4801 field.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4803 // Render and notify
4804 application.SendNotification();
4805 application.Render();
4807 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4808 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4809 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
4811 gSelectionChangedCallbackCalled = false;
4814 DevelTextField::SelectWholeText(field);
4816 // Render and notify
4817 application.SendNotification();
4818 application.Render();
4820 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4821 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4823 gSelectionChangedCallbackCalled = false;
4826 DevelTextField::SelectNone(field);
4828 // Render and notify
4829 application.SendNotification();
4830 application.Render();
4832 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4833 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4834 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);