2 * Copyright (c) 2016 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/tap-gesture-event.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/integration-api/events/pan-gesture-event.h>
27 #include <dali/integration-api/events/long-press-gesture-event.h>
28 #include <dali-toolkit-test-suite-utils.h>
29 #include <dali-toolkit/dali-toolkit.h>
30 #include "toolkit-clipboard.h"
33 using namespace Toolkit;
35 void dali_textfield_startup(void)
37 test_return_value = TET_UNDEF;
40 void dali_textfield_cleanup(void)
42 test_return_value = TET_PASS;
48 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
49 const char* const PROPERTY_NAME_TEXT = "text";
50 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
51 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
52 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
53 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
54 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
55 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
56 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
57 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
58 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
59 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
60 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
61 const char* const PROPERTY_NAME_SHADOW_OFFSET = "shadowOffset";
62 const char* const PROPERTY_NAME_SHADOW_COLOR = "shadowColor";
63 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
64 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
65 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
66 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
67 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
68 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
69 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
70 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
71 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
72 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
73 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
80 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
81 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
82 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
83 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
84 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
85 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
86 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
88 const char* const PROPERTY_NAME_UNDERLINE = "underline";
89 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
90 const char* const PROPERTY_NAME_SHADOW = "shadow";
91 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
92 const char* const PROPERTY_NAME_EMBOSS = "emboss";
93 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
94 const char* const PROPERTY_NAME_OUTLINE = "outline";
95 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
97 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
99 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
100 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
102 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
103 const float RENDER_FRAME_INTERVAL = 16.66f;
105 const float TO_MILLISECONDS = 1000.f;
106 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
108 const float SCROLL_THRESHOLD = 10.f;
109 const float SCROLL_SPEED = 300.f;
111 const unsigned int DEFAULT_FONT_SIZE = 1152u;
112 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
114 static bool gTextChangedCallBackCalled;
115 static bool gMaxCharactersCallBackCalled;
116 static bool gInputStyleChangedCallbackCalled;
117 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
119 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
121 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
122 Integration::ResourcePointer resource(bitmap);
123 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
126 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
130 LoadBitmapResource( app.GetPlatform(), width, height );
132 Property::Map propertyMap;
133 propertyMap["filename"] = "image.png";
134 propertyMap["width"] = width;
135 propertyMap["height"] = height;
136 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
137 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
138 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
139 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
140 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
141 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
142 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
143 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
146 // Generate a PanGestureEvent to send to Core
147 static Integration::PanGestureEvent GeneratePan(
148 Gesture::State state,
149 const Vector2& previousPosition,
150 const Vector2& currentPosition,
151 unsigned long timeDelta,
152 unsigned int numberOfTouches = 1)
154 Integration::PanGestureEvent pan(state);
156 pan.previousPosition = previousPosition;
157 pan.currentPosition = currentPosition;
158 pan.timeDelta = timeDelta;
159 pan.numberOfTouches = numberOfTouches;
165 * Helper to generate PanGestureEvent
167 * @param[in] application Application instance
168 * @param[in] state The Gesture State
169 * @param[in] pos The current position of touch.
171 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
175 if( (state == Gesture::Started) ||
176 (state == Gesture::Possible) )
182 application.ProcessEvent(GeneratePan(state, last, pos, 16));
189 * Simulate time passed by.
191 * @note this will always process at least 1 frame (1/60 sec)
193 * @param application Test application instance
194 * @param duration Time to pass in milliseconds.
195 * @return The actual time passed in milliseconds
197 static int Wait(ToolkitTestApplication& application, int duration = 0)
201 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
203 application.SendNotification();
204 application.Render(RENDER_FRAME_INTERVAL);
205 time += RENDER_FRAME_INTERVAL;
211 Dali::Integration::Point GetPointDownInside( Vector2& pos )
213 Dali::Integration::Point point;
214 point.SetState( PointState::DOWN );
215 point.SetScreenPosition( pos );
219 Dali::Integration::Point GetPointUpInside( Vector2& pos )
221 Dali::Integration::Point point;
222 point.SetState( PointState::UP );
223 point.SetScreenPosition( pos );
227 struct CallbackFunctor
229 CallbackFunctor(bool* callbackFlag)
230 : mCallbackFlag( callbackFlag )
236 *mCallbackFlag = true;
241 static void TestTextChangedCallback( TextField control )
243 tet_infoline(" TestTextChangedCallback");
245 gTextChangedCallBackCalled = true;
248 static void TestMaxLengthReachedCallback( TextField control )
250 tet_infoline(" TestMaxLengthReachedCallback");
252 gMaxCharactersCallBackCalled = true;
255 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
257 tet_infoline(" TestInputStyleChangedCallback");
259 gInputStyleChangedCallbackCalled = true;
260 gInputStyleMask = mask;
263 // Generate a TapGestureEvent to send to Core.
264 Integration::TapGestureEvent GenerateTap(
265 Gesture::State state,
266 unsigned int numberOfTaps,
267 unsigned int numberOfTouches,
270 Integration::TapGestureEvent tap( state );
272 tap.numberOfTaps = numberOfTaps;
273 tap.numberOfTouches = numberOfTouches;
279 Integration::LongPressGestureEvent GenerateLongPress(
280 Gesture::State state,
281 unsigned int numberOfTouches,
284 Integration::LongPressGestureEvent longPress( state );
286 longPress.numberOfTouches = numberOfTouches;
287 longPress.point = point;
291 // Generate a KeyEvent to send to Core.
292 Integration::KeyEvent GenerateKey( const std::string& keyName,
293 const std::string& keyString,
296 unsigned long timeStamp,
297 const Integration::KeyEvent::State& keyState )
299 return Integration::KeyEvent( keyName,
307 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
309 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
311 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
313 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
315 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
316 if( NULL != valueSet )
318 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
320 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
326 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
337 int UtcDaliToolkitTextFieldConstructorP(void)
339 ToolkitTestApplication application;
340 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
342 DALI_TEST_CHECK( !textField );
346 int UtcDaliToolkitTextFieldNewP(void)
348 ToolkitTestApplication application;
349 tet_infoline(" UtcDaliToolkitTextFieldNewP");
350 TextField textField = TextField::New();
351 DALI_TEST_CHECK( textField );
355 int UtcDaliToolkitTextFieldDownCastP(void)
357 ToolkitTestApplication application;
358 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
359 TextField textField1 = TextField::New();
360 BaseHandle object( textField1 );
362 TextField textField2 = TextField::DownCast( object );
363 DALI_TEST_CHECK( textField2 );
365 TextField textField3 = DownCast< TextField >( object );
366 DALI_TEST_CHECK( textField3 );
370 int UtcDaliToolkitTextFieldDownCastN(void)
372 ToolkitTestApplication application;
373 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
374 BaseHandle uninitializedObject;
375 TextField textField1 = TextField::DownCast( uninitializedObject );
376 DALI_TEST_CHECK( !textField1 );
378 TextField textField2 = DownCast< TextField >( uninitializedObject );
379 DALI_TEST_CHECK( !textField2 );
383 int UtcDaliToolkitTextFieldCopyConstructorP(void)
385 ToolkitTestApplication application;
386 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
387 TextField textField = TextField::New();
388 textField.SetProperty( TextField::Property::TEXT, "Test" );
390 TextField copy( textField );
391 DALI_TEST_CHECK( copy );
392 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
396 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
398 ToolkitTestApplication application;
399 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
400 TextField textField = TextField::New();
401 textField.SetProperty( TextField::Property::TEXT, "Test" );
403 TextField copy = textField;
404 DALI_TEST_CHECK( copy );
405 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
409 int UtcDaliTextFieldNewP(void)
411 ToolkitTestApplication application;
412 tet_infoline(" UtcDaliToolkitTextFieldNewP");
413 TextField textField = TextField::New();
414 DALI_TEST_CHECK( textField );
418 // Positive test case for a method
419 int UtcDaliTextFieldGetPropertyP(void)
421 ToolkitTestApplication application;
422 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
423 TextField field = TextField::New();
424 DALI_TEST_CHECK( field );
426 // Check Property Indices are correct
427 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
428 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
429 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
430 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
431 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
432 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
433 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
434 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
435 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
436 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
437 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
438 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
439 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
440 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextField::Property::SHADOW_OFFSET );
441 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextField::Property::SHADOW_COLOR );
442 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
443 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
444 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
445 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
446 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
447 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
448 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
449 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
450 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
451 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
452 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
453 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
454 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
455 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
456 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
457 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
458 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
459 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
460 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
461 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
462 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
463 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
464 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
465 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
466 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
467 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
468 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
469 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
470 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
471 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
472 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
473 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
478 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
481 Property::Map imageMap;
482 imageMap[mapKey] =mapValue;
484 field.SetProperty( property , imageMap );
485 Property::Value propValue = field.GetProperty( property );
486 Property::Map* resultMap = propValue.GetMap();
488 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
496 // Positive test case for a method
497 int UtcDaliTextFieldSetPropertyP(void)
499 ToolkitTestApplication application;
500 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
501 TextField field = TextField::New();
502 DALI_TEST_CHECK( field );
503 Stage::GetCurrent().Add( field );
505 // Note - we can't check the defaults since the stylesheets are platform-specific
507 // Check the render backend property.
508 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
509 DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
511 // Check text property.
512 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
513 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
515 // Check placeholder text properties.
516 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
517 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
519 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
520 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
522 // Check font properties.
523 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
524 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
526 Property::Map fontStyleMapSet;
527 Property::Map fontStyleMapGet;
528 Property::Value* slantValue = NULL;
530 fontStyleMapSet.Insert( "weight", "bold" );
531 fontStyleMapSet.Insert( "width", "condensed" );
532 fontStyleMapSet.Insert( "slant", "italic" );
533 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
535 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
536 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
537 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
539 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
540 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
543 fontStyleMapSet.Clear();
544 fontStyleMapSet.Insert( "weight", "normal" );
545 fontStyleMapSet.Insert( "slant", "oblique" );
546 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
548 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
549 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
550 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
552 fontStyleMapSet.Clear();
553 fontStyleMapSet.Insert( "slant", "roman" );
554 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
555 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
557 // Replace 'roman' for 'normal'.
558 slantValue = fontStyleMapGet.Find( "slant" );
559 if( NULL != slantValue )
561 if( "normal" == slantValue->Get<std::string>() )
563 fontStyleMapGet["slant"] = "roman";
566 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
567 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
569 fontStyleMapSet.Clear();
571 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
572 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
573 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
574 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
576 // Check that the MAX_LENGTH property can be correctly set
577 const int maxNumberOfCharacters = 20;
578 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
579 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
581 // Check exceed policy
582 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
583 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
584 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
585 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
587 // Check that the Alignment properties can be correctly set
588 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
589 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
590 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
591 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
593 // Check text's color property
594 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
595 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
597 // Check placeholder text's color property.
598 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
599 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
601 // Check shadow properties.
602 field.SetProperty( TextField::Property::SHADOW_OFFSET, Vector2( 1.f, 1.f ) );
603 DALI_TEST_EQUALS( field.GetProperty<Vector2>( TextField::Property::SHADOW_OFFSET ), Vector2( 1.f, 1.f ), TEST_LOCATION );
604 field.SetProperty( TextField::Property::SHADOW_COLOR, Color::GREEN );
605 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SHADOW_COLOR ), Color::GREEN, TEST_LOCATION );
607 // Check cursor properties
608 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
609 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
610 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
611 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
613 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
614 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
615 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
616 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
617 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
618 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
619 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
620 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
622 // Check scroll properties.
623 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
624 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
625 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
626 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
628 // Check handle images
629 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
630 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
631 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
632 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
633 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
635 // Check handle images
636 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
637 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
638 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
639 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
640 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
641 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
643 // Check the highlight color
644 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
645 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
647 // Decoration bounding box
648 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
649 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
651 // Check input color property.
652 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
653 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
655 // Check the enable markup property.
656 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
657 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
658 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
660 // Check input font properties.
661 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
662 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
664 fontStyleMapSet.Clear();
665 fontStyleMapSet.Insert( "weight", "bold" );
666 fontStyleMapSet.Insert( "width", "condensed" );
667 fontStyleMapSet.Insert( "slant", "italic" );
669 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
670 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
671 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
672 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
674 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
675 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
677 // Reset input font style.
678 fontStyleMapSet.Clear();
679 fontStyleMapSet.Insert( "weight", "normal" );
680 fontStyleMapSet.Insert( "slant", "oblique" );
682 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
683 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
684 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
685 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
687 fontStyleMapSet.Clear();
688 fontStyleMapSet.Insert( "slant", "roman" );
690 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
691 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
693 // Replace 'roman' for 'normal'.
694 slantValue = fontStyleMapGet.Find( "slant" );
695 if( NULL != slantValue )
697 if( "normal" == slantValue->Get<std::string>() )
699 fontStyleMapGet["slant"] = "roman";
702 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
703 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
705 fontStyleMapSet.Clear();
707 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
708 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
709 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
710 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
712 Property::Map underlineMapSet;
713 Property::Map underlineMapGet;
715 underlineMapSet.Insert( "enable", "true" );
716 underlineMapSet.Insert( "color", "red" );
717 underlineMapSet.Insert( "height", "1" );
719 // Check the underline property
720 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
722 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
723 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
724 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
726 // Check the input underline property
727 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
728 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
730 // Check the shadow property
731 Property::Map shadowMapSet;
732 Property::Map shadowMapGet;
734 shadowMapSet.Insert( "color", "green" );
735 shadowMapSet.Insert( "offset", "2 2" );
737 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
739 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
740 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
741 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
743 // Check the input shadow property
744 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
745 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
747 // Check the emboss property
748 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
749 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
751 // Check the input emboss property
752 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
753 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
755 // Check the outline property
756 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
757 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
759 // Check the input outline property
760 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
761 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
766 // Positive Atlas Text Renderer test
767 int utcDaliTextFieldAtlasRenderP(void)
769 ToolkitTestApplication application;
770 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
771 StyleManager styleManager = StyleManager::Get();
772 styleManager.ApplyDefaultTheme();
773 TextField field = TextField::New();
774 DALI_TEST_CHECK( field );
776 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
778 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
780 Stage::GetCurrent().Add( field );
784 // Render some text with the shared atlas backend
785 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
786 application.SendNotification();
787 application.Render();
791 tet_result(TET_FAIL);
796 // Positive test for the textChanged signal.
797 int utcDaliTextFieldTextChangedP(void)
799 ToolkitTestApplication application;
800 tet_infoline(" utcDaliTextFieldTextChangedP");
801 TextField field = TextField::New();
802 DALI_TEST_CHECK( field );
804 Stage::GetCurrent().Add( field );
806 // connect to the text changed signal.
807 ConnectionTracker* testTracker = new ConnectionTracker();
808 field.TextChangedSignal().Connect(&TestTextChangedCallback);
809 bool textChangedSignal = false;
810 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
812 gTextChangedCallBackCalled = false;
813 field.SetProperty( TextField::Property::TEXT, "ABC" );
814 DALI_TEST_CHECK( gTextChangedCallBackCalled );
815 DALI_TEST_CHECK( textChangedSignal );
817 application.SendNotification();
819 field.SetKeyInputFocus();
821 gTextChangedCallBackCalled = false;
822 application.ProcessEvent( GenerateKey( "D", "D", 0, 0, 0, Integration::KeyEvent::Down ) );
823 DALI_TEST_CHECK( gTextChangedCallBackCalled );
828 // Negative test for the textChanged signal.
829 int utcDaliTextFieldTextChangedN(void)
831 ToolkitTestApplication application;
832 tet_infoline(" utcDaliTextFieldTextChangedN");
833 TextField field = TextField::New();
834 DALI_TEST_CHECK( field );
836 Stage::GetCurrent().Add( field );
838 // connect to the text changed signal.
839 ConnectionTracker* testTracker = new ConnectionTracker();
840 field.TextChangedSignal().Connect(&TestTextChangedCallback);
841 bool textChangedSignal = false;
842 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
844 gTextChangedCallBackCalled = false;
845 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
846 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
847 DALI_TEST_CHECK( !textChangedSignal );
852 // Positive test for Max Characters reached signal.
853 int utcDaliTextFieldMaxCharactersReachedP(void)
855 ToolkitTestApplication application;
856 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
857 TextField field = TextField::New();
858 DALI_TEST_CHECK( field );
860 Stage::GetCurrent().Add( field );
862 const int maxNumberOfCharacters = 1;
863 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
865 field.SetKeyInputFocus();
867 // connect to the text changed signal.
868 ConnectionTracker* testTracker = new ConnectionTracker();
869 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
870 bool maxLengthReachedSignal = false;
871 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
873 gMaxCharactersCallBackCalled = false;
875 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
876 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
878 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
879 DALI_TEST_CHECK( maxLengthReachedSignal );
884 // Negative test for Max Characters reached signal.
885 int utcDaliTextFieldMaxCharactersReachedN(void)
887 ToolkitTestApplication application;
888 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
889 TextField field = TextField::New();
890 DALI_TEST_CHECK( field );
892 Stage::GetCurrent().Add( field );
894 const int maxNumberOfCharacters = 3;
895 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
897 field.SetKeyInputFocus();
899 // connect to the text changed signal.
900 ConnectionTracker* testTracker = new ConnectionTracker();
901 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
902 bool maxLengthReachedSignal = false;
903 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
905 gMaxCharactersCallBackCalled = false;
907 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
908 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
910 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
911 DALI_TEST_CHECK( !maxLengthReachedSignal );
916 int utcDaliTextFieldInputStyleChanged01(void)
918 ToolkitTestApplication application;
919 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
921 // The text-field emits signals when the input style changes. These changes of style are
922 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
923 // can't be emitted during the size negotiation as the callbacks may update the UI.
924 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
925 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
926 application.CreateAdaptor();
930 char* pathNamePtr = get_current_dir_name();
931 const std::string pathName( pathNamePtr );
934 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
935 fontClient.SetDpi( 93u, 93u );
937 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
938 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
940 TextField field = TextField::New();
941 DALI_TEST_CHECK( field );
944 field.SetSize( 300.f, 50.f );
945 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
946 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
948 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
949 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
951 // connect to the text changed signal.
952 ConnectionTracker* testTracker = new ConnectionTracker();
953 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
954 bool inputStyleChangedSignal = false;
955 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
957 Stage::GetCurrent().Add( field );
960 application.SendNotification();
961 application.Render();
963 // Executes the idle callbacks added by the text control on the change of input style.
964 application.RunIdles();
966 gInputStyleChangedCallbackCalled = false;
967 gInputStyleMask = TextField::InputStyle::NONE;
968 inputStyleChangedSignal = false;
970 // Create a tap event to touch the text field.
971 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
972 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
975 application.SendNotification();
976 application.Render();
978 // Executes the idle callbacks added by the text control on the change of input style.
979 application.RunIdles();
981 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
982 if( gInputStyleChangedCallbackCalled )
984 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
986 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
987 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
989 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
990 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
992 DALI_TEST_CHECK( inputStyleChangedSignal );
994 gInputStyleChangedCallbackCalled = false;
995 gInputStyleMask = TextField::InputStyle::NONE;
996 inputStyleChangedSignal = false;
998 // Create a tap event to touch the text field.
999 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1000 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1002 // Render and notify
1003 application.SendNotification();
1004 application.Render();
1006 // Executes the idle callbacks added by the text control on the change of input style.
1007 application.RunIdles();
1009 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1010 DALI_TEST_CHECK( !inputStyleChangedSignal );
1012 gInputStyleChangedCallbackCalled = false;
1013 gInputStyleMask = TextField::InputStyle::NONE;
1014 inputStyleChangedSignal = false;
1016 // Create a tap event to touch the text field.
1017 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1018 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1020 // Render and notify
1021 application.SendNotification();
1022 application.Render();
1024 // Executes the idle callbacks added by the text control on the change of input style.
1025 application.RunIdles();
1027 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1028 if( gInputStyleChangedCallbackCalled )
1030 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1032 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1033 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1035 DALI_TEST_CHECK( inputStyleChangedSignal );
1037 gInputStyleChangedCallbackCalled = false;
1038 gInputStyleMask = TextField::InputStyle::NONE;
1039 inputStyleChangedSignal = false;
1041 // Create a tap event to touch the text field.
1042 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1043 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1045 // Render and notify
1046 application.SendNotification();
1047 application.Render();
1049 // Executes the idle callbacks added by the text control on the change of input style.
1050 application.RunIdles();
1052 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1053 if( gInputStyleChangedCallbackCalled )
1055 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1057 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1058 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1060 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1062 Property::Map fontStyleMapSet;
1063 fontStyleMapSet.Insert( "weight", "bold" );
1065 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1066 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1068 DALI_TEST_CHECK( inputStyleChangedSignal );
1070 gInputStyleChangedCallbackCalled = false;
1071 gInputStyleMask = TextField::InputStyle::NONE;
1072 inputStyleChangedSignal = false;
1074 // Create a tap event to touch the text field.
1075 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1076 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1078 // Render and notify
1079 application.SendNotification();
1080 application.Render();
1082 // Executes the idle callbacks added by the text control on the change of input style.
1083 application.RunIdles();
1085 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1086 DALI_TEST_CHECK( !inputStyleChangedSignal );
1088 gInputStyleChangedCallbackCalled = false;
1089 gInputStyleMask = TextField::InputStyle::NONE;
1090 inputStyleChangedSignal = false;
1092 // Create a tap event to touch the text field.
1093 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1094 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1096 // Render and notify
1097 application.SendNotification();
1098 application.Render();
1100 // Executes the idle callbacks added by the text control on the change of input style.
1101 application.RunIdles();
1103 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1104 if( gInputStyleChangedCallbackCalled )
1106 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1108 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1109 DALI_TEST_CHECK( style.empty() );
1111 DALI_TEST_CHECK( inputStyleChangedSignal );
1113 gInputStyleChangedCallbackCalled = false;
1114 gInputStyleMask = TextField::InputStyle::NONE;
1115 inputStyleChangedSignal = false;
1117 // Create a tap event to touch the text field.
1118 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1119 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1121 // Render and notify
1122 application.SendNotification();
1123 application.Render();
1125 // Executes the idle callbacks added by the text control on the change of input style.
1126 application.RunIdles();
1128 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1129 DALI_TEST_CHECK( !inputStyleChangedSignal );
1134 int utcDaliTextFieldInputStyleChanged02(void)
1136 ToolkitTestApplication application;
1137 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1139 // The text-field emits signals when the input style changes. These changes of style are
1140 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1141 // can't be emitted during the size negotiation as the callbacks may update the UI.
1142 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1143 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1144 application.CreateAdaptor();
1148 char* pathNamePtr = get_current_dir_name();
1149 const std::string pathName( pathNamePtr );
1150 free( pathNamePtr );
1152 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1153 fontClient.SetDpi( 93u, 93u );
1155 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1156 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1158 TextField field = TextField::New();
1159 DALI_TEST_CHECK( field );
1162 field.SetSize( 300.f, 50.f );
1163 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1164 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1166 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1167 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>" );
1169 // connect to the text changed signal.
1170 ConnectionTracker* testTracker = new ConnectionTracker();
1171 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1172 bool inputStyleChangedSignal = false;
1173 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1175 Stage::GetCurrent().Add( field );
1177 // Render and notify
1178 application.SendNotification();
1179 application.Render();
1181 // Executes the idle callbacks added by the text control on the change of input style.
1182 application.RunIdles();
1184 gInputStyleChangedCallbackCalled = false;
1185 gInputStyleMask = TextField::InputStyle::NONE;
1186 inputStyleChangedSignal = false;
1188 // Create a tap event to touch the text field.
1189 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1190 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1191 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1192 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1194 // Render and notify
1195 application.SendNotification();
1196 application.Render();
1198 // Executes the idle callbacks added by the text control on the change of input style.
1199 application.RunIdles();
1201 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1202 if( gInputStyleChangedCallbackCalled )
1204 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1205 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1206 TextField::InputStyle::POINT_SIZE |
1207 TextField::InputStyle::COLOR ),
1210 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1211 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1213 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1214 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1216 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1217 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1219 DALI_TEST_CHECK( inputStyleChangedSignal );
1221 gInputStyleChangedCallbackCalled = false;
1222 gInputStyleMask = TextField::InputStyle::NONE;
1223 inputStyleChangedSignal = false;
1225 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1227 // Render and notify
1228 application.SendNotification();
1229 application.Render();
1231 // Executes the idle callbacks added by the text control on the change of input style.
1232 application.RunIdles();
1234 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1235 if( gInputStyleChangedCallbackCalled )
1237 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1238 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1241 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1242 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1244 DALI_TEST_CHECK( inputStyleChangedSignal );
1246 gInputStyleChangedCallbackCalled = false;
1247 gInputStyleMask = TextField::InputStyle::NONE;
1248 inputStyleChangedSignal = false;
1250 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1252 // Render and notify
1253 application.SendNotification();
1254 application.Render();
1256 // Executes the idle callbacks added by the text control on the change of input style.
1257 application.RunIdles();
1259 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1260 DALI_TEST_CHECK( !inputStyleChangedSignal );
1262 gInputStyleChangedCallbackCalled = false;
1263 gInputStyleMask = TextField::InputStyle::NONE;
1264 inputStyleChangedSignal = false;
1266 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1268 // Render and notify
1269 application.SendNotification();
1270 application.Render();
1272 // Executes the idle callbacks added by the text control on the change of input style.
1273 application.RunIdles();
1275 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1276 if( gInputStyleChangedCallbackCalled )
1278 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1279 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1282 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1283 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1285 DALI_TEST_CHECK( inputStyleChangedSignal );
1287 gInputStyleChangedCallbackCalled = false;
1288 gInputStyleMask = TextField::InputStyle::NONE;
1289 inputStyleChangedSignal = false;
1291 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1293 Property::Map fontStyleMapSet;
1294 fontStyleMapSet.Insert( "weight", "thin" );
1295 fontStyleMapSet.Insert( "width", "condensed" );
1296 fontStyleMapSet.Insert( "slant", "italic" );
1298 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1299 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1301 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1302 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1303 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1304 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1306 // Render and notify
1307 application.SendNotification();
1308 application.Render();
1310 // Executes the idle callbacks added by the text control on the change of input style.
1311 application.RunIdles();
1313 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1314 DALI_TEST_CHECK( !inputStyleChangedSignal );
1316 // Create a tap event to touch the text field.
1317 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1318 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1320 // Render and notify
1321 application.SendNotification();
1322 application.Render();
1324 // Executes the idle callbacks added by the text control on the change of input style.
1325 application.RunIdles();
1327 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1328 if( gInputStyleChangedCallbackCalled )
1330 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1331 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1332 TextField::InputStyle::POINT_SIZE |
1333 TextField::InputStyle::FONT_STYLE |
1334 TextField::InputStyle::UNDERLINE |
1335 TextField::InputStyle::SHADOW |
1336 TextField::InputStyle::EMBOSS |
1337 TextField::InputStyle::OUTLINE ),
1340 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1341 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1343 DALI_TEST_CHECK( inputStyleChangedSignal );
1348 int utcDaliTextFieldEvent01(void)
1350 ToolkitTestApplication application;
1351 tet_infoline(" utcDaliTextFieldEvent01");
1353 // Creates a tap event. After creating a tap event the text field should
1354 // have the focus and add text with key events should be possible.
1356 TextField field = TextField::New();
1357 DALI_TEST_CHECK( field );
1359 Stage::GetCurrent().Add( field );
1361 field.SetSize( 300.f, 50.f );
1362 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1363 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1365 // Avoid a crash when core load gl resources.
1366 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1368 // Render and notify
1369 application.SendNotification();
1370 application.Render();
1372 // Add a key event but as the text field has not the focus it should do nothing.
1373 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1375 // Render and notify
1376 application.SendNotification();
1377 application.Render();
1379 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1381 // Create a tap event to touch the text field.
1382 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1383 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1385 // Render and notify
1386 application.SendNotification();
1387 application.Render();
1389 // Now the text field has the focus, so it can handle the key events.
1390 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1391 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1393 // Render and notify
1394 application.SendNotification();
1395 application.Render();
1397 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1399 // Create a second text field and send key events to it.
1400 TextField field2 = TextField::New();
1402 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1403 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1404 field2.SetSize( 100.f, 100.f );
1405 field2.SetPosition( 100.f, 100.f );
1407 Stage::GetCurrent().Add( field2 );
1409 // Render and notify
1410 application.SendNotification();
1411 application.Render();
1413 // Create a tap event on the second text field.
1414 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1415 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1417 // Render and notify
1418 application.SendNotification();
1419 application.Render();
1421 // The second text field has the focus. It should handle the key events.
1422 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1423 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1425 // Render and notify
1426 application.SendNotification();
1427 application.Render();
1429 // Check the text has been added to the second text field.
1430 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1435 int utcDaliTextFieldEvent02(void)
1437 ToolkitTestApplication application;
1438 tet_infoline(" utcDaliTextFieldEvent02");
1440 // Checks if the right number of actors are created.
1442 TextField field = TextField::New();
1443 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1444 DALI_TEST_CHECK( field );
1445 LoadMarkerImages(application, field);
1447 Stage::GetCurrent().Add( field );
1449 field.SetSize( 300.f, 50.f );
1450 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1451 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1453 // Avoid a crash when core load gl resources.
1454 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1456 // Render and notify
1457 application.SendNotification();
1458 application.Render();
1460 // Check there are the expected number of children ( stencil ).
1461 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1463 Actor stencil = field.GetChildAt( 0u );
1464 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1466 // Create a tap event to touch the text field.
1467 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1468 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1470 // Render and notify
1471 application.SendNotification();
1472 application.Render();
1474 Actor layer = field.GetChildAt( 1u );
1475 DALI_TEST_CHECK( layer.IsLayer() );
1477 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1478 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1480 // Now the text field has the focus, so it can handle the key events.
1481 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1482 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1484 // Render and notify
1485 application.SendNotification();
1486 application.Render();
1488 // Checks the cursor and the renderer have been created.
1489 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1490 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1492 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1493 DALI_TEST_CHECK( cursor );
1495 // The offscreen root actor has a container with all the actors which contain the text renderers.
1496 Actor container = stencil.GetChildAt( 0u );
1497 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1499 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1500 DALI_TEST_CHECK( renderer );
1503 // Move the cursor and check the position changes.
1504 Vector3 position1 = cursor.GetCurrentPosition();
1506 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1507 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1509 // Render and notify
1510 application.SendNotification();
1511 application.Render();
1513 Vector3 position2 = cursor.GetCurrentPosition();
1515 DALI_TEST_CHECK( position2.x < position1.x );
1517 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1518 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1520 // Render and notify
1521 application.SendNotification();
1522 application.Render();
1524 Vector3 position3 = cursor.GetCurrentPosition();
1526 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1528 // Send some taps and check the cursor positions.
1530 // Try to tap at the beginning.
1531 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1532 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1534 // Render and notify
1535 application.SendNotification();
1536 application.Render();
1538 // Cursor position should be the same than position1.
1539 Vector3 position4 = cursor.GetCurrentPosition();
1541 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1543 // Tap away from the start position.
1544 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1545 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1547 // Render and notify
1548 application.SendNotification();
1549 application.Render();
1551 Vector3 position5 = cursor.GetCurrentPosition();
1553 DALI_TEST_CHECK( position5.x > position4.x );
1555 // Remove all the text.
1556 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1557 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1558 field.SetProperty( TextField::Property::TEXT, "" );
1560 // Render and notify
1561 application.SendNotification();
1562 application.Render();
1564 // Cursor position should be the same than position2.
1565 Vector3 position6 = cursor.GetCurrentPosition();
1567 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1569 // Should not be a renderer.
1570 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1575 int utcDaliTextFieldEvent03(void)
1577 ToolkitTestApplication application;
1578 tet_infoline(" utcDaliTextFieldEvent03");
1580 // Checks if the highlight actor is created.
1582 TextField field = TextField::New();
1583 DALI_TEST_CHECK( field );
1585 Stage::GetCurrent().Add( field );
1587 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1588 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1589 field.SetSize( 30.f, 50.f );
1590 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1591 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1593 // Avoid a crash when core load gl resources.
1594 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1595 LoadMarkerImages(application, field);
1597 // Render and notify
1598 application.SendNotification();
1599 application.Render();
1601 // Tap first to get the focus.
1602 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1603 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1605 // Render and notify
1606 application.SendNotification();
1607 application.Render();
1609 // Double tap to select a word.
1610 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1611 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1613 // Render and notify
1614 application.SendNotification();
1615 application.Render();
1617 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1618 Actor stencil = field.GetChildAt( 0u );
1620 // The offscreen root actor has a container with all the actors which contain the text renderers.
1621 Actor container = stencil.GetChildAt( 0u );
1622 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1624 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1625 DALI_TEST_CHECK( renderer );
1628 Renderer highlight = stencil.GetChildAt( 1u ).GetRendererAt( 0u );
1629 DALI_TEST_CHECK( highlight );
1634 int utcDaliTextFieldEvent04(void)
1636 ToolkitTestApplication application;
1637 tet_infoline(" utcDaliTextFieldEvent04");
1639 // Checks if the highlight actor is created.
1641 TextField field = TextField::New();
1642 DALI_TEST_CHECK( field );
1643 Stage::GetCurrent().Add( field );
1644 LoadMarkerImages(application, field);
1645 // Render and notify
1646 application.SendNotification();
1647 application.Render();
1649 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1650 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1651 field.SetSize( 300.f, 50.f );
1652 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1653 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1655 // Avoid a crash when core load gl resources.
1656 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1657 // Render and notify
1658 application.SendNotification();
1659 application.Render();
1661 // Create a tap event to touch the text field.
1662 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1663 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1664 // Render and notify
1665 application.SendNotification();
1666 application.Render();
1669 // Tap first to get the focus.
1670 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1671 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1673 // Render and notify
1674 application.SendNotification();
1675 application.Render();
1677 // Double tap to select a word.
1678 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1679 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1681 // Render and notify
1682 application.SendNotification();
1683 application.Render();
1686 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1687 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1691 int utcDaliTextFieldEvent05(void)
1693 ToolkitTestApplication application;
1694 tet_infoline(" utcDaliTextFieldEvent05");
1696 // Checks dragging of cursor/grab handle
1698 TextField field = TextField::New();
1699 DALI_TEST_CHECK( field );
1700 Stage::GetCurrent().Add( field );
1701 LoadMarkerImages(application, field);
1702 // Render and notify
1703 application.SendNotification();
1704 application.Render();
1706 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1707 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1708 field.SetSize( 300.f, 50.f );
1709 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1710 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1712 // Avoid a crash when core load gl resources.
1713 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1714 // Render and notify
1715 application.SendNotification();
1716 application.Render();
1718 // Create a tap event to touch the text field.
1719 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1720 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1721 // Render and notify
1722 application.SendNotification();
1723 application.Render();
1726 // Tap first to get the focus.
1727 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1728 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1730 // Render and notify
1731 application.SendNotification();
1732 application.Render();
1734 // Double tap to select a word.
1735 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1736 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1738 // Render and notify
1739 application.SendNotification();
1740 application.Render();
1742 // drag grab handle right
1743 Vector2 pos(0.0f, 40.0f);
1744 SendPan(application, Gesture::Possible, pos);
1745 SendPan(application, Gesture::Started, pos);
1747 Wait(application, 100);
1749 for(int i = 0;i<20;i++)
1751 SendPan(application, Gesture::Continuing, pos);
1756 SendPan(application, Gesture::Finished, pos);
1757 Wait(application, RENDER_FRAME_INTERVAL);
1759 Actor stencil = field.GetChildAt( 1u );
1763 int utcDaliTextFieldEvent06(void)
1765 ToolkitTestApplication application;
1766 tet_infoline(" utcDaliTextFieldEvent06");
1768 // Checks Longpress when in edit mode
1770 TextField field = TextField::New();
1771 DALI_TEST_CHECK( field );
1772 Stage::GetCurrent().Add( field );
1773 LoadMarkerImages(application, field);
1774 // Render and notify
1775 application.SendNotification();
1776 application.Render();
1778 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1779 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1780 field.SetSize( 300.f, 50.f );
1781 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1782 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1784 // Avoid a crash when core load gl resources.
1785 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1786 // Render and notify
1787 application.SendNotification();
1788 application.Render();
1790 // Create a tap event to touch the text field.
1791 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1792 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1793 // Render and notify
1794 application.SendNotification();
1795 application.Render();
1798 // Tap first to get the focus.
1799 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1800 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1802 // Render and notify
1803 application.SendNotification();
1804 application.Render();
1807 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1808 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1810 // Render and notify
1811 application.SendNotification();
1812 application.Render();
1817 int utcDaliTextFieldEvent07(void)
1819 ToolkitTestApplication application;
1820 tet_infoline(" utcDaliTextFieldEvent07");
1822 // Checks Longpress to start edit mode
1824 TextField field = TextField::New();
1825 DALI_TEST_CHECK( field );
1826 Stage::GetCurrent().Add( field );
1827 LoadMarkerImages(application, field);
1828 // Render and notify
1829 application.SendNotification();
1830 application.Render();
1832 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1833 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1834 field.SetSize( 300.f, 50.f );
1835 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1836 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1838 // Avoid a crash when core load gl resources.
1839 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1840 // Render and notify
1841 application.SendNotification();
1842 application.Render();
1845 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1846 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1848 // Render and notify
1849 application.SendNotification();
1850 application.Render();
1855 int utcDaliTextFieldEvent08(void)
1857 ToolkitTestApplication application;
1858 tet_infoline(" utcDaliTextFieldEvent08");
1860 Dali::Clipboard clipboard = Clipboard::Get();
1861 clipboard.SetItem("testTextFieldEvent");
1863 // Checks Longpress when only place holder text
1865 TextField field = TextField::New();
1866 DALI_TEST_CHECK( field );
1867 Stage::GetCurrent().Add( field );
1868 LoadMarkerImages(application, field);
1869 // Render and notify
1870 application.SendNotification();
1871 application.Render();
1873 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
1874 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1875 field.SetSize( 300.f, 50.f );
1876 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1877 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1879 // Avoid a crash when core load gl resources.
1880 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1881 // Render and notify
1882 application.SendNotification();
1883 application.Render();
1886 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1887 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1889 // Render and notify
1890 application.SendNotification();
1891 application.Render();
1893 Wait(application, 500);
1895 Stage stage = Stage::GetCurrent();
1896 Layer layer = stage.GetRootLayer();
1897 Actor actor = layer.FindChildByName("optionPaste");
1901 Vector3 worldPosition = actor.GetCurrentWorldPosition();
1902 Vector2 halfStageSize = stage.GetSize() / 2.0f;
1903 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
1905 Dali::Integration::TouchEvent event;
1906 event = Dali::Integration::TouchEvent();
1907 event.AddPoint( GetPointDownInside( position ) );
1908 application.ProcessEvent( event );
1910 event = Dali::Integration::TouchEvent();
1911 event.AddPoint( GetPointUpInside( position ) );
1912 application.ProcessEvent( event );
1914 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
1918 int utcDaliTextFieldStyleWhilstSelected(void)
1920 ToolkitTestApplication application;
1921 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
1923 // Change font and styles whilst text is selected whilst word selected
1925 TextField field = TextField::New();
1926 DALI_TEST_CHECK( field );
1927 Stage::GetCurrent().Add( field );
1928 LoadMarkerImages(application, field);
1929 // Render and notify
1930 application.SendNotification();
1931 application.Render();
1933 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1934 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1935 field.SetSize( 300.f, 50.f );
1936 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1937 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1939 // Avoid a crash when core load gl resources.
1940 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1941 // Render and notify
1942 application.SendNotification();
1943 application.Render();
1945 // Create a tap event to touch the text field.
1946 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1947 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1948 // Render and notify
1949 application.SendNotification();
1950 application.Render();
1953 // Tap first to get the focus.
1954 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1955 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1957 // Render and notify
1958 application.SendNotification();
1959 application.Render();
1961 // Double tap to select a word.
1962 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1963 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1965 // Render and notify
1966 application.SendNotification();
1967 application.Render();
1969 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
1970 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
1972 Property::Map fontStyleMapSet;
1973 Property::Map fontStyleMapGet;
1975 fontStyleMapSet.Insert( "weight", "bold" );
1976 fontStyleMapSet.Insert( "slant", "italic" );
1977 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1979 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
1980 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1981 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1983 fontStyleMapSet.Clear();
1984 fontStyleMapSet.Insert( "width", "expanded" );
1985 fontStyleMapSet.Insert( "slant", "italic" );
1986 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1988 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
1989 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1990 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1992 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
1993 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1995 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
1996 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
1998 fontStyleMapSet.Clear();
1999 fontStyleMapSet.Insert( "weight", "bold" );
2000 fontStyleMapSet.Insert( "slant", "italic" );
2002 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2004 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2005 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2006 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2008 fontStyleMapSet.Clear();
2009 fontStyleMapSet.Insert( "width", "expanded" );
2011 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2013 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2014 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2015 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2017 // Press Escape to increase coverage
2018 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up ) );
2019 application.SendNotification();
2020 application.Render();
2022 DALI_TEST_CHECK( !field.HasKeyInputFocus() );