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 Property::Map underlineMapSet;
716 Property::Map underlineMapGet;
718 underlineMapSet.Insert( "enable", "true" );
719 underlineMapSet.Insert( "color", "red" );
720 underlineMapSet.Insert( "height", "1" );
722 // Check the underline property
723 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
725 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
726 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
727 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
729 // Check the input underline property
730 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
731 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
733 // Check the shadow property
734 Property::Map shadowMapSet;
735 Property::Map shadowMapGet;
737 shadowMapSet.Insert( "color", "green" );
738 shadowMapSet.Insert( "offset", "2 2" );
740 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
742 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
743 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
744 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
746 // Check the input shadow property
747 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
748 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
750 // Check the emboss property
751 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
752 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
754 // Check the input emboss property
755 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
756 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
758 // Check the outline property
759 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
760 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
762 // Check the input outline property
763 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
764 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
769 // Positive Atlas Text Renderer test
770 int utcDaliTextFieldAtlasRenderP(void)
772 ToolkitTestApplication application;
773 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
774 StyleManager styleManager = StyleManager::Get();
775 styleManager.ApplyDefaultTheme();
776 TextField field = TextField::New();
777 DALI_TEST_CHECK( field );
779 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
781 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
783 Stage::GetCurrent().Add( field );
787 // Render some text with the shared atlas backend
788 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
789 application.SendNotification();
790 application.Render();
794 tet_result(TET_FAIL);
799 // Positive test for the textChanged signal.
800 int utcDaliTextFieldTextChangedP(void)
802 ToolkitTestApplication application;
803 tet_infoline(" utcDaliTextFieldTextChangedP");
804 TextField field = TextField::New();
805 DALI_TEST_CHECK( field );
807 Stage::GetCurrent().Add( field );
809 // connect to the text changed signal.
810 ConnectionTracker* testTracker = new ConnectionTracker();
811 field.TextChangedSignal().Connect(&TestTextChangedCallback);
812 bool textChangedSignal = false;
813 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
815 gTextChangedCallBackCalled = false;
816 field.SetProperty( TextField::Property::TEXT, "ABC" );
817 DALI_TEST_CHECK( gTextChangedCallBackCalled );
818 DALI_TEST_CHECK( textChangedSignal );
820 application.SendNotification();
822 field.SetKeyInputFocus();
824 gTextChangedCallBackCalled = false;
825 application.ProcessEvent( GenerateKey( "D", "D", 0, 0, 0, Integration::KeyEvent::Down ) );
826 DALI_TEST_CHECK( gTextChangedCallBackCalled );
831 // Negative test for the textChanged signal.
832 int utcDaliTextFieldTextChangedN(void)
834 ToolkitTestApplication application;
835 tet_infoline(" utcDaliTextFieldTextChangedN");
836 TextField field = TextField::New();
837 DALI_TEST_CHECK( field );
839 Stage::GetCurrent().Add( field );
841 // connect to the text changed signal.
842 ConnectionTracker* testTracker = new ConnectionTracker();
843 field.TextChangedSignal().Connect(&TestTextChangedCallback);
844 bool textChangedSignal = false;
845 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
847 gTextChangedCallBackCalled = false;
848 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
849 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
850 DALI_TEST_CHECK( !textChangedSignal );
855 // Positive test for Max Characters reached signal.
856 int utcDaliTextFieldMaxCharactersReachedP(void)
858 ToolkitTestApplication application;
859 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
860 TextField field = TextField::New();
861 DALI_TEST_CHECK( field );
863 Stage::GetCurrent().Add( field );
865 const int maxNumberOfCharacters = 1;
866 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
868 field.SetKeyInputFocus();
870 // connect to the text changed signal.
871 ConnectionTracker* testTracker = new ConnectionTracker();
872 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
873 bool maxLengthReachedSignal = false;
874 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
876 gMaxCharactersCallBackCalled = false;
878 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
879 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
881 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
882 DALI_TEST_CHECK( maxLengthReachedSignal );
887 // Negative test for Max Characters reached signal.
888 int utcDaliTextFieldMaxCharactersReachedN(void)
890 ToolkitTestApplication application;
891 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
892 TextField field = TextField::New();
893 DALI_TEST_CHECK( field );
895 Stage::GetCurrent().Add( field );
897 const int maxNumberOfCharacters = 3;
898 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
900 field.SetKeyInputFocus();
902 // connect to the text changed signal.
903 ConnectionTracker* testTracker = new ConnectionTracker();
904 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
905 bool maxLengthReachedSignal = false;
906 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
908 gMaxCharactersCallBackCalled = false;
910 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
911 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
913 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
914 DALI_TEST_CHECK( !maxLengthReachedSignal );
919 int utcDaliTextFieldInputStyleChanged01(void)
921 ToolkitTestApplication application;
922 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
924 // The text-field emits signals when the input style changes. These changes of style are
925 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
926 // can't be emitted during the size negotiation as the callbacks may update the UI.
927 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
928 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
929 application.CreateAdaptor();
933 char* pathNamePtr = get_current_dir_name();
934 const std::string pathName( pathNamePtr );
937 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
938 fontClient.SetDpi( 93u, 93u );
940 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
941 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
943 TextField field = TextField::New();
944 DALI_TEST_CHECK( field );
947 field.SetSize( 300.f, 50.f );
948 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
949 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
951 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
952 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
954 // connect to the text changed signal.
955 ConnectionTracker* testTracker = new ConnectionTracker();
956 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
957 bool inputStyleChangedSignal = false;
958 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
960 Stage::GetCurrent().Add( field );
963 application.SendNotification();
964 application.Render();
966 // Executes the idle callbacks added by the text control on the change of input style.
967 application.RunIdles();
969 gInputStyleChangedCallbackCalled = false;
970 gInputStyleMask = TextField::InputStyle::NONE;
971 inputStyleChangedSignal = false;
973 // Create a tap event to touch the text field.
974 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
975 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
978 application.SendNotification();
979 application.Render();
981 // Executes the idle callbacks added by the text control on the change of input style.
982 application.RunIdles();
984 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
985 if( gInputStyleChangedCallbackCalled )
987 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
989 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
990 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
992 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
993 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
995 DALI_TEST_CHECK( inputStyleChangedSignal );
997 gInputStyleChangedCallbackCalled = false;
998 gInputStyleMask = TextField::InputStyle::NONE;
999 inputStyleChangedSignal = false;
1001 // Create a tap event to touch the text field.
1002 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1003 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1005 // Render and notify
1006 application.SendNotification();
1007 application.Render();
1009 // Executes the idle callbacks added by the text control on the change of input style.
1010 application.RunIdles();
1012 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1013 DALI_TEST_CHECK( !inputStyleChangedSignal );
1015 gInputStyleChangedCallbackCalled = false;
1016 gInputStyleMask = TextField::InputStyle::NONE;
1017 inputStyleChangedSignal = false;
1019 // Create a tap event to touch the text field.
1020 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1021 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1023 // Render and notify
1024 application.SendNotification();
1025 application.Render();
1027 // Executes the idle callbacks added by the text control on the change of input style.
1028 application.RunIdles();
1030 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1031 if( gInputStyleChangedCallbackCalled )
1033 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1035 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1036 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1038 DALI_TEST_CHECK( inputStyleChangedSignal );
1040 gInputStyleChangedCallbackCalled = false;
1041 gInputStyleMask = TextField::InputStyle::NONE;
1042 inputStyleChangedSignal = false;
1044 // Create a tap event to touch the text field.
1045 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1046 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1048 // Render and notify
1049 application.SendNotification();
1050 application.Render();
1052 // Executes the idle callbacks added by the text control on the change of input style.
1053 application.RunIdles();
1055 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1056 if( gInputStyleChangedCallbackCalled )
1058 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1060 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1061 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1063 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1065 Property::Map fontStyleMapSet;
1066 fontStyleMapSet.Insert( "weight", "bold" );
1068 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1069 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1071 DALI_TEST_CHECK( inputStyleChangedSignal );
1073 gInputStyleChangedCallbackCalled = false;
1074 gInputStyleMask = TextField::InputStyle::NONE;
1075 inputStyleChangedSignal = false;
1077 // Create a tap event to touch the text field.
1078 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1079 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1081 // Render and notify
1082 application.SendNotification();
1083 application.Render();
1085 // Executes the idle callbacks added by the text control on the change of input style.
1086 application.RunIdles();
1088 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1089 DALI_TEST_CHECK( !inputStyleChangedSignal );
1091 gInputStyleChangedCallbackCalled = false;
1092 gInputStyleMask = TextField::InputStyle::NONE;
1093 inputStyleChangedSignal = false;
1095 // Create a tap event to touch the text field.
1096 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1097 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1099 // Render and notify
1100 application.SendNotification();
1101 application.Render();
1103 // Executes the idle callbacks added by the text control on the change of input style.
1104 application.RunIdles();
1106 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1107 if( gInputStyleChangedCallbackCalled )
1109 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1111 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1112 DALI_TEST_CHECK( style.empty() );
1114 DALI_TEST_CHECK( inputStyleChangedSignal );
1116 gInputStyleChangedCallbackCalled = false;
1117 gInputStyleMask = TextField::InputStyle::NONE;
1118 inputStyleChangedSignal = false;
1120 // Create a tap event to touch the text field.
1121 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1122 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1124 // Render and notify
1125 application.SendNotification();
1126 application.Render();
1128 // Executes the idle callbacks added by the text control on the change of input style.
1129 application.RunIdles();
1131 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1132 DALI_TEST_CHECK( !inputStyleChangedSignal );
1137 int utcDaliTextFieldInputStyleChanged02(void)
1139 ToolkitTestApplication application;
1140 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1142 // The text-field emits signals when the input style changes. These changes of style are
1143 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1144 // can't be emitted during the size negotiation as the callbacks may update the UI.
1145 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1146 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1147 application.CreateAdaptor();
1151 char* pathNamePtr = get_current_dir_name();
1152 const std::string pathName( pathNamePtr );
1153 free( pathNamePtr );
1155 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1156 fontClient.SetDpi( 93u, 93u );
1158 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1159 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1161 TextField field = TextField::New();
1162 DALI_TEST_CHECK( field );
1165 field.SetSize( 300.f, 50.f );
1166 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1167 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1169 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1170 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>" );
1172 // connect to the text changed signal.
1173 ConnectionTracker* testTracker = new ConnectionTracker();
1174 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1175 bool inputStyleChangedSignal = false;
1176 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1178 Stage::GetCurrent().Add( field );
1180 // Render and notify
1181 application.SendNotification();
1182 application.Render();
1184 // Executes the idle callbacks added by the text control on the change of input style.
1185 application.RunIdles();
1187 gInputStyleChangedCallbackCalled = false;
1188 gInputStyleMask = TextField::InputStyle::NONE;
1189 inputStyleChangedSignal = false;
1191 // Create a tap event to touch the text field.
1192 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1193 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1194 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1195 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1197 // Render and notify
1198 application.SendNotification();
1199 application.Render();
1201 // Executes the idle callbacks added by the text control on the change of input style.
1202 application.RunIdles();
1204 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1205 if( gInputStyleChangedCallbackCalled )
1207 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1208 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1209 TextField::InputStyle::POINT_SIZE |
1210 TextField::InputStyle::COLOR ),
1213 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1214 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1216 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1217 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1219 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1220 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1222 DALI_TEST_CHECK( inputStyleChangedSignal );
1224 gInputStyleChangedCallbackCalled = false;
1225 gInputStyleMask = TextField::InputStyle::NONE;
1226 inputStyleChangedSignal = false;
1228 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1230 // Render and notify
1231 application.SendNotification();
1232 application.Render();
1234 // Executes the idle callbacks added by the text control on the change of input style.
1235 application.RunIdles();
1237 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1238 if( gInputStyleChangedCallbackCalled )
1240 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1241 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1244 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1245 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1247 DALI_TEST_CHECK( inputStyleChangedSignal );
1249 gInputStyleChangedCallbackCalled = false;
1250 gInputStyleMask = TextField::InputStyle::NONE;
1251 inputStyleChangedSignal = false;
1253 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1255 // Render and notify
1256 application.SendNotification();
1257 application.Render();
1259 // Executes the idle callbacks added by the text control on the change of input style.
1260 application.RunIdles();
1262 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1263 DALI_TEST_CHECK( !inputStyleChangedSignal );
1265 gInputStyleChangedCallbackCalled = false;
1266 gInputStyleMask = TextField::InputStyle::NONE;
1267 inputStyleChangedSignal = false;
1269 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1271 // Render and notify
1272 application.SendNotification();
1273 application.Render();
1275 // Executes the idle callbacks added by the text control on the change of input style.
1276 application.RunIdles();
1278 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1279 if( gInputStyleChangedCallbackCalled )
1281 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1282 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1285 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1286 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1288 DALI_TEST_CHECK( inputStyleChangedSignal );
1290 gInputStyleChangedCallbackCalled = false;
1291 gInputStyleMask = TextField::InputStyle::NONE;
1292 inputStyleChangedSignal = false;
1294 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1296 Property::Map fontStyleMapSet;
1297 fontStyleMapSet.Insert( "weight", "thin" );
1298 fontStyleMapSet.Insert( "width", "condensed" );
1299 fontStyleMapSet.Insert( "slant", "italic" );
1301 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1302 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1304 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1305 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1306 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1307 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1309 // Render and notify
1310 application.SendNotification();
1311 application.Render();
1313 // Executes the idle callbacks added by the text control on the change of input style.
1314 application.RunIdles();
1316 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1317 DALI_TEST_CHECK( !inputStyleChangedSignal );
1319 // Create a tap event to touch the text field.
1320 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1321 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1323 // Render and notify
1324 application.SendNotification();
1325 application.Render();
1327 // Executes the idle callbacks added by the text control on the change of input style.
1328 application.RunIdles();
1330 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1331 if( gInputStyleChangedCallbackCalled )
1333 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1334 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1335 TextField::InputStyle::POINT_SIZE |
1336 TextField::InputStyle::FONT_STYLE |
1337 TextField::InputStyle::UNDERLINE |
1338 TextField::InputStyle::SHADOW |
1339 TextField::InputStyle::EMBOSS |
1340 TextField::InputStyle::OUTLINE ),
1343 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1344 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1346 DALI_TEST_CHECK( inputStyleChangedSignal );
1351 int utcDaliTextFieldEvent01(void)
1353 ToolkitTestApplication application;
1354 tet_infoline(" utcDaliTextFieldEvent01");
1356 // Creates a tap event. After creating a tap event the text field should
1357 // have the focus and add text with key events should be possible.
1359 TextField field = TextField::New();
1360 DALI_TEST_CHECK( field );
1362 Stage::GetCurrent().Add( field );
1364 field.SetSize( 300.f, 50.f );
1365 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1366 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1368 // Avoid a crash when core load gl resources.
1369 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1371 // Render and notify
1372 application.SendNotification();
1373 application.Render();
1375 // Add a key event but as the text field has not the focus it should do nothing.
1376 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1378 // Render and notify
1379 application.SendNotification();
1380 application.Render();
1382 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1384 // Create a tap event to touch the text field.
1385 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1386 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1388 // Render and notify
1389 application.SendNotification();
1390 application.Render();
1392 // Now the text field has the focus, so it can handle the key events.
1393 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1394 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1396 // Render and notify
1397 application.SendNotification();
1398 application.Render();
1400 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1402 // Create a second text field and send key events to it.
1403 TextField field2 = TextField::New();
1405 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1406 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1407 field2.SetSize( 100.f, 100.f );
1408 field2.SetPosition( 100.f, 100.f );
1410 Stage::GetCurrent().Add( field2 );
1412 // Render and notify
1413 application.SendNotification();
1414 application.Render();
1416 // Create a tap event on the second text field.
1417 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1418 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1420 // Render and notify
1421 application.SendNotification();
1422 application.Render();
1424 // The second text field has the focus. It should handle the key events.
1425 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1426 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1428 // Render and notify
1429 application.SendNotification();
1430 application.Render();
1432 // Check the text has been added to the second text field.
1433 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1438 int utcDaliTextFieldEvent02(void)
1440 ToolkitTestApplication application;
1441 tet_infoline(" utcDaliTextFieldEvent02");
1443 // Checks if the right number of actors are created.
1445 TextField field = TextField::New();
1446 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1447 DALI_TEST_CHECK( field );
1448 LoadMarkerImages(application, field);
1450 Stage::GetCurrent().Add( field );
1452 field.SetSize( 300.f, 50.f );
1453 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1454 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1456 // Avoid a crash when core load gl resources.
1457 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1459 // Render and notify
1460 application.SendNotification();
1461 application.Render();
1463 // Check there are the expected number of children ( offscreen root actor, and the offscreen image view
1464 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1466 Actor offscreenRoot = field.GetChildAt( 0u );
1467 DALI_TEST_CHECK( offscreenRoot.IsLayer() );
1468 DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor.
1470 Actor offscreenImage = field.GetChildAt( 1u );
1471 DALI_TEST_CHECK( offscreenImage );
1473 // Create a tap event to touch the text field.
1474 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1475 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1477 // Render and notify
1478 application.SendNotification();
1479 application.Render();
1481 Actor layer = field.GetChildAt( 2u );
1482 DALI_TEST_CHECK( layer.IsLayer() );
1484 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1485 DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor.
1487 // Now the text field has the focus, so it can handle the key events.
1488 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1489 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1491 // Render and notify
1492 application.SendNotification();
1493 application.Render();
1495 // Checks the cursor and the renderer have been created.
1496 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1497 DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 2u, TEST_LOCATION ); // The camera actor and the renderer
1499 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1500 DALI_TEST_CHECK( cursor );
1502 CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) );
1503 DALI_TEST_CHECK( camera );
1505 // The offscreen root actor has a container with all the actors which contain the text renderers.
1506 Actor container = offscreenRoot.GetChildAt( 1u );
1507 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1509 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1510 DALI_TEST_CHECK( renderer );
1513 // Move the cursor and check the position changes.
1514 Vector3 position1 = cursor.GetCurrentPosition();
1516 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1517 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1519 // Render and notify
1520 application.SendNotification();
1521 application.Render();
1523 Vector3 position2 = cursor.GetCurrentPosition();
1525 DALI_TEST_CHECK( position2.x < position1.x );
1527 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1528 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1530 // Render and notify
1531 application.SendNotification();
1532 application.Render();
1534 Vector3 position3 = cursor.GetCurrentPosition();
1536 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1538 // Send some taps and check the cursor positions.
1540 // Try to tap at the beginning.
1541 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1542 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1544 // Render and notify
1545 application.SendNotification();
1546 application.Render();
1548 // Cursor position should be the same than position1.
1549 Vector3 position4 = cursor.GetCurrentPosition();
1551 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1553 // Tap away from the start position.
1554 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1555 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1557 // Render and notify
1558 application.SendNotification();
1559 application.Render();
1561 Vector3 position5 = cursor.GetCurrentPosition();
1563 DALI_TEST_CHECK( position5.x > position4.x );
1565 // Remove all the text.
1566 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1567 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1568 field.SetProperty( TextField::Property::TEXT, "" );
1570 // Render and notify
1571 application.SendNotification();
1572 application.Render();
1574 // Cursor position should be the same than position2.
1575 Vector3 position6 = cursor.GetCurrentPosition();
1577 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1579 // Should not be a renderer.
1580 DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor only.
1585 int utcDaliTextFieldEvent03(void)
1587 ToolkitTestApplication application;
1588 tet_infoline(" utcDaliTextFieldEvent03");
1590 // Checks if the highlight actor is created.
1592 TextField field = TextField::New();
1593 DALI_TEST_CHECK( field );
1595 Stage::GetCurrent().Add( field );
1597 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1598 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1599 field.SetSize( 30.f, 50.f );
1600 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1601 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1603 // Avoid a crash when core load gl resources.
1604 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1605 LoadMarkerImages(application, field);
1607 // Render and notify
1608 application.SendNotification();
1609 application.Render();
1611 // Tap first to get the focus.
1612 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1613 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1615 // Render and notify
1616 application.SendNotification();
1617 application.Render();
1619 // Double tap to select a word.
1620 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1621 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1623 // Render and notify
1624 application.SendNotification();
1625 application.Render();
1627 // The offscreen root actor should have three actors: the camera, a renderer and the highlight actor.
1628 Actor offscreenRoot = field.GetChildAt( 1u );
1629 DALI_TEST_CHECK( offscreenRoot.IsLayer() );
1631 CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) );
1632 DALI_TEST_CHECK( camera );
1634 // The offscreen root actor has a container with all the actors which contain the text renderers.
1635 Actor container = offscreenRoot.GetChildAt( 1u );
1636 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1638 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1639 DALI_TEST_CHECK( renderer );
1642 Renderer highlight = offscreenRoot.GetChildAt( 2u ).GetRendererAt( 0u );
1643 DALI_TEST_CHECK( highlight );
1648 int utcDaliTextFieldEvent04(void)
1650 ToolkitTestApplication application;
1651 tet_infoline(" utcDaliTextFieldEvent04");
1653 // Checks if the highlight actor is created.
1655 TextField field = TextField::New();
1656 DALI_TEST_CHECK( field );
1657 Stage::GetCurrent().Add( field );
1658 LoadMarkerImages(application, field);
1659 // Render and notify
1660 application.SendNotification();
1661 application.Render();
1663 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1664 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1665 field.SetSize( 300.f, 50.f );
1666 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1667 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1669 // Avoid a crash when core load gl resources.
1670 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1671 // Render and notify
1672 application.SendNotification();
1673 application.Render();
1675 // Create a tap event to touch the text field.
1676 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1677 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1678 // Render and notify
1679 application.SendNotification();
1680 application.Render();
1683 // Tap first to get the focus.
1684 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1685 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1687 // Render and notify
1688 application.SendNotification();
1689 application.Render();
1691 // Double tap to select a word.
1692 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1693 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1695 // Render and notify
1696 application.SendNotification();
1697 application.Render();
1700 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1701 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1705 int utcDaliTextFieldEvent05(void)
1707 ToolkitTestApplication application;
1708 tet_infoline(" utcDaliTextFieldEvent05");
1710 // Checks dragging of cursor/grab handle
1712 TextField field = TextField::New();
1713 DALI_TEST_CHECK( field );
1714 Stage::GetCurrent().Add( field );
1715 LoadMarkerImages(application, field);
1716 // Render and notify
1717 application.SendNotification();
1718 application.Render();
1720 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1721 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1722 field.SetSize( 300.f, 50.f );
1723 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1724 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1726 // Avoid a crash when core load gl resources.
1727 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1728 // Render and notify
1729 application.SendNotification();
1730 application.Render();
1732 // Create a tap event to touch the text field.
1733 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1734 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1735 // Render and notify
1736 application.SendNotification();
1737 application.Render();
1740 // Tap first to get the focus.
1741 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1742 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1744 // Render and notify
1745 application.SendNotification();
1746 application.Render();
1748 // Double tap to select a word.
1749 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1750 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1752 // Render and notify
1753 application.SendNotification();
1754 application.Render();
1756 // drag grab handle right
1757 Vector2 pos(0.0f, 40.0f);
1758 SendPan(application, Gesture::Possible, pos);
1759 SendPan(application, Gesture::Started, pos);
1761 Wait(application, 100);
1763 for(int i = 0;i<20;i++)
1765 SendPan(application, Gesture::Continuing, pos);
1770 SendPan(application, Gesture::Finished, pos);
1771 Wait(application, RENDER_FRAME_INTERVAL);
1773 Actor offscreenRoot = field.GetChildAt( 1u );
1777 int utcDaliTextFieldEvent06(void)
1779 ToolkitTestApplication application;
1780 tet_infoline(" utcDaliTextFieldEvent06");
1782 // Checks Longpress when in edit mode
1784 TextField field = TextField::New();
1785 DALI_TEST_CHECK( field );
1786 Stage::GetCurrent().Add( field );
1787 LoadMarkerImages(application, field);
1788 // Render and notify
1789 application.SendNotification();
1790 application.Render();
1792 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1793 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1794 field.SetSize( 300.f, 50.f );
1795 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1796 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1798 // Avoid a crash when core load gl resources.
1799 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1800 // Render and notify
1801 application.SendNotification();
1802 application.Render();
1804 // Create a tap event to touch the text field.
1805 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1806 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1807 // Render and notify
1808 application.SendNotification();
1809 application.Render();
1812 // Tap first to get the focus.
1813 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1814 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1816 // Render and notify
1817 application.SendNotification();
1818 application.Render();
1821 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1822 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1824 // Render and notify
1825 application.SendNotification();
1826 application.Render();
1831 int utcDaliTextFieldEvent07(void)
1833 ToolkitTestApplication application;
1834 tet_infoline(" utcDaliTextFieldEvent07");
1836 // Checks Longpress to start edit mode
1838 TextField field = TextField::New();
1839 DALI_TEST_CHECK( field );
1840 Stage::GetCurrent().Add( field );
1841 LoadMarkerImages(application, field);
1842 // Render and notify
1843 application.SendNotification();
1844 application.Render();
1846 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1847 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1848 field.SetSize( 300.f, 50.f );
1849 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1850 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1852 // Avoid a crash when core load gl resources.
1853 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1854 // Render and notify
1855 application.SendNotification();
1856 application.Render();
1859 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1860 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1862 // Render and notify
1863 application.SendNotification();
1864 application.Render();
1869 int utcDaliTextFieldEvent08(void)
1871 ToolkitTestApplication application;
1872 tet_infoline(" utcDaliTextFieldEvent08");
1874 Dali::Clipboard clipboard = Clipboard::Get();
1875 clipboard.SetItem("testTextFieldEvent");
1877 // Checks Longpress when only place holder text
1879 TextField field = TextField::New();
1880 DALI_TEST_CHECK( field );
1881 Stage::GetCurrent().Add( field );
1882 LoadMarkerImages(application, field);
1883 // Render and notify
1884 application.SendNotification();
1885 application.Render();
1887 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
1888 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1889 field.SetSize( 300.f, 50.f );
1890 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1891 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1893 // Avoid a crash when core load gl resources.
1894 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1895 // Render and notify
1896 application.SendNotification();
1897 application.Render();
1900 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1901 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1903 // Render and notify
1904 application.SendNotification();
1905 application.Render();
1907 Wait(application, 500);
1909 Stage stage = Stage::GetCurrent();
1910 Layer layer = stage.GetRootLayer();
1911 Actor actor = layer.FindChildByName("optionPaste");
1915 Vector3 worldPosition = actor.GetCurrentWorldPosition();
1916 Vector2 halfStageSize = stage.GetSize() / 2.0f;
1917 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
1919 Dali::Integration::TouchEvent event;
1920 event = Dali::Integration::TouchEvent();
1921 event.AddPoint( GetPointDownInside( position ) );
1922 application.ProcessEvent( event );
1924 event = Dali::Integration::TouchEvent();
1925 event.AddPoint( GetPointUpInside( position ) );
1926 application.ProcessEvent( event );
1928 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
1932 int utcDaliTextFieldStyleWhilstSelected(void)
1934 ToolkitTestApplication application;
1935 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
1937 // Change font and styles whilst text is selected whilst word selected
1939 TextField field = TextField::New();
1940 DALI_TEST_CHECK( field );
1941 Stage::GetCurrent().Add( field );
1942 LoadMarkerImages(application, field);
1943 // Render and notify
1944 application.SendNotification();
1945 application.Render();
1947 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1948 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1949 field.SetSize( 300.f, 50.f );
1950 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1951 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1953 // Avoid a crash when core load gl resources.
1954 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1955 // Render and notify
1956 application.SendNotification();
1957 application.Render();
1959 // Create a tap event to touch the text field.
1960 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1961 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1962 // Render and notify
1963 application.SendNotification();
1964 application.Render();
1967 // Tap first to get the focus.
1968 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1969 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1971 // Render and notify
1972 application.SendNotification();
1973 application.Render();
1975 // Double tap to select a word.
1976 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1977 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1979 // Render and notify
1980 application.SendNotification();
1981 application.Render();
1983 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
1984 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
1986 Property::Map fontStyleMapSet;
1987 Property::Map fontStyleMapGet;
1989 fontStyleMapSet.Insert( "weight", "bold" );
1990 fontStyleMapSet.Insert( "slant", "italic" );
1991 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1993 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
1994 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1995 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1997 fontStyleMapSet.Clear();
1998 fontStyleMapSet.Insert( "width", "expanded" );
1999 fontStyleMapSet.Insert( "slant", "italic" );
2000 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2002 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2003 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2004 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2006 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2007 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2009 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2010 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2012 fontStyleMapSet.Clear();
2013 fontStyleMapSet.Insert( "weight", "bold" );
2014 fontStyleMapSet.Insert( "slant", "italic" );
2016 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2018 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2019 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2020 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2022 fontStyleMapSet.Clear();
2023 fontStyleMapSet.Insert( "width", "expanded" );
2025 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2027 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2028 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2029 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );