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::ResourceRequest* request = platform.GetRequest();
122 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
123 Integration::ResourcePointer resource(bitmap);
124 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
128 platform.SetResourceLoaded(request->GetId(), request->GetType()->id, resource);
132 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
136 LoadBitmapResource( app.GetPlatform(), width, height );
138 Property::Map propertyMap;
139 propertyMap["filename"] = "image.png";
140 propertyMap["width"] = width;
141 propertyMap["height"] = height;
142 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
143 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
144 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
145 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
146 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
147 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
148 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
149 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
152 // Generate a PanGestureEvent to send to Core
153 static Integration::PanGestureEvent GeneratePan(
154 Gesture::State state,
155 const Vector2& previousPosition,
156 const Vector2& currentPosition,
157 unsigned long timeDelta,
158 unsigned int numberOfTouches = 1)
160 Integration::PanGestureEvent pan(state);
162 pan.previousPosition = previousPosition;
163 pan.currentPosition = currentPosition;
164 pan.timeDelta = timeDelta;
165 pan.numberOfTouches = numberOfTouches;
171 * Helper to generate PanGestureEvent
173 * @param[in] application Application instance
174 * @param[in] state The Gesture State
175 * @param[in] pos The current position of touch.
177 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
181 if( (state == Gesture::Started) ||
182 (state == Gesture::Possible) )
188 application.ProcessEvent(GeneratePan(state, last, pos, 16));
195 * Simulate time passed by.
197 * @note this will always process at least 1 frame (1/60 sec)
199 * @param application Test application instance
200 * @param duration Time to pass in milliseconds.
201 * @return The actual time passed in milliseconds
203 static int Wait(ToolkitTestApplication& application, int duration = 0)
207 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
209 application.SendNotification();
210 application.Render(RENDER_FRAME_INTERVAL);
211 time += RENDER_FRAME_INTERVAL;
217 Dali::Integration::Point GetPointDownInside( Vector2& pos )
219 Dali::Integration::Point point;
220 point.SetState( PointState::DOWN );
221 point.SetScreenPosition( pos );
225 Dali::Integration::Point GetPointUpInside( Vector2& pos )
227 Dali::Integration::Point point;
228 point.SetState( PointState::UP );
229 point.SetScreenPosition( pos );
233 struct CallbackFunctor
235 CallbackFunctor(bool* callbackFlag)
236 : mCallbackFlag( callbackFlag )
242 *mCallbackFlag = true;
247 static void TestTextChangedCallback( TextField control )
249 tet_infoline(" TestTextChangedCallback");
251 gTextChangedCallBackCalled = true;
254 static void TestMaxLengthReachedCallback( TextField control )
256 tet_infoline(" TestMaxLengthReachedCallback");
258 gMaxCharactersCallBackCalled = true;
261 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
263 tet_infoline(" TestInputStyleChangedCallback");
265 gInputStyleChangedCallbackCalled = true;
266 gInputStyleMask = mask;
269 // Generate a TapGestureEvent to send to Core.
270 Integration::TapGestureEvent GenerateTap(
271 Gesture::State state,
272 unsigned int numberOfTaps,
273 unsigned int numberOfTouches,
276 Integration::TapGestureEvent tap( state );
278 tap.numberOfTaps = numberOfTaps;
279 tap.numberOfTouches = numberOfTouches;
285 Integration::LongPressGestureEvent GenerateLongPress(
286 Gesture::State state,
287 unsigned int numberOfTouches,
290 Integration::LongPressGestureEvent longPress( state );
292 longPress.numberOfTouches = numberOfTouches;
293 longPress.point = point;
297 // Generate a KeyEvent to send to Core.
298 Integration::KeyEvent GenerateKey( const std::string& keyName,
299 const std::string& keyString,
302 unsigned long timeStamp,
303 const Integration::KeyEvent::State& keyState )
305 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 = fontStyleMapSet.Find( valueGet.first.stringKey );
322 if( NULL != valueSet )
324 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
326 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
332 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
343 int UtcDaliToolkitTextFieldConstructorP(void)
345 ToolkitTestApplication application;
346 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
348 DALI_TEST_CHECK( !textField );
352 int UtcDaliToolkitTextFieldNewP(void)
354 ToolkitTestApplication application;
355 tet_infoline(" UtcDaliToolkitTextFieldNewP");
356 TextField textField = TextField::New();
357 DALI_TEST_CHECK( textField );
361 int UtcDaliToolkitTextFieldDownCastP(void)
363 ToolkitTestApplication application;
364 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
365 TextField textField1 = TextField::New();
366 BaseHandle object( textField1 );
368 TextField textField2 = TextField::DownCast( object );
369 DALI_TEST_CHECK( textField2 );
371 TextField textField3 = DownCast< TextField >( object );
372 DALI_TEST_CHECK( textField3 );
376 int UtcDaliToolkitTextFieldDownCastN(void)
378 ToolkitTestApplication application;
379 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
380 BaseHandle uninitializedObject;
381 TextField textField1 = TextField::DownCast( uninitializedObject );
382 DALI_TEST_CHECK( !textField1 );
384 TextField textField2 = DownCast< TextField >( uninitializedObject );
385 DALI_TEST_CHECK( !textField2 );
389 int UtcDaliToolkitTextFieldCopyConstructorP(void)
391 ToolkitTestApplication application;
392 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
393 TextField textField = TextField::New();
394 textField.SetProperty( TextField::Property::TEXT, "Test" );
396 TextField copy( textField );
397 DALI_TEST_CHECK( copy );
398 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
402 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
404 ToolkitTestApplication application;
405 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
406 TextField textField = TextField::New();
407 textField.SetProperty( TextField::Property::TEXT, "Test" );
409 TextField copy = textField;
410 DALI_TEST_CHECK( copy );
411 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
415 int UtcDaliTextFieldNewP(void)
417 ToolkitTestApplication application;
418 tet_infoline(" UtcDaliToolkitTextFieldNewP");
419 TextField textField = TextField::New();
420 DALI_TEST_CHECK( textField );
424 // Positive test case for a method
425 int UtcDaliTextFieldGetPropertyP(void)
427 ToolkitTestApplication application;
428 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
429 TextField field = TextField::New();
430 DALI_TEST_CHECK( field );
432 // Check Property Indices are correct
433 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
434 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
435 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
436 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
437 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
438 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
439 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
440 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
441 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
442 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
443 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
444 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
445 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
446 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextField::Property::SHADOW_OFFSET );
447 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextField::Property::SHADOW_COLOR );
448 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
449 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
450 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
451 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
452 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
453 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
454 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
455 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
456 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
457 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
458 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
459 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
460 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
461 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
462 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
463 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
464 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
465 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
466 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
467 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
468 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
469 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
470 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
471 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
472 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
473 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
474 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
475 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
476 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
477 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
478 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
479 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
484 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
487 Property::Map imageMap;
488 imageMap[mapKey] =mapValue;
490 field.SetProperty( property , imageMap );
491 Property::Value propValue = field.GetProperty( property );
492 Property::Map* resultMap = propValue.GetMap();
494 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
502 // Positive test case for a method
503 int UtcDaliTextFieldSetPropertyP(void)
505 ToolkitTestApplication application;
506 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
507 TextField field = TextField::New();
508 DALI_TEST_CHECK( field );
509 Stage::GetCurrent().Add( field );
511 // Note - we can't check the defaults since the stylesheets are platform-specific
513 // Check the render backend property.
514 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
515 DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
517 // Check text property.
518 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
519 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
521 // Check placeholder text properties.
522 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
523 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
525 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
526 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
528 // Check font properties.
529 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
530 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
532 Property::Map fontStyleMapSet;
533 Property::Map fontStyleMapGet;
534 Property::Value* slantValue = NULL;
536 fontStyleMapSet.Insert( "weight", "bold" );
537 fontStyleMapSet.Insert( "width", "condensed" );
538 fontStyleMapSet.Insert( "slant", "italic" );
539 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
541 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
542 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
543 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
545 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
546 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
549 fontStyleMapSet.Clear();
550 fontStyleMapSet.Insert( "weight", "normal" );
551 fontStyleMapSet.Insert( "slant", "oblique" );
552 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
554 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
555 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
556 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
558 fontStyleMapSet.Clear();
559 fontStyleMapSet.Insert( "slant", "roman" );
560 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
561 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
563 // Replace 'roman' for 'normal'.
564 slantValue = fontStyleMapGet.Find( "slant" );
565 if( NULL != slantValue )
567 if( "normal" == slantValue->Get<std::string>() )
569 fontStyleMapGet["slant"] = "roman";
572 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
573 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
575 fontStyleMapSet.Clear();
577 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
578 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
579 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
580 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
582 // Check that the MAX_LENGTH property can be correctly set
583 const int maxNumberOfCharacters = 20;
584 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
585 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
587 // Check exceed policy
588 // Set a different exceed policy is not implemented.
590 // Check that the Alignment properties can be correctly set
591 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
592 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
593 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
594 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
596 // Check text's color property
597 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
598 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
600 // Check placeholder text's color property.
601 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
602 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
604 // Check shadow properties.
605 field.SetProperty( TextField::Property::SHADOW_OFFSET, Vector2( 1.f, 1.f ) );
606 DALI_TEST_EQUALS( field.GetProperty<Vector2>( TextField::Property::SHADOW_OFFSET ), Vector2( 1.f, 1.f ), TEST_LOCATION );
607 field.SetProperty( TextField::Property::SHADOW_COLOR, Color::GREEN );
608 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SHADOW_COLOR ), Color::GREEN, TEST_LOCATION );
610 // Check cursor properties
611 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
612 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
613 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
614 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
616 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
617 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
618 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
619 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
620 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
621 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
622 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
623 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
625 // Check scroll properties.
626 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
627 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
628 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
629 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
631 // Check handle images
632 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
633 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
634 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
635 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
636 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
638 // Check handle images
639 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
640 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
641 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
642 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
643 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
644 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
646 // Check the highlight color
647 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
648 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
650 // Decoration bounding box
651 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
652 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
654 // Check input color property.
655 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
656 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
658 // Check the enable markup property.
659 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
660 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
661 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
663 // Check input font properties.
664 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
665 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
667 fontStyleMapSet.Clear();
668 fontStyleMapSet.Insert( "weight", "bold" );
669 fontStyleMapSet.Insert( "width", "condensed" );
670 fontStyleMapSet.Insert( "slant", "italic" );
672 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
673 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
674 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
675 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
677 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
678 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
680 // Reset input font style.
681 fontStyleMapSet.Clear();
682 fontStyleMapSet.Insert( "weight", "normal" );
683 fontStyleMapSet.Insert( "slant", "oblique" );
685 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
686 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
687 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
688 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
690 fontStyleMapSet.Clear();
691 fontStyleMapSet.Insert( "slant", "roman" );
693 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
694 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
696 // Replace 'roman' for 'normal'.
697 slantValue = fontStyleMapGet.Find( "slant" );
698 if( NULL != slantValue )
700 if( "normal" == slantValue->Get<std::string>() )
702 fontStyleMapGet["slant"] = "roman";
705 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
706 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
708 fontStyleMapSet.Clear();
710 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
711 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
712 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
713 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
715 // Check the underline property
716 field.SetProperty( TextField::Property::UNDERLINE, "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
717 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::UNDERLINE ), std::string("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}"), TEST_LOCATION );
719 // Check the input underline property
720 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
721 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
723 // Check the shadow property
724 field.SetProperty( TextField::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\"}" );
725 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::SHADOW ), std::string("{\"color\":\"green\",\"offset\":\"2 2\"}"), TEST_LOCATION );
727 // Check the input shadow property
728 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
729 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
731 // Check the emboss property
732 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
733 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
735 // Check the input emboss property
736 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
737 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
739 // Check the outline property
740 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
741 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
743 // Check the input outline property
744 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
745 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
750 // Positive Atlas Text Renderer test
751 int utcDaliTextFieldAtlasRenderP(void)
753 ToolkitTestApplication application;
754 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
755 StyleManager styleManager = StyleManager::Get();
756 styleManager.ApplyDefaultTheme();
757 TextField field = TextField::New();
758 DALI_TEST_CHECK( field );
760 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
762 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
764 Stage::GetCurrent().Add( field );
768 // Render some text with the shared atlas backend
769 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
770 application.SendNotification();
771 application.Render();
775 tet_result(TET_FAIL);
780 // Positive test for the textChanged signal.
781 int utcDaliTextFieldTextChangedP(void)
783 ToolkitTestApplication application;
784 tet_infoline(" utcDaliTextFieldTextChangedP");
785 TextField field = TextField::New();
786 DALI_TEST_CHECK( field );
788 Stage::GetCurrent().Add( field );
790 // connect to the text changed signal.
791 ConnectionTracker* testTracker = new ConnectionTracker();
792 field.TextChangedSignal().Connect(&TestTextChangedCallback);
793 bool textChangedSignal = false;
794 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
796 gTextChangedCallBackCalled = false;
797 field.SetProperty( TextField::Property::TEXT, "ABC" );
798 DALI_TEST_CHECK( gTextChangedCallBackCalled );
799 DALI_TEST_CHECK( textChangedSignal );
801 application.SendNotification();
803 field.SetKeyInputFocus();
805 gTextChangedCallBackCalled = false;
806 application.ProcessEvent( GenerateKey( "D", "D", 0, 0, 0, Integration::KeyEvent::Down ) );
807 DALI_TEST_CHECK( gTextChangedCallBackCalled );
812 // Negative test for the textChanged signal.
813 int utcDaliTextFieldTextChangedN(void)
815 ToolkitTestApplication application;
816 tet_infoline(" utcDaliTextFieldTextChangedN");
817 TextField field = TextField::New();
818 DALI_TEST_CHECK( field );
820 Stage::GetCurrent().Add( field );
822 // connect to the text changed signal.
823 ConnectionTracker* testTracker = new ConnectionTracker();
824 field.TextChangedSignal().Connect(&TestTextChangedCallback);
825 bool textChangedSignal = false;
826 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
828 gTextChangedCallBackCalled = false;
829 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
830 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
831 DALI_TEST_CHECK( !textChangedSignal );
836 // Positive test for Max Characters reached signal.
837 int utcDaliTextFieldMaxCharactersReachedP(void)
839 ToolkitTestApplication application;
840 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
841 TextField field = TextField::New();
842 DALI_TEST_CHECK( field );
844 Stage::GetCurrent().Add( field );
846 const int maxNumberOfCharacters = 1;
847 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
849 field.SetKeyInputFocus();
851 // connect to the text changed signal.
852 ConnectionTracker* testTracker = new ConnectionTracker();
853 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
854 bool maxLengthReachedSignal = false;
855 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
857 gMaxCharactersCallBackCalled = false;
859 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
860 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
862 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
863 DALI_TEST_CHECK( maxLengthReachedSignal );
868 // Negative test for Max Characters reached signal.
869 int utcDaliTextFieldMaxCharactersReachedN(void)
871 ToolkitTestApplication application;
872 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
873 TextField field = TextField::New();
874 DALI_TEST_CHECK( field );
876 Stage::GetCurrent().Add( field );
878 const int maxNumberOfCharacters = 3;
879 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
881 field.SetKeyInputFocus();
883 // connect to the text changed signal.
884 ConnectionTracker* testTracker = new ConnectionTracker();
885 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
886 bool maxLengthReachedSignal = false;
887 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
889 gMaxCharactersCallBackCalled = false;
891 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
892 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
894 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
895 DALI_TEST_CHECK( !maxLengthReachedSignal );
900 int utcDaliTextFieldInputStyleChanged01(void)
902 ToolkitTestApplication application;
903 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
905 // The text-field emits signals when the input style changes. These changes of style are
906 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
907 // can't be emitted during the size negotiation as the callbacks may update the UI.
908 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
909 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
910 application.CreateAdaptor();
914 char* pathNamePtr = get_current_dir_name();
915 const std::string pathName( pathNamePtr );
918 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
919 fontClient.SetDpi( 93u, 93u );
921 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
922 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
924 TextField field = TextField::New();
925 DALI_TEST_CHECK( field );
928 field.SetSize( 300.f, 50.f );
929 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
930 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
932 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
933 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
935 // connect to the text changed signal.
936 ConnectionTracker* testTracker = new ConnectionTracker();
937 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
938 bool inputStyleChangedSignal = false;
939 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
941 Stage::GetCurrent().Add( field );
944 application.SendNotification();
945 application.Render();
947 // Executes the idle callbacks added by the text control on the change of input style.
948 application.RunIdles();
950 gInputStyleChangedCallbackCalled = false;
951 gInputStyleMask = TextField::InputStyle::NONE;
952 inputStyleChangedSignal = false;
954 // Create a tap event to touch the text field.
955 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
956 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
959 application.SendNotification();
960 application.Render();
962 // Executes the idle callbacks added by the text control on the change of input style.
963 application.RunIdles();
965 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
966 if( gInputStyleChangedCallbackCalled )
968 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
970 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
971 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
973 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
974 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
976 DALI_TEST_CHECK( inputStyleChangedSignal );
978 gInputStyleChangedCallbackCalled = false;
979 gInputStyleMask = TextField::InputStyle::NONE;
980 inputStyleChangedSignal = false;
982 // Create a tap event to touch the text field.
983 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
984 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
987 application.SendNotification();
988 application.Render();
990 // Executes the idle callbacks added by the text control on the change of input style.
991 application.RunIdles();
993 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
994 DALI_TEST_CHECK( !inputStyleChangedSignal );
996 gInputStyleChangedCallbackCalled = false;
997 gInputStyleMask = TextField::InputStyle::NONE;
998 inputStyleChangedSignal = false;
1000 // Create a tap event to touch the text field.
1001 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1002 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1004 // Render and notify
1005 application.SendNotification();
1006 application.Render();
1008 // Executes the idle callbacks added by the text control on the change of input style.
1009 application.RunIdles();
1011 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1012 if( gInputStyleChangedCallbackCalled )
1014 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1016 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1017 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1019 DALI_TEST_CHECK( inputStyleChangedSignal );
1021 gInputStyleChangedCallbackCalled = false;
1022 gInputStyleMask = TextField::InputStyle::NONE;
1023 inputStyleChangedSignal = false;
1025 // Create a tap event to touch the text field.
1026 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1027 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1029 // Render and notify
1030 application.SendNotification();
1031 application.Render();
1033 // Executes the idle callbacks added by the text control on the change of input style.
1034 application.RunIdles();
1036 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1037 if( gInputStyleChangedCallbackCalled )
1039 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1041 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1042 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1044 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1046 Property::Map fontStyleMapSet;
1047 fontStyleMapSet.Insert( "weight", "bold" );
1049 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1050 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1052 DALI_TEST_CHECK( inputStyleChangedSignal );
1054 gInputStyleChangedCallbackCalled = false;
1055 gInputStyleMask = TextField::InputStyle::NONE;
1056 inputStyleChangedSignal = false;
1058 // Create a tap event to touch the text field.
1059 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1060 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1062 // Render and notify
1063 application.SendNotification();
1064 application.Render();
1066 // Executes the idle callbacks added by the text control on the change of input style.
1067 application.RunIdles();
1069 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1070 DALI_TEST_CHECK( !inputStyleChangedSignal );
1072 gInputStyleChangedCallbackCalled = false;
1073 gInputStyleMask = TextField::InputStyle::NONE;
1074 inputStyleChangedSignal = false;
1076 // Create a tap event to touch the text field.
1077 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1078 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1080 // Render and notify
1081 application.SendNotification();
1082 application.Render();
1084 // Executes the idle callbacks added by the text control on the change of input style.
1085 application.RunIdles();
1087 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1088 if( gInputStyleChangedCallbackCalled )
1090 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1092 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1093 DALI_TEST_CHECK( style.empty() );
1095 DALI_TEST_CHECK( inputStyleChangedSignal );
1097 gInputStyleChangedCallbackCalled = false;
1098 gInputStyleMask = TextField::InputStyle::NONE;
1099 inputStyleChangedSignal = false;
1101 // Create a tap event to touch the text field.
1102 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1103 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1105 // Render and notify
1106 application.SendNotification();
1107 application.Render();
1109 // Executes the idle callbacks added by the text control on the change of input style.
1110 application.RunIdles();
1112 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1113 DALI_TEST_CHECK( !inputStyleChangedSignal );
1118 int utcDaliTextFieldInputStyleChanged02(void)
1120 ToolkitTestApplication application;
1121 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1123 // The text-field emits signals when the input style changes. These changes of style are
1124 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1125 // can't be emitted during the size negotiation as the callbacks may update the UI.
1126 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1127 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1128 application.CreateAdaptor();
1132 char* pathNamePtr = get_current_dir_name();
1133 const std::string pathName( pathNamePtr );
1134 free( pathNamePtr );
1136 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1137 fontClient.SetDpi( 93u, 93u );
1139 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1140 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1142 TextField field = TextField::New();
1143 DALI_TEST_CHECK( field );
1146 field.SetSize( 300.f, 50.f );
1147 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1148 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1150 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1151 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>" );
1153 // connect to the text changed signal.
1154 ConnectionTracker* testTracker = new ConnectionTracker();
1155 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1156 bool inputStyleChangedSignal = false;
1157 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1159 Stage::GetCurrent().Add( field );
1161 // Render and notify
1162 application.SendNotification();
1163 application.Render();
1165 // Executes the idle callbacks added by the text control on the change of input style.
1166 application.RunIdles();
1168 gInputStyleChangedCallbackCalled = false;
1169 gInputStyleMask = TextField::InputStyle::NONE;
1170 inputStyleChangedSignal = false;
1172 // Create a tap event to touch the text field.
1173 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1174 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1175 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1176 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1178 // Render and notify
1179 application.SendNotification();
1180 application.Render();
1182 // Executes the idle callbacks added by the text control on the change of input style.
1183 application.RunIdles();
1185 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1186 if( gInputStyleChangedCallbackCalled )
1188 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1189 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1190 TextField::InputStyle::POINT_SIZE |
1191 TextField::InputStyle::COLOR ),
1194 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1195 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1197 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1198 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1200 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1201 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1203 DALI_TEST_CHECK( inputStyleChangedSignal );
1205 gInputStyleChangedCallbackCalled = false;
1206 gInputStyleMask = TextField::InputStyle::NONE;
1207 inputStyleChangedSignal = false;
1209 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1211 // Render and notify
1212 application.SendNotification();
1213 application.Render();
1215 // Executes the idle callbacks added by the text control on the change of input style.
1216 application.RunIdles();
1218 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1219 if( gInputStyleChangedCallbackCalled )
1221 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1222 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1225 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1226 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1228 DALI_TEST_CHECK( inputStyleChangedSignal );
1230 gInputStyleChangedCallbackCalled = false;
1231 gInputStyleMask = TextField::InputStyle::NONE;
1232 inputStyleChangedSignal = false;
1234 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1236 // Render and notify
1237 application.SendNotification();
1238 application.Render();
1240 // Executes the idle callbacks added by the text control on the change of input style.
1241 application.RunIdles();
1243 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
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 if( gInputStyleChangedCallbackCalled )
1262 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1263 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1266 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1267 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1269 DALI_TEST_CHECK( inputStyleChangedSignal );
1271 gInputStyleChangedCallbackCalled = false;
1272 gInputStyleMask = TextField::InputStyle::NONE;
1273 inputStyleChangedSignal = false;
1275 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1277 Property::Map fontStyleMapSet;
1278 fontStyleMapSet.Insert( "weight", "thin" );
1279 fontStyleMapSet.Insert( "width", "condensed" );
1280 fontStyleMapSet.Insert( "slant", "italic" );
1282 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1283 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1285 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1286 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1287 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1288 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1290 // Render and notify
1291 application.SendNotification();
1292 application.Render();
1294 // Executes the idle callbacks added by the text control on the change of input style.
1295 application.RunIdles();
1297 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1298 DALI_TEST_CHECK( !inputStyleChangedSignal );
1300 // Create a tap event to touch the text field.
1301 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1302 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1304 // Render and notify
1305 application.SendNotification();
1306 application.Render();
1308 // Executes the idle callbacks added by the text control on the change of input style.
1309 application.RunIdles();
1311 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1312 if( gInputStyleChangedCallbackCalled )
1314 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1315 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1316 TextField::InputStyle::POINT_SIZE |
1317 TextField::InputStyle::FONT_STYLE |
1318 TextField::InputStyle::UNDERLINE |
1319 TextField::InputStyle::SHADOW |
1320 TextField::InputStyle::EMBOSS |
1321 TextField::InputStyle::OUTLINE ),
1324 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1325 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1327 DALI_TEST_CHECK( inputStyleChangedSignal );
1332 int utcDaliTextFieldEvent01(void)
1334 ToolkitTestApplication application;
1335 tet_infoline(" utcDaliTextFieldEvent01");
1337 // Creates a tap event. After creating a tap event the text field should
1338 // have the focus and add text with key events should be possible.
1340 TextField field = TextField::New();
1341 DALI_TEST_CHECK( field );
1343 Stage::GetCurrent().Add( field );
1345 field.SetSize( 300.f, 50.f );
1346 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1347 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1349 // Avoid a crash when core load gl resources.
1350 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1352 // Render and notify
1353 application.SendNotification();
1354 application.Render();
1356 // Add a key event but as the text field has not the focus it should do nothing.
1357 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1359 // Render and notify
1360 application.SendNotification();
1361 application.Render();
1363 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1365 // Create a tap event to touch the text field.
1366 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1367 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1369 // Render and notify
1370 application.SendNotification();
1371 application.Render();
1373 // Now the text field has the focus, so it can handle the key events.
1374 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1375 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1377 // Render and notify
1378 application.SendNotification();
1379 application.Render();
1381 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1383 // Create a second text field and send key events to it.
1384 TextField field2 = TextField::New();
1386 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1387 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1388 field2.SetSize( 100.f, 100.f );
1389 field2.SetPosition( 100.f, 100.f );
1391 Stage::GetCurrent().Add( field2 );
1393 // Render and notify
1394 application.SendNotification();
1395 application.Render();
1397 // Create a tap event on the second text field.
1398 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1399 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1401 // Render and notify
1402 application.SendNotification();
1403 application.Render();
1405 // The second text field has the focus. It should handle the key events.
1406 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1407 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1409 // Render and notify
1410 application.SendNotification();
1411 application.Render();
1413 // Check the text has been added to the second text field.
1414 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1419 int utcDaliTextFieldEvent02(void)
1421 ToolkitTestApplication application;
1422 tet_infoline(" utcDaliTextFieldEvent02");
1424 // Checks if the right number of actors are created.
1426 TextField field = TextField::New();
1427 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1428 DALI_TEST_CHECK( field );
1429 LoadMarkerImages(application, field);
1431 Stage::GetCurrent().Add( field );
1433 field.SetSize( 300.f, 50.f );
1434 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1435 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1437 // Avoid a crash when core load gl resources.
1438 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1440 // Render and notify
1441 application.SendNotification();
1442 application.Render();
1444 // Check there are the expected number of children ( offscreen root actor, and the offscreen image view
1445 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1447 Actor offscreenRoot = field.GetChildAt( 0u );
1448 DALI_TEST_CHECK( offscreenRoot.IsLayer() );
1449 DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor.
1451 Actor offscreenImage = field.GetChildAt( 1u );
1452 DALI_TEST_CHECK( offscreenImage );
1454 // Create a tap event to touch the text field.
1455 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1456 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1458 // Render and notify
1459 application.SendNotification();
1460 application.Render();
1462 Actor layer = field.GetChildAt( 2u );
1463 DALI_TEST_CHECK( layer.IsLayer() );
1465 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1466 DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor.
1468 // Now the text field has the focus, so it can handle the key events.
1469 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1470 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1472 // Render and notify
1473 application.SendNotification();
1474 application.Render();
1476 // Checks the cursor and the renderer have been created.
1477 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1478 DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 2u, TEST_LOCATION ); // The camera actor and the renderer
1480 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1481 DALI_TEST_CHECK( cursor );
1483 CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) );
1484 DALI_TEST_CHECK( camera );
1486 // The offscreen root actor has a container with all the actors which contain the text renderers.
1487 Actor container = offscreenRoot.GetChildAt( 1u );
1488 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1490 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1491 DALI_TEST_CHECK( renderer );
1494 // Move the cursor and check the position changes.
1495 Vector3 position1 = cursor.GetCurrentPosition();
1497 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1498 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1500 // Render and notify
1501 application.SendNotification();
1502 application.Render();
1504 Vector3 position2 = cursor.GetCurrentPosition();
1506 DALI_TEST_CHECK( position2.x < position1.x );
1508 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1509 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1511 // Render and notify
1512 application.SendNotification();
1513 application.Render();
1515 Vector3 position3 = cursor.GetCurrentPosition();
1517 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1519 // Send some taps and check the cursor positions.
1521 // Try to tap at the beginning.
1522 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1523 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1525 // Render and notify
1526 application.SendNotification();
1527 application.Render();
1529 // Cursor position should be the same than position1.
1530 Vector3 position4 = cursor.GetCurrentPosition();
1532 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1534 // Tap away from the start position.
1535 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1536 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1538 // Render and notify
1539 application.SendNotification();
1540 application.Render();
1542 Vector3 position5 = cursor.GetCurrentPosition();
1544 DALI_TEST_CHECK( position5.x > position4.x );
1546 // Remove all the text.
1547 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1548 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1549 field.SetProperty( TextField::Property::TEXT, "" );
1551 // Render and notify
1552 application.SendNotification();
1553 application.Render();
1555 // Cursor position should be the same than position2.
1556 Vector3 position6 = cursor.GetCurrentPosition();
1558 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1560 // Should not be a renderer.
1561 DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor only.
1566 int utcDaliTextFieldEvent03(void)
1568 ToolkitTestApplication application;
1569 tet_infoline(" utcDaliTextFieldEvent03");
1571 // Checks if the highlight actor is created.
1573 TextField field = TextField::New();
1574 DALI_TEST_CHECK( field );
1576 Stage::GetCurrent().Add( field );
1578 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1579 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1580 field.SetSize( 30.f, 50.f );
1581 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1582 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1584 // Avoid a crash when core load gl resources.
1585 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1586 LoadMarkerImages(application, field);
1588 // Render and notify
1589 application.SendNotification();
1590 application.Render();
1592 // Tap first to get the focus.
1593 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1594 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1596 // Render and notify
1597 application.SendNotification();
1598 application.Render();
1600 // Double tap to select a word.
1601 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1602 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1604 // Render and notify
1605 application.SendNotification();
1606 application.Render();
1608 // The offscreen root actor should have three actors: the camera, a renderer and the highlight actor.
1609 Actor offscreenRoot = field.GetChildAt( 1u );
1610 DALI_TEST_CHECK( offscreenRoot.IsLayer() );
1612 CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) );
1613 DALI_TEST_CHECK( camera );
1615 // The offscreen root actor has a container with all the actors which contain the text renderers.
1616 Actor container = offscreenRoot.GetChildAt( 1u );
1617 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1619 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1620 DALI_TEST_CHECK( renderer );
1623 Renderer highlight = offscreenRoot.GetChildAt( 2u ).GetRendererAt( 0u );
1624 DALI_TEST_CHECK( highlight );
1629 int utcDaliTextFieldEvent04(void)
1631 ToolkitTestApplication application;
1632 tet_infoline(" utcDaliTextFieldEvent04");
1634 // Checks if the highlight actor is created.
1636 TextField field = TextField::New();
1637 DALI_TEST_CHECK( field );
1638 Stage::GetCurrent().Add( field );
1639 LoadMarkerImages(application, field);
1640 // Render and notify
1641 application.SendNotification();
1642 application.Render();
1644 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1645 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1646 field.SetSize( 300.f, 50.f );
1647 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1648 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1650 // Avoid a crash when core load gl resources.
1651 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1652 // Render and notify
1653 application.SendNotification();
1654 application.Render();
1656 // Create a tap event to touch the text field.
1657 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1658 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1659 // Render and notify
1660 application.SendNotification();
1661 application.Render();
1664 // Tap first to get the focus.
1665 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1666 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1668 // Render and notify
1669 application.SendNotification();
1670 application.Render();
1672 // Double tap to select a word.
1673 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1674 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1676 // Render and notify
1677 application.SendNotification();
1678 application.Render();
1681 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1682 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1686 int utcDaliTextFieldEvent05(void)
1688 ToolkitTestApplication application;
1689 tet_infoline(" utcDaliTextFieldEvent05");
1691 // Checks dragging of cursor/grab handle
1693 TextField field = TextField::New();
1694 DALI_TEST_CHECK( field );
1695 Stage::GetCurrent().Add( field );
1696 LoadMarkerImages(application, field);
1697 // Render and notify
1698 application.SendNotification();
1699 application.Render();
1701 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1702 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1703 field.SetSize( 300.f, 50.f );
1704 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1705 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1707 // Avoid a crash when core load gl resources.
1708 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1709 // Render and notify
1710 application.SendNotification();
1711 application.Render();
1713 // Create a tap event to touch the text field.
1714 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1715 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1716 // Render and notify
1717 application.SendNotification();
1718 application.Render();
1721 // Tap first to get the focus.
1722 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1723 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1725 // Render and notify
1726 application.SendNotification();
1727 application.Render();
1729 // Double tap to select a word.
1730 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1731 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1733 // Render and notify
1734 application.SendNotification();
1735 application.Render();
1737 // drag grab handle right
1738 Vector2 pos(0.0f, 40.0f);
1739 SendPan(application, Gesture::Possible, pos);
1740 SendPan(application, Gesture::Started, pos);
1742 Wait(application, 100);
1744 for(int i = 0;i<20;i++)
1746 SendPan(application, Gesture::Continuing, pos);
1751 SendPan(application, Gesture::Finished, pos);
1752 Wait(application, RENDER_FRAME_INTERVAL);
1754 Actor offscreenRoot = field.GetChildAt( 1u );
1758 int utcDaliTextFieldEvent06(void)
1760 ToolkitTestApplication application;
1761 tet_infoline(" utcDaliTextFieldEvent06");
1763 // Checks Longpress when in edit mode
1765 TextField field = TextField::New();
1766 DALI_TEST_CHECK( field );
1767 Stage::GetCurrent().Add( field );
1768 LoadMarkerImages(application, field);
1769 // Render and notify
1770 application.SendNotification();
1771 application.Render();
1773 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1774 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1775 field.SetSize( 300.f, 50.f );
1776 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1777 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1779 // Avoid a crash when core load gl resources.
1780 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1781 // Render and notify
1782 application.SendNotification();
1783 application.Render();
1785 // Create a tap event to touch the text field.
1786 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1787 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1788 // Render and notify
1789 application.SendNotification();
1790 application.Render();
1793 // Tap first to get the focus.
1794 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1795 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1797 // Render and notify
1798 application.SendNotification();
1799 application.Render();
1802 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1803 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1805 // Render and notify
1806 application.SendNotification();
1807 application.Render();
1812 int utcDaliTextFieldEvent07(void)
1814 ToolkitTestApplication application;
1815 tet_infoline(" utcDaliTextFieldEvent07");
1817 // Checks Longpress to start edit mode
1819 TextField field = TextField::New();
1820 DALI_TEST_CHECK( field );
1821 Stage::GetCurrent().Add( field );
1822 LoadMarkerImages(application, field);
1823 // Render and notify
1824 application.SendNotification();
1825 application.Render();
1827 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1828 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1829 field.SetSize( 300.f, 50.f );
1830 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1831 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1833 // Avoid a crash when core load gl resources.
1834 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1835 // Render and notify
1836 application.SendNotification();
1837 application.Render();
1840 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1841 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1843 // Render and notify
1844 application.SendNotification();
1845 application.Render();
1850 int utcDaliTextFieldEvent08(void)
1852 ToolkitTestApplication application;
1853 tet_infoline(" utcDaliTextFieldEvent08");
1855 Dali::Clipboard clipboard = Clipboard::Get();
1856 clipboard.SetItem("testTextFieldEvent");
1858 // Checks Longpress when only place holder text
1860 TextField field = TextField::New();
1861 DALI_TEST_CHECK( field );
1862 Stage::GetCurrent().Add( field );
1863 LoadMarkerImages(application, field);
1864 // Render and notify
1865 application.SendNotification();
1866 application.Render();
1868 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
1869 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1870 field.SetSize( 300.f, 50.f );
1871 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1872 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1874 // Avoid a crash when core load gl resources.
1875 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1876 // Render and notify
1877 application.SendNotification();
1878 application.Render();
1881 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1882 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1884 // Render and notify
1885 application.SendNotification();
1886 application.Render();
1888 Wait(application, 500);
1890 Stage stage = Stage::GetCurrent();
1891 Layer layer = stage.GetRootLayer();
1892 Actor actor = layer.FindChildByName("optionPaste");
1896 Vector3 worldPosition = actor.GetCurrentWorldPosition();
1897 Vector2 halfStageSize = stage.GetSize() / 2.0f;
1898 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
1900 Dali::Integration::TouchEvent event;
1901 event = Dali::Integration::TouchEvent();
1902 event.AddPoint( GetPointDownInside( position ) );
1903 application.ProcessEvent( event );
1905 event = Dali::Integration::TouchEvent();
1906 event.AddPoint( GetPointUpInside( position ) );
1907 application.ProcessEvent( event );
1909 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
1913 int utcDaliTextFieldStyleWhilstSelected(void)
1915 ToolkitTestApplication application;
1916 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
1918 // Change font and styles whilst text is selected whilst word selected
1920 TextField field = TextField::New();
1921 DALI_TEST_CHECK( field );
1922 Stage::GetCurrent().Add( field );
1923 LoadMarkerImages(application, field);
1924 // Render and notify
1925 application.SendNotification();
1926 application.Render();
1928 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1929 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1930 field.SetSize( 300.f, 50.f );
1931 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1932 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1934 // Avoid a crash when core load gl resources.
1935 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1936 // Render and notify
1937 application.SendNotification();
1938 application.Render();
1940 // Create a tap event to touch the text field.
1941 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1942 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1943 // Render and notify
1944 application.SendNotification();
1945 application.Render();
1948 // Tap first to get the focus.
1949 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1950 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1952 // Render and notify
1953 application.SendNotification();
1954 application.Render();
1956 // Double tap to select a word.
1957 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1958 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1960 // Render and notify
1961 application.SendNotification();
1962 application.Render();
1964 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
1965 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
1967 Property::Map fontStyleMapSet;
1968 Property::Map fontStyleMapGet;
1970 fontStyleMapSet.Insert( "weight", "bold" );
1971 fontStyleMapSet.Insert( "slant", "italic" );
1972 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1974 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
1975 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1976 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1978 fontStyleMapSet.Clear();
1979 fontStyleMapSet.Insert( "width", "expanded" );
1980 fontStyleMapSet.Insert( "slant", "italic" );
1981 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1983 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
1984 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1985 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1987 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
1988 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1990 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
1991 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
1993 fontStyleMapSet.Clear();
1994 fontStyleMapSet.Insert( "weight", "bold" );
1995 fontStyleMapSet.Insert( "slant", "italic" );
1997 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
1999 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2000 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2001 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2003 fontStyleMapSet.Clear();
2004 fontStyleMapSet.Insert( "width", "expanded" );
2006 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2008 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2009 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2010 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );