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;
124 const int KEY_SHIFT_MODIFIER = 257;
126 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
128 static bool gSelectionChangedCallbackCalled;
129 static uint32_t oldSelectionStart;
130 static uint32_t oldSelectionEnd;
131 static bool gAnchorClickedCallBackCalled;
132 static bool gAnchorClickedCallBackNotCalled;
133 static bool gTextChangedCallBackCalled;
134 static bool gMaxCharactersCallBackCalled;
135 static bool gInputFilteredAcceptedCallbackCalled;
136 static bool gInputFilteredRejectedCallbackCalled;
137 static bool gInputStyleChangedCallbackCalled;
138 static bool gCursorPositionChangedCallbackCalled;
139 static uint32_t oldCursorPos;
140 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
142 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
144 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
145 Integration::ResourcePointer resource(bitmap);
146 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
149 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
153 LoadBitmapResource( app.GetPlatform(), width, height );
155 Property::Map propertyMap;
156 propertyMap["filename"] = "image.png";
157 propertyMap["width"] = width;
158 propertyMap["height"] = height;
159 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
160 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
161 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
162 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
163 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
164 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
165 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
166 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
170 * Simulate time passed by.
172 * @note this will always process at least 1 frame (1/60 sec)
174 * @param application Test application instance
175 * @param duration Time to pass in milliseconds.
176 * @return The actual time passed in milliseconds
178 static int Wait(ToolkitTestApplication& application, int duration = 0)
182 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
184 application.SendNotification();
185 application.Render(RENDER_FRAME_INTERVAL);
186 time += RENDER_FRAME_INTERVAL;
192 Dali::Integration::Point GetPointDownInside( Vector2& pos )
194 Dali::Integration::Point point;
195 point.SetState( PointState::DOWN );
196 point.SetScreenPosition( pos );
200 Dali::Integration::Point GetPointUpInside( Vector2& pos )
202 Dali::Integration::Point point;
203 point.SetState( PointState::UP );
204 point.SetScreenPosition( pos );
208 struct CallbackFunctor
210 CallbackFunctor(bool* callbackFlag)
211 : mCallbackFlag( callbackFlag )
217 *mCallbackFlag = true;
222 static void TestSelectionChangedCallback(TextField control, uint32_t oldStart, uint32_t oldEnd)
224 tet_infoline(" TestSelectionChangedCallback");
226 gSelectionChangedCallbackCalled = true;
227 oldSelectionStart = oldStart;
228 oldSelectionEnd = oldEnd;
231 static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength)
233 tet_infoline(" TestAnchorClickedCallback");
235 gAnchorClickedCallBackNotCalled = false;
237 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
239 gAnchorClickedCallBackCalled = true;
243 static void TestCursorPositionChangedCallback( TextField control, unsigned int oldPos )
245 tet_infoline(" TestCursorPositionChangedCallback");
247 gCursorPositionChangedCallbackCalled = true;
248 oldCursorPos = oldPos;
251 static void TestTextChangedCallback( TextField control )
253 tet_infoline(" TestTextChangedCallback");
255 gTextChangedCallBackCalled = true;
258 static void TestMaxLengthReachedCallback( TextField control )
260 tet_infoline(" TestMaxLengthReachedCallback");
262 gMaxCharactersCallBackCalled = true;
265 static void TestInputFilteredCallback(TextField control, Toolkit::InputFilter::Property::Type type)
267 tet_infoline(" TestInputFilteredCallback");
269 if(type == Toolkit::InputFilter::Property::ACCEPTED)
271 gInputFilteredAcceptedCallbackCalled = true;
273 else if(type == Toolkit::InputFilter::Property::REJECTED)
275 gInputFilteredRejectedCallbackCalled = true;
279 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
281 tet_infoline(" TestInputStyleChangedCallback");
283 gInputStyleChangedCallbackCalled = true;
284 gInputStyleMask = mask;
287 // Generate a KeyEvent to send to Core.
288 Integration::KeyEvent GenerateKey( const std::string& keyName,
289 const std::string& logicalKey,
290 const std::string& keyString,
293 unsigned long timeStamp,
294 const Integration::KeyEvent::State& keyState,
295 const std::string& compose = "",
296 const std::string& deviceName = DEFAULT_DEVICE_NAME,
297 const Device::Class::Type& deviceClass = Device::Class::NONE,
298 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
300 return Integration::KeyEvent( keyName,
313 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
315 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
317 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
319 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
321 Property::Value* valueSet = NULL;
322 if ( valueGet.first.type == Property::Key::INDEX )
324 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
328 // Get Key is a string so searching Set Map for a string key
329 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
332 if( NULL != valueSet )
334 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
336 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
339 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
341 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
344 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
346 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
349 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
351 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
354 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
356 Vector2 vector2Get = valueGet.second.Get<Vector2>();
357 Vector2 vector2Set = valueSet->Get<Vector2>();
358 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
361 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
363 Vector4 vector4Get = valueGet.second.Get<Vector4>();
364 Vector4 vector4Set = valueSet->Get<Vector4>();
365 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 );
371 if ( valueGet.first.type == Property::Key::INDEX )
373 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
377 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
389 int UtcDaliToolkitTextFieldConstructorP(void)
391 ToolkitTestApplication application;
392 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
394 DALI_TEST_CHECK( !textField );
398 int UtcDaliToolkitTextFieldNewP(void)
400 ToolkitTestApplication application;
401 tet_infoline(" UtcDaliToolkitTextFieldNewP");
402 TextField textField = TextField::New();
403 DALI_TEST_CHECK( textField );
407 int UtcDaliToolkitTextFieldDownCastP(void)
409 ToolkitTestApplication application;
410 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
411 TextField textField1 = TextField::New();
412 BaseHandle object( textField1 );
414 TextField textField2 = TextField::DownCast( object );
415 DALI_TEST_CHECK( textField2 );
417 TextField textField3 = DownCast< TextField >( object );
418 DALI_TEST_CHECK( textField3 );
422 int UtcDaliToolkitTextFieldDownCastN(void)
424 ToolkitTestApplication application;
425 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
426 BaseHandle uninitializedObject;
427 TextField textField1 = TextField::DownCast( uninitializedObject );
428 DALI_TEST_CHECK( !textField1 );
430 TextField textField2 = DownCast< TextField >( uninitializedObject );
431 DALI_TEST_CHECK( !textField2 );
435 int UtcDaliToolkitTextFieldCopyConstructorP(void)
437 ToolkitTestApplication application;
438 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
439 TextField textField = TextField::New();
440 textField.SetProperty( TextField::Property::TEXT, "Test" );
442 TextField copy( textField );
443 DALI_TEST_CHECK( copy );
444 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
448 int UtcDaliTextFieldMoveConstructor(void)
450 ToolkitTestApplication application;
452 TextField textField = TextField::New();
453 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
454 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
456 TextField moved = std::move( textField );
457 DALI_TEST_CHECK( moved );
458 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
459 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
460 DALI_TEST_CHECK( !textField );
465 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
467 ToolkitTestApplication application;
468 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
469 TextField textField = TextField::New();
470 textField.SetProperty( TextField::Property::TEXT, "Test" );
472 TextField copy = textField;
473 DALI_TEST_CHECK( copy );
474 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
478 int UtcDaliTextFieldMoveAssignment(void)
480 ToolkitTestApplication application;
482 TextField textField = TextField::New();
483 textField.SetProperty( TextEditor::Property::TEXT, "Test" );
484 DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
487 moved = std::move( textField );
488 DALI_TEST_CHECK( moved );
489 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
490 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
491 DALI_TEST_CHECK( !textField );
496 int UtcDaliTextFieldNewP(void)
498 ToolkitTestApplication application;
499 tet_infoline(" UtcDaliToolkitTextFieldNewP");
500 TextField textField = TextField::New();
501 DALI_TEST_CHECK( textField );
505 // Positive test case for a method
506 int UtcDaliTextFieldGetPropertyP(void)
508 ToolkitTestApplication application;
509 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
510 TextField field = TextField::New();
511 DALI_TEST_CHECK( field );
513 // Check Property Indices are correct
514 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextField::Property::RENDERING_BACKEND );
515 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
516 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
517 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
518 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
519 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
520 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
521 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
522 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
523 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
524 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
525 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
526 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
527 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
528 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
529 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
530 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
531 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
532 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
533 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
534 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
535 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
536 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
537 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
538 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
539 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
540 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
541 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
542 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
543 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
544 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
545 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
546 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
547 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
548 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
549 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
550 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
551 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
552 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
553 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
554 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
555 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
556 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
557 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
558 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
559 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
560 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
561 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
562 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
563 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
564 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextField::Property::FONT_SIZE_SCALE );
565 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
566 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
567 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
568 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP );
569 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextField::Property::BACKGROUND );
570 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextField::Property::GRAB_HANDLE_COLOR );
571 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FILTER ) == DevelTextField::Property::INPUT_FILTER );
576 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
579 Property::Map imageMap;
580 imageMap[mapKey] =mapValue;
582 field.SetProperty( property , imageMap );
583 Property::Value propValue = field.GetProperty( property );
584 Property::Map* resultMap = propValue.GetMap();
586 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
594 // Positive test case for a method
595 int UtcDaliTextFieldSetPropertyP(void)
597 ToolkitTestApplication application;
598 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
599 TextField field = TextField::New();
600 DALI_TEST_CHECK( field );
601 application.GetScene().Add( field );
603 // Note - we can't check the defaults since the stylesheets are platform-specific
605 // Check the render backend property.
606 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
607 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
609 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
610 DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION );
612 // Check text property.
613 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
614 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
616 // Check placeholder text properties.
617 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
618 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
620 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
621 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
623 // Check font properties.
624 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
625 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
627 Property::Map fontStyleMapSet;
628 Property::Map fontStyleMapGet;
629 Property::Value* slantValue = NULL;
631 fontStyleMapSet.Insert( "weight", "bold" );
632 fontStyleMapSet.Insert( "width", "condensed" );
633 fontStyleMapSet.Insert( "slant", "italic" );
634 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
636 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
637 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
638 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
640 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
641 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
643 field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 2.5f );
644 DALI_TEST_EQUALS( field.GetProperty<float>( DevelTextField::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
645 field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 1.0f );
648 fontStyleMapSet.Clear();
649 fontStyleMapSet.Insert( "weight", "normal" );
650 fontStyleMapSet.Insert( "slant", "oblique" );
651 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
653 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
654 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
655 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
657 fontStyleMapSet.Clear();
658 fontStyleMapSet.Insert( "slant", "roman" );
659 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
660 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
662 // Replace 'roman' for 'normal'.
663 slantValue = fontStyleMapGet.Find( "slant" );
664 if( NULL != slantValue )
666 if( "normal" == slantValue->Get<std::string>() )
668 fontStyleMapGet["slant"] = "roman";
671 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
672 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
674 fontStyleMapSet.Clear();
676 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
677 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
678 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
679 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
681 // Check that the MAX_LENGTH property can be correctly set
682 const int maxNumberOfCharacters = 20;
683 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
684 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
686 // Check exceed policy
687 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
688 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
689 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
690 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
692 // Check that the Alignment properties can be correctly set
693 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
694 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
695 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
696 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
698 // Check text's color property
699 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
700 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
702 // Check placeholder text's color property.
703 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
704 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
706 // Check cursor properties
707 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
708 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
709 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
710 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
712 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
713 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
714 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
715 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
716 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
717 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
718 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
719 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
721 // Check scroll properties.
722 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
723 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
724 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
725 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
727 // Check handle images
728 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
729 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
730 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
731 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
732 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
734 // Check handle images
735 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
736 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
737 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
738 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
739 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
740 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
742 // Check the highlight color
743 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
744 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
746 // Decoration bounding box
747 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
748 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
750 // Check the input method setting
751 Property::Map propertyMap;
752 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
753 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
754 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
755 int inputVariation = 1;
756 propertyMap["PANEL_LAYOUT"] = panelLayout;
757 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
758 propertyMap["BUTTON_ACTION"] = buttonAction;
759 propertyMap["VARIATION"] = inputVariation;
760 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
762 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
764 DALI_TEST_CHECK( value.Get( map ) );
767 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
768 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
771 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
772 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
775 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
776 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
779 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
780 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
782 // Check input color property.
783 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
784 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
786 // Check the enable markup property.
787 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
788 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
789 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
791 // Check input font properties.
792 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
793 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
795 fontStyleMapSet.Clear();
796 fontStyleMapSet.Insert( "weight", "bold" );
797 fontStyleMapSet.Insert( "width", "condensed" );
798 fontStyleMapSet.Insert( "slant", "italic" );
800 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
801 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
802 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
803 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
805 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
806 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
808 // Reset input font style.
809 fontStyleMapSet.Clear();
810 fontStyleMapSet.Insert( "weight", "normal" );
811 fontStyleMapSet.Insert( "slant", "oblique" );
813 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
814 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
815 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
816 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
818 fontStyleMapSet.Clear();
819 fontStyleMapSet.Insert( "slant", "roman" );
821 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
822 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
824 // Replace 'roman' for 'normal'.
825 slantValue = fontStyleMapGet.Find( "slant" );
826 if( NULL != slantValue )
828 if( "normal" == slantValue->Get<std::string>() )
830 fontStyleMapGet["slant"] = "roman";
833 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
834 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
836 fontStyleMapSet.Clear();
838 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
839 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
840 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
841 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
843 Property::Map underlineMapSet;
844 Property::Map underlineMapGet;
846 underlineMapSet.Insert( "enable", true );
847 underlineMapSet.Insert( "color", Color::RED );
848 underlineMapSet.Insert( "height", 1 );
850 // Check the underline property
851 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
853 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
854 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
855 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
857 // Check the input underline property
858 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
859 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
861 // Check the shadow property
862 Property::Map shadowMapSet;
863 Property::Map shadowMapGet;
865 shadowMapSet.Insert( "color", Color::GREEN );
866 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
867 shadowMapSet.Insert( "blurRadius", 3.0f );
869 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
871 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
872 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
873 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
875 // Check the input shadow property
876 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
877 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
879 // Check the emboss property
880 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
881 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
883 // Check the input emboss property
884 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
885 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
887 // Check the outline property
889 // Test string type first
890 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
891 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
892 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
894 // Then test the property map type
895 Property::Map outlineMapSet;
896 Property::Map outlineMapGet;
898 outlineMapSet["color"] = Color::RED;
899 outlineMapSet["width"] = 2.0f;
901 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
903 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
904 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
905 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
907 // Check the input outline property
908 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
909 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
911 // Check the hidden input settings property
912 Property::Map hiddenMapSet;
913 Property::Map hiddenMapGet;
914 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
915 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
916 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
917 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
918 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
920 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
921 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
922 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
924 // Check the pixel size of font
925 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
926 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
928 // Check the enable selection property
929 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
930 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
932 // Check the placeholder property with pixel size
933 Property::Map placeholderPixelSizeMapSet;
934 Property::Map placeholderPixelSizeMapGet;
935 Property::Map placeholderFontstyleMap;
936 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
937 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
938 placeholderPixelSizeMapSet["color"] = Color::BLUE;
939 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
940 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
941 placeholderPixelSizeMapSet["ellipsis"] = true;
943 placeholderFontstyleMap.Insert( "weight", "bold" );
944 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
945 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
947 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
948 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
950 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
951 Property::Map placeholderConversionMap;
952 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
953 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
954 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
955 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
956 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
957 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
959 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
961 // Check the placeholder property with point size
962 Property::Map placeholderMapSet;
963 Property::Map placeholderMapGet;
964 placeholderMapSet["text"] = "Setting Placeholder Text";
965 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
966 placeholderMapSet["color"] = Color::RED;
967 placeholderMapSet["fontFamily"] = "Arial";
968 placeholderMapSet["pointSize"] = 12.0f;
969 placeholderMapSet["ellipsis"] = false;
971 // Check the placeholder font style property
972 placeholderFontstyleMap.Clear();
974 placeholderFontstyleMap.Insert( "weight", "bold" );
975 placeholderFontstyleMap.Insert( "width", "condensed" );
976 placeholderFontstyleMap.Insert( "slant", "italic" );
977 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
978 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
980 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
981 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
983 placeholderConversionMap.Clear();
984 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
985 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
986 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
987 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
988 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
989 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
991 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
994 placeholderFontstyleMap.Clear();
995 placeholderFontstyleMap.Insert( "weight", "normal" );
996 placeholderFontstyleMap.Insert( "slant", "oblique" );
997 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
998 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1000 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1001 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1003 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1004 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1006 placeholderFontstyleMap.Clear();
1007 placeholderFontstyleMap.Insert( "slant", "roman" );
1008 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1009 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1011 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1013 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1015 placeholderFontstyleMap.Clear();
1016 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1017 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1019 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1020 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1021 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1023 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1025 // Check the ellipsis property
1026 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1027 field.SetProperty( TextField::Property::ELLIPSIS, true );
1028 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1030 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
1031 DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1033 // Test the ENABLE_GRAB_HANDLE_POPUP property
1034 DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1035 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false );
1036 DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1038 // Check the background property
1039 field.SetProperty( DevelTextField::Property::BACKGROUND, Color::RED );
1040 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::BACKGROUND ), Color::RED, TEST_LOCATION );
1042 //Check handle color
1043 field.SetProperty( DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN );
1044 DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
1046 // Check the input filter property
1047 Property::Map inputFilterMapSet;
1048 Property::Map inputFilterMapGet;
1049 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1050 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1052 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1054 inputFilterMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::INPUT_FILTER);
1055 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1058 inputFilterMapSet.Clear();
1059 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1061 application.SendNotification();
1062 application.Render();
1067 // Positive Atlas Text Renderer test
1068 int utcDaliTextFieldAtlasRenderP(void)
1070 ToolkitTestApplication application;
1071 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1072 StyleManager styleManager = StyleManager::Get();
1073 styleManager.ApplyDefaultTheme();
1074 TextField field = TextField::New();
1075 DALI_TEST_CHECK( field );
1077 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1079 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1081 application.GetScene().Add( field );
1085 // Render some text with the shared atlas backend
1086 field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1087 application.SendNotification();
1088 application.Render();
1092 tet_result(TET_FAIL);
1097 // Positive test for the anchorClicked signal.
1098 int utcDaliTextFieldAnchorClicked01(void)
1100 ToolkitTestApplication application;
1101 tet_infoline(" utcDaliTextFieldAnchorClicked01");
1102 TextField field = TextField::New();
1103 DALI_TEST_CHECK(field);
1105 application.GetScene().Add(field);
1107 // connect to the anchor clicked signal.
1108 ConnectionTracker* testTracker = new ConnectionTracker();
1109 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1110 bool anchorClickedSignal = false;
1111 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1113 gAnchorClickedCallBackCalled = false;
1114 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1115 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1116 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1117 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1118 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1120 application.SendNotification();
1121 application.Render();
1122 field.SetKeyInputFocus();
1124 // Create a tap event to touch the text field.
1125 TestGenerateTap(application, 5.0f, 25.0f);
1126 application.SendNotification();
1127 application.Render();
1129 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1130 DALI_TEST_CHECK(anchorClickedSignal);
1132 gAnchorClickedCallBackNotCalled = true;
1133 // Tap the outside of anchor, callback should not be called.
1134 TestGenerateTap(application, 150.f, 100.f);
1135 application.SendNotification();
1136 application.Render();
1138 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1143 // Positive test for the anchorClicked signal.
1144 int utcDaliTextFieldAnchorClicked02(void)
1146 ToolkitTestApplication application;
1147 tet_infoline(" utcDaliTextFieldAnchorClicked02");
1148 TextField field = TextField::New();
1149 DALI_TEST_CHECK(field);
1151 application.GetScene().Add(field);
1153 // connect to the anchor clicked signal.
1154 ConnectionTracker* testTracker = new ConnectionTracker();
1155 DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1156 bool anchorClickedSignal = false;
1157 field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1159 gAnchorClickedCallBackCalled = false;
1160 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1161 field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1162 field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1163 field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1164 field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1166 application.SendNotification();
1167 application.Render();
1168 field.SetKeyInputFocus();
1170 // Avoid a crash when core load gl resources.
1171 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1173 // Create a tap event to touch the text field.
1174 TestGenerateTap(application, 30.0f, 25.0f, 100);
1175 application.SendNotification();
1176 application.Render();
1178 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1179 DALI_TEST_CHECK(anchorClickedSignal);
1182 // For coverage InsertTextAnchor, RemoveTextAnchor
1183 // first index insert
1184 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1185 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1186 application.SendNotification();
1187 application.Render();
1189 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1190 application.SendNotification();
1191 application.Render();
1193 gAnchorClickedCallBackCalled = false;
1194 // Create a tap event to touch the text field.
1195 TestGenerateTap(application, 30.0f, 25.0f, 700);
1196 application.SendNotification();
1197 field.SetKeyInputFocus();
1199 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1201 // last index insert
1202 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1203 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1204 application.SendNotification();
1205 application.Render();
1207 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1208 application.SendNotification();
1209 application.Render();
1211 gAnchorClickedCallBackCalled = false;
1212 // Create a tap event to touch the text field.
1213 TestGenerateTap(application, 30.0f, 25.0f, 1300);
1214 application.SendNotification();
1215 field.SetKeyInputFocus();
1217 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1220 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1221 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1222 application.SendNotification();
1223 application.Render();
1225 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1226 application.SendNotification();
1227 application.Render();
1229 gAnchorClickedCallBackCalled = false;
1230 // Create a tap event to touch the text field.
1231 TestGenerateTap(application, 30.0f, 25.0f, 1900);
1232 application.SendNotification();
1233 field.SetKeyInputFocus();
1235 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1237 // first index remove
1238 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1239 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1240 application.SendNotification();
1241 application.Render();
1243 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1244 application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1245 application.SendNotification();
1246 application.Render();
1248 gAnchorClickedCallBackCalled = false;
1249 // Create a tap event to touch the text field.
1250 TestGenerateTap(application, 30.0f, 25.0f, 2500);
1251 application.SendNotification();
1252 field.SetKeyInputFocus();
1254 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1256 // last index remove
1257 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1258 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1259 application.SendNotification();
1260 application.Render();
1262 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1263 application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1264 application.SendNotification();
1265 application.Render();
1267 gAnchorClickedCallBackCalled = false;
1268 // Create a tap event to touch the text field.
1269 TestGenerateTap(application, 30.0f, 25.0f, 3100);
1270 application.SendNotification();
1271 application.Render();
1273 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1276 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1277 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1278 application.SendNotification();
1279 application.Render();
1281 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1282 application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1283 application.SendNotification();
1284 application.Render();
1286 gAnchorClickedCallBackCalled = false;
1287 // Create a tap event to touch the text field.
1288 TestGenerateTap(application, 30.0f, 25.0f, 3700);
1289 application.SendNotification();
1290 application.Render();
1292 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1294 // 0 ~ 1 index remove
1295 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1296 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 0);
1297 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 1);
1298 application.SendNotification();
1299 application.Render();
1301 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1302 application.SendNotification();
1303 application.Render();
1305 gAnchorClickedCallBackCalled = false;
1306 // Create a tap event to touch the text field.
1307 TestGenerateTap(application, 30.0f, 25.0f, 4300);
1308 application.SendNotification();
1309 application.Render();
1311 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1313 // 1 ~ 3 index remove
1314 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1315 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 1);
1316 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 3);
1317 application.SendNotification();
1318 application.Render();
1320 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1321 application.SendNotification();
1322 application.Render();
1324 gAnchorClickedCallBackCalled = false;
1325 // Create a tap event to touch the text field.
1326 TestGenerateTap(application, 30.0f, 25.0f, 4900);
1327 application.SendNotification();
1328 application.Render();
1330 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1332 // 3 ~ 4 index remove
1333 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1334 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 3);
1335 field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 4);
1336 application.SendNotification();
1337 application.Render();
1339 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1340 application.SendNotification();
1341 application.Render();
1343 gAnchorClickedCallBackCalled = false;
1344 // Create a tap event to touch the text field.
1345 TestGenerateTap(application, 30.0f, 25.0f, 5500);
1346 application.SendNotification();
1347 application.Render();
1349 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1351 // Remove front of anchor
1352 field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
1353 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
1354 application.SendNotification();
1355 application.Render();
1357 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1358 application.SendNotification();
1359 application.Render();
1361 // Remove whole text
1362 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1363 DevelTextField::SelectWholeText(field);
1364 application.SendNotification();
1365 application.Render();
1367 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1368 application.SendNotification();
1369 application.Render();
1371 // Remove all with backspace
1372 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1373 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
1374 application.SendNotification();
1375 application.Render();
1377 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1378 application.SendNotification();
1379 application.Render();
1381 // Remove all with delete
1382 field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1383 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1384 application.SendNotification();
1385 application.Render();
1387 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));
1388 application.SendNotification();
1389 application.Render();
1394 // Positive test for the textChanged signal.
1395 int utcDaliTextFieldTextChangedP(void)
1397 ToolkitTestApplication application;
1398 tet_infoline(" utcDaliTextFieldTextChangedP");
1399 TextField field = TextField::New();
1400 DALI_TEST_CHECK( field );
1402 application.GetScene().Add( field );
1404 // connect to the text changed signal.
1405 ConnectionTracker* testTracker = new ConnectionTracker();
1406 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1407 bool textChangedSignal = false;
1408 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1410 gTextChangedCallBackCalled = false;
1411 field.SetProperty( TextField::Property::TEXT, "ABC" );
1412 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1413 DALI_TEST_CHECK( textChangedSignal );
1415 application.SendNotification();
1416 field.SetKeyInputFocus();
1418 gTextChangedCallBackCalled = false;
1419 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1420 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1423 field.SetProperty( TextField::Property::TEXT, "" );
1425 // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1426 gTextChangedCallBackCalled = false;
1427 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1428 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1430 // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1431 gTextChangedCallBackCalled = false;
1432 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1433 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1438 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1440 ToolkitTestApplication application;
1441 tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1442 TextField field = TextField::New();
1443 DALI_TEST_CHECK( field );
1446 application.GetScene().Add( field );
1448 // connect to the text changed signal.
1449 ConnectionTracker* testTracker = new ConnectionTracker();
1450 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1451 bool textChangedSignal = false;
1452 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1455 // get InputMethodContext
1457 InputMethodContext::EventData imfEvent;
1458 InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext( field );
1460 field.SetKeyInputFocus();
1461 field.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
1464 gTextChangedCallBackCalled = false;
1465 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1466 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1467 application.SendNotification();
1468 application.Render();
1469 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1470 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1472 gTextChangedCallBackCalled = false;
1473 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1474 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1475 application.SendNotification();
1476 application.Render();
1477 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1478 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호"), TEST_LOCATION );
1480 gTextChangedCallBackCalled = false;
1481 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1482 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1483 application.SendNotification();
1484 application.Render();
1485 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1486 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1488 gTextChangedCallBackCalled = false;
1489 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1490 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1491 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1493 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1494 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1495 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1497 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1498 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1499 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1501 application.SendNotification();
1502 application.Render();
1503 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1504 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1510 // Negative test for the textChanged signal.
1511 int utcDaliTextFieldTextChangedN(void)
1513 ToolkitTestApplication application;
1514 tet_infoline(" utcDaliTextFieldTextChangedN");
1515 TextField field = TextField::New();
1516 DALI_TEST_CHECK( field );
1518 application.GetScene().Add( field );
1520 // connect to the text changed signal.
1521 ConnectionTracker* testTracker = new ConnectionTracker();
1522 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1523 bool textChangedSignal = false;
1524 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1526 gTextChangedCallBackCalled = false;
1527 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1528 application.SendNotification();
1529 application.Render();
1530 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1531 DALI_TEST_CHECK( !textChangedSignal );
1536 // Positive test for Max Characters reached signal.
1537 int utcDaliTextFieldMaxCharactersReachedP(void)
1539 ToolkitTestApplication application;
1540 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1541 TextField field = TextField::New();
1542 DALI_TEST_CHECK( field );
1544 application.GetScene().Add( field );
1546 const int maxNumberOfCharacters = 1;
1547 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1549 field.SetKeyInputFocus();
1551 // connect to the text changed signal.
1552 ConnectionTracker* testTracker = new ConnectionTracker();
1553 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1554 bool maxLengthReachedSignal = false;
1555 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1557 gMaxCharactersCallBackCalled = false;
1559 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1560 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1562 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1563 DALI_TEST_CHECK( maxLengthReachedSignal );
1568 // Negative test for Max Characters reached signal.
1569 int utcDaliTextFieldMaxCharactersReachedN(void)
1571 ToolkitTestApplication application;
1572 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1573 TextField field = TextField::New();
1574 DALI_TEST_CHECK( field );
1576 application.GetScene().Add( field );
1578 const int maxNumberOfCharacters = 3;
1579 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1581 field.SetKeyInputFocus();
1583 // connect to the text changed signal.
1584 ConnectionTracker* testTracker = new ConnectionTracker();
1585 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1586 bool maxLengthReachedSignal = false;
1587 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1589 gMaxCharactersCallBackCalled = false;
1591 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1592 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1594 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1595 DALI_TEST_CHECK( !maxLengthReachedSignal );
1597 application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1599 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1600 DALI_TEST_CHECK( !maxLengthReachedSignal );
1605 // Positive test for Input Filtered signal.
1606 int utcDaliTextFieldInputFilteredP(void)
1608 ToolkitTestApplication application;
1609 tet_infoline(" utcDaliTextFieldInputFilteredP");
1610 TextField field = TextField::New();
1611 DALI_TEST_CHECK(field);
1613 application.GetScene().Add(field);
1615 Property::Map inputFilter;
1617 // Only digit is accepted.
1618 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1620 // Set input filter to TextField.
1621 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1623 field.SetKeyInputFocus();
1625 // connect to the input filtered signal.
1626 ConnectionTracker* testTracker = new ConnectionTracker();
1627 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1628 bool inputFilteredSignal = false;
1629 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1631 gInputFilteredAcceptedCallbackCalled = false;
1633 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ));
1635 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1636 DALI_TEST_CHECK(inputFilteredSignal);
1638 // Word is rejected.
1639 inputFilter[InputFilter::Property::ACCEPTED] = "";
1640 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1642 // Set input filter to TextField.
1643 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1645 field.SetKeyInputFocus();
1647 inputFilteredSignal = false;
1648 gInputFilteredRejectedCallbackCalled = false;
1650 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1652 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1653 DALI_TEST_CHECK(inputFilteredSignal);
1658 // Negative test for Input Filtered signal.
1659 int utcDaliTextFieldInputFilteredN(void)
1661 ToolkitTestApplication application;
1662 tet_infoline(" utcDaliTextFieldInputFilteredP");
1663 TextField field = TextField::New();
1664 DALI_TEST_CHECK(field);
1666 application.GetScene().Add(field);
1668 Property::Map inputFilter;
1670 // Only word is accepted.
1671 inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
1673 // Set input filter to TextField.
1674 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1676 field.SetKeyInputFocus();
1678 // connect to the input filtered signal.
1679 ConnectionTracker* testTracker = new ConnectionTracker();
1680 DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1681 bool inputFilteredSignal = false;
1682 field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1684 gInputFilteredAcceptedCallbackCalled = false;
1686 // Key a, d should not be filtered.
1687 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1688 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1689 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1690 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1692 // Backspace, Delete should not be filtered.
1693 application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1694 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));
1696 // Render and notify
1697 application.SendNotification();
1698 application.Render();
1700 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1701 DALI_TEST_CHECK(!inputFilteredSignal);
1703 // Digit is rejected.
1704 inputFilter[InputFilter::Property::ACCEPTED] = "";
1705 inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
1707 field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1709 field.SetKeyInputFocus();
1711 inputFilteredSignal = false;
1712 gInputFilteredRejectedCallbackCalled = false;
1714 // Key a, d should not be filtered.
1715 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1716 application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1717 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1718 application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1720 // Backspace, Delete should not be filtered.
1721 application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1722 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));
1724 // Render and notify
1725 application.SendNotification();
1726 application.Render();
1728 DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1729 DALI_TEST_CHECK(!inputFilteredSignal);
1734 int utcDaliTextFieldInputStyleChanged01(void)
1736 // The text-field emits signals when the input style changes. These changes of style are
1737 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1738 // can't be emitted during the size negotiation as the callbacks may update the UI.
1739 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1740 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1741 ToolkitTestApplication application;
1742 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1746 char* pathNamePtr = get_current_dir_name();
1747 const std::string pathName( pathNamePtr );
1748 free( pathNamePtr );
1750 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1751 fontClient.SetDpi( 93u, 93u );
1753 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1754 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1756 TextField field = TextField::New();
1757 DALI_TEST_CHECK( field );
1760 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1761 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1762 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1764 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1765 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1767 // connect to the text changed signal.
1768 ConnectionTracker* testTracker = new ConnectionTracker();
1769 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1770 bool inputStyleChangedSignal = false;
1771 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1773 application.GetScene().Add( field );
1775 // Render and notify
1776 application.SendNotification();
1777 application.Render();
1779 // Executes the idle callbacks added by the text control on the change of input style.
1780 application.RunIdles();
1782 gInputStyleChangedCallbackCalled = false;
1783 gInputStyleMask = TextField::InputStyle::NONE;
1784 inputStyleChangedSignal = false;
1786 // Create a tap event to touch the text field.
1787 TestGenerateTap( application, 18.0f, 25.0f );
1789 // Render and notify
1790 application.SendNotification();
1791 application.Render();
1793 // Executes the idle callbacks added by the text control on the change of input style.
1794 application.RunIdles();
1796 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1797 if( gInputStyleChangedCallbackCalled )
1799 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1801 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1802 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1804 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1805 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1807 DALI_TEST_CHECK( inputStyleChangedSignal );
1809 gInputStyleChangedCallbackCalled = false;
1810 gInputStyleMask = TextField::InputStyle::NONE;
1811 inputStyleChangedSignal = false;
1813 // Create a tap event to touch the text field.
1814 TestGenerateTap( application, 30.0f, 25.0f );
1816 // Render and notify
1817 application.SendNotification();
1818 application.Render();
1820 // Executes the idle callbacks added by the text control on the change of input style.
1821 application.RunIdles();
1823 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1824 DALI_TEST_CHECK( !inputStyleChangedSignal );
1826 gInputStyleChangedCallbackCalled = false;
1827 gInputStyleMask = TextField::InputStyle::NONE;
1828 inputStyleChangedSignal = false;
1830 // Create a tap event to touch the text field.
1831 TestGenerateTap( application, 43.0f, 25.0f );
1833 // Render and notify
1834 application.SendNotification();
1835 application.Render();
1837 // Executes the idle callbacks added by the text control on the change of input style.
1838 application.RunIdles();
1840 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1841 if( gInputStyleChangedCallbackCalled )
1843 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1845 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1846 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1848 DALI_TEST_CHECK( inputStyleChangedSignal );
1850 gInputStyleChangedCallbackCalled = false;
1851 gInputStyleMask = TextField::InputStyle::NONE;
1852 inputStyleChangedSignal = false;
1854 // Create a tap event to touch the text field.
1855 TestGenerateTap( application, 88.0f, 25.0f );
1857 // Render and notify
1858 application.SendNotification();
1859 application.Render();
1861 // Executes the idle callbacks added by the text control on the change of input style.
1862 application.RunIdles();
1864 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1865 if( gInputStyleChangedCallbackCalled )
1867 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1869 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1870 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1872 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1874 Property::Map fontStyleMapSet;
1875 fontStyleMapSet.Insert( "weight", "bold" );
1877 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1878 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1880 DALI_TEST_CHECK( inputStyleChangedSignal );
1882 gInputStyleChangedCallbackCalled = false;
1883 gInputStyleMask = TextField::InputStyle::NONE;
1884 inputStyleChangedSignal = false;
1886 // Create a tap event to touch the text field.
1887 TestGenerateTap( application, 115.0f, 25.0f );
1889 // Render and notify
1890 application.SendNotification();
1891 application.Render();
1893 // Executes the idle callbacks added by the text control on the change of input style.
1894 application.RunIdles();
1896 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1897 DALI_TEST_CHECK( !inputStyleChangedSignal );
1899 gInputStyleChangedCallbackCalled = false;
1900 gInputStyleMask = TextField::InputStyle::NONE;
1901 inputStyleChangedSignal = false;
1903 // Create a tap event to touch the text field.
1904 TestGenerateTap( application, 164.0f, 25.0f );
1906 // Render and notify
1907 application.SendNotification();
1908 application.Render();
1910 // Executes the idle callbacks added by the text control on the change of input style.
1911 application.RunIdles();
1913 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1914 if( gInputStyleChangedCallbackCalled )
1916 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1918 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1919 DALI_TEST_CHECK( style.empty() );
1921 DALI_TEST_CHECK( inputStyleChangedSignal );
1923 gInputStyleChangedCallbackCalled = false;
1924 gInputStyleMask = TextField::InputStyle::NONE;
1925 inputStyleChangedSignal = false;
1927 // Create a tap event to touch the text field.
1928 TestGenerateTap( application, 191.0f, 25.0f );
1930 // Render and notify
1931 application.SendNotification();
1932 application.Render();
1934 // Executes the idle callbacks added by the text control on the change of input style.
1935 application.RunIdles();
1937 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1938 DALI_TEST_CHECK( !inputStyleChangedSignal );
1943 int utcDaliTextFieldInputStyleChanged02(void)
1945 // The text-field emits signals when the input style changes. These changes of style are
1946 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1947 // can't be emitted during the size negotiation as the callbacks may update the UI.
1948 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1949 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1950 ToolkitTestApplication application;
1951 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1955 char* pathNamePtr = get_current_dir_name();
1956 const std::string pathName( pathNamePtr );
1957 free( pathNamePtr );
1959 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1960 fontClient.SetDpi( 93u, 93u );
1962 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1963 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1965 TextField field = TextField::New();
1966 DALI_TEST_CHECK( field );
1968 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1969 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1970 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1972 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1973 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>" );
1975 // connect to the text changed signal.
1976 ConnectionTracker* testTracker = new ConnectionTracker();
1977 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1978 bool inputStyleChangedSignal = false;
1979 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1981 application.GetScene().Add( field );
1983 // Render and notify
1984 application.SendNotification();
1985 application.Render();
1987 // Executes the idle callbacks added by the text control on the change of input style.
1988 application.RunIdles();
1990 gInputStyleChangedCallbackCalled = false;
1991 gInputStyleMask = TextField::InputStyle::NONE;
1992 inputStyleChangedSignal = false;
1994 // Create a tap event to touch the text field.
1995 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1996 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1998 // Render and notify
1999 application.SendNotification();
2000 application.Render();
2002 // Executes the idle callbacks added by the text control on the change of input style.
2003 application.RunIdles();
2005 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2006 if( gInputStyleChangedCallbackCalled )
2008 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2009 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
2010 TextField::InputStyle::POINT_SIZE |
2011 TextField::InputStyle::COLOR ),
2014 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2015 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
2017 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
2018 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
2020 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
2021 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2023 DALI_TEST_CHECK( inputStyleChangedSignal );
2025 gInputStyleChangedCallbackCalled = false;
2026 gInputStyleMask = TextField::InputStyle::NONE;
2027 inputStyleChangedSignal = false;
2029 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2031 // Render and notify
2032 application.SendNotification();
2033 application.Render();
2035 // Executes the idle callbacks added by the text control on the change of input style.
2036 application.RunIdles();
2038 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2039 if( gInputStyleChangedCallbackCalled )
2041 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2042 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
2045 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2046 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
2048 DALI_TEST_CHECK( inputStyleChangedSignal );
2050 gInputStyleChangedCallbackCalled = false;
2051 gInputStyleMask = TextField::InputStyle::NONE;
2052 inputStyleChangedSignal = false;
2054 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2056 // Render and notify
2057 application.SendNotification();
2058 application.Render();
2060 // Executes the idle callbacks added by the text control on the change of input style.
2061 application.RunIdles();
2063 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
2064 DALI_TEST_CHECK( !inputStyleChangedSignal );
2066 gInputStyleChangedCallbackCalled = false;
2067 gInputStyleMask = TextField::InputStyle::NONE;
2068 inputStyleChangedSignal = false;
2070 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2072 // Render and notify
2073 application.SendNotification();
2074 application.Render();
2076 // Executes the idle callbacks added by the text control on the change of input style.
2077 application.RunIdles();
2079 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2080 if( gInputStyleChangedCallbackCalled )
2082 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2083 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
2086 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2087 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
2089 DALI_TEST_CHECK( inputStyleChangedSignal );
2091 gInputStyleChangedCallbackCalled = false;
2092 gInputStyleMask = TextField::InputStyle::NONE;
2093 inputStyleChangedSignal = false;
2095 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
2097 Property::Map fontStyleMapSet;
2098 fontStyleMapSet.Insert( "weight", "thin" );
2099 fontStyleMapSet.Insert( "width", "condensed" );
2100 fontStyleMapSet.Insert( "slant", "italic" );
2102 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2103 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
2105 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
2106 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
2107 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
2108 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
2110 // Render and notify
2111 application.SendNotification();
2112 application.Render();
2114 // Executes the idle callbacks added by the text control on the change of input style.
2115 application.RunIdles();
2117 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
2118 DALI_TEST_CHECK( !inputStyleChangedSignal );
2120 // Create a tap event to touch the text field.
2121 TestGenerateTap( application, 63.0f, 25.0f, 700 );
2123 // Render and notify
2124 application.SendNotification();
2125 application.Render();
2127 // Executes the idle callbacks added by the text control on the change of input style.
2128 application.RunIdles();
2130 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2131 if( gInputStyleChangedCallbackCalled )
2133 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2134 static_cast<unsigned int>( TextField::InputStyle::COLOR |
2135 TextField::InputStyle::POINT_SIZE |
2136 TextField::InputStyle::FONT_STYLE |
2137 TextField::InputStyle::UNDERLINE |
2138 TextField::InputStyle::SHADOW |
2139 TextField::InputStyle::EMBOSS |
2140 TextField::InputStyle::OUTLINE ),
2143 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2144 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
2146 DALI_TEST_CHECK( inputStyleChangedSignal );
2151 int utcDaliTextFieldEvent01(void)
2153 ToolkitTestApplication application;
2154 tet_infoline(" utcDaliTextFieldEvent01");
2156 // Creates a tap event. After creating a tap event the text field should
2157 // have the focus and add text with key events should be possible.
2159 TextField field = TextField::New();
2160 DALI_TEST_CHECK( field );
2162 application.GetScene().Add( field );
2164 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2165 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2166 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2168 // Render and notify
2169 application.SendNotification();
2170 application.Render();
2172 // Avoid a crash when core load gl resources.
2173 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2175 // Render and notify
2176 application.SendNotification();
2177 application.Render();
2179 // Add a key event but as the text field has not the focus it should do nothing.
2180 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2182 // Render and notify
2183 application.SendNotification();
2184 application.Render();
2186 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2188 // Create a tap event to touch the text field.
2189 TestGenerateTap( application, 150.0f, 25.0f );
2191 // Render and notify
2192 application.SendNotification();
2193 application.Render();
2195 // Pressing delete key should be fine even if there is no text in TextField.
2196 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 ) );
2197 // Render and notify
2198 application.SendNotification();
2199 application.Render();
2201 // Now the text field has the focus, so it can handle the key events.
2202 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2203 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2205 // Render and notify
2206 application.SendNotification();
2207 application.Render();
2209 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2211 // Create a second text field and send key events to it.
2212 TextField field2 = TextField::New();
2214 field2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2215 field2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2216 field2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2217 field2.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
2219 application.GetScene().Add( field2 );
2221 // Render and notify
2222 application.SendNotification();
2223 application.Render();
2225 // Create a tap event on the second text field.
2226 TestGenerateTap( application, 150.0f, 125.0f );
2228 // Render and notify
2229 application.SendNotification();
2230 application.Render();
2232 // The second text field has the focus. It should handle the key events.
2233 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2234 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2236 // Render and notify
2237 application.SendNotification();
2238 application.Render();
2240 // Check the text has been added to the second text field.
2241 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2246 int utcDaliTextFieldEvent02(void)
2248 ToolkitTestApplication application;
2249 tet_infoline(" utcDaliTextFieldEvent02");
2251 // Checks if the right number of actors are created.
2253 TextField field = TextField::New();
2254 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2255 DALI_TEST_CHECK( field );
2256 LoadMarkerImages(application, field);
2258 application.GetScene().Add( field );
2260 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2261 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2262 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2264 // Avoid a crash when core load gl resources.
2265 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2267 // Render and notify
2268 application.SendNotification();
2269 application.Render();
2271 // Check there are the expected number of children ( stencil ).
2272 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
2274 Actor stencil = field.GetChildAt( 0u );
2275 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2277 // Create a tap event to touch the text field.
2278 TestGenerateTap( application, 150.0f, 25.0f, 300 );
2280 // Render and notify
2281 application.SendNotification();
2282 application.Render();
2284 Actor layer = field.GetChildAt( 1u );
2285 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2286 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2288 // Now the text field has the focus, so it can handle the key events.
2289 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2290 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2292 // Render and notify
2293 application.SendNotification();
2294 application.Render();
2296 // Checks the cursor and the renderer have been created.
2297 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2298 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
2300 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
2301 DALI_TEST_CHECK( cursor );
2303 // The offscreen root actor has a container with all the actors which contain the text renderers.
2304 Actor container = stencil.GetChildAt( 0u );
2305 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2307 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2308 DALI_TEST_CHECK( renderer );
2311 // Move the cursor and check the position changes.
2312 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2313 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2315 // Render and notify
2316 application.SendNotification();
2317 application.Render();
2319 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2320 DALI_TEST_CHECK( position2.x < position1.x );
2322 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2324 // Render and notify
2325 application.SendNotification();
2326 application.Render();
2328 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2329 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
2332 // Move the cursor to the first position.
2333 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2334 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2336 // Render and notify
2337 application.SendNotification();
2338 application.Render();
2340 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2342 // Send some taps and check the cursor positions.
2344 // Try to tap at the beginning.
2345 TestGenerateTap( application, 1.0f, 25.0f, 900 );
2347 // Render and notify
2348 application.SendNotification();
2349 application.Render();
2351 // Cursor position should be the same than position1.
2352 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2354 DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
2356 // Tap away from the start position.
2357 TestGenerateTap( application, 16.0f, 25.0f, 1500 );
2359 // Render and notify
2360 application.SendNotification();
2361 application.Render();
2363 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2365 DALI_TEST_CHECK( position6.x > position5.x );
2367 // Remove all the text.
2368 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2369 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2370 field.SetProperty( TextField::Property::TEXT, "" );
2372 // Render and notify
2373 application.SendNotification();
2374 application.Render();
2376 // Cursor position should be the same than position2.
2377 Vector3 position7 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2379 DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
2381 // Should not be a renderer.
2382 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2384 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2385 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2386 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
2388 application.SendNotification();
2389 application.Render();
2391 // There are renderer and decorator layer
2392 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
2397 int utcDaliTextFieldEvent03(void)
2399 ToolkitTestApplication application;
2400 tet_infoline(" utcDaliTextFieldEvent03");
2402 // Checks if the highlight actor is created.
2404 TextField field = TextField::New();
2405 DALI_TEST_CHECK( field );
2407 application.GetScene().Add( field );
2409 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2410 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2411 field.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
2412 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2413 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2415 // Avoid a crash when core load gl resources.
2416 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2417 LoadMarkerImages(application, field);
2419 // Render and notify
2420 application.SendNotification();
2421 application.Render();
2423 // Tap first to get the focus.
2424 TestGenerateTap( application, 3.0f, 25.0f );
2426 // Render and notify
2427 application.SendNotification();
2428 application.Render();
2430 // Double tap to select a word.
2431 TestGenerateTap( application, 3.0f, 25.0f );
2433 // Render and notify
2434 application.SendNotification();
2435 application.Render();
2437 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2438 Actor stencil = field.GetChildAt( 0u );
2440 // The highlight actor is drawn first, so is the first actor in the list
2441 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2442 DALI_TEST_CHECK( highlight );
2444 // The offscreen root actor has a container with all the actors which contain the text renderers.
2445 Actor container = stencil.GetChildAt( 1u );
2446 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2448 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2449 DALI_TEST_CHECK( renderer );
2455 int utcDaliTextFieldEvent04(void)
2457 ToolkitTestApplication application;
2458 tet_infoline(" utcDaliTextFieldEvent04");
2460 // Checks if the highlight actor is created.
2462 TextField field = TextField::New();
2463 DALI_TEST_CHECK( field );
2464 application.GetScene().Add( field );
2465 LoadMarkerImages(application, field);
2466 // Render and notify
2467 application.SendNotification();
2468 application.Render();
2470 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2471 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2472 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2473 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2474 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2476 // Avoid a crash when core load gl resources.
2477 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2478 // Render and notify
2479 application.SendNotification();
2480 application.Render();
2482 // Create a tap event to touch the text field.
2483 TestGenerateTap( application, 150.0f, 25.0f );
2484 // Render and notify
2485 application.SendNotification();
2486 application.Render();
2489 // Tap first to get the focus.
2490 TestGenerateTap( application, 1.0f, 25.0f );
2492 // Render and notify
2493 application.SendNotification();
2494 application.Render();
2496 // Double tap to select a word.
2497 TestGenerateTap( application, 1.0f, 25.0f );
2499 // Render and notify
2500 application.SendNotification();
2501 application.Render();
2504 TestGenerateTap( application, 0.0f, 40.0f );
2508 int utcDaliTextFieldEvent05(void)
2510 ToolkitTestApplication application;
2511 tet_infoline(" utcDaliTextFieldEvent05");
2513 // Checks dragging of cursor/grab handle
2515 TextField field = TextField::New();
2516 DALI_TEST_CHECK( field );
2517 application.GetScene().Add( field );
2518 LoadMarkerImages(application, field);
2519 // Render and notify
2520 application.SendNotification();
2521 application.Render();
2523 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2524 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2525 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2526 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2527 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2529 // Avoid a crash when core load gl resources.
2530 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2531 // Render and notify
2532 application.SendNotification();
2533 application.Render();
2535 // Create a tap event to touch the text field.
2536 TestGenerateTap( application, 150.0f, 25.0f );
2537 // Render and notify
2538 application.SendNotification();
2539 application.Render();
2541 // Tap first to get the focus.
2542 TestGenerateTap( application, 1.0f, 25.0f );
2544 // Render and notify
2545 application.SendNotification();
2546 application.Render();
2548 // Double tap to select a word.
2549 TestGenerateTap( application, 1.0f, 25.0f );
2551 // Render and notify
2552 application.SendNotification();
2553 application.Render();
2555 Actor stencil = field.GetChildAt( 1u );
2559 int utcDaliTextFieldEvent06(void)
2561 ToolkitTestApplication application;
2562 tet_infoline(" utcDaliTextFieldEvent06");
2564 // Checks Longpress when in edit mode
2566 TextField field = TextField::New();
2567 DALI_TEST_CHECK( field );
2568 application.GetScene().Add( field );
2569 LoadMarkerImages(application, field);
2570 // Render and notify
2571 application.SendNotification();
2572 application.Render();
2574 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2575 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2576 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2577 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2578 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2580 // Avoid a crash when core load gl resources.
2581 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2582 // Render and notify
2583 application.SendNotification();
2584 application.Render();
2586 // Create a tap event to touch the text field.
2587 TestGenerateTap( application, 150.0f, 25.0f );
2588 // Render and notify
2589 application.SendNotification();
2590 application.Render();
2593 // Tap first to get the focus.
2594 TestGenerateTap( application, 1.0f, 25.0f );
2596 // Render and notify
2597 application.SendNotification();
2598 application.Render();
2601 TestGenerateLongPress(application, 1.0f, 25.0f);
2603 // Render and notify
2604 application.SendNotification();
2605 application.Render();
2610 int utcDaliTextFieldEvent07(void)
2612 ToolkitTestApplication application;
2613 tet_infoline(" utcDaliTextFieldEvent07");
2615 // Checks Longpress to start edit mode
2617 TextField field = TextField::New();
2618 DALI_TEST_CHECK( field );
2619 application.GetScene().Add( field );
2620 LoadMarkerImages(application, field);
2621 // Render and notify
2622 application.SendNotification();
2623 application.Render();
2625 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2626 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2627 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2628 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2629 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2630 Property::Map propertyMap;
2631 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2632 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2634 // Avoid a crash when core load gl resources.
2635 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2636 // Render and notify
2637 application.SendNotification();
2638 application.Render();
2641 TestGenerateLongPress(application, 1.0f, 25.0f);
2643 // Render and notify
2644 application.SendNotification();
2645 application.Render();
2650 int utcDaliTextFieldEvent08(void)
2652 ToolkitTestApplication application;
2653 tet_infoline(" utcDaliTextFieldEvent08");
2655 Dali::Clipboard clipboard = Clipboard::Get();
2656 clipboard.SetItem("testTextFieldEvent");
2658 // Checks Longpress when only place holder text
2660 TextField field = TextField::New();
2661 DALI_TEST_CHECK( field );
2662 application.GetScene().Add( field );
2663 LoadMarkerImages(application, field);
2664 // Render and notify
2665 application.SendNotification();
2666 application.Render();
2668 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2669 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2670 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2671 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2672 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2674 // Avoid a crash when core load gl resources.
2675 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2676 // Render and notify
2677 application.SendNotification();
2678 application.Render();
2681 TestGenerateLongPress( application, 1.0f, 25.0f, 20 );
2683 // Render and notify
2684 application.SendNotification();
2685 application.Render();
2687 Wait(application, 500);
2689 TestEndLongPress( application, 1.0f, 25.0f, 520 );
2692 TestGenerateLongPress( application, 1.0f, 25.0f, 600 );
2694 // Render and notify
2695 application.Render();
2697 Wait(application, 500);
2699 Integration::Scene stage = application.GetScene();
2700 Layer layer = stage.GetRootLayer();
2701 Actor actor = layer.FindChildByName("optionPaste");
2705 Vector3 worldPosition = actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION );
2706 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2707 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2709 Dali::Integration::TouchEvent event;
2710 event = Dali::Integration::TouchEvent();
2711 event.AddPoint( GetPointDownInside( position ) );
2712 application.ProcessEvent( event );
2714 event = Dali::Integration::TouchEvent();
2715 event.AddPoint( GetPointUpInside( position ) );
2716 application.ProcessEvent( event );
2718 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2723 int utcDaliTextFieldEvent09(void)
2725 ToolkitTestApplication application;
2726 tet_infoline(" utcDaliTextFieldEvent09");
2728 TextField field = TextField::New();
2729 DALI_TEST_CHECK( field );
2730 application.GetScene().Add( field );
2731 LoadMarkerImages(application, field);
2732 // Render and notify
2733 application.SendNotification();
2734 application.Render();
2736 field.SetProperty( TextField::Property::TEXT, "Hello" );
2737 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2738 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2739 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2740 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2742 // Avoid a crash when core load gl resources.
2743 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2745 // Create a tap event to touch the text field.
2746 TestGenerateTap( application, 150.0f, 25.0f );
2747 application.SendNotification();
2748 application.Render();
2751 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2752 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2753 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2754 application.SendNotification();
2755 application.Render();
2757 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2758 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2759 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2760 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2761 application.SendNotification();
2762 application.Render();
2764 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2765 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2766 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2767 for( unsigned int index = 0u; index < 5u; ++index )
2769 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2770 application.SendNotification();
2771 application.Render();
2774 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2775 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2776 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2777 for( unsigned int index = 0u; index < 5u; ++index )
2779 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2780 application.SendNotification();
2781 application.Render();
2784 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2785 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2786 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2787 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2788 application.SendNotification();
2789 application.Render();
2790 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2791 application.SendNotification();
2792 application.Render();
2794 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2795 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2796 application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2797 application.SendNotification();
2798 application.Render();
2800 Property::Map mapGet;
2801 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2802 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2803 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2808 int utcDaliTextFieldStyleWhilstSelected(void)
2810 ToolkitTestApplication application;
2811 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2813 // Change font and styles whilst text is selected whilst word selected
2815 TextField field = TextField::New();
2816 DALI_TEST_CHECK( field );
2817 application.GetScene().Add( field );
2818 LoadMarkerImages(application, field);
2819 // Render and notify
2820 application.SendNotification();
2821 application.Render();
2823 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2824 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2825 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2826 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2827 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2829 // Avoid a crash when core load gl resources.
2830 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2831 // Render and notify
2832 application.SendNotification();
2833 application.Render();
2835 // Create a tap event to touch the text field.
2836 TestGenerateTap( application, 150.0f, 25.0f );
2837 // Render and notify
2838 application.SendNotification();
2839 application.Render();
2842 // Tap first to get the focus.
2843 TestGenerateTap( application, 1.0f, 25.0f );
2845 // Render and notify
2846 application.SendNotification();
2847 application.Render();
2849 // Double tap to select a word.
2850 TestGenerateTap( application, 1.0f, 25.0f );
2852 // Render and notify
2853 application.SendNotification();
2854 application.Render();
2856 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2857 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2859 Property::Map fontStyleMapSet;
2860 Property::Map fontStyleMapGet;
2862 fontStyleMapSet.Insert( "weight", "bold" );
2863 fontStyleMapSet.Insert( "slant", "italic" );
2864 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2866 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2867 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2868 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2870 fontStyleMapSet.Clear();
2871 fontStyleMapSet.Insert( "width", "expanded" );
2872 fontStyleMapSet.Insert( "slant", "italic" );
2873 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2875 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2876 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2877 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2879 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2880 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2882 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2883 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2885 fontStyleMapSet.Clear();
2886 fontStyleMapSet.Insert( "weight", "bold" );
2887 fontStyleMapSet.Insert( "slant", "italic" );
2889 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2891 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2892 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2893 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2895 fontStyleMapSet.Clear();
2896 fontStyleMapSet.Insert( "width", "expanded" );
2898 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2900 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2901 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2902 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2904 // Press Escape to increase coverage
2905 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2906 application.SendNotification();
2907 application.Render();
2909 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2914 int utcDaliTextFieldEscKeyLoseFocus(void)
2916 ToolkitTestApplication application;
2917 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2919 // Creates a tap event. After creating a tap event the text field should
2920 // have the focus and add text with key events should be possible.
2922 TextField field = TextField::New();
2923 DALI_TEST_CHECK( field );
2925 application.GetScene().Add( field );
2927 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2928 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2929 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2931 // Avoid a crash when core load gl resources.
2932 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2934 // Render and notify
2935 application.SendNotification();
2936 application.Render();
2938 // Add a key event but as the text field has not the focus it should do nothing.
2939 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2940 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2942 // Render and notify
2943 application.SendNotification();
2944 application.Render();
2946 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2948 // Create a tap event to touch the text field.
2949 TestGenerateTap( application, 150.0f, 25.0f );
2951 // Render and notify
2952 application.SendNotification();
2953 application.Render();
2955 // Now the text field has the focus, so it can handle the key events.
2956 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2957 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2958 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2959 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2961 // Render and notify
2962 application.SendNotification();
2963 application.Render();
2965 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2967 // Generate a Esc key event. The text field should lose the focus.
2968 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2969 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2971 // Render and notify
2972 application.SendNotification();
2973 application.Render();
2975 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2977 // No more text should be introduced
2978 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2979 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2981 // Render and notify
2982 application.SendNotification();
2983 application.Render();
2985 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2990 int utcDaliTextFieldSomeSpecialKeys(void)
2992 ToolkitTestApplication application;
2993 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2995 // Checks some special keys when the text is selected.
2997 TextField field = TextField::New();
2998 DALI_TEST_CHECK( field );
2999 application.GetScene().Add( field );
3000 LoadMarkerImages(application, field);
3001 // Render and notify
3002 application.SendNotification();
3003 application.Render();
3005 const std::string longText( "This is a long text for the size of the text-field." );
3007 field.SetProperty( TextField::Property::TEXT, longText );
3008 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
3009 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3010 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3011 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3013 // Avoid a crash when core load gl resources.
3014 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3015 // Render and notify
3016 application.SendNotification();
3017 application.Render();
3019 // Create a tap event to touch the text field.
3020 TestGenerateTap( application, 150.0f, 25.0f );
3022 // Render and notify
3023 application.SendNotification();
3024 application.Render();
3026 // Tap first to get the focus.
3027 TestGenerateTap( application, 1.0f, 25.0f );
3029 // Render and notify
3030 application.SendNotification();
3031 application.Render();
3033 // Double tap to select a word.
3034 TestGenerateTap( application, 1.0f, 25.0f );
3036 // Render and notify
3037 application.SendNotification();
3038 application.Render();
3040 // Generate a Esc key event. The text field should lose the focus.
3041 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3042 application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3044 // Render and notify
3045 application.SendNotification();
3046 application.Render();
3048 // Generate a Esc key event. The text field should lose the focus.
3049 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3050 application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3052 // Render and notify
3053 application.SendNotification();
3054 application.Render();
3056 // Generate a Esc key event. The text field should lose the focus.
3057 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3058 application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3060 // Render and notify
3061 application.SendNotification();
3062 application.Render();
3064 // The text shouldn't be deleted.
3065 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
3070 int utcDaliTextFieldSizeUpdate(void)
3072 ToolkitTestApplication application;
3073 tet_infoline("utcDaliTextFieldSizeUpdate");
3075 // Checks some special keys when the text is selected.
3076 TextField field = TextField::New();
3077 DALI_TEST_CHECK( field );
3078 application.GetScene().Add( field );
3080 float previousHeight = 0.0f;
3081 float currentHeight = 0.0f;
3082 const float fieldWidth = 1920.0f;
3085 // "ㅁ" is bigger then "ኢ"
3086 field.SetProperty( Actor::Property::SIZE, Vector2( fieldWidth ,10.0f ) );
3087 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
3088 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
3090 field.SetProperty( TextField::Property::TEXT, "ኢ");
3091 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3092 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3094 field.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
3095 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
3097 application.SendNotification();
3098 application.Render();
3100 previousHeight = field.GetHeightForWidth( fieldWidth );
3101 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
3103 // Add another script characters ( glyph height is defferent )
3104 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3105 application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3107 application.SendNotification();
3108 application.Render();
3110 currentHeight = field.GetHeightForWidth( fieldWidth );
3111 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
3112 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
3117 int utcDaliTextFieldExtremlyLargePointSize(void)
3119 ToolkitTestApplication application;
3120 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
3122 TextField field = TextField::New();
3124 field.SetProperty( TextField::Property::TEXT, "Text" );
3125 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3126 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3127 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3128 application.GetScene().Add( field );
3132 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
3133 application.SendNotification();
3134 DALI_TEST_CHECK( field );
3138 tet_result(TET_FAIL);
3143 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
3145 ToolkitTestApplication application;
3146 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
3147 TextField field = TextField::New();
3148 DALI_TEST_CHECK( field );
3149 application.GetScene().Add( field );
3151 Property::Map fontStyleMapGet;
3153 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
3155 Property::Value* weightValue = NULL;
3156 Property::Value* widthValue = NULL;
3157 Property::Value* slantValue = NULL;
3158 weightValue = fontStyleMapGet.Find( "weight" );
3159 widthValue = fontStyleMapGet.Find( "width" );
3160 slantValue = fontStyleMapGet.Find( "slant" );
3161 DALI_TEST_CHECK( !weightValue );
3162 DALI_TEST_CHECK( !widthValue );
3163 DALI_TEST_CHECK( !slantValue );
3168 int UtcDaliTextFieldSettingPlaceholder(void)
3170 ToolkitTestApplication application;
3171 tet_infoline("UtcDaliTextFieldSettingPlaceholder");
3173 TextField field = TextField::New();
3174 DALI_TEST_CHECK( field );
3175 application.GetScene().Add( field );
3177 // Check the placeholder property with pixel size
3178 Property::Map placeholderPixelSizeMapSet;
3179 Property::Map placeholderPixelSizeMapGet;
3180 Property::Map placeholderFontstyleMap;
3181 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
3182 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
3183 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
3184 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
3185 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
3186 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
3188 placeholderFontstyleMap.Insert( "weight", "bold" );
3189 placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3190 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
3192 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3193 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
3194 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
3196 // Check the placeholder property with point size
3197 Property::Map placeholderMapSet;
3198 Property::Map placeholderMapGet;
3199 placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
3200 placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
3201 placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
3202 placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
3203 placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
3204 placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
3206 // Check the placeholder font style property
3207 placeholderFontstyleMap.Clear();
3209 placeholderFontstyleMap.Insert( "weight", "bold" );
3210 placeholderFontstyleMap.Insert( "width", "condensed" );
3211 placeholderFontstyleMap.Insert( "slant", "italic" );
3212 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3213 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3215 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3216 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3217 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3219 // Reset font style.
3220 placeholderFontstyleMap.Clear();
3221 placeholderFontstyleMap.Insert( "weight", "normal" );
3222 placeholderFontstyleMap.Insert( "slant", "oblique" );
3223 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3224 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3226 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3227 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3228 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3230 placeholderFontstyleMap.Clear();
3231 placeholderFontstyleMap.Insert( "slant", "roman" );
3232 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3233 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3235 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3237 placeholderFontstyleMap.Clear();
3238 placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3240 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3241 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3242 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3243 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3248 int UtcDaliTextFieldPlaceholderCoverage(void)
3250 ToolkitTestApplication application;
3251 tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
3253 // mPlaceholderFont is created only once, so create a new control for coverage.
3254 TextField fieldForCoverage = TextField::New();
3255 DALI_TEST_CHECK(fieldForCoverage);
3256 application.GetScene().Add(fieldForCoverage);
3258 // for SetPlaceholderFontFamily() coverage.
3259 Property::Map fontFamilyMap;
3260 fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3261 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
3263 // mPlaceholderFont is created only once, so create a new control for coverage.
3264 fieldForCoverage = TextField::New();
3265 DALI_TEST_CHECK(fieldForCoverage);
3266 application.GetScene().Add(fieldForCoverage);
3268 // for SetPlaceholderTextFontSize coverage.
3269 Property::Map fontSizeMap;
3270 fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3271 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
3273 // mPlaceholderFont is created only once, so create a new control for coverage.
3274 fieldForCoverage = TextField::New();
3275 DALI_TEST_CHECK(fieldForCoverage);
3276 application.GetScene().Add(fieldForCoverage);
3278 // for SetPlaceholderTextFontWeight coverage.
3279 Property::Map fontStyleWeightMap;
3280 Property::Map fontStyleWeightPropertyMap;
3281 fontStyleWeightPropertyMap.Insert("weight", "bold");
3282 fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
3283 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
3285 // mPlaceholderFont is created only once, so create a new control for coverage.
3286 fieldForCoverage = TextField::New();
3287 DALI_TEST_CHECK(fieldForCoverage);
3288 application.GetScene().Add(fieldForCoverage);
3290 // for SetPlaceholderTextFontWidth coverage.
3291 Property::Map fontStyleWidthMap;
3292 Property::Map fontStyleWidthPropertyMap;
3293 fontStyleWidthPropertyMap.Insert("width", "expanded");
3294 fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
3295 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
3297 // mPlaceholderFont is created only once, so create a new control for coverage.
3298 fieldForCoverage = TextField::New();
3299 DALI_TEST_CHECK(fieldForCoverage);
3300 application.GetScene().Add(fieldForCoverage);
3302 // for SetPlaceholderTextFontSlant coverage.
3303 Property::Map fontStyleSlantMap;
3304 Property::Map fontStyleSlantPropertyMap;
3305 fontStyleSlantPropertyMap.Insert("slant", "italic");
3306 fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
3307 fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
3312 int UtcDaliTextFieldSetPaddingProperty(void)
3314 ToolkitTestApplication application;
3315 tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3317 TextField field = TextField::New();
3318 DALI_TEST_CHECK( field );
3319 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3320 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3321 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3322 application.GetScene().Add( field );
3324 application.SendNotification();
3325 application.Render();
3327 Vector3 originalSize = field.GetNaturalSize();
3329 field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
3331 application.SendNotification();
3332 application.Render();
3334 DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
3336 Vector3 paddingAddedSize = field.GetNaturalSize();
3338 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3340 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3345 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3347 ToolkitTestApplication application;
3348 tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3350 TextField field = TextField::New();
3351 DALI_TEST_CHECK( field );
3352 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3353 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3354 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3355 application.GetScene().Add( field );
3357 application.SendNotification();
3358 application.Render();
3360 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3361 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
3363 // Check the enable shift selection property
3364 field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
3365 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
3367 application.SendNotification();
3368 application.Render();
3373 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3375 ToolkitTestApplication application;
3376 tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3378 TextField field = TextField::New();
3379 DALI_TEST_CHECK( field );
3380 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3381 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3382 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3383 application.GetScene().Add( field );
3385 application.SendNotification();
3386 application.Render();
3388 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3389 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
3391 // Check the enable grab handle property
3392 field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
3393 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
3395 application.SendNotification();
3396 application.Render();
3401 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
3403 ToolkitTestApplication application;
3404 tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
3406 TextField field = TextField::New();
3407 DALI_TEST_CHECK( field );
3408 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3409 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3410 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3411 application.GetScene().Add( field );
3413 application.SendNotification();
3414 application.Render();
3416 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3417 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
3419 // Check the match system language direction property
3420 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
3421 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
3423 application.SendNotification();
3424 application.Render();
3429 int utcDaliTextFieldLayoutDirectionCoverage(void)
3431 ToolkitTestApplication application;
3432 tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
3434 // Creates a tap event. After creating a tap event the text field should
3435 // have the focus and add text with key events should be possible.
3436 TextField field = TextField::New();
3437 DALI_TEST_CHECK( field );
3439 application.GetScene().Add( field );
3441 field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3442 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3443 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3445 // Avoid a crash when core load gl resources.
3446 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3448 // Render and notify
3449 application.SendNotification();
3450 application.Render();
3452 // init direction for coverage
3453 // Set horizontal alignment END
3454 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3456 // Create a tap event to touch the text field.
3457 TestGenerateTap( application, 150.0f, 25.0f );
3459 // Render and notify
3460 application.SendNotification();
3461 application.Render();
3463 // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
3464 field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
3465 field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
3467 // Set horizontal alignment BEGIN
3468 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
3470 // Create a tap event to touch the text field.
3471 TestGenerateTap( application, 150.0f, 25.0f );
3473 // Render and notify
3474 application.SendNotification();
3475 application.Render();
3477 // Set horizontal alignment CENTER
3478 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
3480 // Create a tap event to touch the text field.
3481 TestGenerateTap( application, 150.0f, 25.0f );
3483 // Render and notify
3484 application.SendNotification();
3485 application.Render();
3487 // Set horizontal alignment END
3488 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3490 // Create a tap event to touch the text field.
3491 TestGenerateTap( application, 150.0f, 25.0f );
3493 // Render and notify
3494 application.SendNotification();
3495 application.Render();
3497 // Generate a Esc key event. The text field should lose the focus.
3498 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3499 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3501 // Render and notify
3502 application.SendNotification();
3503 application.Render();
3505 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
3510 int UtcDaliTextFieldGetInputMethodContext(void)
3512 ToolkitTestApplication application;
3513 tet_infoline("UtcDaliTextFieldGetInputMethodContext");
3515 TextField field = TextField::New();
3516 DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );
3521 int UtcDaliTextFieldSelectWholeText(void)
3523 ToolkitTestApplication application;
3524 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3526 TextField textField = TextField::New();
3528 application.GetScene().Add( textField );
3530 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3531 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3532 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3534 // Avoid a crash when core load gl resources.
3535 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3537 application.SendNotification();
3538 application.Render();
3540 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
3542 DevelTextField::SelectWholeText( textField );
3544 application.SendNotification();
3545 application.Render();
3547 // Nothing should have been selected. The number of children is still 1
3548 DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
3550 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3552 application.SendNotification();
3553 application.Render();
3555 DevelTextField::SelectWholeText( textField );
3557 application.SendNotification();
3558 application.Render();
3560 // Should be 2 children, the stencil and the layer
3561 DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
3563 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3564 Actor stencil = textField.GetChildAt( 0u );
3566 // The highlight actor is drawn first, so is the first actor in the list
3567 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3568 DALI_TEST_CHECK( highlight );
3573 int UtcDaliTextFieldSelectText(void)
3575 ToolkitTestApplication application;
3576 tet_infoline(" UtcDaliTextFieldSelectText ");
3578 TextField textField = TextField::New();
3580 application.GetScene().Add( textField );
3582 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3583 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3584 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3586 // Avoid a crash when core load gl resources.
3587 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3589 application.SendNotification();
3590 application.Render();
3592 DevelTextField::SelectText( textField, 0, 5 );
3594 application.SendNotification();
3595 application.Render();
3597 // Nothing is selected
3598 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3599 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3601 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3603 application.SendNotification();
3604 application.Render();
3606 // Hello is selected
3607 DevelTextField::SelectText( textField, 0, 5 );
3609 application.SendNotification();
3610 application.Render();
3612 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3613 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3615 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3616 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3618 // world is selected
3619 DevelTextField::SelectText( textField, 6, 11 );
3621 application.SendNotification();
3622 application.Render();
3624 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3625 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3627 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3628 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3633 int UtcDaliTextFieldSelectNone(void)
3635 ToolkitTestApplication application;
3636 tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3638 TextField textField = TextField::New();
3640 application.GetScene().Add( textField );
3642 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3643 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3644 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3646 // Avoid a crash when core load gl resources.
3647 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3649 application.SendNotification();
3650 application.Render();
3652 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3654 application.SendNotification();
3655 application.Render();
3657 // Nothing is selected
3658 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3659 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3661 DevelTextField::SelectWholeText( textField );
3663 application.SendNotification();
3664 application.Render();
3666 // whole text is selected
3667 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3668 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3670 DevelTextField::SelectNone( textField );
3672 application.SendNotification();
3673 application.Render();
3675 // Nothing is selected
3676 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3677 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3682 int UtcDaliTextFieldSelectRange(void)
3684 ToolkitTestApplication application;
3685 tet_infoline(" UtcDaliTextFieldSelectRange ");
3687 TextField textField = TextField::New();
3689 application.GetScene().Add( textField );
3691 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3692 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3693 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3695 // Avoid a crash when core load gl resources.
3696 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3698 application.SendNotification();
3699 application.Render();
3701 textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3703 application.SendNotification();
3704 application.Render();
3706 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 0);
3707 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 5);
3709 // Hello is selected
3710 std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3711 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3713 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3714 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3716 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 6);
3717 textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 11);
3719 // world is selected
3720 selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3721 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3723 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3724 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3729 int UtcDaliTextFieldEnableEditing(void)
3731 ToolkitTestApplication application;
3732 tet_infoline(" UtcDaliTextFieldEnableEditing ");
3734 TextField textField = TextField::New();
3736 application.GetScene().Add( textField );
3738 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3739 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3740 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3742 // Avoid a crash when core load gl resources.
3743 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3745 application.SendNotification();
3746 application.Render();
3748 textField.SetKeyInputFocus();
3749 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, false );
3750 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3752 // Render and notify
3753 application.SendNotification();
3754 application.Render();
3756 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3757 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3760 textField.SetKeyInputFocus();
3761 textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
3762 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3764 // Render and notify
3765 application.SendNotification();
3766 application.Render();
3768 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3769 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3774 int UtcDaliToolkitTextFieldFontSizeScale(void)
3776 ToolkitTestApplication application;
3777 tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
3779 TextField textField = TextField::New();
3780 textField.SetProperty( TextField::Property::POINT_SIZE, 30.f );
3781 textField.SetProperty( TextField::Property::TEXT, "Test" );
3782 Vector3 nonScaledSize = textField.GetNaturalSize();
3784 TextField textFieldScaled = TextField::New();
3785 textFieldScaled.SetProperty( TextField::Property::POINT_SIZE, 15.f );
3786 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3787 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3788 Vector3 scaledSize = textFieldScaled.GetNaturalSize();
3790 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3792 textField.SetProperty( TextField::Property::PIXEL_SIZE, 30.f );
3793 textField.SetProperty( TextField::Property::TEXT, "Test" );
3794 nonScaledSize = textField.GetNaturalSize();
3796 textFieldScaled.SetProperty( TextField::Property::PIXEL_SIZE, 15.f );
3797 textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3798 textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3799 scaledSize = textFieldScaled.GetNaturalSize();
3801 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3806 int UtcDaliTextFieldPrimaryCursorPosition(void)
3808 ToolkitTestApplication application;
3809 tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
3811 TextField textField = TextField::New();
3813 application.GetScene().Add( textField );
3815 textField.SetProperty( TextField::Property::TEXT, "ABCEF");
3816 textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3817 textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3818 textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3820 // Avoid a crash when core load gl resources.
3821 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3823 textField.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
3824 application.SendNotification();
3825 application.Render();
3826 textField.SetKeyInputFocus();
3828 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3830 // Render and notify
3831 application.SendNotification();
3832 application.Render();
3834 DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3835 DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3840 // test max length when set after setting long text
3841 int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
3843 ToolkitTestApplication application;
3844 tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
3845 TextField field = TextField::New();
3846 DALI_TEST_CHECK( field );
3848 application.GetScene().Add( field );
3850 field.SetProperty(TextField::Property::TEXT, "123456789");
3852 const int maxNumberOfCharacters = 3;
3853 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
3855 field.SetKeyInputFocus();
3857 // connect to the text max lengh reached signal.
3858 ConnectionTracker* testTracker = new ConnectionTracker();
3859 bool maxLengthReachedSignal = false;
3860 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
3862 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3863 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3865 DALI_TEST_CHECK( maxLengthReachedSignal );
3867 DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "123456789", TEST_LOCATION );
3874 int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
3876 ToolkitTestApplication application;
3877 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
3879 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3880 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3881 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3883 // Create a text field
3884 TextField textField = TextField::New();
3886 //Set size to avoid automatic eliding
3887 textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3888 //Set very large font-size using point-size
3889 textField.SetProperty( TextField::Property::POINT_SIZE, 1000) ;
3890 //Specify font-family
3891 textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
3892 //Set text to check if appear or not
3893 textField.SetProperty( TextField::Property::TEXT, "A");
3895 application.GetScene().Add( textField );
3897 application.SendNotification();
3898 application.Render();
3899 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3900 Vector3 naturalSize = textField.GetNaturalSize();
3902 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3903 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3908 int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
3910 ToolkitTestApplication application;
3911 tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
3913 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3914 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3915 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3917 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3918 // Create a text editor
3919 TextField textField = TextField::New();
3921 //Set size to avoid automatic eliding
3922 textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3923 textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
3924 textField.SetProperty( TextField::Property::TEXT, "A");
3926 const int numberOfCases = 6;
3927 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
3929 for (int index=0; index < numberOfCases; index++)
3931 tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
3932 textField.SetProperty( TextField::Property::POINT_SIZE, arrayCases[index]) ;
3933 application.GetScene().Add( textField );
3934 application.SendNotification();
3935 application.Render();
3936 naturalSize = textField.GetNaturalSize();
3937 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3938 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3945 int UtcDaliToolkitTextFieldEllipsisPositionProperty(void)
3947 ToolkitTestApplication application;
3948 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty ");
3949 TextField textField = TextField::New();
3951 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Default is END");
3952 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3954 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START");
3955 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
3956 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3958 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE");
3959 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
3960 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3962 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END");
3963 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
3964 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3966 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START using integer");
3967 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 1);
3968 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3970 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE using integer");
3971 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 2);
3972 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3974 tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END using integer");
3975 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 0);
3976 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3978 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
3979 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "START");
3980 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3982 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
3983 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "MIDDLE");
3984 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3986 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
3987 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "END");
3988 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3990 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
3991 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "start");
3992 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3994 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
3995 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "middle");
3996 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3998 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
3999 textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "end");
4000 DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4005 int utcDaliTextFieldCursorPositionChangedSignal(void)
4007 ToolkitTestApplication application;
4008 tet_infoline(" utcDaliTextFieldCursorPositionChangedSignal");
4010 TextField field = TextField::New();
4011 DALI_TEST_CHECK( field );
4013 application.GetScene().Add( field );
4015 // connect to the selection changed signal.
4016 ConnectionTracker* testTracker = new ConnectionTracker();
4017 DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
4018 bool cursorPositionChangedSignal = false;
4019 field.ConnectSignal( testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal) );
4021 field.SetProperty( TextField::Property::TEXT, "Hello world Hello world" );
4022 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
4023 field.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4024 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4025 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4027 // Avoid a crash when core load gl resources.
4028 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4030 // Render and notify
4031 application.SendNotification();
4032 application.Render();
4034 field.SetKeyInputFocus();
4036 // Tap on the text field
4037 TestGenerateTap( application, 3.0f, 25.0f );
4039 // Render and notify
4040 application.SendNotification();
4041 application.Render();
4043 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4044 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4046 gCursorPositionChangedCallbackCalled = false;
4049 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4051 // Render and notify
4052 application.SendNotification();
4053 application.Render();
4055 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4056 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4058 gCursorPositionChangedCallbackCalled = false;
4061 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4063 // Render and notify
4064 application.SendNotification();
4065 application.Render();
4067 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4068 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4070 gCursorPositionChangedCallbackCalled = false;
4072 //delete one character
4073 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4075 // Render and notify
4076 application.SendNotification();
4077 application.Render();
4079 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4080 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4082 gCursorPositionChangedCallbackCalled = false;
4084 field.SetProperty( TextField::Property::TEXT, "Hello" );
4086 // Render and notify
4087 application.SendNotification();
4088 application.Render();
4090 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4091 DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4093 gCursorPositionChangedCallbackCalled = false;
4095 field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4097 // Render and notify
4098 application.SendNotification();
4099 application.Render();
4101 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4102 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4107 int utcDaliTextFieldSelectionChangedSignal(void)
4109 ToolkitTestApplication application;
4110 tet_infoline(" utcDaliTextFieldSelectionChangedSignal");
4112 TextField field = TextField::New();
4113 DALI_TEST_CHECK( field );
4115 application.GetScene().Add( field );
4117 // connect to the selection changed signal.
4118 ConnectionTracker* testTracker = new ConnectionTracker();
4119 DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
4120 bool selectionChangedSignal = false;
4121 field.ConnectSignal( testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal) );
4123 field.SetProperty( TextField::Property::TEXT, "Hello world Hello world" );
4124 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
4125 field.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4126 field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4127 field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4129 // Avoid a crash when core load gl resources.
4130 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4132 // Render and notify
4133 application.SendNotification();
4134 application.Render();
4136 // Tap on the text field
4137 TestGenerateTap( application, 3.0f, 25.0f );
4139 // Render and notify
4140 application.SendNotification();
4141 application.Render();
4143 // Select some text in the right of the current cursor position
4144 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4145 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4147 // Render and notify
4148 application.SendNotification();
4149 application.Render();
4151 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4152 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4154 gSelectionChangedCallbackCalled = false;
4156 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4158 // Render and notify
4159 application.SendNotification();
4160 application.Render();
4162 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4163 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4164 DALI_TEST_EQUALS(oldSelectionEnd, 1, TEST_LOCATION);
4166 gSelectionChangedCallbackCalled = false;
4168 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4170 // Render and notify
4171 application.SendNotification();
4172 application.Render();
4174 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4175 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4176 DALI_TEST_EQUALS(oldSelectionEnd, 2, TEST_LOCATION);
4178 gSelectionChangedCallbackCalled = false;
4179 field.SetKeyInputFocus();
4181 // Render and notify
4182 application.SendNotification();
4183 application.Render();
4185 DevelTextField::SelectText( field ,0, 5 );
4187 application.SendNotification();
4188 application.Render();
4190 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4191 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4193 gSelectionChangedCallbackCalled = false;
4195 field.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4197 // Render and notify
4198 application.SendNotification();
4199 application.Render();
4201 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4202 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4203 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
4205 gSelectionChangedCallbackCalled = false;
4208 DevelTextField::SelectWholeText(field);
4210 // Render and notify
4211 application.SendNotification();
4212 application.Render();
4214 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4215 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4217 gSelectionChangedCallbackCalled = false;
4220 DevelTextField::SelectNone(field);
4222 // Render and notify
4223 application.SendNotification();
4224 application.Render();
4226 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4227 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4228 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);