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 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
589 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
590 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
591 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
593 // Check that the Alignment properties can be correctly set
594 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
595 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
596 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
597 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
599 // Check text's color property
600 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
601 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
603 // Check placeholder text's color property.
604 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
605 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
607 // Check shadow properties.
608 field.SetProperty( TextField::Property::SHADOW_OFFSET, Vector2( 1.f, 1.f ) );
609 DALI_TEST_EQUALS( field.GetProperty<Vector2>( TextField::Property::SHADOW_OFFSET ), Vector2( 1.f, 1.f ), TEST_LOCATION );
610 field.SetProperty( TextField::Property::SHADOW_COLOR, Color::GREEN );
611 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SHADOW_COLOR ), Color::GREEN, TEST_LOCATION );
613 // Check cursor properties
614 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
615 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
616 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
617 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
619 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
620 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
621 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
622 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
623 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
624 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
625 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
626 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
628 // Check scroll properties.
629 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
630 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
631 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
632 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
634 // Check handle images
635 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
636 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
637 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
638 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
639 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
641 // Check handle images
642 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
643 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
644 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
645 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
646 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
647 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
649 // Check the highlight color
650 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
651 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
653 // Decoration bounding box
654 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
655 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
657 // Check input color property.
658 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
659 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
661 // Check the enable markup property.
662 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
663 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
664 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
666 // Check input font properties.
667 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
668 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
670 fontStyleMapSet.Clear();
671 fontStyleMapSet.Insert( "weight", "bold" );
672 fontStyleMapSet.Insert( "width", "condensed" );
673 fontStyleMapSet.Insert( "slant", "italic" );
675 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
676 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
677 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
678 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
680 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
681 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
683 // Reset input font style.
684 fontStyleMapSet.Clear();
685 fontStyleMapSet.Insert( "weight", "normal" );
686 fontStyleMapSet.Insert( "slant", "oblique" );
688 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
689 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
690 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
691 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
693 fontStyleMapSet.Clear();
694 fontStyleMapSet.Insert( "slant", "roman" );
696 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
697 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
699 // Replace 'roman' for 'normal'.
700 slantValue = fontStyleMapGet.Find( "slant" );
701 if( NULL != slantValue )
703 if( "normal" == slantValue->Get<std::string>() )
705 fontStyleMapGet["slant"] = "roman";
708 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
709 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
711 fontStyleMapSet.Clear();
713 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
714 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
715 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
716 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
718 Property::Map underlineMapSet;
719 Property::Map underlineMapGet;
721 underlineMapSet.Insert( "enable", "true" );
722 underlineMapSet.Insert( "color", "red" );
723 underlineMapSet.Insert( "height", "1" );
725 // Check the underline property
726 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
728 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
729 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
730 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
732 // Check the input underline property
733 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
734 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
736 // Check the shadow property
737 Property::Map shadowMapSet;
738 Property::Map shadowMapGet;
740 shadowMapSet.Insert( "color", "green" );
741 shadowMapSet.Insert( "offset", "2 2" );
743 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
745 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
746 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
747 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
749 // Check the input shadow property
750 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
751 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
753 // Check the emboss property
754 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
755 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
757 // Check the input emboss property
758 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
759 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
761 // Check the outline property
762 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
763 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
765 // Check the input outline property
766 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
767 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
772 // Positive Atlas Text Renderer test
773 int utcDaliTextFieldAtlasRenderP(void)
775 ToolkitTestApplication application;
776 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
777 StyleManager styleManager = StyleManager::Get();
778 styleManager.ApplyDefaultTheme();
779 TextField field = TextField::New();
780 DALI_TEST_CHECK( field );
782 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
784 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
786 Stage::GetCurrent().Add( field );
790 // Render some text with the shared atlas backend
791 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
792 application.SendNotification();
793 application.Render();
797 tet_result(TET_FAIL);
802 // Positive test for the textChanged signal.
803 int utcDaliTextFieldTextChangedP(void)
805 ToolkitTestApplication application;
806 tet_infoline(" utcDaliTextFieldTextChangedP");
807 TextField field = TextField::New();
808 DALI_TEST_CHECK( field );
810 Stage::GetCurrent().Add( field );
812 // connect to the text changed signal.
813 ConnectionTracker* testTracker = new ConnectionTracker();
814 field.TextChangedSignal().Connect(&TestTextChangedCallback);
815 bool textChangedSignal = false;
816 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
818 gTextChangedCallBackCalled = false;
819 field.SetProperty( TextField::Property::TEXT, "ABC" );
820 DALI_TEST_CHECK( gTextChangedCallBackCalled );
821 DALI_TEST_CHECK( textChangedSignal );
823 application.SendNotification();
825 field.SetKeyInputFocus();
827 gTextChangedCallBackCalled = false;
828 application.ProcessEvent( GenerateKey( "D", "D", 0, 0, 0, Integration::KeyEvent::Down ) );
829 DALI_TEST_CHECK( gTextChangedCallBackCalled );
834 // Negative test for the textChanged signal.
835 int utcDaliTextFieldTextChangedN(void)
837 ToolkitTestApplication application;
838 tet_infoline(" utcDaliTextFieldTextChangedN");
839 TextField field = TextField::New();
840 DALI_TEST_CHECK( field );
842 Stage::GetCurrent().Add( field );
844 // connect to the text changed signal.
845 ConnectionTracker* testTracker = new ConnectionTracker();
846 field.TextChangedSignal().Connect(&TestTextChangedCallback);
847 bool textChangedSignal = false;
848 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
850 gTextChangedCallBackCalled = false;
851 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
852 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
853 DALI_TEST_CHECK( !textChangedSignal );
858 // Positive test for Max Characters reached signal.
859 int utcDaliTextFieldMaxCharactersReachedP(void)
861 ToolkitTestApplication application;
862 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
863 TextField field = TextField::New();
864 DALI_TEST_CHECK( field );
866 Stage::GetCurrent().Add( field );
868 const int maxNumberOfCharacters = 1;
869 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
871 field.SetKeyInputFocus();
873 // connect to the text changed signal.
874 ConnectionTracker* testTracker = new ConnectionTracker();
875 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
876 bool maxLengthReachedSignal = false;
877 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
879 gMaxCharactersCallBackCalled = false;
881 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
882 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
884 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
885 DALI_TEST_CHECK( maxLengthReachedSignal );
890 // Negative test for Max Characters reached signal.
891 int utcDaliTextFieldMaxCharactersReachedN(void)
893 ToolkitTestApplication application;
894 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
895 TextField field = TextField::New();
896 DALI_TEST_CHECK( field );
898 Stage::GetCurrent().Add( field );
900 const int maxNumberOfCharacters = 3;
901 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
903 field.SetKeyInputFocus();
905 // connect to the text changed signal.
906 ConnectionTracker* testTracker = new ConnectionTracker();
907 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
908 bool maxLengthReachedSignal = false;
909 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
911 gMaxCharactersCallBackCalled = false;
913 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
914 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
916 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
917 DALI_TEST_CHECK( !maxLengthReachedSignal );
922 int utcDaliTextFieldInputStyleChanged01(void)
924 ToolkitTestApplication application;
925 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
927 // The text-field emits signals when the input style changes. These changes of style are
928 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
929 // can't be emitted during the size negotiation as the callbacks may update the UI.
930 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
931 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
932 application.CreateAdaptor();
936 char* pathNamePtr = get_current_dir_name();
937 const std::string pathName( pathNamePtr );
940 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
941 fontClient.SetDpi( 93u, 93u );
943 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
944 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
946 TextField field = TextField::New();
947 DALI_TEST_CHECK( field );
950 field.SetSize( 300.f, 50.f );
951 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
952 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
954 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
955 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
957 // connect to the text changed signal.
958 ConnectionTracker* testTracker = new ConnectionTracker();
959 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
960 bool inputStyleChangedSignal = false;
961 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
963 Stage::GetCurrent().Add( field );
966 application.SendNotification();
967 application.Render();
969 // Executes the idle callbacks added by the text control on the change of input style.
970 application.RunIdles();
972 gInputStyleChangedCallbackCalled = false;
973 gInputStyleMask = TextField::InputStyle::NONE;
974 inputStyleChangedSignal = false;
976 // Create a tap event to touch the text field.
977 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
978 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
981 application.SendNotification();
982 application.Render();
984 // Executes the idle callbacks added by the text control on the change of input style.
985 application.RunIdles();
987 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
988 if( gInputStyleChangedCallbackCalled )
990 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
992 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
993 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
995 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
996 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
998 DALI_TEST_CHECK( inputStyleChangedSignal );
1000 gInputStyleChangedCallbackCalled = false;
1001 gInputStyleMask = TextField::InputStyle::NONE;
1002 inputStyleChangedSignal = false;
1004 // Create a tap event to touch the text field.
1005 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1006 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1008 // Render and notify
1009 application.SendNotification();
1010 application.Render();
1012 // Executes the idle callbacks added by the text control on the change of input style.
1013 application.RunIdles();
1015 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1016 DALI_TEST_CHECK( !inputStyleChangedSignal );
1018 gInputStyleChangedCallbackCalled = false;
1019 gInputStyleMask = TextField::InputStyle::NONE;
1020 inputStyleChangedSignal = false;
1022 // Create a tap event to touch the text field.
1023 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1024 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1026 // Render and notify
1027 application.SendNotification();
1028 application.Render();
1030 // Executes the idle callbacks added by the text control on the change of input style.
1031 application.RunIdles();
1033 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1034 if( gInputStyleChangedCallbackCalled )
1036 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1038 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1039 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1041 DALI_TEST_CHECK( inputStyleChangedSignal );
1043 gInputStyleChangedCallbackCalled = false;
1044 gInputStyleMask = TextField::InputStyle::NONE;
1045 inputStyleChangedSignal = false;
1047 // Create a tap event to touch the text field.
1048 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1049 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1051 // Render and notify
1052 application.SendNotification();
1053 application.Render();
1055 // Executes the idle callbacks added by the text control on the change of input style.
1056 application.RunIdles();
1058 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1059 if( gInputStyleChangedCallbackCalled )
1061 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1063 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1064 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1066 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1068 Property::Map fontStyleMapSet;
1069 fontStyleMapSet.Insert( "weight", "bold" );
1071 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1072 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1074 DALI_TEST_CHECK( inputStyleChangedSignal );
1076 gInputStyleChangedCallbackCalled = false;
1077 gInputStyleMask = TextField::InputStyle::NONE;
1078 inputStyleChangedSignal = false;
1080 // Create a tap event to touch the text field.
1081 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1082 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1084 // Render and notify
1085 application.SendNotification();
1086 application.Render();
1088 // Executes the idle callbacks added by the text control on the change of input style.
1089 application.RunIdles();
1091 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1092 DALI_TEST_CHECK( !inputStyleChangedSignal );
1094 gInputStyleChangedCallbackCalled = false;
1095 gInputStyleMask = TextField::InputStyle::NONE;
1096 inputStyleChangedSignal = false;
1098 // Create a tap event to touch the text field.
1099 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1100 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1102 // Render and notify
1103 application.SendNotification();
1104 application.Render();
1106 // Executes the idle callbacks added by the text control on the change of input style.
1107 application.RunIdles();
1109 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1110 if( gInputStyleChangedCallbackCalled )
1112 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1114 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1115 DALI_TEST_CHECK( style.empty() );
1117 DALI_TEST_CHECK( inputStyleChangedSignal );
1119 gInputStyleChangedCallbackCalled = false;
1120 gInputStyleMask = TextField::InputStyle::NONE;
1121 inputStyleChangedSignal = false;
1123 // Create a tap event to touch the text field.
1124 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1125 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1127 // Render and notify
1128 application.SendNotification();
1129 application.Render();
1131 // Executes the idle callbacks added by the text control on the change of input style.
1132 application.RunIdles();
1134 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1135 DALI_TEST_CHECK( !inputStyleChangedSignal );
1140 int utcDaliTextFieldInputStyleChanged02(void)
1142 ToolkitTestApplication application;
1143 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1145 // The text-field emits signals when the input style changes. These changes of style are
1146 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1147 // can't be emitted during the size negotiation as the callbacks may update the UI.
1148 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1149 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1150 application.CreateAdaptor();
1154 char* pathNamePtr = get_current_dir_name();
1155 const std::string pathName( pathNamePtr );
1156 free( pathNamePtr );
1158 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1159 fontClient.SetDpi( 93u, 93u );
1161 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1162 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1164 TextField field = TextField::New();
1165 DALI_TEST_CHECK( field );
1168 field.SetSize( 300.f, 50.f );
1169 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1170 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1172 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1173 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>" );
1175 // connect to the text changed signal.
1176 ConnectionTracker* testTracker = new ConnectionTracker();
1177 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1178 bool inputStyleChangedSignal = false;
1179 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1181 Stage::GetCurrent().Add( field );
1183 // Render and notify
1184 application.SendNotification();
1185 application.Render();
1187 // Executes the idle callbacks added by the text control on the change of input style.
1188 application.RunIdles();
1190 gInputStyleChangedCallbackCalled = false;
1191 gInputStyleMask = TextField::InputStyle::NONE;
1192 inputStyleChangedSignal = false;
1194 // Create a tap event to touch the text field.
1195 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1196 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1197 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1198 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1200 // Render and notify
1201 application.SendNotification();
1202 application.Render();
1204 // Executes the idle callbacks added by the text control on the change of input style.
1205 application.RunIdles();
1207 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1208 if( gInputStyleChangedCallbackCalled )
1210 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1211 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1212 TextField::InputStyle::POINT_SIZE |
1213 TextField::InputStyle::COLOR ),
1216 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1217 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1219 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1220 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1222 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1223 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1225 DALI_TEST_CHECK( inputStyleChangedSignal );
1227 gInputStyleChangedCallbackCalled = false;
1228 gInputStyleMask = TextField::InputStyle::NONE;
1229 inputStyleChangedSignal = false;
1231 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1233 // Render and notify
1234 application.SendNotification();
1235 application.Render();
1237 // Executes the idle callbacks added by the text control on the change of input style.
1238 application.RunIdles();
1240 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1241 if( gInputStyleChangedCallbackCalled )
1243 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1244 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1247 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1248 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1250 DALI_TEST_CHECK( inputStyleChangedSignal );
1252 gInputStyleChangedCallbackCalled = false;
1253 gInputStyleMask = TextField::InputStyle::NONE;
1254 inputStyleChangedSignal = false;
1256 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1258 // Render and notify
1259 application.SendNotification();
1260 application.Render();
1262 // Executes the idle callbacks added by the text control on the change of input style.
1263 application.RunIdles();
1265 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1266 DALI_TEST_CHECK( !inputStyleChangedSignal );
1268 gInputStyleChangedCallbackCalled = false;
1269 gInputStyleMask = TextField::InputStyle::NONE;
1270 inputStyleChangedSignal = false;
1272 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1274 // Render and notify
1275 application.SendNotification();
1276 application.Render();
1278 // Executes the idle callbacks added by the text control on the change of input style.
1279 application.RunIdles();
1281 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1282 if( gInputStyleChangedCallbackCalled )
1284 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1285 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1288 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1289 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1291 DALI_TEST_CHECK( inputStyleChangedSignal );
1293 gInputStyleChangedCallbackCalled = false;
1294 gInputStyleMask = TextField::InputStyle::NONE;
1295 inputStyleChangedSignal = false;
1297 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1299 Property::Map fontStyleMapSet;
1300 fontStyleMapSet.Insert( "weight", "thin" );
1301 fontStyleMapSet.Insert( "width", "condensed" );
1302 fontStyleMapSet.Insert( "slant", "italic" );
1304 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1305 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1307 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1308 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1309 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1310 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1312 // Render and notify
1313 application.SendNotification();
1314 application.Render();
1316 // Executes the idle callbacks added by the text control on the change of input style.
1317 application.RunIdles();
1319 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1320 DALI_TEST_CHECK( !inputStyleChangedSignal );
1322 // Create a tap event to touch the text field.
1323 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1324 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1326 // Render and notify
1327 application.SendNotification();
1328 application.Render();
1330 // Executes the idle callbacks added by the text control on the change of input style.
1331 application.RunIdles();
1333 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1334 if( gInputStyleChangedCallbackCalled )
1336 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1337 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1338 TextField::InputStyle::POINT_SIZE |
1339 TextField::InputStyle::FONT_STYLE |
1340 TextField::InputStyle::UNDERLINE |
1341 TextField::InputStyle::SHADOW |
1342 TextField::InputStyle::EMBOSS |
1343 TextField::InputStyle::OUTLINE ),
1346 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1347 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1349 DALI_TEST_CHECK( inputStyleChangedSignal );
1354 int utcDaliTextFieldEvent01(void)
1356 ToolkitTestApplication application;
1357 tet_infoline(" utcDaliTextFieldEvent01");
1359 // Creates a tap event. After creating a tap event the text field should
1360 // have the focus and add text with key events should be possible.
1362 TextField field = TextField::New();
1363 DALI_TEST_CHECK( field );
1365 Stage::GetCurrent().Add( field );
1367 field.SetSize( 300.f, 50.f );
1368 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1369 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1371 // Avoid a crash when core load gl resources.
1372 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1374 // Render and notify
1375 application.SendNotification();
1376 application.Render();
1378 // Add a key event but as the text field has not the focus it should do nothing.
1379 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1381 // Render and notify
1382 application.SendNotification();
1383 application.Render();
1385 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1387 // Create a tap event to touch the text field.
1388 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1389 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1391 // Render and notify
1392 application.SendNotification();
1393 application.Render();
1395 // Now the text field has the focus, so it can handle the key events.
1396 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1397 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1399 // Render and notify
1400 application.SendNotification();
1401 application.Render();
1403 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1405 // Create a second text field and send key events to it.
1406 TextField field2 = TextField::New();
1408 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1409 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1410 field2.SetSize( 100.f, 100.f );
1411 field2.SetPosition( 100.f, 100.f );
1413 Stage::GetCurrent().Add( field2 );
1415 // Render and notify
1416 application.SendNotification();
1417 application.Render();
1419 // Create a tap event on the second text field.
1420 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1421 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1423 // Render and notify
1424 application.SendNotification();
1425 application.Render();
1427 // The second text field has the focus. It should handle the key events.
1428 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1429 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1431 // Render and notify
1432 application.SendNotification();
1433 application.Render();
1435 // Check the text has been added to the second text field.
1436 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1441 int utcDaliTextFieldEvent02(void)
1443 ToolkitTestApplication application;
1444 tet_infoline(" utcDaliTextFieldEvent02");
1446 // Checks if the right number of actors are created.
1448 TextField field = TextField::New();
1449 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1450 DALI_TEST_CHECK( field );
1451 LoadMarkerImages(application, field);
1453 Stage::GetCurrent().Add( field );
1455 field.SetSize( 300.f, 50.f );
1456 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1457 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1459 // Avoid a crash when core load gl resources.
1460 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1462 // Render and notify
1463 application.SendNotification();
1464 application.Render();
1466 // Check there are the expected number of children ( stencil ).
1467 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1469 Actor stencil = field.GetChildAt( 0u );
1470 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1472 // Create a tap event to touch the text field.
1473 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1474 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1476 // Render and notify
1477 application.SendNotification();
1478 application.Render();
1480 Actor layer = field.GetChildAt( 1u );
1481 DALI_TEST_CHECK( layer.IsLayer() );
1483 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1484 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1486 // Now the text field has the focus, so it can handle the key events.
1487 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1488 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1490 // Render and notify
1491 application.SendNotification();
1492 application.Render();
1494 // Checks the cursor and the renderer have been created.
1495 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1496 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1498 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1499 DALI_TEST_CHECK( cursor );
1501 // The offscreen root actor has a container with all the actors which contain the text renderers.
1502 Actor container = stencil.GetChildAt( 0u );
1503 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1505 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1506 DALI_TEST_CHECK( renderer );
1509 // Move the cursor and check the position changes.
1510 Vector3 position1 = cursor.GetCurrentPosition();
1512 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1513 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1515 // Render and notify
1516 application.SendNotification();
1517 application.Render();
1519 Vector3 position2 = cursor.GetCurrentPosition();
1521 DALI_TEST_CHECK( position2.x < position1.x );
1523 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1524 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1526 // Render and notify
1527 application.SendNotification();
1528 application.Render();
1530 Vector3 position3 = cursor.GetCurrentPosition();
1532 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1534 // Send some taps and check the cursor positions.
1536 // Try to tap at the beginning.
1537 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1538 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1540 // Render and notify
1541 application.SendNotification();
1542 application.Render();
1544 // Cursor position should be the same than position1.
1545 Vector3 position4 = cursor.GetCurrentPosition();
1547 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1549 // Tap away from the start position.
1550 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1551 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1553 // Render and notify
1554 application.SendNotification();
1555 application.Render();
1557 Vector3 position5 = cursor.GetCurrentPosition();
1559 DALI_TEST_CHECK( position5.x > position4.x );
1561 // Remove all the text.
1562 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1563 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1564 field.SetProperty( TextField::Property::TEXT, "" );
1566 // Render and notify
1567 application.SendNotification();
1568 application.Render();
1570 // Cursor position should be the same than position2.
1571 Vector3 position6 = cursor.GetCurrentPosition();
1573 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1575 // Should not be a renderer.
1576 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1581 int utcDaliTextFieldEvent03(void)
1583 ToolkitTestApplication application;
1584 tet_infoline(" utcDaliTextFieldEvent03");
1586 // Checks if the highlight actor is created.
1588 TextField field = TextField::New();
1589 DALI_TEST_CHECK( field );
1591 Stage::GetCurrent().Add( field );
1593 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1594 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1595 field.SetSize( 30.f, 50.f );
1596 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1597 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1599 // Avoid a crash when core load gl resources.
1600 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1601 LoadMarkerImages(application, field);
1603 // Render and notify
1604 application.SendNotification();
1605 application.Render();
1607 // Tap first to get the focus.
1608 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1609 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1611 // Render and notify
1612 application.SendNotification();
1613 application.Render();
1615 // Double tap to select a word.
1616 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1617 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1619 // Render and notify
1620 application.SendNotification();
1621 application.Render();
1623 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1624 Actor stencil = field.GetChildAt( 0u );
1626 // The offscreen root actor has a container with all the actors which contain the text renderers.
1627 Actor container = stencil.GetChildAt( 0u );
1628 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1630 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1631 DALI_TEST_CHECK( renderer );
1634 Renderer highlight = stencil.GetChildAt( 1u ).GetRendererAt( 0u );
1635 DALI_TEST_CHECK( highlight );
1640 int utcDaliTextFieldEvent04(void)
1642 ToolkitTestApplication application;
1643 tet_infoline(" utcDaliTextFieldEvent04");
1645 // Checks if the highlight actor is created.
1647 TextField field = TextField::New();
1648 DALI_TEST_CHECK( field );
1649 Stage::GetCurrent().Add( field );
1650 LoadMarkerImages(application, field);
1651 // Render and notify
1652 application.SendNotification();
1653 application.Render();
1655 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1656 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1657 field.SetSize( 300.f, 50.f );
1658 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1659 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1661 // Avoid a crash when core load gl resources.
1662 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1663 // Render and notify
1664 application.SendNotification();
1665 application.Render();
1667 // Create a tap event to touch the text field.
1668 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1669 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1670 // Render and notify
1671 application.SendNotification();
1672 application.Render();
1675 // Tap first to get the focus.
1676 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1677 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1679 // Render and notify
1680 application.SendNotification();
1681 application.Render();
1683 // Double tap to select a word.
1684 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1685 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1687 // Render and notify
1688 application.SendNotification();
1689 application.Render();
1692 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1693 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1697 int utcDaliTextFieldEvent05(void)
1699 ToolkitTestApplication application;
1700 tet_infoline(" utcDaliTextFieldEvent05");
1702 // Checks dragging of cursor/grab handle
1704 TextField field = TextField::New();
1705 DALI_TEST_CHECK( field );
1706 Stage::GetCurrent().Add( field );
1707 LoadMarkerImages(application, field);
1708 // Render and notify
1709 application.SendNotification();
1710 application.Render();
1712 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1713 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1714 field.SetSize( 300.f, 50.f );
1715 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1716 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1718 // Avoid a crash when core load gl resources.
1719 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1720 // Render and notify
1721 application.SendNotification();
1722 application.Render();
1724 // Create a tap event to touch the text field.
1725 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1726 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1727 // Render and notify
1728 application.SendNotification();
1729 application.Render();
1732 // Tap first to get the focus.
1733 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1734 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1736 // Render and notify
1737 application.SendNotification();
1738 application.Render();
1740 // Double tap to select a word.
1741 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1742 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1744 // Render and notify
1745 application.SendNotification();
1746 application.Render();
1748 // drag grab handle right
1749 Vector2 pos(0.0f, 40.0f);
1750 SendPan(application, Gesture::Possible, pos);
1751 SendPan(application, Gesture::Started, pos);
1753 Wait(application, 100);
1755 for(int i = 0;i<20;i++)
1757 SendPan(application, Gesture::Continuing, pos);
1762 SendPan(application, Gesture::Finished, pos);
1763 Wait(application, RENDER_FRAME_INTERVAL);
1765 Actor stencil = field.GetChildAt( 1u );
1769 int utcDaliTextFieldEvent06(void)
1771 ToolkitTestApplication application;
1772 tet_infoline(" utcDaliTextFieldEvent06");
1774 // Checks Longpress when in edit mode
1776 TextField field = TextField::New();
1777 DALI_TEST_CHECK( field );
1778 Stage::GetCurrent().Add( field );
1779 LoadMarkerImages(application, field);
1780 // Render and notify
1781 application.SendNotification();
1782 application.Render();
1784 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1785 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1786 field.SetSize( 300.f, 50.f );
1787 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1788 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1790 // Avoid a crash when core load gl resources.
1791 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1792 // Render and notify
1793 application.SendNotification();
1794 application.Render();
1796 // Create a tap event to touch the text field.
1797 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1798 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1799 // Render and notify
1800 application.SendNotification();
1801 application.Render();
1804 // Tap first to get the focus.
1805 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1806 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1808 // Render and notify
1809 application.SendNotification();
1810 application.Render();
1813 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1814 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1816 // Render and notify
1817 application.SendNotification();
1818 application.Render();
1823 int utcDaliTextFieldEvent07(void)
1825 ToolkitTestApplication application;
1826 tet_infoline(" utcDaliTextFieldEvent07");
1828 // Checks Longpress to start edit mode
1830 TextField field = TextField::New();
1831 DALI_TEST_CHECK( field );
1832 Stage::GetCurrent().Add( field );
1833 LoadMarkerImages(application, field);
1834 // Render and notify
1835 application.SendNotification();
1836 application.Render();
1838 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1839 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1840 field.SetSize( 300.f, 50.f );
1841 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1842 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1844 // Avoid a crash when core load gl resources.
1845 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1846 // Render and notify
1847 application.SendNotification();
1848 application.Render();
1851 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1852 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1854 // Render and notify
1855 application.SendNotification();
1856 application.Render();
1861 int utcDaliTextFieldEvent08(void)
1863 ToolkitTestApplication application;
1864 tet_infoline(" utcDaliTextFieldEvent08");
1866 Dali::Clipboard clipboard = Clipboard::Get();
1867 clipboard.SetItem("testTextFieldEvent");
1869 // Checks Longpress when only place holder text
1871 TextField field = TextField::New();
1872 DALI_TEST_CHECK( field );
1873 Stage::GetCurrent().Add( field );
1874 LoadMarkerImages(application, field);
1875 // Render and notify
1876 application.SendNotification();
1877 application.Render();
1879 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
1880 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1881 field.SetSize( 300.f, 50.f );
1882 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1883 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1885 // Avoid a crash when core load gl resources.
1886 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1887 // Render and notify
1888 application.SendNotification();
1889 application.Render();
1892 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1893 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1895 // Render and notify
1896 application.SendNotification();
1897 application.Render();
1899 Wait(application, 500);
1901 Stage stage = Stage::GetCurrent();
1902 Layer layer = stage.GetRootLayer();
1903 Actor actor = layer.FindChildByName("optionPaste");
1907 Vector3 worldPosition = actor.GetCurrentWorldPosition();
1908 Vector2 halfStageSize = stage.GetSize() / 2.0f;
1909 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
1911 Dali::Integration::TouchEvent event;
1912 event = Dali::Integration::TouchEvent();
1913 event.AddPoint( GetPointDownInside( position ) );
1914 application.ProcessEvent( event );
1916 event = Dali::Integration::TouchEvent();
1917 event.AddPoint( GetPointUpInside( position ) );
1918 application.ProcessEvent( event );
1920 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
1924 int utcDaliTextFieldStyleWhilstSelected(void)
1926 ToolkitTestApplication application;
1927 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
1929 // Change font and styles whilst text is selected whilst word selected
1931 TextField field = TextField::New();
1932 DALI_TEST_CHECK( field );
1933 Stage::GetCurrent().Add( field );
1934 LoadMarkerImages(application, field);
1935 // Render and notify
1936 application.SendNotification();
1937 application.Render();
1939 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1940 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1941 field.SetSize( 300.f, 50.f );
1942 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1943 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1945 // Avoid a crash when core load gl resources.
1946 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1947 // Render and notify
1948 application.SendNotification();
1949 application.Render();
1951 // Create a tap event to touch the text field.
1952 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1953 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1954 // Render and notify
1955 application.SendNotification();
1956 application.Render();
1959 // Tap first to get the focus.
1960 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1961 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1963 // Render and notify
1964 application.SendNotification();
1965 application.Render();
1967 // Double tap to select a word.
1968 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1969 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1971 // Render and notify
1972 application.SendNotification();
1973 application.Render();
1975 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
1976 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
1978 Property::Map fontStyleMapSet;
1979 Property::Map fontStyleMapGet;
1981 fontStyleMapSet.Insert( "weight", "bold" );
1982 fontStyleMapSet.Insert( "slant", "italic" );
1983 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1985 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
1986 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1987 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1989 fontStyleMapSet.Clear();
1990 fontStyleMapSet.Insert( "width", "expanded" );
1991 fontStyleMapSet.Insert( "slant", "italic" );
1992 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1994 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
1995 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1996 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1998 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
1999 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2001 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2002 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2004 fontStyleMapSet.Clear();
2005 fontStyleMapSet.Insert( "weight", "bold" );
2006 fontStyleMapSet.Insert( "slant", "italic" );
2008 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2010 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2011 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2012 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2014 fontStyleMapSet.Clear();
2015 fontStyleMapSet.Insert( "width", "expanded" );
2017 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2019 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2020 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2021 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );