2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali/public-api/rendering/renderer.h>
23 #include <dali/integration-api/events/key-event-integ.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/devel-api/adaptor-framework/key-devel.h>
27 #include <dali/devel-api/text-abstraction/font-client.h>
28 #include <dali-toolkit-test-suite-utils.h>
29 #include <dali-toolkit/dali-toolkit.h>
30 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
31 #include <dali-toolkit/devel-api/text/rendering-backend.h>
32 #include "toolkit-clipboard.h"
33 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
36 using namespace Toolkit;
38 void dali_textfield_startup(void)
40 test_return_value = TET_UNDEF;
43 void dali_textfield_cleanup(void)
45 test_return_value = TET_PASS;
51 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
52 const char* const PROPERTY_NAME_TEXT = "text";
53 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
54 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
55 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
56 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
57 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
58 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
59 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
60 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
61 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
62 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
63 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
64 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
65 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
66 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
67 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
68 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
69 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
70 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
71 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
72 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
73 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
79 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
80 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
81 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
82 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
83 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
84 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
85 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
86 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
87 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
89 const char* const PROPERTY_NAME_UNDERLINE = "underline";
90 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
91 const char* const PROPERTY_NAME_SHADOW = "shadow";
92 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
93 const char* const PROPERTY_NAME_EMBOSS = "emboss";
94 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
95 const char* const PROPERTY_NAME_OUTLINE = "outline";
96 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
98 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
99 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
100 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
101 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
102 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
103 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
104 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
105 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
106 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
107 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
108 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
109 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
110 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
112 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
113 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
115 const float RENDER_FRAME_INTERVAL = 16.66f;
117 const unsigned int DEFAULT_FONT_SIZE = 1152u;
118 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
120 const int KEY_RETURN_CODE = 36;
121 const int KEY_A_CODE = 38;
122 const int KEY_D_CODE = 40;
123 const int KEY_SHIFT_MODIFIER = 257;
125 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
127 static bool gSelectionChangedCallbackCalled;
128 static uint32_t oldSelectionStart;
129 static uint32_t oldSelectionEnd;
130 static bool gAnchorClickedCallBackCalled;
131 static bool gAnchorClickedCallBackNotCalled;
132 static bool gTextChangedCallBackCalled;
133 static bool gMaxCharactersCallBackCalled;
134 static bool gInputFilteredAcceptedCallbackCalled;
135 static bool gInputFilteredRejectedCallbackCalled;
136 static bool gInputStyleChangedCallbackCalled;
137 static bool gCursorPositionChangedCallbackCalled;
138 static uint32_t oldCursorPos;
139 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
141 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
143 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
144 Integration::ResourcePointer resource(bitmap);
145 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
148 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
152 LoadBitmapResource( app.GetPlatform(), width, height );
154 Property::Map propertyMap;
155 propertyMap["filename"] = "image.png";
156 propertyMap["width"] = width;
157 propertyMap["height"] = height;
158 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
159 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
160 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
161 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
162 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
163 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
164 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
165 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
169 * Simulate time passed by.
171 * @note this will always process at least 1 frame (1/60 sec)
173 * @param application Test application instance
174 * @param duration Time to pass in milliseconds.
175 * @return The actual time passed in milliseconds
177 static int Wait(ToolkitTestApplication& application, int duration = 0)
181 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
183 application.SendNotification();
184 application.Render(RENDER_FRAME_INTERVAL);
185 time += RENDER_FRAME_INTERVAL;
191 Dali::Integration::Point GetPointDownInside( Vector2& pos )
193 Dali::Integration::Point point;
194 point.SetState( PointState::DOWN );
195 point.SetScreenPosition( pos );
199 Dali::Integration::Point GetPointUpInside( Vector2& pos )
201 Dali::Integration::Point point;
202 point.SetState( PointState::UP );
203 point.SetScreenPosition( pos );
207 struct CallbackFunctor
209 CallbackFunctor(bool* callbackFlag)
210 : mCallbackFlag( callbackFlag )
216 *mCallbackFlag = true;
221 static void TestSelectionChangedCallback(TextField control, uint32_t oldStart, uint32_t oldEnd)
223 tet_infoline(" TestSelectionChangedCallback");
225 gSelectionChangedCallbackCalled = true;
226 oldSelectionStart = oldStart;
227 oldSelectionEnd = oldEnd;
230 static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength)
232 tet_infoline(" TestAnchorClickedCallback");
234 gAnchorClickedCallBackNotCalled = false;
236 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
238 gAnchorClickedCallBackCalled = true;
242 static void TestCursorPositionChangedCallback( TextField control, unsigned int oldPos )
244 tet_infoline(" TestCursorPositionChangedCallback");
246 gCursorPositionChangedCallbackCalled = true;
247 oldCursorPos = oldPos;
250 static void TestTextChangedCallback( TextField control )
252 tet_infoline(" TestTextChangedCallback");
254 gTextChangedCallBackCalled = true;
257 static void TestMaxLengthReachedCallback( TextField control )
259 tet_infoline(" TestMaxLengthReachedCallback");
261 gMaxCharactersCallBackCalled = true;
264 static void TestInputFilteredCallback(TextField control, Toolkit::InputFilter::Property::Type type)
266 tet_infoline(" TestInputFilteredCallback");
268 if(type == Toolkit::InputFilter::Property::ACCEPTED)
270 gInputFilteredAcceptedCallbackCalled = true;
272 else if(type == Toolkit::InputFilter::Property::REJECTED)
274 gInputFilteredRejectedCallbackCalled = true;
278 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
280 tet_infoline(" TestInputStyleChangedCallback");
282 gInputStyleChangedCallbackCalled = true;
283 gInputStyleMask = mask;
286 // Generate a KeyEvent to send to Core.
287 Integration::KeyEvent GenerateKey( const std::string& keyName,
288 const std::string& logicalKey,
289 const std::string& keyString,
292 unsigned long timeStamp,
293 const Integration::KeyEvent::State& keyState,
294 const std::string& compose = "",
295 const std::string& deviceName = DEFAULT_DEVICE_NAME,
296 const Device::Class::Type& deviceClass = Device::Class::NONE,
297 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
299 return Integration::KeyEvent( keyName,
312 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
314 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
316 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
318 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
320 Property::Value* valueSet = NULL;
321 if ( valueGet.first.type == Property::Key::INDEX )
323 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
327 // Get Key is a string so searching Set Map for a string key
328 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
331 if( NULL != valueSet )
333 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
335 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
338 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
340 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
343 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
345 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
348 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
350 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
353 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
355 Vector2 vector2Get = valueGet.second.Get<Vector2>();
356 Vector2 vector2Set = valueSet->Get<Vector2>();
357 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
360 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
362 Vector4 vector4Get = valueGet.second.Get<Vector4>();
363 Vector4 vector4Set = valueSet->Get<Vector4>();
364 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 );
370 if ( valueGet.first.type == Property::Key::INDEX )
372 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
376 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
388 int UtcDaliToolkitTextFieldConstructorP(void)
390 ToolkitTestApplication application;
391 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
393 DALI_TEST_CHECK( !textField );
397 int UtcDaliToolkitTextFieldNewP(void)
399 ToolkitTestApplication application;
400 tet_infoline(" UtcDaliToolkitTextFieldNewP");
401 TextField textField = TextField::New();
402 DALI_TEST_CHECK( textField );
406 int UtcDaliToolkitTextFieldDownCastP(void)
408 ToolkitTestApplication application;
409 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
410 TextField textField1 = TextField::New();
411 BaseHandle object( textField1 );
413 TextField textField2 = TextField::DownCast( object );
414 DALI_TEST_CHECK( textField2 );
416 TextField textField3 = DownCast< TextField >( object );
417 DALI_TEST_CHECK( textField3 );
421 int UtcDaliToolkitTextFieldDownCastN(void)
423 ToolkitTestApplication application;
424 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
425 BaseHandle uninitializedObject;
426 TextField textField1 = TextField::DownCast( uninitializedObject );
427 DALI_TEST_CHECK( !textField1 );
429 TextField textField2 = DownCast< TextField >( uninitializedObject );
430 DALI_TEST_CHECK( !textField2 );
434 int UtcDaliToolkitTextFieldCopyConstructorP(void)
436 ToolkitTestApplication application;
437 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
438 TextField textField = TextField::New();
439 textField.SetProperty( TextField::Property::TEXT, "Test" );
441 TextField copy( textField );
442 DALI_TEST_CHECK( copy );
443 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
447 int UtcDaliTextFieldMoveConstructor(void)
449 ToolkitTestApplication application;
451 TextField textField = TextField::New();
452 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
453 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
455 TextField moved = std::move( textField );
456 DALI_TEST_CHECK( moved );
457 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
458 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
459 DALI_TEST_CHECK( !textField );
464 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
466 ToolkitTestApplication application;
467 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
468 TextField textField = TextField::New();
469 textField.SetProperty( TextField::Property::TEXT, "Test" );
471 TextField copy = textField;
472 DALI_TEST_CHECK( copy );
473 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
477 int UtcDaliTextFieldMoveAssignment(void)
479 ToolkitTestApplication application;
481 TextField textField = TextField::New();
482 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
483 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
486 moved = std::move( textField );
487 DALI_TEST_CHECK( moved );
488 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
489 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
490 DALI_TEST_CHECK( !textField );
495 int UtcDaliTextFieldNewP(void)
497 ToolkitTestApplication application;
498 tet_infoline(" UtcDaliToolkitTextFieldNewP");
499 TextField textField = TextField::New();
500 DALI_TEST_CHECK( textField );
504 // Positive test case for a method
505 int UtcDaliTextFieldGetPropertyP(void)
507 ToolkitTestApplication application;
508 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
509 TextField field = TextField::New();
510 DALI_TEST_CHECK( field );
512 // Check Property Indices are correct
513 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextField::Property::RENDERING_BACKEND );
514 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
515 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
516 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
517 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
518 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
519 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
520 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
521 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
522 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
523 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
524 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
525 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
526 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
527 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
528 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
529 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
530 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
531 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
532 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
533 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
534 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
535 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
536 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
537 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
538 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
539 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
540 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
541 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
542 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
543 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
544 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
545 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
546 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
547 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
548 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
549 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
550 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
551 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
552 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
553 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
554 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
555 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
556 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
557 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
558 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
559 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
560 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
561 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
562 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
563 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextField::Property::FONT_SIZE_SCALE );
564 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
565 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
566 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
567 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP );
568 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextField::Property::BACKGROUND );
569 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextField::Property::GRAB_HANDLE_COLOR );
570 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FILTER ) == DevelTextField::Property::INPUT_FILTER );
575 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
578 Property::Map imageMap;
579 imageMap[mapKey] =mapValue;
581 field.SetProperty( property , imageMap );
582 Property::Value propValue = field.GetProperty( property );
583 Property::Map* resultMap = propValue.GetMap();
585 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
593 // Positive test case for a method
594 int UtcDaliTextFieldSetPropertyP(void)
596 ToolkitTestApplication application;
597 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
598 TextField field = TextField::New();
599 DALI_TEST_CHECK( field );
600 application.GetScene().Add( field );
602 // Note - we can't check the defaults since the stylesheets are platform-specific
604 // Check the render backend property.
605 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
606 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
608 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
609 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION );
611 // Check text property.
612 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
613 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
615 // Check placeholder text properties.
616 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
617 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
619 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
620 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
622 // Check font properties.
623 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
624 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
626 Property::Map fontStyleMapSet;
627 Property::Map fontStyleMapGet;
628 Property::Value* slantValue = NULL;
630 fontStyleMapSet.Insert( "weight", "bold" );
631 fontStyleMapSet.Insert( "width", "condensed" );
632 fontStyleMapSet.Insert( "slant", "italic" );
633 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
635 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
636 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
637 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
639 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
640 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
642 field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 2.5f );
643 DALI_TEST_EQUALS( field.GetProperty<float>( DevelTextField::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
644 field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 1.0f );
647 fontStyleMapSet.Clear();
648 fontStyleMapSet.Insert( "weight", "normal" );
649 fontStyleMapSet.Insert( "slant", "oblique" );
650 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
652 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
653 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
654 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
656 fontStyleMapSet.Clear();
657 fontStyleMapSet.Insert( "slant", "roman" );
658 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
659 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
661 // Replace 'roman' for 'normal'.
662 slantValue = fontStyleMapGet.Find( "slant" );
663 if( NULL != slantValue )
665 if( "normal" == slantValue->Get<std::string>() )
667 fontStyleMapGet["slant"] = "roman";
670 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
671 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
673 fontStyleMapSet.Clear();
675 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
676 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
677 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
678 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
680 // Check that the MAX_LENGTH property can be correctly set
681 const int maxNumberOfCharacters = 20;
682 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
683 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
685 // Check exceed policy
686 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
687 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
688 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
689 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
691 // Check that the Alignment properties can be correctly set
692 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
693 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
694 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
695 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
697 // Check text's color property
698 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
699 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
701 // Check placeholder text's color property.
702 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
703 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
705 // Check cursor properties
706 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
707 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
708 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
709 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
711 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
712 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
713 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
714 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
715 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
716 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
717 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
718 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
720 // Check scroll properties.
721 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
722 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
723 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
724 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
726 // Check handle images
727 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
728 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
729 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
730 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
731 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
733 // Check handle images
734 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
735 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
736 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
737 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
738 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
739 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
741 // Check the highlight color
742 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
743 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
745 // Decoration bounding box
746 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
747 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
749 // Check the input method setting
750 Property::Map propertyMap;
751 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
752 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
753 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
754 int inputVariation = 1;
755 propertyMap["PANEL_LAYOUT"] = panelLayout;
756 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
757 propertyMap["BUTTON_ACTION"] = buttonAction;
758 propertyMap["VARIATION"] = inputVariation;
759 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
761 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
763 DALI_TEST_CHECK( value.Get( map ) );
766 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
767 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
770 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
771 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
774 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
775 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
778 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
779 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
781 // Check input color property.
782 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
783 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
785 // Check the enable markup property.
786 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
787 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
788 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
790 // Check input font properties.
791 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
792 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
794 fontStyleMapSet.Clear();
795 fontStyleMapSet.Insert( "weight", "bold" );
796 fontStyleMapSet.Insert( "width", "condensed" );
797 fontStyleMapSet.Insert( "slant", "italic" );
799 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
800 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
801 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
802 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
804 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
805 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
807 // Reset input font style.
808 fontStyleMapSet.Clear();
809 fontStyleMapSet.Insert( "weight", "normal" );
810 fontStyleMapSet.Insert( "slant", "oblique" );
812 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
813 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
814 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
815 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
817 fontStyleMapSet.Clear();
818 fontStyleMapSet.Insert( "slant", "roman" );
820 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
821 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
823 // Replace 'roman' for 'normal'.
824 slantValue = fontStyleMapGet.Find( "slant" );
825 if( NULL != slantValue )
827 if( "normal" == slantValue->Get<std::string>() )
829 fontStyleMapGet["slant"] = "roman";
832 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
833 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
835 fontStyleMapSet.Clear();
837 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
838 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
839 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
840 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
842 Property::Map underlineMapSet;
843 Property::Map underlineMapGet;
845 underlineMapSet.Insert( "enable", true );
846 underlineMapSet.Insert( "color", Color::RED );
847 underlineMapSet.Insert( "height", 1 );
849 // Check the underline property
850 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
852 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
853 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
854 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
856 // Check the input underline property
857 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
858 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
860 // Check the shadow property
861 Property::Map shadowMapSet;
862 Property::Map shadowMapGet;
864 shadowMapSet.Insert( "color", Color::GREEN );
865 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
866 shadowMapSet.Insert( "blurRadius", 3.0f );
868 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
870 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
871 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
872 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
874 // Check the input shadow property
875 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
876 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
878 // Check the emboss property
879 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
880 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
882 // Check the input emboss property
883 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
884 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
886 // Check the outline property
888 // Test string type first
889 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
890 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
891 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
893 // Then test the property map type
894 Property::Map outlineMapSet;
895 Property::Map outlineMapGet;
897 outlineMapSet["color"] = Color::RED;
898 outlineMapSet["width"] = 2.0f;
900 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
902 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
903 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
904 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
906 // Check the input outline property
907 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
908 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
910 // Check the hidden input settings property
911 Property::Map hiddenMapSet;
912 Property::Map hiddenMapGet;
913 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
914 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
915 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
916 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
917 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
919 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
920 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
921 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
923 // Check the pixel size of font
924 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
925 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
927 // Check the enable selection property
928 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
929 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
931 // Check the placeholder property with pixel size
932 Property::Map placeholderPixelSizeMapSet;
933 Property::Map placeholderPixelSizeMapGet;
934 Property::Map placeholderFontstyleMap;
935 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
936 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
937 placeholderPixelSizeMapSet["color"] = Color::BLUE;
938 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
939 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
940 placeholderPixelSizeMapSet["ellipsis"] = true;
942 placeholderFontstyleMap.Insert( "weight", "bold" );
943 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
944 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
946 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
947 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
949 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
950 Property::Map placeholderConversionMap;
951 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
952 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
953 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
954 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
955 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
956 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
958 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
960 // Check the placeholder property with point size
961 Property::Map placeholderMapSet;
962 Property::Map placeholderMapGet;
963 placeholderMapSet["text"] = "Setting Placeholder Text";
964 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
965 placeholderMapSet["color"] = Color::RED;
966 placeholderMapSet["fontFamily"] = "Arial";
967 placeholderMapSet["pointSize"] = 12.0f;
968 placeholderMapSet["ellipsis"] = false;
970 // Check the placeholder font style property
971 placeholderFontstyleMap.Clear();
973 placeholderFontstyleMap.Insert( "weight", "bold" );
974 placeholderFontstyleMap.Insert( "width", "condensed" );
975 placeholderFontstyleMap.Insert( "slant", "italic" );
976 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
977 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
979 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
980 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
982 placeholderConversionMap.Clear();
983 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
984 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
985 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
986 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
987 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
988 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
990 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
993 placeholderFontstyleMap.Clear();
994 placeholderFontstyleMap.Insert( "weight", "normal" );
995 placeholderFontstyleMap.Insert( "slant", "oblique" );
996 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
997 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
999 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1000 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1002 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1003 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1005 placeholderFontstyleMap.Clear();
1006 placeholderFontstyleMap.Insert( "slant", "roman" );
1007 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1008 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1010 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1012 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1014 placeholderFontstyleMap.Clear();
1015 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1016 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1018 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1019 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1020 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1022 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1024 // Check the ellipsis property
1025 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1026 field.SetProperty( TextField::Property::ELLIPSIS, true );
1027 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1029 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
1030 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1032 // Test the ENABLE_GRAB_HANDLE_POPUP property
1033 DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1034 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false );
1035 DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1037 // Check the background property
1038 field.SetProperty( DevelTextField::Property::BACKGROUND, Color::RED );
1039 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::BACKGROUND ), Color::RED, TEST_LOCATION );
1041 //Check handle color
1042 field.SetProperty( DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN );
1043 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
1045 // Check the input filter property
1046 Property::Map inputFilterMapSet;
1047 Property::Map inputFilterMapGet;
1048 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1049 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1051 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1053 inputFilterMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::INPUT_FILTER);
1054 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1057 inputFilterMapSet.Clear();
1058 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1060 application.SendNotification();
1061 application.Render();
1066 // Positive Atlas Text Renderer test
1067 int utcDaliTextFieldAtlasRenderP(void)
1069 ToolkitTestApplication application;
1070 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1071 StyleManager styleManager = StyleManager::Get();
1072 styleManager.ApplyDefaultTheme();
1073 TextField field = TextField::New();
1074 DALI_TEST_CHECK( field );
1076 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1078 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1080 application.GetScene().Add( field );
1084 // Render some text with the shared atlas backend
1085 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1086 application.SendNotification();
1087 application.Render();
1091 tet_result(TET_FAIL);
1096 // Positive test for the anchorClicked signal.
1097 int utcDaliTextFieldAnchorClicked01(void)
1099 ToolkitTestApplication application;
1100 tet_infoline(" utcDaliTextFieldAnchorClicked01");
1101 TextField field = TextField::New();
1102 DALI_TEST_CHECK(field);
1104 application.GetScene().Add(field);
1106 // connect to the anchor clicked signal.
1107 ConnectionTracker* testTracker = new ConnectionTracker();
1108 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1109 bool anchorClickedSignal = false;
1110 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1112 gAnchorClickedCallBackCalled = false;
1113 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1114 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1115 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1116 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1117 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1119 application.SendNotification();
1120 application.Render();
1121 field.SetKeyInputFocus();
1123 // Create a tap event to touch the text field.
1124 TestGenerateTap(application, 5.0f, 25.0f);
1125 application.SendNotification();
1126 application.Render();
1128 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1129 DALI_TEST_CHECK(anchorClickedSignal);
1131 gAnchorClickedCallBackNotCalled = true;
1132 // Tap the outside of anchor, callback should not be called.
1133 TestGenerateTap(application, 150.f, 100.f);
1134 application.SendNotification();
1135 application.Render();
1137 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1142 // Positive test for the anchorClicked signal.
1143 int utcDaliTextFieldAnchorClicked02(void)
1145 ToolkitTestApplication application;
1146 tet_infoline(" utcDaliTextFieldAnchorClicked02");
1147 TextField field = TextField::New();
1148 DALI_TEST_CHECK(field);
1150 application.GetScene().Add(field);
1152 // connect to the anchor clicked signal.
1153 ConnectionTracker* testTracker = new ConnectionTracker();
1154 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1155 bool anchorClickedSignal = false;
1156 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1158 gAnchorClickedCallBackCalled = false;
1159 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1160 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1161 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1162 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1163 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1165 application.SendNotification();
1166 application.Render();
1167 field.SetKeyInputFocus();
1169 // Avoid a crash when core load gl resources.
1170 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1172 // Create a tap event to touch the text field.
1173 TestGenerateTap(application, 30.0f, 25.0f, 100);
1174 application.SendNotification();
1175 application.Render();
1177 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1178 DALI_TEST_CHECK(anchorClickedSignal);
1181 // For coverage InsertTextAnchor, RemoveTextAnchor
1182 // first index insert
1183 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1184 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1185 application.SendNotification();
1186 application.Render();
1188 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1189 application.SendNotification();
1190 application.Render();
1192 gAnchorClickedCallBackCalled = false;
1193 // Create a tap event to touch the text field.
1194 TestGenerateTap(application, 30.0f, 25.0f, 700);
1195 application.SendNotification();
1196 field.SetKeyInputFocus();
1198 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1200 // last index insert
1201 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1202 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1203 application.SendNotification();
1204 application.Render();
1206 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1207 application.SendNotification();
1208 application.Render();
1210 gAnchorClickedCallBackCalled = false;
1211 // Create a tap event to touch the text field.
1212 TestGenerateTap(application, 30.0f, 25.0f, 1300);
1213 application.SendNotification();
1214 field.SetKeyInputFocus();
1216 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1219 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1220 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1221 application.SendNotification();
1222 application.Render();
1224 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1225 application.SendNotification();
1226 application.Render();
1228 gAnchorClickedCallBackCalled = false;
1229 // Create a tap event to touch the text field.
1230 TestGenerateTap(application, 30.0f, 25.0f, 1900);
1231 application.SendNotification();
1232 field.SetKeyInputFocus();
1234 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1236 // first index remove
1237 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1238 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1239 application.SendNotification();
1240 application.Render();
1242 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1243 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));
1244 application.SendNotification();
1245 application.Render();
1247 gAnchorClickedCallBackCalled = false;
1248 // Create a tap event to touch the text field.
1249 TestGenerateTap(application, 30.0f, 25.0f, 2500);
1250 application.SendNotification();
1251 field.SetKeyInputFocus();
1253 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1255 // last index remove
1256 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1257 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1258 application.SendNotification();
1259 application.Render();
1261 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1262 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));
1263 application.SendNotification();
1264 application.Render();
1266 gAnchorClickedCallBackCalled = false;
1267 // Create a tap event to touch the text field.
1268 TestGenerateTap(application, 30.0f, 25.0f, 3100);
1269 application.SendNotification();
1270 application.Render();
1272 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1275 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1276 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1277 application.SendNotification();
1278 application.Render();
1280 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1281 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));
1282 application.SendNotification();
1283 application.Render();
1285 gAnchorClickedCallBackCalled = false;
1286 // Create a tap event to touch the text field.
1287 TestGenerateTap(application, 30.0f, 25.0f, 3700);
1288 application.SendNotification();
1289 application.Render();
1291 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1293 // 0 ~ 1 index remove
1294 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1295 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 0);
1296 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 1);
1297 application.SendNotification();
1298 application.Render();
1300 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1301 application.SendNotification();
1302 application.Render();
1304 gAnchorClickedCallBackCalled = false;
1305 // Create a tap event to touch the text field.
1306 TestGenerateTap(application, 30.0f, 25.0f, 4300);
1307 application.SendNotification();
1308 application.Render();
1310 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1312 // 1 ~ 3 index remove
1313 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1314 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 1);
1315 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 3);
1316 application.SendNotification();
1317 application.Render();
1319 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1320 application.SendNotification();
1321 application.Render();
1323 gAnchorClickedCallBackCalled = false;
1324 // Create a tap event to touch the text field.
1325 TestGenerateTap(application, 30.0f, 25.0f, 4900);
1326 application.SendNotification();
1327 application.Render();
1329 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1331 // 3 ~ 4 index remove
1332 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1333 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 3);
1334 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 4);
1335 application.SendNotification();
1336 application.Render();
1338 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1339 application.SendNotification();
1340 application.Render();
1342 gAnchorClickedCallBackCalled = false;
1343 // Create a tap event to touch the text field.
1344 TestGenerateTap(application, 30.0f, 25.0f, 5500);
1345 application.SendNotification();
1346 application.Render();
1348 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1350 // Remove front of anchor
1351 field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
1352 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
1353 application.SendNotification();
1354 application.Render();
1356 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1357 application.SendNotification();
1358 application.Render();
1360 // Remove whole text
1361 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1362 DevelTextField::SelectWholeText(field);
1363 application.SendNotification();
1364 application.Render();
1366 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1367 application.SendNotification();
1368 application.Render();
1370 // Remove all with backspace
1371 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1372 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
1373 application.SendNotification();
1374 application.Render();
1376 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1377 application.SendNotification();
1378 application.Render();
1380 // Remove all with delete
1381 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1382 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1383 application.SendNotification();
1384 application.Render();
1386 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));
1387 application.SendNotification();
1388 application.Render();
1393 // Positive test for the textChanged signal.
1394 int utcDaliTextFieldTextChangedP(void)
1396 ToolkitTestApplication application;
1397 tet_infoline(" utcDaliTextFieldTextChangedP");
1398 TextField field = TextField::New();
1399 DALI_TEST_CHECK( field );
1401 application.GetScene().Add( field );
1403 // connect to the text changed signal.
1404 ConnectionTracker* testTracker = new ConnectionTracker();
1405 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1406 bool textChangedSignal = false;
1407 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1409 gTextChangedCallBackCalled = false;
1410 field.SetProperty( TextField::Property::TEXT, "ABC" );
1411 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1412 DALI_TEST_CHECK( textChangedSignal );
1414 application.SendNotification();
1415 field.SetKeyInputFocus();
1417 gTextChangedCallBackCalled = false;
1418 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1419 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1422 field.SetProperty( TextField::Property::TEXT, "" );
1424 // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1425 gTextChangedCallBackCalled = false;
1426 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1427 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1429 // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1430 gTextChangedCallBackCalled = false;
1431 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1432 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1437 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1439 ToolkitTestApplication application;
1440 tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1441 TextField field = TextField::New();
1442 DALI_TEST_CHECK( field );
1445 application.GetScene().Add( field );
1447 // connect to the text changed signal.
1448 ConnectionTracker* testTracker = new ConnectionTracker();
1449 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1450 bool textChangedSignal = false;
1451 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1454 // get InputMethodContext
1456 InputMethodContext::EventData imfEvent;
1457 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext( field );
1459 field.SetKeyInputFocus();
1460 field.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
1463 gTextChangedCallBackCalled = false;
1464 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1465 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1466 application.SendNotification();
1467 application.Render();
1468 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1469 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1471 gTextChangedCallBackCalled = false;
1472 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1473 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1474 application.SendNotification();
1475 application.Render();
1476 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1477 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호"), TEST_LOCATION );
1479 gTextChangedCallBackCalled = false;
1480 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1481 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1482 application.SendNotification();
1483 application.Render();
1484 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1485 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1487 gTextChangedCallBackCalled = false;
1488 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1489 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1490 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1492 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1493 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1494 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1496 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1497 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1498 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1500 application.SendNotification();
1501 application.Render();
1502 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1503 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1509 // Negative test for the textChanged signal.
1510 int utcDaliTextFieldTextChangedN(void)
1512 ToolkitTestApplication application;
1513 tet_infoline(" utcDaliTextFieldTextChangedN");
1514 TextField field = TextField::New();
1515 DALI_TEST_CHECK( field );
1517 application.GetScene().Add( field );
1519 // connect to the text changed signal.
1520 ConnectionTracker* testTracker = new ConnectionTracker();
1521 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1522 bool textChangedSignal = false;
1523 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1525 gTextChangedCallBackCalled = false;
1526 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1527 application.SendNotification();
1528 application.Render();
1529 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1530 DALI_TEST_CHECK( !textChangedSignal );
1535 // Positive test for Max Characters reached signal.
1536 int utcDaliTextFieldMaxCharactersReachedP(void)
1538 ToolkitTestApplication application;
1539 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1540 TextField field = TextField::New();
1541 DALI_TEST_CHECK( field );
1543 application.GetScene().Add( field );
1545 const int maxNumberOfCharacters = 1;
1546 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1548 field.SetKeyInputFocus();
1550 // connect to the text changed signal.
1551 ConnectionTracker* testTracker = new ConnectionTracker();
1552 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1553 bool maxLengthReachedSignal = false;
1554 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1556 gMaxCharactersCallBackCalled = false;
1558 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1559 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1561 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1562 DALI_TEST_CHECK( maxLengthReachedSignal );
1567 // Negative test for Max Characters reached signal.
1568 int utcDaliTextFieldMaxCharactersReachedN(void)
1570 ToolkitTestApplication application;
1571 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1572 TextField field = TextField::New();
1573 DALI_TEST_CHECK( field );
1575 application.GetScene().Add( field );
1577 const int maxNumberOfCharacters = 3;
1578 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1580 field.SetKeyInputFocus();
1582 // connect to the text changed signal.
1583 ConnectionTracker* testTracker = new ConnectionTracker();
1584 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1585 bool maxLengthReachedSignal = false;
1586 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1588 gMaxCharactersCallBackCalled = false;
1590 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1591 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1593 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1594 DALI_TEST_CHECK( !maxLengthReachedSignal );
1596 application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1598 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1599 DALI_TEST_CHECK( !maxLengthReachedSignal );
1604 // Positive test for Input Filtered signal.
1605 int utcDaliTextFieldInputFilteredP(void)
1607 ToolkitTestApplication application;
1608 tet_infoline(" utcDaliTextFieldInputFilteredP");
1609 TextField field = TextField::New();
1610 DALI_TEST_CHECK(field);
1612 application.GetScene().Add(field);
1614 Property::Map inputFilter;
1616 // Only digit is accepted.
1617 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1619 // Set input filter to TextField.
1620 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1622 field.SetKeyInputFocus();
1624 // connect to the input filtered signal.
1625 ConnectionTracker* testTracker = new ConnectionTracker();
1626 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1627 bool inputFilteredSignal = false;
1628 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1630 gInputFilteredAcceptedCallbackCalled = false;
1632 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ));
1634 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1635 DALI_TEST_CHECK(inputFilteredSignal);
1637 // Word is rejected.
1638 inputFilter[InputFilter::Property::ACCEPTED] = "";
1639 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1641 // Set input filter to TextField.
1642 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1644 field.SetKeyInputFocus();
1646 inputFilteredSignal = false;
1647 gInputFilteredRejectedCallbackCalled = false;
1649 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1651 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1652 DALI_TEST_CHECK(inputFilteredSignal);
1657 // Negative test for Input Filtered signal.
1658 int utcDaliTextFieldInputFilteredN(void)
1660 ToolkitTestApplication application;
1661 tet_infoline(" utcDaliTextFieldInputFilteredP");
1662 TextField field = TextField::New();
1663 DALI_TEST_CHECK(field);
1665 application.GetScene().Add(field);
1667 Property::Map inputFilter;
1669 // Only word is accepted.
1670 inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
1672 // Set input filter to TextField.
1673 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1675 field.SetKeyInputFocus();
1677 // connect to the input filtered signal.
1678 ConnectionTracker* testTracker = new ConnectionTracker();
1679 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1680 bool inputFilteredSignal = false;
1681 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1683 gInputFilteredAcceptedCallbackCalled = false;
1685 // Key a, d should not be filtered.
1686 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1687 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1688 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1689 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1691 // Backspace, Delete should not be filtered.
1692 application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1693 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));
1695 // Render and notify
1696 application.SendNotification();
1697 application.Render();
1699 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1700 DALI_TEST_CHECK(!inputFilteredSignal);
1702 // Digit is rejected.
1703 inputFilter[InputFilter::Property::ACCEPTED] = "";
1704 inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
1706 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1708 field.SetKeyInputFocus();
1710 inputFilteredSignal = false;
1711 gInputFilteredRejectedCallbackCalled = false;
1713 // Key a, d should not be filtered.
1714 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1715 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1716 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1717 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1719 // Backspace, Delete should not be filtered.
1720 application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1721 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));
1723 // Render and notify
1724 application.SendNotification();
1725 application.Render();
1727 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1728 DALI_TEST_CHECK(!inputFilteredSignal);
1733 int utcDaliTextFieldInputStyleChanged01(void)
1735 // The text-field emits signals when the input style changes. These changes of style are
1736 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1737 // can't be emitted during the size negotiation as the callbacks may update the UI.
1738 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1739 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1740 ToolkitTestApplication application;
1741 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1745 char* pathNamePtr = get_current_dir_name();
1746 const std::string pathName( pathNamePtr );
1747 free( pathNamePtr );
1749 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1750 fontClient.SetDpi( 93u, 93u );
1752 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1753 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1755 TextField field = TextField::New();
1756 DALI_TEST_CHECK( field );
1759 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1760 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1761 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1763 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1764 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1766 // connect to the text changed signal.
1767 ConnectionTracker* testTracker = new ConnectionTracker();
1768 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1769 bool inputStyleChangedSignal = false;
1770 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1772 application.GetScene().Add( field );
1774 // Render and notify
1775 application.SendNotification();
1776 application.Render();
1778 // Executes the idle callbacks added by the text control on the change of input style.
1779 application.RunIdles();
1781 gInputStyleChangedCallbackCalled = false;
1782 gInputStyleMask = TextField::InputStyle::NONE;
1783 inputStyleChangedSignal = false;
1785 // Create a tap event to touch the text field.
1786 TestGenerateTap( application, 18.0f, 25.0f );
1788 // Render and notify
1789 application.SendNotification();
1790 application.Render();
1792 // Executes the idle callbacks added by the text control on the change of input style.
1793 application.RunIdles();
1795 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1796 if( gInputStyleChangedCallbackCalled )
1798 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1800 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1801 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1803 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1804 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1806 DALI_TEST_CHECK( inputStyleChangedSignal );
1808 gInputStyleChangedCallbackCalled = false;
1809 gInputStyleMask = TextField::InputStyle::NONE;
1810 inputStyleChangedSignal = false;
1812 // Create a tap event to touch the text field.
1813 TestGenerateTap( application, 30.0f, 25.0f );
1815 // Render and notify
1816 application.SendNotification();
1817 application.Render();
1819 // Executes the idle callbacks added by the text control on the change of input style.
1820 application.RunIdles();
1822 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1823 DALI_TEST_CHECK( !inputStyleChangedSignal );
1825 gInputStyleChangedCallbackCalled = false;
1826 gInputStyleMask = TextField::InputStyle::NONE;
1827 inputStyleChangedSignal = false;
1829 // Create a tap event to touch the text field.
1830 TestGenerateTap( application, 43.0f, 25.0f );
1832 // Render and notify
1833 application.SendNotification();
1834 application.Render();
1836 // Executes the idle callbacks added by the text control on the change of input style.
1837 application.RunIdles();
1839 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1840 if( gInputStyleChangedCallbackCalled )
1842 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1844 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1845 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1847 DALI_TEST_CHECK( inputStyleChangedSignal );
1849 gInputStyleChangedCallbackCalled = false;
1850 gInputStyleMask = TextField::InputStyle::NONE;
1851 inputStyleChangedSignal = false;
1853 // Create a tap event to touch the text field.
1854 TestGenerateTap( application, 88.0f, 25.0f );
1856 // Render and notify
1857 application.SendNotification();
1858 application.Render();
1860 // Executes the idle callbacks added by the text control on the change of input style.
1861 application.RunIdles();
1863 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1864 if( gInputStyleChangedCallbackCalled )
1866 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1868 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1869 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1871 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1873 Property::Map fontStyleMapSet;
1874 fontStyleMapSet.Insert( "weight", "bold" );
1876 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1877 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1879 DALI_TEST_CHECK( inputStyleChangedSignal );
1881 gInputStyleChangedCallbackCalled = false;
1882 gInputStyleMask = TextField::InputStyle::NONE;
1883 inputStyleChangedSignal = false;
1885 // Create a tap event to touch the text field.
1886 TestGenerateTap( application, 115.0f, 25.0f );
1888 // Render and notify
1889 application.SendNotification();
1890 application.Render();
1892 // Executes the idle callbacks added by the text control on the change of input style.
1893 application.RunIdles();
1895 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1896 DALI_TEST_CHECK( !inputStyleChangedSignal );
1898 gInputStyleChangedCallbackCalled = false;
1899 gInputStyleMask = TextField::InputStyle::NONE;
1900 inputStyleChangedSignal = false;
1902 // Create a tap event to touch the text field.
1903 TestGenerateTap( application, 164.0f, 25.0f );
1905 // Render and notify
1906 application.SendNotification();
1907 application.Render();
1909 // Executes the idle callbacks added by the text control on the change of input style.
1910 application.RunIdles();
1912 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1913 if( gInputStyleChangedCallbackCalled )
1915 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1917 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1918 DALI_TEST_CHECK( style.empty() );
1920 DALI_TEST_CHECK( inputStyleChangedSignal );
1922 gInputStyleChangedCallbackCalled = false;
1923 gInputStyleMask = TextField::InputStyle::NONE;
1924 inputStyleChangedSignal = false;
1926 // Create a tap event to touch the text field.
1927 TestGenerateTap( application, 191.0f, 25.0f );
1929 // Render and notify
1930 application.SendNotification();
1931 application.Render();
1933 // Executes the idle callbacks added by the text control on the change of input style.
1934 application.RunIdles();
1936 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1937 DALI_TEST_CHECK( !inputStyleChangedSignal );
1942 int utcDaliTextFieldInputStyleChanged02(void)
1944 // The text-field emits signals when the input style changes. These changes of style are
1945 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1946 // can't be emitted during the size negotiation as the callbacks may update the UI.
1947 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1948 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1949 ToolkitTestApplication application;
1950 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1954 char* pathNamePtr = get_current_dir_name();
1955 const std::string pathName( pathNamePtr );
1956 free( pathNamePtr );
1958 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1959 fontClient.SetDpi( 93u, 93u );
1961 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1962 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1964 TextField field = TextField::New();
1965 DALI_TEST_CHECK( field );
1967 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1968 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1969 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1971 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1972 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>" );
1974 // connect to the text changed signal.
1975 ConnectionTracker* testTracker = new ConnectionTracker();
1976 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1977 bool inputStyleChangedSignal = false;
1978 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1980 application.GetScene().Add( field );
1982 // Render and notify
1983 application.SendNotification();
1984 application.Render();
1986 // Executes the idle callbacks added by the text control on the change of input style.
1987 application.RunIdles();
1989 gInputStyleChangedCallbackCalled = false;
1990 gInputStyleMask = TextField::InputStyle::NONE;
1991 inputStyleChangedSignal = false;
1993 // Create a tap event to touch the text field.
1994 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1995 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1997 // Render and notify
1998 application.SendNotification();
1999 application.Render();
2001 // Executes the idle callbacks added by the text control on the change of input style.
2002 application.RunIdles();
2004 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2005 if( gInputStyleChangedCallbackCalled )
2007 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2008 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
2009 TextField::InputStyle::POINT_SIZE |
2010 TextField::InputStyle::COLOR ),
2013 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2014 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
2016 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
2017 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
2019 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
2020 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2022 DALI_TEST_CHECK( inputStyleChangedSignal );
2024 gInputStyleChangedCallbackCalled = false;
2025 gInputStyleMask = TextField::InputStyle::NONE;
2026 inputStyleChangedSignal = false;
2028 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2030 // Render and notify
2031 application.SendNotification();
2032 application.Render();
2034 // Executes the idle callbacks added by the text control on the change of input style.
2035 application.RunIdles();
2037 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2038 if( gInputStyleChangedCallbackCalled )
2040 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2041 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
2044 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2045 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
2047 DALI_TEST_CHECK( inputStyleChangedSignal );
2049 gInputStyleChangedCallbackCalled = false;
2050 gInputStyleMask = TextField::InputStyle::NONE;
2051 inputStyleChangedSignal = false;
2053 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2055 // Render and notify
2056 application.SendNotification();
2057 application.Render();
2059 // Executes the idle callbacks added by the text control on the change of input style.
2060 application.RunIdles();
2062 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
2063 DALI_TEST_CHECK( !inputStyleChangedSignal );
2065 gInputStyleChangedCallbackCalled = false;
2066 gInputStyleMask = TextField::InputStyle::NONE;
2067 inputStyleChangedSignal = false;
2069 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2071 // Render and notify
2072 application.SendNotification();
2073 application.Render();
2075 // Executes the idle callbacks added by the text control on the change of input style.
2076 application.RunIdles();
2078 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2079 if( gInputStyleChangedCallbackCalled )
2081 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2082 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
2085 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2086 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
2088 DALI_TEST_CHECK( inputStyleChangedSignal );
2090 gInputStyleChangedCallbackCalled = false;
2091 gInputStyleMask = TextField::InputStyle::NONE;
2092 inputStyleChangedSignal = false;
2094 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
2096 Property::Map fontStyleMapSet;
2097 fontStyleMapSet.Insert( "weight", "thin" );
2098 fontStyleMapSet.Insert( "width", "condensed" );
2099 fontStyleMapSet.Insert( "slant", "italic" );
2101 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2102 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
2104 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
2105 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
2106 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
2107 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
2109 // Render and notify
2110 application.SendNotification();
2111 application.Render();
2113 // Executes the idle callbacks added by the text control on the change of input style.
2114 application.RunIdles();
2116 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
2117 DALI_TEST_CHECK( !inputStyleChangedSignal );
2119 // Create a tap event to touch the text field.
2120 TestGenerateTap( application, 63.0f, 25.0f, 700 );
2122 // Render and notify
2123 application.SendNotification();
2124 application.Render();
2126 // Executes the idle callbacks added by the text control on the change of input style.
2127 application.RunIdles();
2129 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2130 if( gInputStyleChangedCallbackCalled )
2132 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2133 static_cast<unsigned int>( TextField::InputStyle::COLOR |
2134 TextField::InputStyle::POINT_SIZE |
2135 TextField::InputStyle::FONT_STYLE |
2136 TextField::InputStyle::UNDERLINE |
2137 TextField::InputStyle::SHADOW |
2138 TextField::InputStyle::EMBOSS |
2139 TextField::InputStyle::OUTLINE ),
2142 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2143 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
2145 DALI_TEST_CHECK( inputStyleChangedSignal );
2150 int utcDaliTextFieldEvent01(void)
2152 ToolkitTestApplication application;
2153 tet_infoline(" utcDaliTextFieldEvent01");
2155 // Creates a tap event. After creating a tap event the text field should
2156 // have the focus and add text with key events should be possible.
2158 TextField field = TextField::New();
2159 DALI_TEST_CHECK( field );
2161 application.GetScene().Add( field );
2163 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2164 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2165 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2167 // Render and notify
2168 application.SendNotification();
2169 application.Render();
2171 // Avoid a crash when core load gl resources.
2172 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2174 // Render and notify
2175 application.SendNotification();
2176 application.Render();
2178 // Add a key event but as the text field has not the focus it should do nothing.
2179 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2181 // Render and notify
2182 application.SendNotification();
2183 application.Render();
2185 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2187 // Create a tap event to touch the text field.
2188 TestGenerateTap( application, 150.0f, 25.0f );
2190 // Render and notify
2191 application.SendNotification();
2192 application.Render();
2194 // Pressing delete key should be fine even if there is no text in TextField.
2195 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 ) );
2196 // Render and notify
2197 application.SendNotification();
2198 application.Render();
2200 // Now the text field has the focus, so it can handle the key events.
2201 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2202 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2204 // Render and notify
2205 application.SendNotification();
2206 application.Render();
2208 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2210 // Create a second text field and send key events to it.
2211 TextField field2 = TextField::New();
2213 field2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2214 field2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2215 field2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2216 field2.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
2218 application.GetScene().Add( field2 );
2220 // Render and notify
2221 application.SendNotification();
2222 application.Render();
2224 // Create a tap event on the second text field.
2225 TestGenerateTap( application, 150.0f, 125.0f );
2227 // Render and notify
2228 application.SendNotification();
2229 application.Render();
2231 // The second text field has the focus. It should handle the key events.
2232 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2233 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2235 // Render and notify
2236 application.SendNotification();
2237 application.Render();
2239 // Check the text has been added to the second text field.
2240 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2245 int utcDaliTextFieldEvent02(void)
2247 ToolkitTestApplication application;
2248 tet_infoline(" utcDaliTextFieldEvent02");
2250 // Checks if the right number of actors are created.
2252 TextField field = TextField::New();
2253 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2254 DALI_TEST_CHECK( field );
2255 LoadMarkerImages(application, field);
2257 application.GetScene().Add( field );
2259 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2260 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2261 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2263 // Avoid a crash when core load gl resources.
2264 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2266 // Render and notify
2267 application.SendNotification();
2268 application.Render();
2270 // Check there are the expected number of children ( stencil ).
2271 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
2273 Actor stencil = field.GetChildAt( 0u );
2274 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2276 // Create a tap event to touch the text field.
2277 TestGenerateTap( application, 150.0f, 25.0f, 300 );
2279 // Render and notify
2280 application.SendNotification();
2281 application.Render();
2283 Actor layer = field.GetChildAt( 1u );
2284 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2285 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2287 // Now the text field has the focus, so it can handle the key events.
2288 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2289 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2291 // Render and notify
2292 application.SendNotification();
2293 application.Render();
2295 // Checks the cursor and the renderer have been created.
2296 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2297 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
2299 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
2300 DALI_TEST_CHECK( cursor );
2302 // The offscreen root actor has a container with all the actors which contain the text renderers.
2303 Actor container = stencil.GetChildAt( 0u );
2304 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2306 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2307 DALI_TEST_CHECK( renderer );
2310 // Move the cursor and check the position changes.
2311 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2312 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2314 // Render and notify
2315 application.SendNotification();
2316 application.Render();
2318 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2319 DALI_TEST_CHECK( position2.x < position1.x );
2321 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 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 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2328 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
2331 // Move the cursor to the first position.
2332 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2333 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2335 // Render and notify
2336 application.SendNotification();
2337 application.Render();
2339 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2341 // Send some taps and check the cursor positions.
2343 // Try to tap at the beginning.
2344 TestGenerateTap( application, 1.0f, 25.0f, 900 );
2346 // Render and notify
2347 application.SendNotification();
2348 application.Render();
2350 // Cursor position should be the same than position1.
2351 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2353 DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
2355 // Tap away from the start position.
2356 TestGenerateTap( application, 16.0f, 25.0f, 1500 );
2358 // Render and notify
2359 application.SendNotification();
2360 application.Render();
2362 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2364 DALI_TEST_CHECK( position6.x > position5.x );
2366 // Remove all the text.
2367 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2368 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2369 field.SetProperty( TextField::Property::TEXT, "" );
2371 // Render and notify
2372 application.SendNotification();
2373 application.Render();
2375 // Cursor position should be the same than position2.
2376 Vector3 position7 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2378 DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
2380 // Should not be a renderer.
2381 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2383 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2384 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2385 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
2387 application.SendNotification();
2388 application.Render();
2390 // There are renderer and decorator layer
2391 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
2396 int utcDaliTextFieldEvent03(void)
2398 ToolkitTestApplication application;
2399 tet_infoline(" utcDaliTextFieldEvent03");
2401 // Checks if the highlight actor is created.
2403 TextField field = TextField::New();
2404 DALI_TEST_CHECK( field );
2406 application.GetScene().Add( field );
2408 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2409 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2410 field.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
2411 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2412 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2414 // Avoid a crash when core load gl resources.
2415 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2416 LoadMarkerImages(application, field);
2418 // Render and notify
2419 application.SendNotification();
2420 application.Render();
2422 // Tap first to get the focus.
2423 TestGenerateTap( application, 3.0f, 25.0f );
2425 // Render and notify
2426 application.SendNotification();
2427 application.Render();
2429 // Double tap to select a word.
2430 TestGenerateTap( application, 3.0f, 25.0f );
2432 // Render and notify
2433 application.SendNotification();
2434 application.Render();
2436 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2437 Actor stencil = field.GetChildAt( 0u );
2439 // The highlight actor is drawn first, so is the first actor in the list
2440 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2441 DALI_TEST_CHECK( highlight );
2443 // The offscreen root actor has a container with all the actors which contain the text renderers.
2444 Actor container = stencil.GetChildAt( 1u );
2445 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2447 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2448 DALI_TEST_CHECK( renderer );
2454 int utcDaliTextFieldEvent04(void)
2456 ToolkitTestApplication application;
2457 tet_infoline(" utcDaliTextFieldEvent04");
2459 // Checks if the highlight actor is created.
2461 TextField field = TextField::New();
2462 DALI_TEST_CHECK( field );
2463 application.GetScene().Add( field );
2464 LoadMarkerImages(application, field);
2465 // Render and notify
2466 application.SendNotification();
2467 application.Render();
2469 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2470 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2471 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2472 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2473 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2475 // Avoid a crash when core load gl resources.
2476 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2477 // Render and notify
2478 application.SendNotification();
2479 application.Render();
2481 // Create a tap event to touch the text field.
2482 TestGenerateTap( application, 150.0f, 25.0f );
2483 // Render and notify
2484 application.SendNotification();
2485 application.Render();
2488 // Tap first to get the focus.
2489 TestGenerateTap( application, 1.0f, 25.0f );
2491 // Render and notify
2492 application.SendNotification();
2493 application.Render();
2495 // Double tap to select a word.
2496 TestGenerateTap( application, 1.0f, 25.0f );
2498 // Render and notify
2499 application.SendNotification();
2500 application.Render();
2503 TestGenerateTap( application, 0.0f, 40.0f );
2507 int utcDaliTextFieldEvent05(void)
2509 ToolkitTestApplication application;
2510 tet_infoline(" utcDaliTextFieldEvent05");
2512 // Checks dragging of cursor/grab handle
2514 TextField field = TextField::New();
2515 DALI_TEST_CHECK( field );
2516 application.GetScene().Add( field );
2517 LoadMarkerImages(application, field);
2518 // Render and notify
2519 application.SendNotification();
2520 application.Render();
2522 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2523 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2524 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2525 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2526 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2528 // Avoid a crash when core load gl resources.
2529 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2530 // Render and notify
2531 application.SendNotification();
2532 application.Render();
2534 // Create a tap event to touch the text field.
2535 TestGenerateTap( application, 150.0f, 25.0f );
2536 // Render and notify
2537 application.SendNotification();
2538 application.Render();
2540 // Tap first to get the focus.
2541 TestGenerateTap( application, 1.0f, 25.0f );
2543 // Render and notify
2544 application.SendNotification();
2545 application.Render();
2547 // Double tap to select a word.
2548 TestGenerateTap( application, 1.0f, 25.0f );
2550 // Render and notify
2551 application.SendNotification();
2552 application.Render();
2554 Actor stencil = field.GetChildAt( 1u );
2558 int utcDaliTextFieldEvent06(void)
2560 ToolkitTestApplication application;
2561 tet_infoline(" utcDaliTextFieldEvent06");
2563 // Checks Longpress when in edit mode
2565 TextField field = TextField::New();
2566 DALI_TEST_CHECK( field );
2567 application.GetScene().Add( field );
2568 LoadMarkerImages(application, field);
2569 // Render and notify
2570 application.SendNotification();
2571 application.Render();
2573 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2574 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2575 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2576 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2577 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2579 // Avoid a crash when core load gl resources.
2580 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2581 // Render and notify
2582 application.SendNotification();
2583 application.Render();
2585 // Create a tap event to touch the text field.
2586 TestGenerateTap( application, 150.0f, 25.0f );
2587 // Render and notify
2588 application.SendNotification();
2589 application.Render();
2592 // Tap first to get the focus.
2593 TestGenerateTap( application, 1.0f, 25.0f );
2595 // Render and notify
2596 application.SendNotification();
2597 application.Render();
2600 TestGenerateLongPress(application, 1.0f, 25.0f);
2602 // Render and notify
2603 application.SendNotification();
2604 application.Render();
2609 int utcDaliTextFieldEvent07(void)
2611 ToolkitTestApplication application;
2612 tet_infoline(" utcDaliTextFieldEvent07");
2614 // Checks Longpress to start edit mode
2616 TextField field = TextField::New();
2617 DALI_TEST_CHECK( field );
2618 application.GetScene().Add( field );
2619 LoadMarkerImages(application, field);
2620 // Render and notify
2621 application.SendNotification();
2622 application.Render();
2624 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2625 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2626 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2627 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2628 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2629 Property::Map propertyMap;
2630 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2631 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2633 // Avoid a crash when core load gl resources.
2634 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2635 // Render and notify
2636 application.SendNotification();
2637 application.Render();
2640 TestGenerateLongPress(application, 1.0f, 25.0f);
2642 // Render and notify
2643 application.SendNotification();
2644 application.Render();
2649 int utcDaliTextFieldEvent08(void)
2651 ToolkitTestApplication application;
2652 tet_infoline(" utcDaliTextFieldEvent08");
2654 Dali::Clipboard clipboard = Clipboard::Get();
2655 clipboard.SetItem("testTextFieldEvent");
2657 // Checks Longpress when only place holder text
2659 TextField field = TextField::New();
2660 DALI_TEST_CHECK( field );
2661 application.GetScene().Add( field );
2662 LoadMarkerImages(application, field);
2663 // Render and notify
2664 application.SendNotification();
2665 application.Render();
2667 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2668 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2669 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2670 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2671 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2673 // Avoid a crash when core load gl resources.
2674 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2675 // Render and notify
2676 application.SendNotification();
2677 application.Render();
2680 TestGenerateLongPress( application, 1.0f, 25.0f, 20 );
2682 // Render and notify
2683 application.SendNotification();
2684 application.Render();
2686 Wait(application, 500);
2688 TestEndLongPress( application, 1.0f, 25.0f, 520 );
2691 TestGenerateLongPress( application, 1.0f, 25.0f, 600 );
2693 // Render and notify
2694 application.Render();
2696 Wait(application, 500);
2698 Integration::Scene stage = application.GetScene();
2699 Layer layer = stage.GetRootLayer();
2700 Actor actor = layer.FindChildByName("optionPaste");
2704 Vector3 worldPosition = actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION );
2705 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2706 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2708 Dali::Integration::TouchEvent event;
2709 event = Dali::Integration::TouchEvent();
2710 event.AddPoint( GetPointDownInside( position ) );
2711 application.ProcessEvent( event );
2713 event = Dali::Integration::TouchEvent();
2714 event.AddPoint( GetPointUpInside( position ) );
2715 application.ProcessEvent( event );
2717 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2722 int utcDaliTextFieldEvent09(void)
2724 ToolkitTestApplication application;
2725 tet_infoline(" utcDaliTextFieldEvent09");
2727 TextField field = TextField::New();
2728 DALI_TEST_CHECK( field );
2729 application.GetScene().Add( field );
2730 LoadMarkerImages(application, field);
2731 // Render and notify
2732 application.SendNotification();
2733 application.Render();
2735 field.SetProperty( TextField::Property::TEXT, "Hello" );
2736 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2737 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2738 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2739 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2741 // Avoid a crash when core load gl resources.
2742 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2744 // Create a tap event to touch the text field.
2745 TestGenerateTap( application, 150.0f, 25.0f );
2746 application.SendNotification();
2747 application.Render();
2750 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2751 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2752 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2753 application.SendNotification();
2754 application.Render();
2756 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2757 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2758 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2759 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2760 application.SendNotification();
2761 application.Render();
2763 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2764 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2765 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2766 for( unsigned int index = 0u; index < 5u; ++index )
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();
2773 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2774 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2775 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2776 for( unsigned int index = 0u; index < 5u; ++index )
2778 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2779 application.SendNotification();
2780 application.Render();
2783 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2784 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2785 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2786 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2787 application.SendNotification();
2788 application.Render();
2789 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2790 application.SendNotification();
2791 application.Render();
2793 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2794 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2795 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2796 application.SendNotification();
2797 application.Render();
2799 Property::Map mapGet;
2800 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2801 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2802 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2807 int utcDaliTextFieldStyleWhilstSelected(void)
2809 ToolkitTestApplication application;
2810 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2812 // Change font and styles whilst text is selected whilst word selected
2814 TextField field = TextField::New();
2815 DALI_TEST_CHECK( field );
2816 application.GetScene().Add( field );
2817 LoadMarkerImages(application, field);
2818 // Render and notify
2819 application.SendNotification();
2820 application.Render();
2822 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2823 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2824 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2825 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2826 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2828 // Avoid a crash when core load gl resources.
2829 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2830 // Render and notify
2831 application.SendNotification();
2832 application.Render();
2834 // Create a tap event to touch the text field.
2835 TestGenerateTap( application, 150.0f, 25.0f );
2836 // Render and notify
2837 application.SendNotification();
2838 application.Render();
2841 // Tap first to get the focus.
2842 TestGenerateTap( application, 1.0f, 25.0f );
2844 // Render and notify
2845 application.SendNotification();
2846 application.Render();
2848 // Double tap to select a word.
2849 TestGenerateTap( application, 1.0f, 25.0f );
2851 // Render and notify
2852 application.SendNotification();
2853 application.Render();
2855 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2856 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2858 Property::Map fontStyleMapSet;
2859 Property::Map fontStyleMapGet;
2861 fontStyleMapSet.Insert( "weight", "bold" );
2862 fontStyleMapSet.Insert( "slant", "italic" );
2863 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2865 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2866 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2867 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2869 fontStyleMapSet.Clear();
2870 fontStyleMapSet.Insert( "width", "expanded" );
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 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2879 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2881 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2882 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2884 fontStyleMapSet.Clear();
2885 fontStyleMapSet.Insert( "weight", "bold" );
2886 fontStyleMapSet.Insert( "slant", "italic" );
2888 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2890 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2891 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2892 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2894 fontStyleMapSet.Clear();
2895 fontStyleMapSet.Insert( "width", "expanded" );
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 // Press Escape to increase coverage
2904 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2905 application.SendNotification();
2906 application.Render();
2908 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2913 int utcDaliTextFieldEscKeyLoseFocus(void)
2915 ToolkitTestApplication application;
2916 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2918 // Creates a tap event. After creating a tap event the text field should
2919 // have the focus and add text with key events should be possible.
2921 TextField field = TextField::New();
2922 DALI_TEST_CHECK( field );
2924 application.GetScene().Add( field );
2926 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2927 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2928 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2930 // Avoid a crash when core load gl resources.
2931 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2933 // Render and notify
2934 application.SendNotification();
2935 application.Render();
2937 // Add a key event but as the text field has not the focus it should do nothing.
2938 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2939 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2941 // Render and notify
2942 application.SendNotification();
2943 application.Render();
2945 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2947 // Create a tap event to touch the text field.
2948 TestGenerateTap( application, 150.0f, 25.0f );
2950 // Render and notify
2951 application.SendNotification();
2952 application.Render();
2954 // Now the text field has the focus, so it can handle the key events.
2955 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2956 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2957 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2958 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2960 // Render and notify
2961 application.SendNotification();
2962 application.Render();
2964 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2966 // Generate a Esc key event. The text field should lose the focus.
2967 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2968 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2970 // Render and notify
2971 application.SendNotification();
2972 application.Render();
2974 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2976 // No more text should be introduced
2977 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2978 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2980 // Render and notify
2981 application.SendNotification();
2982 application.Render();
2984 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2989 int utcDaliTextFieldSomeSpecialKeys(void)
2991 ToolkitTestApplication application;
2992 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2994 // Checks some special keys when the text is selected.
2996 TextField field = TextField::New();
2997 DALI_TEST_CHECK( field );
2998 application.GetScene().Add( field );
2999 LoadMarkerImages(application, field);
3000 // Render and notify
3001 application.SendNotification();
3002 application.Render();
3004 const std::string longText( "This is a long text for the size of the text-field." );
3006 field.SetProperty( TextField::Property::TEXT, longText );
3007 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
3008 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3009 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3010 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3012 // Avoid a crash when core load gl resources.
3013 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3014 // Render and notify
3015 application.SendNotification();
3016 application.Render();
3018 // Create a tap event to touch the text field.
3019 TestGenerateTap( application, 150.0f, 25.0f );
3021 // Render and notify
3022 application.SendNotification();
3023 application.Render();
3025 // Tap first to get the focus.
3026 TestGenerateTap( application, 1.0f, 25.0f );
3028 // Render and notify
3029 application.SendNotification();
3030 application.Render();
3032 // Double tap to select a word.
3033 TestGenerateTap( application, 1.0f, 25.0f );
3035 // Render and notify
3036 application.SendNotification();
3037 application.Render();
3039 // Generate a Esc key event. The text field should lose the focus.
3040 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3041 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3043 // Render and notify
3044 application.SendNotification();
3045 application.Render();
3047 // Generate a Esc key event. The text field should lose the focus.
3048 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3049 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3051 // Render and notify
3052 application.SendNotification();
3053 application.Render();
3055 // Generate a Esc key event. The text field should lose the focus.
3056 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3057 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3059 // Render and notify
3060 application.SendNotification();
3061 application.Render();
3063 // The text shouldn't be deleted.
3064 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
3069 int utcDaliTextFieldSizeUpdate(void)
3071 ToolkitTestApplication application;
3072 tet_infoline("utcDaliTextFieldSizeUpdate");
3074 // Checks some special keys when the text is selected.
3075 TextField field = TextField::New();
3076 DALI_TEST_CHECK( field );
3077 application.GetScene().Add( field );
3079 float previousHeight = 0.0f;
3080 float currentHeight = 0.0f;
3081 const float fieldWidth = 1920.0f;
3084 // "ㅁ" is bigger then "ኢ"
3085 field.SetProperty( Actor::Property::SIZE, Vector2( fieldWidth ,10.0f ) );
3086 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
3087 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
3089 field.SetProperty( TextField::Property::TEXT, "ኢ");
3090 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3091 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3093 field.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
3094 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
3096 application.SendNotification();
3097 application.Render();
3099 previousHeight = field.GetHeightForWidth( fieldWidth );
3100 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
3102 // Add another script characters ( glyph height is defferent )
3103 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3104 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3106 application.SendNotification();
3107 application.Render();
3109 currentHeight = field.GetHeightForWidth( fieldWidth );
3110 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
3111 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
3116 int utcDaliTextFieldExtremlyLargePointSize(void)
3118 ToolkitTestApplication application;
3119 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
3121 TextField field = TextField::New();
3123 field.SetProperty( TextField::Property::TEXT, "Text" );
3124 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3125 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3126 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3127 application.GetScene().Add( field );
3131 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
3132 application.SendNotification();
3133 DALI_TEST_CHECK( field );
3137 tet_result(TET_FAIL);
3142 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
3144 ToolkitTestApplication application;
3145 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
3146 TextField field = TextField::New();
3147 DALI_TEST_CHECK( field );
3148 application.GetScene().Add( field );
3150 Property::Map fontStyleMapGet;
3152 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
3154 Property::Value* weightValue = NULL;
3155 Property::Value* widthValue = NULL;
3156 Property::Value* slantValue = NULL;
3157 weightValue = fontStyleMapGet.Find( "weight" );
3158 widthValue = fontStyleMapGet.Find( "width" );
3159 slantValue = fontStyleMapGet.Find( "slant" );
3160 DALI_TEST_CHECK( !weightValue );
3161 DALI_TEST_CHECK( !widthValue );
3162 DALI_TEST_CHECK( !slantValue );
3167 int UtcDaliTextFieldSettingPlaceholder(void)
3169 ToolkitTestApplication application;
3170 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
3172 TextField field = TextField::New();
3173 DALI_TEST_CHECK( field );
3174 application.GetScene().Add( field );
3176 // Check the placeholder property with pixel size
3177 Property::Map placeholderPixelSizeMapSet;
3178 Property::Map placeholderPixelSizeMapGet;
3179 Property::Map placeholderFontstyleMap;
3180 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
3181 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
3182 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
3183 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
3184 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
3185 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
3187 placeholderFontstyleMap.Insert( "weight", "bold" );
3188 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3189 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
3191 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3192 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
3193 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
3195 // Check the placeholder property with point size
3196 Property::Map placeholderMapSet;
3197 Property::Map placeholderMapGet;
3198 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
3199 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
3200 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
3201 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
3202 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
3203 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
3205 // Check the placeholder font style property
3206 placeholderFontstyleMap.Clear();
3208 placeholderFontstyleMap.Insert( "weight", "bold" );
3209 placeholderFontstyleMap.Insert( "width", "condensed" );
3210 placeholderFontstyleMap.Insert( "slant", "italic" );
3211 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3212 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3214 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3215 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3216 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3218 // Reset font style.
3219 placeholderFontstyleMap.Clear();
3220 placeholderFontstyleMap.Insert( "weight", "normal" );
3221 placeholderFontstyleMap.Insert( "slant", "oblique" );
3222 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3223 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3225 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3226 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3227 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3229 placeholderFontstyleMap.Clear();
3230 placeholderFontstyleMap.Insert( "slant", "roman" );
3231 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3232 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3234 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3236 placeholderFontstyleMap.Clear();
3237 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3239 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3240 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3241 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3242 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3247 int UtcDaliTextFieldPlaceholderCoverage(void)
3249 ToolkitTestApplication application;
3250 tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
3252 // mPlaceholderFont is created only once, so create a new control for coverage.
3253 TextField fieldForCoverage = TextField::New();
3254 DALI_TEST_CHECK(fieldForCoverage);
3255 application.GetScene().Add(fieldForCoverage);
3257 // for SetPlaceholderFontFamily() coverage.
3258 Property::Map fontFamilyMap;
3259 fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3260 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
3262 // mPlaceholderFont is created only once, so create a new control for coverage.
3263 fieldForCoverage = TextField::New();
3264 DALI_TEST_CHECK(fieldForCoverage);
3265 application.GetScene().Add(fieldForCoverage);
3267 // for SetPlaceholderTextFontSize coverage.
3268 Property::Map fontSizeMap;
3269 fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3270 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
3272 // mPlaceholderFont is created only once, so create a new control for coverage.
3273 fieldForCoverage = TextField::New();
3274 DALI_TEST_CHECK(fieldForCoverage);
3275 application.GetScene().Add(fieldForCoverage);
3277 // for SetPlaceholderTextFontWeight coverage.
3278 Property::Map fontStyleWeightMap;
3279 Property::Map fontStyleWeightPropertyMap;
3280 fontStyleWeightPropertyMap.Insert("weight", "bold");
3281 fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
3282 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
3284 // mPlaceholderFont is created only once, so create a new control for coverage.
3285 fieldForCoverage = TextField::New();
3286 DALI_TEST_CHECK(fieldForCoverage);
3287 application.GetScene().Add(fieldForCoverage);
3289 // for SetPlaceholderTextFontWidth coverage.
3290 Property::Map fontStyleWidthMap;
3291 Property::Map fontStyleWidthPropertyMap;
3292 fontStyleWidthPropertyMap.Insert("width", "expanded");
3293 fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
3294 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
3296 // mPlaceholderFont is created only once, so create a new control for coverage.
3297 fieldForCoverage = TextField::New();
3298 DALI_TEST_CHECK(fieldForCoverage);
3299 application.GetScene().Add(fieldForCoverage);
3301 // for SetPlaceholderTextFontSlant coverage.
3302 Property::Map fontStyleSlantMap;
3303 Property::Map fontStyleSlantPropertyMap;
3304 fontStyleSlantPropertyMap.Insert("slant", "italic");
3305 fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
3306 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
3311 int UtcDaliTextFieldSetPaddingProperty(void)
3313 ToolkitTestApplication application;
3314 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3316 TextField field = TextField::New();
3317 DALI_TEST_CHECK( field );
3318 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3319 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3320 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3321 application.GetScene().Add( field );
3323 application.SendNotification();
3324 application.Render();
3326 Vector3 originalSize = field.GetNaturalSize();
3328 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
3330 application.SendNotification();
3331 application.Render();
3333 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
3335 Vector3 paddingAddedSize = field.GetNaturalSize();
3337 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3339 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3344 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3346 ToolkitTestApplication application;
3347 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3349 TextField field = TextField::New();
3350 DALI_TEST_CHECK( field );
3351 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3352 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3353 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3354 application.GetScene().Add( field );
3356 application.SendNotification();
3357 application.Render();
3359 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3360 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
3362 // Check the enable shift selection property
3363 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
3364 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
3366 application.SendNotification();
3367 application.Render();
3372 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3374 ToolkitTestApplication application;
3375 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3377 TextField field = TextField::New();
3378 DALI_TEST_CHECK( field );
3379 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3380 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3381 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3382 application.GetScene().Add( field );
3384 application.SendNotification();
3385 application.Render();
3387 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3388 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
3390 // Check the enable grab handle property
3391 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
3392 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
3394 application.SendNotification();
3395 application.Render();
3400 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
3402 ToolkitTestApplication application;
3403 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
3405 TextField field = TextField::New();
3406 DALI_TEST_CHECK( field );
3407 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3408 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3409 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3410 application.GetScene().Add( field );
3412 application.SendNotification();
3413 application.Render();
3415 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3416 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
3418 // Check the match system language direction property
3419 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
3420 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
3422 application.SendNotification();
3423 application.Render();
3428 int utcDaliTextFieldLayoutDirectionCoverage(void)
3430 ToolkitTestApplication application;
3431 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
3433 // Creates a tap event. After creating a tap event the text field should
3434 // have the focus and add text with key events should be possible.
3435 TextField field = TextField::New();
3436 DALI_TEST_CHECK( field );
3438 application.GetScene().Add( field );
3440 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3441 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3442 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3444 // Avoid a crash when core load gl resources.
3445 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3447 // Render and notify
3448 application.SendNotification();
3449 application.Render();
3451 // init direction for coverage
3452 // Set horizontal alignment END
3453 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3455 // Create a tap event to touch the text field.
3456 TestGenerateTap( application, 150.0f, 25.0f );
3458 // Render and notify
3459 application.SendNotification();
3460 application.Render();
3462 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
3463 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
3464 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
3466 // Set horizontal alignment BEGIN
3467 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
3469 // Create a tap event to touch the text field.
3470 TestGenerateTap( application, 150.0f, 25.0f );
3472 // Render and notify
3473 application.SendNotification();
3474 application.Render();
3476 // Set horizontal alignment CENTER
3477 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
3479 // Create a tap event to touch the text field.
3480 TestGenerateTap( application, 150.0f, 25.0f );
3482 // Render and notify
3483 application.SendNotification();
3484 application.Render();
3486 // Set horizontal alignment END
3487 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3489 // Create a tap event to touch the text field.
3490 TestGenerateTap( application, 150.0f, 25.0f );
3492 // Render and notify
3493 application.SendNotification();
3494 application.Render();
3496 // Generate a Esc key event. The text field should lose the focus.
3497 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3498 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3500 // Render and notify
3501 application.SendNotification();
3502 application.Render();
3504 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
3509 int UtcDaliTextFieldGetInputMethodContext(void)
3511 ToolkitTestApplication application;
3512 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
3514 TextField field = TextField::New();
3515 DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );
3520 int UtcDaliTextFieldSelectWholeText(void)
3522 ToolkitTestApplication application;
3523 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3525 TextField textField = TextField::New();
3527 application.GetScene().Add( textField );
3529 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3530 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3531 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3533 // Avoid a crash when core load gl resources.
3534 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3536 application.SendNotification();
3537 application.Render();
3539 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
3541 DevelTextField::SelectWholeText( textField );
3543 application.SendNotification();
3544 application.Render();
3546 // Nothing should have been selected. The number of children is still 1
3547 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
3549 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3551 application.SendNotification();
3552 application.Render();
3554 DevelTextField::SelectWholeText( textField );
3556 application.SendNotification();
3557 application.Render();
3559 // Should be 2 children, the stencil and the layer
3560 DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
3562 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3563 Actor stencil = textField.GetChildAt( 0u );
3565 // The highlight actor is drawn first, so is the first actor in the list
3566 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3567 DALI_TEST_CHECK( highlight );
3572 int UtcDaliTextFieldSelectText(void)
3574 ToolkitTestApplication application;
3575 tet_infoline(" UtcDaliTextFieldSelectText ");
3577 TextField textField = TextField::New();
3579 application.GetScene().Add( textField );
3581 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3582 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3583 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3585 // Avoid a crash when core load gl resources.
3586 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3588 application.SendNotification();
3589 application.Render();
3591 DevelTextField::SelectText( textField, 0, 5 );
3593 application.SendNotification();
3594 application.Render();
3596 // Nothing is selected
3597 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3598 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3600 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3602 application.SendNotification();
3603 application.Render();
3605 // Hello is selected
3606 DevelTextField::SelectText( textField, 0, 5 );
3608 application.SendNotification();
3609 application.Render();
3611 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3612 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3614 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3615 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3617 // world is selected
3618 DevelTextField::SelectText( textField, 6, 11 );
3620 application.SendNotification();
3621 application.Render();
3623 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3624 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3626 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3627 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3632 int UtcDaliTextFieldSelectNone(void)
3634 ToolkitTestApplication application;
3635 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3637 TextField textField = TextField::New();
3639 application.GetScene().Add( textField );
3641 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3642 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3643 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3645 // Avoid a crash when core load gl resources.
3646 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3648 application.SendNotification();
3649 application.Render();
3651 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3653 application.SendNotification();
3654 application.Render();
3656 // Nothing is selected
3657 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3658 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3660 DevelTextField::SelectWholeText( textField );
3662 application.SendNotification();
3663 application.Render();
3665 // whole text is selected
3666 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3667 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3669 DevelTextField::SelectNone( textField );
3671 application.SendNotification();
3672 application.Render();
3674 // Nothing is selected
3675 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3676 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3681 int UtcDaliTextFieldSelectRange(void)
3683 ToolkitTestApplication application;
3684 tet_infoline(" UtcDaliTextFieldSelectRange ");
3686 TextField textField = TextField::New();
3688 application.GetScene().Add( textField );
3690 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3691 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3692 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3694 // Avoid a crash when core load gl resources.
3695 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3697 application.SendNotification();
3698 application.Render();
3700 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3702 application.SendNotification();
3703 application.Render();
3705 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 0);
3706 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 5);
3708 // Hello is selected
3709 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3710 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3712 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3713 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3715 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 6);
3716 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 11);
3718 // world is selected
3719 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3720 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3722 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3723 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3728 int UtcDaliTextFieldEnableEditing(void)
3730 ToolkitTestApplication application;
3731 tet_infoline(" UtcDaliTextFieldEnableEditing ");
3733 TextField textField = TextField::New();
3735 application.GetScene().Add( textField );
3737 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3738 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3739 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3741 // Avoid a crash when core load gl resources.
3742 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3744 application.SendNotification();
3745 application.Render();
3747 textField.SetKeyInputFocus();
3748 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, false );
3749 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3751 // Render and notify
3752 application.SendNotification();
3753 application.Render();
3755 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3756 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3759 textField.SetKeyInputFocus();
3760 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
3761 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3763 // Render and notify
3764 application.SendNotification();
3765 application.Render();
3767 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3768 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3773 int UtcDaliToolkitTextFieldFontSizeScale(void)
3775 ToolkitTestApplication application;
3776 tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
3778 TextField textField = TextField::New();
3779 textField.SetProperty( TextField::Property::POINT_SIZE, 30.f );
3780 textField.SetProperty( TextField::Property::TEXT, "Test" );
3781 Vector3 nonScaledSize = textField.GetNaturalSize();
3783 TextField textFieldScaled = TextField::New();
3784 textFieldScaled.SetProperty( TextField::Property::POINT_SIZE, 15.f );
3785 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3786 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3787 Vector3 scaledSize = textFieldScaled.GetNaturalSize();
3789 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3791 textField.SetProperty( TextField::Property::PIXEL_SIZE, 30.f );
3792 textField.SetProperty( TextField::Property::TEXT, "Test" );
3793 nonScaledSize = textField.GetNaturalSize();
3795 textFieldScaled.SetProperty( TextField::Property::PIXEL_SIZE, 15.f );
3796 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3797 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3798 scaledSize = textFieldScaled.GetNaturalSize();
3800 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3805 int UtcDaliTextFieldPrimaryCursorPosition(void)
3807 ToolkitTestApplication application;
3808 tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
3810 TextField textField = TextField::New();
3812 application.GetScene().Add( textField );
3814 textField.SetProperty( TextField::Property::TEXT, "ABCEF");
3815 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3816 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3817 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3819 // Avoid a crash when core load gl resources.
3820 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3822 textField.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
3823 application.SendNotification();
3824 application.Render();
3825 textField.SetKeyInputFocus();
3827 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3829 // Render and notify
3830 application.SendNotification();
3831 application.Render();
3833 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3834 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3839 // test max length when set after setting long text
3840 int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
3842 ToolkitTestApplication application;
3843 tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
3844 TextField field = TextField::New();
3845 DALI_TEST_CHECK( field );
3847 application.GetScene().Add( field );
3849 field.SetProperty(TextField::Property::TEXT, "123456789");
3851 const int maxNumberOfCharacters = 3;
3852 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
3854 field.SetKeyInputFocus();
3856 // connect to the text max lengh reached signal.
3857 ConnectionTracker* testTracker = new ConnectionTracker();
3858 bool maxLengthReachedSignal = false;
3859 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
3861 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3862 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3864 DALI_TEST_CHECK( maxLengthReachedSignal );
3866 DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "123456789", TEST_LOCATION );
3873 int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
3875 ToolkitTestApplication application;
3876 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
3878 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3879 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3880 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3882 // Create a text field
3883 TextField textField = TextField::New();
3885 //Set size to avoid automatic eliding
3886 textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3887 //Set very large font-size using point-size
3888 textField.SetProperty( TextField::Property::POINT_SIZE, 1000) ;
3889 //Specify font-family
3890 textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
3891 //Set text to check if appear or not
3892 textField.SetProperty( TextField::Property::TEXT, "A");
3894 application.GetScene().Add( textField );
3896 application.SendNotification();
3897 application.Render();
3898 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3899 Vector3 naturalSize = textField.GetNaturalSize();
3901 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3902 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3907 int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
3909 ToolkitTestApplication application;
3910 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
3912 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3913 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3914 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3916 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3917 // Create a text editor
3918 TextField textField = TextField::New();
3920 //Set size to avoid automatic eliding
3921 textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3922 textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
3923 textField.SetProperty( TextField::Property::TEXT, "A");
3925 const int numberOfCases = 6;
3926 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
3928 for (int index=0; index < numberOfCases; index++)
3930 tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
3931 textField.SetProperty( TextField::Property::POINT_SIZE, arrayCases[index]) ;
3932 application.GetScene().Add( textField );
3933 application.SendNotification();
3934 application.Render();
3935 naturalSize = textField.GetNaturalSize();
3936 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3937 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3944 int UtcDaliToolkitTextFieldEllipsisPositionProperty(void)
3946 ToolkitTestApplication application;
3947 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty ");
3948 TextField textField = TextField::New();
3950 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Default is END");
3951 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3953 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START");
3954 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
3955 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3957 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE");
3958 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
3959 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3961 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END");
3962 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
3963 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3965 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START using integer");
3966 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 1);
3967 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3969 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE using integer");
3970 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 2);
3971 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3973 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END using integer");
3974 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 0);
3975 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3977 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
3978 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "START");
3979 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3981 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
3982 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "MIDDLE");
3983 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3985 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
3986 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "END");
3987 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3989 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
3990 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "start");
3991 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3993 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
3994 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "middle");
3995 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3997 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
3998 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "end");
3999 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4004 int UtcDaliTextFieldCopyText(void)
4006 ToolkitTestApplication application;
4007 tet_infoline(" UtcDaliTextFieldCopyText ");
4009 TextField textField = TextField::New();
4011 std::string selectedText = "";
4012 std::string copiedText = "";
4014 application.GetScene().Add( textField );
4016 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4017 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4018 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4020 // Avoid a crash when core load gl resources.
4021 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4023 application.SendNotification();
4024 application.Render();
4026 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
4028 application.SendNotification();
4029 application.Render();
4031 // Hello is selected
4032 DevelTextField::SelectText( textField, 0, 5 );
4034 application.SendNotification();
4035 application.Render();
4037 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4038 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4040 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4041 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4044 copiedText = DevelTextField::CopyText( textField );
4045 DALI_TEST_EQUALS( "Hello", copiedText, TEST_LOCATION );
4047 // world is selected
4048 DevelTextField::SelectText( textField, 6, 11 );
4050 application.SendNotification();
4051 application.Render();
4053 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4054 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
4056 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
4057 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
4060 copiedText = DevelTextField::CopyText( textField );
4061 DALI_TEST_EQUALS( "world", copiedText, TEST_LOCATION );
4063 // "lo wo" is selected
4064 DevelTextField::SelectText( textField, 3, 8 );
4066 application.SendNotification();
4067 application.Render();
4069 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4070 DALI_TEST_EQUALS( "lo wo", selectedText, TEST_LOCATION );
4072 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 3, TEST_LOCATION );
4073 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 8, TEST_LOCATION );
4075 // "lo wo" is copied
4076 copiedText = DevelTextField::CopyText( textField );
4077 DALI_TEST_EQUALS( "lo wo", copiedText, TEST_LOCATION );
4082 int UtcDaliTextFieldCutText(void)
4084 ToolkitTestApplication application;
4085 tet_infoline(" UtcDaliTextFieldCutText ");
4087 TextField textField = TextField::New();
4089 std::string selectedText = "";
4091 application.GetScene().Add( textField );
4093 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4094 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4095 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4097 // Avoid a crash when core load gl resources.
4098 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4100 application.SendNotification();
4101 application.Render();
4103 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
4105 application.SendNotification();
4106 application.Render();
4108 // Hello is selected
4109 DevelTextField::SelectText( textField, 0, 5 );
4111 application.SendNotification();
4112 application.Render();
4114 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4115 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4117 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4118 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4121 DALI_TEST_EQUALS( "Hello", DevelTextField::CutText( textField ), TEST_LOCATION );
4123 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), " world", TEST_LOCATION );
4126 DevelTextField::SelectText( textField, 0, 2 );
4128 application.SendNotification();
4129 application.Render();
4131 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4132 DALI_TEST_EQUALS( " w", selectedText, TEST_LOCATION );
4134 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4135 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4138 DALI_TEST_EQUALS( " w", DevelTextField::CutText( textField ), TEST_LOCATION );
4140 application.SendNotification();
4141 application.Render();
4143 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "orld", TEST_LOCATION );
4145 // Test Cut from the middle
4148 DevelTextField::SelectText( textField, 1, 3 );
4150 application.SendNotification();
4151 application.Render();
4153 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4154 DALI_TEST_EQUALS( "rl", selectedText, TEST_LOCATION );
4156 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4157 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 3, TEST_LOCATION );
4160 DALI_TEST_EQUALS( "rl", DevelTextField::CutText( textField ), TEST_LOCATION );
4162 application.SendNotification();
4163 application.Render();
4165 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "od", TEST_LOCATION );
4167 // Test Cut from the end
4170 DevelTextField::SelectText( textField, 1, 2 );
4172 application.SendNotification();
4173 application.Render();
4175 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4176 DALI_TEST_EQUALS( "d", selectedText, TEST_LOCATION );
4178 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4179 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4182 DALI_TEST_EQUALS( "d", DevelTextField::CutText( textField ), TEST_LOCATION );
4184 application.SendNotification();
4185 application.Render();
4187 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "o", TEST_LOCATION );
4192 int UtcDaliTextFieldPasteText(void)
4194 ToolkitTestApplication application;
4195 tet_infoline(" UtcDaliTextFieldPasteText ");
4197 TextField textField = TextField::New();
4199 application.GetScene().Add( textField );
4201 std::string cutText = "";
4202 std::string copiedText = "";
4204 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4205 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4206 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4208 // Avoid a crash when core load gl resources.
4209 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4211 application.SendNotification();
4212 application.Render();
4214 textField.SetProperty( TextField::Property::TEXT, "Hello World" );
4216 application.SendNotification();
4217 application.Render();
4219 // Tap on the text editor
4220 TestGenerateTap( application, 3.0f, 25.0f );
4222 // Render and notify
4223 application.SendNotification();
4224 application.Render();
4226 // Select some text in the right of the current cursor position
4227 DevelTextField::SelectText( textField, 0, 3 );
4229 // Render and notify
4230 application.SendNotification();
4231 application.Render();
4233 // Cut the selected text
4234 cutText = DevelTextField::CutText(textField);
4236 // Render and notify
4237 application.SendNotification();
4238 application.Render();
4240 DALI_TEST_EQUALS( "Hel", cutText, TEST_LOCATION );
4241 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "lo World", TEST_LOCATION );
4243 DevelTextField::SelectText( textField, 0, 3 );
4245 // Render and notify
4246 application.SendNotification();
4247 application.Render();
4249 // Copy the selected text
4250 copiedText = DevelTextField::CopyText(textField);
4252 // Render and notify
4253 application.SendNotification();
4254 application.Render();
4256 DALI_TEST_EQUALS( "lo ", copiedText, TEST_LOCATION );
4257 DALI_TEST_EQUALS( "lo World", textField.GetProperty<std::string>( TextField::Property::TEXT ), TEST_LOCATION );
4259 // Move the cursor to the end of the line
4260 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4261 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4262 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4263 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4264 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4265 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4266 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4267 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4269 // Render and notify
4270 application.SendNotification();
4271 application.Render();
4273 // Paste the selected text at the current cursor position
4274 DevelTextField::PasteText(textField);
4276 // Render and notify
4277 application.SendNotification();
4278 application.Render();
4280 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "lo Worldlo ", TEST_LOCATION );
4284 int utcDaliTextFieldCursorPositionChangedSignal(void)
4286 ToolkitTestApplication application;
4287 tet_infoline(" utcDaliTextFieldCursorPositionChangedSignal");
4289 TextField field = TextField::New();
4290 DALI_TEST_CHECK( field );
4292 application.GetScene().Add( field );
4294 // connect to the selection changed signal.
4295 ConnectionTracker* testTracker = new ConnectionTracker();
4296 DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
4297 bool cursorPositionChangedSignal = false;
4298 field.ConnectSignal( testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal) );
4300 field.SetProperty( TextField::Property::TEXT, "Hello world Hello world" );
4301 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
4302 field.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4303 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4304 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4306 // Avoid a crash when core load gl resources.
4307 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4309 // Render and notify
4310 application.SendNotification();
4311 application.Render();
4313 field.SetKeyInputFocus();
4315 // Tap on the text field
4316 TestGenerateTap( application, 3.0f, 25.0f );
4318 // Render and notify
4319 application.SendNotification();
4320 application.Render();
4322 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4323 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4325 gCursorPositionChangedCallbackCalled = false;
4328 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4330 // Render and notify
4331 application.SendNotification();
4332 application.Render();
4334 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4335 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4337 gCursorPositionChangedCallbackCalled = false;
4340 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4342 // Render and notify
4343 application.SendNotification();
4344 application.Render();
4346 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4347 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4349 gCursorPositionChangedCallbackCalled = false;
4351 //delete one character
4352 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4354 // Render and notify
4355 application.SendNotification();
4356 application.Render();
4358 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4359 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4361 gCursorPositionChangedCallbackCalled = false;
4363 field.SetProperty( TextField::Property::TEXT, "Hello" );
4365 // Render and notify
4366 application.SendNotification();
4367 application.Render();
4369 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4370 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4372 gCursorPositionChangedCallbackCalled = false;
4374 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4376 // Render and notify
4377 application.SendNotification();
4378 application.Render();
4380 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4381 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4386 int utcDaliTextFieldSelectionChangedSignal(void)
4388 ToolkitTestApplication application;
4389 tet_infoline(" utcDaliTextFieldSelectionChangedSignal");
4391 TextField field = TextField::New();
4392 DALI_TEST_CHECK( field );
4394 application.GetScene().Add( field );
4396 // connect to the selection changed signal.
4397 ConnectionTracker* testTracker = new ConnectionTracker();
4398 DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
4399 bool selectionChangedSignal = false;
4400 field.ConnectSignal( testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal) );
4402 field.SetProperty( TextField::Property::TEXT, "Hello world Hello world" );
4403 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
4404 field.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4405 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4406 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4408 // Avoid a crash when core load gl resources.
4409 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4411 // Render and notify
4412 application.SendNotification();
4413 application.Render();
4415 // Tap on the text field
4416 TestGenerateTap( application, 3.0f, 25.0f );
4418 // Render and notify
4419 application.SendNotification();
4420 application.Render();
4422 // Select some text in the right of the current cursor position
4423 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4424 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4426 // Render and notify
4427 application.SendNotification();
4428 application.Render();
4430 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4431 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4433 gSelectionChangedCallbackCalled = false;
4435 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4437 // Render and notify
4438 application.SendNotification();
4439 application.Render();
4441 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4442 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4443 DALI_TEST_EQUALS(oldSelectionEnd, 1, TEST_LOCATION);
4445 gSelectionChangedCallbackCalled = false;
4447 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4449 // Render and notify
4450 application.SendNotification();
4451 application.Render();
4453 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4454 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4455 DALI_TEST_EQUALS(oldSelectionEnd, 2, TEST_LOCATION);
4457 gSelectionChangedCallbackCalled = false;
4458 field.SetKeyInputFocus();
4460 // Render and notify
4461 application.SendNotification();
4462 application.Render();
4464 DevelTextField::SelectText( field ,0, 5 );
4466 application.SendNotification();
4467 application.Render();
4469 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4470 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4472 gSelectionChangedCallbackCalled = false;
4474 field.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4476 // Render and notify
4477 application.SendNotification();
4478 application.Render();
4480 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4481 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4482 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
4484 gSelectionChangedCallbackCalled = false;
4487 DevelTextField::SelectWholeText(field);
4489 // Render and notify
4490 application.SendNotification();
4491 application.Render();
4493 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4494 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4496 gSelectionChangedCallbackCalled = false;
4499 DevelTextField::SelectNone(field);
4501 // Render and notify
4502 application.SendNotification();
4503 application.Render();
4505 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4506 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4507 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);