2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali/public-api/rendering/renderer.h>
23 #include <dali/integration-api/events/key-event-integ.h>
24 #include <dali/integration-api/events/tap-gesture-event.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/integration-api/events/pan-gesture-event.h>
27 #include <dali/integration-api/events/long-press-gesture-event.h>
28 #include <dali-toolkit-test-suite-utils.h>
29 #include <dali-toolkit/dali-toolkit.h>
30 #include "toolkit-clipboard.h"
33 using namespace Toolkit;
35 void dali_textfield_startup(void)
37 test_return_value = TET_UNDEF;
40 void dali_textfield_cleanup(void)
42 test_return_value = TET_PASS;
48 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
49 const char* const PROPERTY_NAME_TEXT = "text";
50 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
51 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
52 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
53 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
54 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
55 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
56 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
57 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
58 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
59 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
60 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
61 const char* const PROPERTY_NAME_SHADOW_OFFSET = "shadowOffset";
62 const char* const PROPERTY_NAME_SHADOW_COLOR = "shadowColor";
63 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
64 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
65 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
66 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
67 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
68 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
69 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
70 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
71 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
72 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
73 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
80 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
81 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
82 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
83 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
84 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
85 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
86 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
88 const char* const PROPERTY_NAME_UNDERLINE = "underline";
89 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
90 const char* const PROPERTY_NAME_SHADOW = "shadow";
91 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
92 const char* const PROPERTY_NAME_EMBOSS = "emboss";
93 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
94 const char* const PROPERTY_NAME_OUTLINE = "outline";
95 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
97 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
99 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
100 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
102 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
103 const float RENDER_FRAME_INTERVAL = 16.66f;
105 const float TO_MILLISECONDS = 1000.f;
106 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
108 const float SCROLL_THRESHOLD = 10.f;
109 const float SCROLL_SPEED = 300.f;
111 const unsigned int DEFAULT_FONT_SIZE = 1152u;
112 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
114 static bool gTextChangedCallBackCalled;
115 static bool gMaxCharactersCallBackCalled;
116 static bool gInputStyleChangedCallbackCalled;
117 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
119 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
121 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
122 Integration::ResourcePointer resource(bitmap);
123 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
126 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
130 LoadBitmapResource( app.GetPlatform(), width, height );
132 Property::Map propertyMap;
133 propertyMap["filename"] = "image.png";
134 propertyMap["width"] = width;
135 propertyMap["height"] = height;
136 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
137 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
138 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
139 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
140 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
141 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
142 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
143 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
146 // Generate a PanGestureEvent to send to Core
147 static Integration::PanGestureEvent GeneratePan(
148 Gesture::State state,
149 const Vector2& previousPosition,
150 const Vector2& currentPosition,
151 unsigned long timeDelta,
152 unsigned int numberOfTouches = 1)
154 Integration::PanGestureEvent pan(state);
156 pan.previousPosition = previousPosition;
157 pan.currentPosition = currentPosition;
158 pan.timeDelta = timeDelta;
159 pan.numberOfTouches = numberOfTouches;
165 * Helper to generate PanGestureEvent
167 * @param[in] application Application instance
168 * @param[in] state The Gesture State
169 * @param[in] pos The current position of touch.
171 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
175 if( (state == Gesture::Started) ||
176 (state == Gesture::Possible) )
182 application.ProcessEvent(GeneratePan(state, last, pos, 16));
189 * Simulate time passed by.
191 * @note this will always process at least 1 frame (1/60 sec)
193 * @param application Test application instance
194 * @param duration Time to pass in milliseconds.
195 * @return The actual time passed in milliseconds
197 static int Wait(ToolkitTestApplication& application, int duration = 0)
201 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
203 application.SendNotification();
204 application.Render(RENDER_FRAME_INTERVAL);
205 time += RENDER_FRAME_INTERVAL;
211 Dali::Integration::Point GetPointDownInside( Vector2& pos )
213 Dali::Integration::Point point;
214 point.SetState( PointState::DOWN );
215 point.SetScreenPosition( pos );
219 Dali::Integration::Point GetPointUpInside( Vector2& pos )
221 Dali::Integration::Point point;
222 point.SetState( PointState::UP );
223 point.SetScreenPosition( pos );
227 struct CallbackFunctor
229 CallbackFunctor(bool* callbackFlag)
230 : mCallbackFlag( callbackFlag )
236 *mCallbackFlag = true;
241 static void TestTextChangedCallback( TextField control )
243 tet_infoline(" TestTextChangedCallback");
245 gTextChangedCallBackCalled = true;
248 static void TestMaxLengthReachedCallback( TextField control )
250 tet_infoline(" TestMaxLengthReachedCallback");
252 gMaxCharactersCallBackCalled = true;
255 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
257 tet_infoline(" TestInputStyleChangedCallback");
259 gInputStyleChangedCallbackCalled = true;
260 gInputStyleMask = mask;
263 // Generate a TapGestureEvent to send to Core.
264 Integration::TapGestureEvent GenerateTap(
265 Gesture::State state,
266 unsigned int numberOfTaps,
267 unsigned int numberOfTouches,
270 Integration::TapGestureEvent tap( state );
272 tap.numberOfTaps = numberOfTaps;
273 tap.numberOfTouches = numberOfTouches;
279 Integration::LongPressGestureEvent GenerateLongPress(
280 Gesture::State state,
281 unsigned int numberOfTouches,
284 Integration::LongPressGestureEvent longPress( state );
286 longPress.numberOfTouches = numberOfTouches;
287 longPress.point = point;
291 // Generate a KeyEvent to send to Core.
292 Integration::KeyEvent GenerateKey( const std::string& keyName,
293 const std::string& keyString,
296 unsigned long timeStamp,
297 const Integration::KeyEvent::State& keyState )
299 return Integration::KeyEvent( keyName,
307 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
309 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
311 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
313 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
315 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
316 if( NULL != valueSet )
318 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
320 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
326 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
337 int UtcDaliToolkitTextFieldConstructorP(void)
339 ToolkitTestApplication application;
340 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
342 DALI_TEST_CHECK( !textField );
346 int UtcDaliToolkitTextFieldNewP(void)
348 ToolkitTestApplication application;
349 tet_infoline(" UtcDaliToolkitTextFieldNewP");
350 TextField textField = TextField::New();
351 DALI_TEST_CHECK( textField );
355 int UtcDaliToolkitTextFieldDownCastP(void)
357 ToolkitTestApplication application;
358 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
359 TextField textField1 = TextField::New();
360 BaseHandle object( textField1 );
362 TextField textField2 = TextField::DownCast( object );
363 DALI_TEST_CHECK( textField2 );
365 TextField textField3 = DownCast< TextField >( object );
366 DALI_TEST_CHECK( textField3 );
370 int UtcDaliToolkitTextFieldDownCastN(void)
372 ToolkitTestApplication application;
373 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
374 BaseHandle uninitializedObject;
375 TextField textField1 = TextField::DownCast( uninitializedObject );
376 DALI_TEST_CHECK( !textField1 );
378 TextField textField2 = DownCast< TextField >( uninitializedObject );
379 DALI_TEST_CHECK( !textField2 );
383 int UtcDaliToolkitTextFieldCopyConstructorP(void)
385 ToolkitTestApplication application;
386 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
387 TextField textField = TextField::New();
388 textField.SetProperty( TextField::Property::TEXT, "Test" );
390 TextField copy( textField );
391 DALI_TEST_CHECK( copy );
392 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
396 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
398 ToolkitTestApplication application;
399 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
400 TextField textField = TextField::New();
401 textField.SetProperty( TextField::Property::TEXT, "Test" );
403 TextField copy = textField;
404 DALI_TEST_CHECK( copy );
405 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
409 int UtcDaliTextFieldNewP(void)
411 ToolkitTestApplication application;
412 tet_infoline(" UtcDaliToolkitTextFieldNewP");
413 TextField textField = TextField::New();
414 DALI_TEST_CHECK( textField );
418 // Positive test case for a method
419 int UtcDaliTextFieldGetPropertyP(void)
421 ToolkitTestApplication application;
422 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
423 TextField field = TextField::New();
424 DALI_TEST_CHECK( field );
426 // Check Property Indices are correct
427 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
428 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
429 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
430 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
431 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
432 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
433 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
434 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
435 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
436 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
437 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
438 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
439 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
440 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextField::Property::SHADOW_OFFSET );
441 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextField::Property::SHADOW_COLOR );
442 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
443 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
444 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
445 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
446 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
447 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
448 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
449 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
450 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
451 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
452 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
453 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
454 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
455 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
456 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
457 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
458 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
459 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
460 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
461 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
462 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
463 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
464 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
465 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
466 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
467 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
468 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
469 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
470 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
471 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
472 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
473 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
478 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
481 Property::Map imageMap;
482 imageMap[mapKey] =mapValue;
484 field.SetProperty( property , imageMap );
485 Property::Value propValue = field.GetProperty( property );
486 Property::Map* resultMap = propValue.GetMap();
488 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
496 // Positive test case for a method
497 int UtcDaliTextFieldSetPropertyP(void)
499 ToolkitTestApplication application;
500 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
501 TextField field = TextField::New();
502 DALI_TEST_CHECK( field );
503 Stage::GetCurrent().Add( field );
505 // Note - we can't check the defaults since the stylesheets are platform-specific
507 // Check the render backend property.
508 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
509 DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
511 // Check text property.
512 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
513 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
515 // Check placeholder text properties.
516 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
517 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
519 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
520 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
522 // Check font properties.
523 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
524 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
526 Property::Map fontStyleMapSet;
527 Property::Map fontStyleMapGet;
528 Property::Value* slantValue = NULL;
530 fontStyleMapSet.Insert( "weight", "bold" );
531 fontStyleMapSet.Insert( "width", "condensed" );
532 fontStyleMapSet.Insert( "slant", "italic" );
533 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
535 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
536 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
537 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
539 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
540 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
543 fontStyleMapSet.Clear();
544 fontStyleMapSet.Insert( "weight", "normal" );
545 fontStyleMapSet.Insert( "slant", "oblique" );
546 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
548 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
549 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
550 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
552 fontStyleMapSet.Clear();
553 fontStyleMapSet.Insert( "slant", "roman" );
554 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
555 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
557 // Replace 'roman' for 'normal'.
558 slantValue = fontStyleMapGet.Find( "slant" );
559 if( NULL != slantValue )
561 if( "normal" == slantValue->Get<std::string>() )
563 fontStyleMapGet["slant"] = "roman";
566 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
567 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
569 fontStyleMapSet.Clear();
571 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
572 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
573 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
574 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
576 // Check that the MAX_LENGTH property can be correctly set
577 const int maxNumberOfCharacters = 20;
578 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
579 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
581 // Check exceed policy
582 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
583 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
584 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
585 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
587 // Check that the Alignment properties can be correctly set
588 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
589 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
590 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
591 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
593 // Check text's color property
594 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
595 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
597 // Check placeholder text's color property.
598 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
599 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
601 // Check shadow properties.
602 field.SetProperty( TextField::Property::SHADOW_OFFSET, Vector2( 1.f, 1.f ) );
603 DALI_TEST_EQUALS( field.GetProperty<Vector2>( TextField::Property::SHADOW_OFFSET ), Vector2( 1.f, 1.f ), TEST_LOCATION );
604 field.SetProperty( TextField::Property::SHADOW_COLOR, Color::GREEN );
605 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SHADOW_COLOR ), Color::GREEN, TEST_LOCATION );
607 // Check cursor properties
608 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
609 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
610 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
611 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
613 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
614 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
615 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
616 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
617 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
618 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
619 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
620 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
622 // Check scroll properties.
623 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
624 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
625 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
626 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
628 // Check handle images
629 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
630 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
631 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
632 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
633 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
635 // Check handle images
636 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
637 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
638 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
639 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
640 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
641 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
643 // Check the highlight color
644 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
645 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
647 // Decoration bounding box
648 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
649 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
651 // Check the input method setting
652 Property::Map propertyMap;
653 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
654 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
655 InputMethod::ActionButtonTitle::Type actionButton = InputMethod::ActionButtonTitle::GO;
656 int inputVariation = 1;
657 propertyMap["PANEL_LAYOUT"] = panelLayout;
658 propertyMap["AUTO_CAPITALISE"] = autoCapital;
659 propertyMap["ACTION_BUTTON"] = actionButton;
660 propertyMap["VARIATION"] = inputVariation;
661 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
663 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
665 DALI_TEST_CHECK( value.Get( map ) );
668 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
669 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
672 DALI_TEST_CHECK( map[ "AUTO_CAPITALISE" ].Get( capital ) );
673 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
676 DALI_TEST_CHECK( map[ "ACTION_BUTTON" ].Get( action ) );
677 DALI_TEST_EQUALS( static_cast<int>(actionButton), action, TEST_LOCATION );
680 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
681 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
683 // Check input color property.
684 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
685 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
687 // Check the enable markup property.
688 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
689 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
690 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
692 // Check input font properties.
693 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
694 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
696 fontStyleMapSet.Clear();
697 fontStyleMapSet.Insert( "weight", "bold" );
698 fontStyleMapSet.Insert( "width", "condensed" );
699 fontStyleMapSet.Insert( "slant", "italic" );
701 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
702 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
703 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
704 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
706 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
707 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
709 // Reset input font style.
710 fontStyleMapSet.Clear();
711 fontStyleMapSet.Insert( "weight", "normal" );
712 fontStyleMapSet.Insert( "slant", "oblique" );
714 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
715 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
716 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
717 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
719 fontStyleMapSet.Clear();
720 fontStyleMapSet.Insert( "slant", "roman" );
722 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
723 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
725 // Replace 'roman' for 'normal'.
726 slantValue = fontStyleMapGet.Find( "slant" );
727 if( NULL != slantValue )
729 if( "normal" == slantValue->Get<std::string>() )
731 fontStyleMapGet["slant"] = "roman";
734 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
735 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
737 fontStyleMapSet.Clear();
739 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
740 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
741 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
742 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
744 Property::Map underlineMapSet;
745 Property::Map underlineMapGet;
747 underlineMapSet.Insert( "enable", "true" );
748 underlineMapSet.Insert( "color", "red" );
749 underlineMapSet.Insert( "height", "1" );
751 // Check the underline property
752 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
754 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
755 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
756 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
758 // Check the input underline property
759 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
760 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
762 // Check the shadow property
763 Property::Map shadowMapSet;
764 Property::Map shadowMapGet;
766 shadowMapSet.Insert( "color", "green" );
767 shadowMapSet.Insert( "offset", "2 2" );
769 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
771 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
772 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
773 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
775 // Check the input shadow property
776 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
777 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
779 // Check the emboss property
780 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
781 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
783 // Check the input emboss property
784 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
785 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
787 // Check the outline property
788 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
789 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
791 // Check the input outline property
792 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
793 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
798 // Positive Atlas Text Renderer test
799 int utcDaliTextFieldAtlasRenderP(void)
801 ToolkitTestApplication application;
802 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
803 StyleManager styleManager = StyleManager::Get();
804 styleManager.ApplyDefaultTheme();
805 TextField field = TextField::New();
806 DALI_TEST_CHECK( field );
808 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
810 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
812 Stage::GetCurrent().Add( field );
816 // Render some text with the shared atlas backend
817 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
818 application.SendNotification();
819 application.Render();
823 tet_result(TET_FAIL);
828 // Positive test for the textChanged signal.
829 int utcDaliTextFieldTextChangedP(void)
831 ToolkitTestApplication application;
832 tet_infoline(" utcDaliTextFieldTextChangedP");
833 TextField field = TextField::New();
834 DALI_TEST_CHECK( field );
836 Stage::GetCurrent().Add( field );
838 // connect to the text changed signal.
839 ConnectionTracker* testTracker = new ConnectionTracker();
840 field.TextChangedSignal().Connect(&TestTextChangedCallback);
841 bool textChangedSignal = false;
842 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
844 gTextChangedCallBackCalled = false;
845 field.SetProperty( TextField::Property::TEXT, "ABC" );
846 DALI_TEST_CHECK( gTextChangedCallBackCalled );
847 DALI_TEST_CHECK( textChangedSignal );
849 application.SendNotification();
851 field.SetKeyInputFocus();
853 gTextChangedCallBackCalled = false;
854 application.ProcessEvent( GenerateKey( "D", "D", 0, 0, 0, Integration::KeyEvent::Down ) );
855 DALI_TEST_CHECK( gTextChangedCallBackCalled );
860 // Negative test for the textChanged signal.
861 int utcDaliTextFieldTextChangedN(void)
863 ToolkitTestApplication application;
864 tet_infoline(" utcDaliTextFieldTextChangedN");
865 TextField field = TextField::New();
866 DALI_TEST_CHECK( field );
868 Stage::GetCurrent().Add( field );
870 // connect to the text changed signal.
871 ConnectionTracker* testTracker = new ConnectionTracker();
872 field.TextChangedSignal().Connect(&TestTextChangedCallback);
873 bool textChangedSignal = false;
874 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
876 gTextChangedCallBackCalled = false;
877 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
878 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
879 DALI_TEST_CHECK( !textChangedSignal );
884 // Positive test for Max Characters reached signal.
885 int utcDaliTextFieldMaxCharactersReachedP(void)
887 ToolkitTestApplication application;
888 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
889 TextField field = TextField::New();
890 DALI_TEST_CHECK( field );
892 Stage::GetCurrent().Add( field );
894 const int maxNumberOfCharacters = 1;
895 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
897 field.SetKeyInputFocus();
899 // connect to the text changed signal.
900 ConnectionTracker* testTracker = new ConnectionTracker();
901 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
902 bool maxLengthReachedSignal = false;
903 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
905 gMaxCharactersCallBackCalled = false;
907 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
908 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
910 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
911 DALI_TEST_CHECK( maxLengthReachedSignal );
916 // Negative test for Max Characters reached signal.
917 int utcDaliTextFieldMaxCharactersReachedN(void)
919 ToolkitTestApplication application;
920 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
921 TextField field = TextField::New();
922 DALI_TEST_CHECK( field );
924 Stage::GetCurrent().Add( field );
926 const int maxNumberOfCharacters = 3;
927 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
929 field.SetKeyInputFocus();
931 // connect to the text changed signal.
932 ConnectionTracker* testTracker = new ConnectionTracker();
933 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
934 bool maxLengthReachedSignal = false;
935 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
937 gMaxCharactersCallBackCalled = false;
939 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
940 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
942 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
943 DALI_TEST_CHECK( !maxLengthReachedSignal );
948 int utcDaliTextFieldInputStyleChanged01(void)
950 ToolkitTestApplication application;
951 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
953 // The text-field emits signals when the input style changes. These changes of style are
954 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
955 // can't be emitted during the size negotiation as the callbacks may update the UI.
956 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
957 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
958 application.CreateAdaptor();
962 char* pathNamePtr = get_current_dir_name();
963 const std::string pathName( pathNamePtr );
966 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
967 fontClient.SetDpi( 93u, 93u );
969 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
970 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
972 TextField field = TextField::New();
973 DALI_TEST_CHECK( field );
976 field.SetSize( 300.f, 50.f );
977 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
978 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
980 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
981 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
983 // connect to the text changed signal.
984 ConnectionTracker* testTracker = new ConnectionTracker();
985 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
986 bool inputStyleChangedSignal = false;
987 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
989 Stage::GetCurrent().Add( field );
992 application.SendNotification();
993 application.Render();
995 // Executes the idle callbacks added by the text control on the change of input style.
996 application.RunIdles();
998 gInputStyleChangedCallbackCalled = false;
999 gInputStyleMask = TextField::InputStyle::NONE;
1000 inputStyleChangedSignal = false;
1002 // Create a tap event to touch the text field.
1003 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1004 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1006 // Render and notify
1007 application.SendNotification();
1008 application.Render();
1010 // Executes the idle callbacks added by the text control on the change of input style.
1011 application.RunIdles();
1013 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1014 if( gInputStyleChangedCallbackCalled )
1016 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1018 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1019 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1021 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1022 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1024 DALI_TEST_CHECK( inputStyleChangedSignal );
1026 gInputStyleChangedCallbackCalled = false;
1027 gInputStyleMask = TextField::InputStyle::NONE;
1028 inputStyleChangedSignal = false;
1030 // Create a tap event to touch the text field.
1031 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1032 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1034 // Render and notify
1035 application.SendNotification();
1036 application.Render();
1038 // Executes the idle callbacks added by the text control on the change of input style.
1039 application.RunIdles();
1041 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1042 DALI_TEST_CHECK( !inputStyleChangedSignal );
1044 gInputStyleChangedCallbackCalled = false;
1045 gInputStyleMask = TextField::InputStyle::NONE;
1046 inputStyleChangedSignal = false;
1048 // Create a tap event to touch the text field.
1049 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1050 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1052 // Render and notify
1053 application.SendNotification();
1054 application.Render();
1056 // Executes the idle callbacks added by the text control on the change of input style.
1057 application.RunIdles();
1059 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1060 if( gInputStyleChangedCallbackCalled )
1062 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1064 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1065 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1067 DALI_TEST_CHECK( inputStyleChangedSignal );
1069 gInputStyleChangedCallbackCalled = false;
1070 gInputStyleMask = TextField::InputStyle::NONE;
1071 inputStyleChangedSignal = false;
1073 // Create a tap event to touch the text field.
1074 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1075 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1077 // Render and notify
1078 application.SendNotification();
1079 application.Render();
1081 // Executes the idle callbacks added by the text control on the change of input style.
1082 application.RunIdles();
1084 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1085 if( gInputStyleChangedCallbackCalled )
1087 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1089 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1090 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1092 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1094 Property::Map fontStyleMapSet;
1095 fontStyleMapSet.Insert( "weight", "bold" );
1097 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1098 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1100 DALI_TEST_CHECK( inputStyleChangedSignal );
1102 gInputStyleChangedCallbackCalled = false;
1103 gInputStyleMask = TextField::InputStyle::NONE;
1104 inputStyleChangedSignal = false;
1106 // Create a tap event to touch the text field.
1107 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1108 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1110 // Render and notify
1111 application.SendNotification();
1112 application.Render();
1114 // Executes the idle callbacks added by the text control on the change of input style.
1115 application.RunIdles();
1117 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1118 DALI_TEST_CHECK( !inputStyleChangedSignal );
1120 gInputStyleChangedCallbackCalled = false;
1121 gInputStyleMask = TextField::InputStyle::NONE;
1122 inputStyleChangedSignal = false;
1124 // Create a tap event to touch the text field.
1125 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1126 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1128 // Render and notify
1129 application.SendNotification();
1130 application.Render();
1132 // Executes the idle callbacks added by the text control on the change of input style.
1133 application.RunIdles();
1135 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1136 if( gInputStyleChangedCallbackCalled )
1138 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1140 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1141 DALI_TEST_CHECK( style.empty() );
1143 DALI_TEST_CHECK( inputStyleChangedSignal );
1145 gInputStyleChangedCallbackCalled = false;
1146 gInputStyleMask = TextField::InputStyle::NONE;
1147 inputStyleChangedSignal = false;
1149 // Create a tap event to touch the text field.
1150 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1151 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1153 // Render and notify
1154 application.SendNotification();
1155 application.Render();
1157 // Executes the idle callbacks added by the text control on the change of input style.
1158 application.RunIdles();
1160 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1161 DALI_TEST_CHECK( !inputStyleChangedSignal );
1166 int utcDaliTextFieldInputStyleChanged02(void)
1168 ToolkitTestApplication application;
1169 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1171 // The text-field emits signals when the input style changes. These changes of style are
1172 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1173 // can't be emitted during the size negotiation as the callbacks may update the UI.
1174 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1175 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1176 application.CreateAdaptor();
1180 char* pathNamePtr = get_current_dir_name();
1181 const std::string pathName( pathNamePtr );
1182 free( pathNamePtr );
1184 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1185 fontClient.SetDpi( 93u, 93u );
1187 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1188 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1190 TextField field = TextField::New();
1191 DALI_TEST_CHECK( field );
1194 field.SetSize( 300.f, 50.f );
1195 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1196 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1198 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1199 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>" );
1201 // connect to the text changed signal.
1202 ConnectionTracker* testTracker = new ConnectionTracker();
1203 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1204 bool inputStyleChangedSignal = false;
1205 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1207 Stage::GetCurrent().Add( field );
1209 // Render and notify
1210 application.SendNotification();
1211 application.Render();
1213 // Executes the idle callbacks added by the text control on the change of input style.
1214 application.RunIdles();
1216 gInputStyleChangedCallbackCalled = false;
1217 gInputStyleMask = TextField::InputStyle::NONE;
1218 inputStyleChangedSignal = false;
1220 // Create a tap event to touch the text field.
1221 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1222 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1223 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1224 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1226 // Render and notify
1227 application.SendNotification();
1228 application.Render();
1230 // Executes the idle callbacks added by the text control on the change of input style.
1231 application.RunIdles();
1233 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1234 if( gInputStyleChangedCallbackCalled )
1236 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1237 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1238 TextField::InputStyle::POINT_SIZE |
1239 TextField::InputStyle::COLOR ),
1242 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1243 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1245 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1246 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1248 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1249 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1251 DALI_TEST_CHECK( inputStyleChangedSignal );
1253 gInputStyleChangedCallbackCalled = false;
1254 gInputStyleMask = TextField::InputStyle::NONE;
1255 inputStyleChangedSignal = false;
1257 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1259 // Render and notify
1260 application.SendNotification();
1261 application.Render();
1263 // Executes the idle callbacks added by the text control on the change of input style.
1264 application.RunIdles();
1266 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1267 if( gInputStyleChangedCallbackCalled )
1269 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1270 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1273 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1274 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1276 DALI_TEST_CHECK( inputStyleChangedSignal );
1278 gInputStyleChangedCallbackCalled = false;
1279 gInputStyleMask = TextField::InputStyle::NONE;
1280 inputStyleChangedSignal = false;
1282 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1284 // Render and notify
1285 application.SendNotification();
1286 application.Render();
1288 // Executes the idle callbacks added by the text control on the change of input style.
1289 application.RunIdles();
1291 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1292 DALI_TEST_CHECK( !inputStyleChangedSignal );
1294 gInputStyleChangedCallbackCalled = false;
1295 gInputStyleMask = TextField::InputStyle::NONE;
1296 inputStyleChangedSignal = false;
1298 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1300 // Render and notify
1301 application.SendNotification();
1302 application.Render();
1304 // Executes the idle callbacks added by the text control on the change of input style.
1305 application.RunIdles();
1307 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1308 if( gInputStyleChangedCallbackCalled )
1310 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1311 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1314 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1315 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1317 DALI_TEST_CHECK( inputStyleChangedSignal );
1319 gInputStyleChangedCallbackCalled = false;
1320 gInputStyleMask = TextField::InputStyle::NONE;
1321 inputStyleChangedSignal = false;
1323 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1325 Property::Map fontStyleMapSet;
1326 fontStyleMapSet.Insert( "weight", "thin" );
1327 fontStyleMapSet.Insert( "width", "condensed" );
1328 fontStyleMapSet.Insert( "slant", "italic" );
1330 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1331 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1333 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1334 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1335 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1336 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1338 // Render and notify
1339 application.SendNotification();
1340 application.Render();
1342 // Executes the idle callbacks added by the text control on the change of input style.
1343 application.RunIdles();
1345 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1346 DALI_TEST_CHECK( !inputStyleChangedSignal );
1348 // Create a tap event to touch the text field.
1349 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1350 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1352 // Render and notify
1353 application.SendNotification();
1354 application.Render();
1356 // Executes the idle callbacks added by the text control on the change of input style.
1357 application.RunIdles();
1359 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1360 if( gInputStyleChangedCallbackCalled )
1362 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1363 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1364 TextField::InputStyle::POINT_SIZE |
1365 TextField::InputStyle::FONT_STYLE |
1366 TextField::InputStyle::UNDERLINE |
1367 TextField::InputStyle::SHADOW |
1368 TextField::InputStyle::EMBOSS |
1369 TextField::InputStyle::OUTLINE ),
1372 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1373 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1375 DALI_TEST_CHECK( inputStyleChangedSignal );
1380 int utcDaliTextFieldEvent01(void)
1382 ToolkitTestApplication application;
1383 tet_infoline(" utcDaliTextFieldEvent01");
1385 // Creates a tap event. After creating a tap event the text field should
1386 // have the focus and add text with key events should be possible.
1388 TextField field = TextField::New();
1389 DALI_TEST_CHECK( field );
1391 Stage::GetCurrent().Add( field );
1393 field.SetSize( 300.f, 50.f );
1394 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1395 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1397 // Avoid a crash when core load gl resources.
1398 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1400 // Render and notify
1401 application.SendNotification();
1402 application.Render();
1404 // Add a key event but as the text field has not the focus it should do nothing.
1405 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1407 // Render and notify
1408 application.SendNotification();
1409 application.Render();
1411 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1413 // Create a tap event to touch the text field.
1414 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1415 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1417 // Render and notify
1418 application.SendNotification();
1419 application.Render();
1421 // Now the text field has the focus, so it can handle the key events.
1422 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1423 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1425 // Render and notify
1426 application.SendNotification();
1427 application.Render();
1429 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1431 // Create a second text field and send key events to it.
1432 TextField field2 = TextField::New();
1434 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1435 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1436 field2.SetSize( 100.f, 100.f );
1437 field2.SetPosition( 100.f, 100.f );
1439 Stage::GetCurrent().Add( field2 );
1441 // Render and notify
1442 application.SendNotification();
1443 application.Render();
1445 // Create a tap event on the second text field.
1446 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1447 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1449 // Render and notify
1450 application.SendNotification();
1451 application.Render();
1453 // The second text field has the focus. It should handle the key events.
1454 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1455 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1457 // Render and notify
1458 application.SendNotification();
1459 application.Render();
1461 // Check the text has been added to the second text field.
1462 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1467 int utcDaliTextFieldEvent02(void)
1469 ToolkitTestApplication application;
1470 tet_infoline(" utcDaliTextFieldEvent02");
1472 // Checks if the right number of actors are created.
1474 TextField field = TextField::New();
1475 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1476 DALI_TEST_CHECK( field );
1477 LoadMarkerImages(application, field);
1479 Stage::GetCurrent().Add( field );
1481 field.SetSize( 300.f, 50.f );
1482 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1483 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1485 // Avoid a crash when core load gl resources.
1486 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1488 // Render and notify
1489 application.SendNotification();
1490 application.Render();
1492 // Check there are the expected number of children ( stencil ).
1493 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1495 Actor stencil = field.GetChildAt( 0u );
1496 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1498 // Create a tap event to touch the text field.
1499 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1500 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1502 // Render and notify
1503 application.SendNotification();
1504 application.Render();
1506 Actor layer = field.GetChildAt( 1u );
1507 DALI_TEST_CHECK( layer.IsLayer() );
1509 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1510 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1512 // Now the text field has the focus, so it can handle the key events.
1513 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1514 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1516 // Render and notify
1517 application.SendNotification();
1518 application.Render();
1520 // Checks the cursor and the renderer have been created.
1521 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1522 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1524 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1525 DALI_TEST_CHECK( cursor );
1527 // The offscreen root actor has a container with all the actors which contain the text renderers.
1528 Actor container = stencil.GetChildAt( 0u );
1529 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1531 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1532 DALI_TEST_CHECK( renderer );
1535 // Move the cursor and check the position changes.
1536 Vector3 position1 = cursor.GetCurrentPosition();
1538 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1539 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1541 // Render and notify
1542 application.SendNotification();
1543 application.Render();
1545 Vector3 position2 = cursor.GetCurrentPosition();
1547 DALI_TEST_CHECK( position2.x < position1.x );
1549 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1550 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1552 // Render and notify
1553 application.SendNotification();
1554 application.Render();
1556 Vector3 position3 = cursor.GetCurrentPosition();
1558 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1560 // Send some taps and check the cursor positions.
1562 // Try to tap at the beginning.
1563 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1564 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1566 // Render and notify
1567 application.SendNotification();
1568 application.Render();
1570 // Cursor position should be the same than position1.
1571 Vector3 position4 = cursor.GetCurrentPosition();
1573 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1575 // Tap away from the start position.
1576 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1577 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1579 // Render and notify
1580 application.SendNotification();
1581 application.Render();
1583 Vector3 position5 = cursor.GetCurrentPosition();
1585 DALI_TEST_CHECK( position5.x > position4.x );
1587 // Remove all the text.
1588 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1589 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1590 field.SetProperty( TextField::Property::TEXT, "" );
1592 // Render and notify
1593 application.SendNotification();
1594 application.Render();
1596 // Cursor position should be the same than position2.
1597 Vector3 position6 = cursor.GetCurrentPosition();
1599 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1601 // Should not be a renderer.
1602 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1607 int utcDaliTextFieldEvent03(void)
1609 ToolkitTestApplication application;
1610 tet_infoline(" utcDaliTextFieldEvent03");
1612 // Checks if the highlight actor is created.
1614 TextField field = TextField::New();
1615 DALI_TEST_CHECK( field );
1617 Stage::GetCurrent().Add( field );
1619 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1620 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1621 field.SetSize( 30.f, 50.f );
1622 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1623 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1625 // Avoid a crash when core load gl resources.
1626 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1627 LoadMarkerImages(application, field);
1629 // Render and notify
1630 application.SendNotification();
1631 application.Render();
1633 // Tap first to get the focus.
1634 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1635 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1637 // Render and notify
1638 application.SendNotification();
1639 application.Render();
1641 // Double tap to select a word.
1642 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1643 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1645 // Render and notify
1646 application.SendNotification();
1647 application.Render();
1649 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1650 Actor stencil = field.GetChildAt( 0u );
1652 // The offscreen root actor has a container with all the actors which contain the text renderers.
1653 Actor container = stencil.GetChildAt( 0u );
1654 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1656 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1657 DALI_TEST_CHECK( renderer );
1660 Renderer highlight = stencil.GetChildAt( 1u ).GetRendererAt( 0u );
1661 DALI_TEST_CHECK( highlight );
1666 int utcDaliTextFieldEvent04(void)
1668 ToolkitTestApplication application;
1669 tet_infoline(" utcDaliTextFieldEvent04");
1671 // Checks if the highlight actor is created.
1673 TextField field = TextField::New();
1674 DALI_TEST_CHECK( field );
1675 Stage::GetCurrent().Add( field );
1676 LoadMarkerImages(application, field);
1677 // Render and notify
1678 application.SendNotification();
1679 application.Render();
1681 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1682 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1683 field.SetSize( 300.f, 50.f );
1684 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1685 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1687 // Avoid a crash when core load gl resources.
1688 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1689 // Render and notify
1690 application.SendNotification();
1691 application.Render();
1693 // Create a tap event to touch the text field.
1694 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1695 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1696 // Render and notify
1697 application.SendNotification();
1698 application.Render();
1701 // Tap first to get the focus.
1702 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1703 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1705 // Render and notify
1706 application.SendNotification();
1707 application.Render();
1709 // Double tap to select a word.
1710 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1711 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1713 // Render and notify
1714 application.SendNotification();
1715 application.Render();
1718 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1719 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1723 int utcDaliTextFieldEvent05(void)
1725 ToolkitTestApplication application;
1726 tet_infoline(" utcDaliTextFieldEvent05");
1728 // Checks dragging of cursor/grab handle
1730 TextField field = TextField::New();
1731 DALI_TEST_CHECK( field );
1732 Stage::GetCurrent().Add( field );
1733 LoadMarkerImages(application, field);
1734 // Render and notify
1735 application.SendNotification();
1736 application.Render();
1738 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1739 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1740 field.SetSize( 300.f, 50.f );
1741 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1742 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1744 // Avoid a crash when core load gl resources.
1745 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1746 // Render and notify
1747 application.SendNotification();
1748 application.Render();
1750 // Create a tap event to touch the text field.
1751 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1752 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1753 // Render and notify
1754 application.SendNotification();
1755 application.Render();
1758 // Tap first to get the focus.
1759 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1760 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1762 // Render and notify
1763 application.SendNotification();
1764 application.Render();
1766 // Double tap to select a word.
1767 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1768 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1770 // Render and notify
1771 application.SendNotification();
1772 application.Render();
1774 // drag grab handle right
1775 Vector2 pos(0.0f, 40.0f);
1776 SendPan(application, Gesture::Possible, pos);
1777 SendPan(application, Gesture::Started, pos);
1779 Wait(application, 100);
1781 for(int i = 0;i<20;i++)
1783 SendPan(application, Gesture::Continuing, pos);
1788 SendPan(application, Gesture::Finished, pos);
1789 Wait(application, RENDER_FRAME_INTERVAL);
1791 Actor stencil = field.GetChildAt( 1u );
1795 int utcDaliTextFieldEvent06(void)
1797 ToolkitTestApplication application;
1798 tet_infoline(" utcDaliTextFieldEvent06");
1800 // Checks Longpress when in edit mode
1802 TextField field = TextField::New();
1803 DALI_TEST_CHECK( field );
1804 Stage::GetCurrent().Add( field );
1805 LoadMarkerImages(application, field);
1806 // Render and notify
1807 application.SendNotification();
1808 application.Render();
1810 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1811 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1812 field.SetSize( 300.f, 50.f );
1813 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1814 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1816 // Avoid a crash when core load gl resources.
1817 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1818 // Render and notify
1819 application.SendNotification();
1820 application.Render();
1822 // Create a tap event to touch the text field.
1823 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1824 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1825 // Render and notify
1826 application.SendNotification();
1827 application.Render();
1830 // Tap first to get the focus.
1831 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1832 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1834 // Render and notify
1835 application.SendNotification();
1836 application.Render();
1839 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1840 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1842 // Render and notify
1843 application.SendNotification();
1844 application.Render();
1849 int utcDaliTextFieldEvent07(void)
1851 ToolkitTestApplication application;
1852 tet_infoline(" utcDaliTextFieldEvent07");
1854 // Checks Longpress to start edit mode
1856 TextField field = TextField::New();
1857 DALI_TEST_CHECK( field );
1858 Stage::GetCurrent().Add( field );
1859 LoadMarkerImages(application, field);
1860 // Render and notify
1861 application.SendNotification();
1862 application.Render();
1864 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1865 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1866 field.SetSize( 300.f, 50.f );
1867 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1868 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1869 Property::Map propertyMap;
1870 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
1871 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
1873 // Avoid a crash when core load gl resources.
1874 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1875 // Render and notify
1876 application.SendNotification();
1877 application.Render();
1880 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1881 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1883 // Render and notify
1884 application.SendNotification();
1885 application.Render();
1890 int utcDaliTextFieldEvent08(void)
1892 ToolkitTestApplication application;
1893 tet_infoline(" utcDaliTextFieldEvent08");
1895 Dali::Clipboard clipboard = Clipboard::Get();
1896 clipboard.SetItem("testTextFieldEvent");
1898 // Checks Longpress when only place holder text
1900 TextField field = TextField::New();
1901 DALI_TEST_CHECK( field );
1902 Stage::GetCurrent().Add( field );
1903 LoadMarkerImages(application, field);
1904 // Render and notify
1905 application.SendNotification();
1906 application.Render();
1908 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
1909 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1910 field.SetSize( 300.f, 50.f );
1911 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1912 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1914 // Avoid a crash when core load gl resources.
1915 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1916 // Render and notify
1917 application.SendNotification();
1918 application.Render();
1921 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1922 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1924 // Render and notify
1925 application.SendNotification();
1926 application.Render();
1928 Wait(application, 500);
1930 Stage stage = Stage::GetCurrent();
1931 Layer layer = stage.GetRootLayer();
1932 Actor actor = layer.FindChildByName("optionPaste");
1936 Vector3 worldPosition = actor.GetCurrentWorldPosition();
1937 Vector2 halfStageSize = stage.GetSize() / 2.0f;
1938 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
1940 Dali::Integration::TouchEvent event;
1941 event = Dali::Integration::TouchEvent();
1942 event.AddPoint( GetPointDownInside( position ) );
1943 application.ProcessEvent( event );
1945 event = Dali::Integration::TouchEvent();
1946 event.AddPoint( GetPointUpInside( position ) );
1947 application.ProcessEvent( event );
1949 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
1953 int utcDaliTextFieldStyleWhilstSelected(void)
1955 ToolkitTestApplication application;
1956 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
1958 // Change font and styles whilst text is selected whilst word selected
1960 TextField field = TextField::New();
1961 DALI_TEST_CHECK( field );
1962 Stage::GetCurrent().Add( field );
1963 LoadMarkerImages(application, field);
1964 // Render and notify
1965 application.SendNotification();
1966 application.Render();
1968 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1969 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1970 field.SetSize( 300.f, 50.f );
1971 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1972 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1974 // Avoid a crash when core load gl resources.
1975 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1976 // Render and notify
1977 application.SendNotification();
1978 application.Render();
1980 // Create a tap event to touch the text field.
1981 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1982 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1983 // Render and notify
1984 application.SendNotification();
1985 application.Render();
1988 // Tap first to get the focus.
1989 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1990 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1992 // Render and notify
1993 application.SendNotification();
1994 application.Render();
1996 // Double tap to select a word.
1997 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1998 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2000 // Render and notify
2001 application.SendNotification();
2002 application.Render();
2004 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2005 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2007 Property::Map fontStyleMapSet;
2008 Property::Map fontStyleMapGet;
2010 fontStyleMapSet.Insert( "weight", "bold" );
2011 fontStyleMapSet.Insert( "slant", "italic" );
2012 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2014 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2015 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2016 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2018 fontStyleMapSet.Clear();
2019 fontStyleMapSet.Insert( "width", "expanded" );
2020 fontStyleMapSet.Insert( "slant", "italic" );
2021 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2023 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2024 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2025 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2027 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2028 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2030 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2031 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2033 fontStyleMapSet.Clear();
2034 fontStyleMapSet.Insert( "weight", "bold" );
2035 fontStyleMapSet.Insert( "slant", "italic" );
2037 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2039 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2040 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2041 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2043 fontStyleMapSet.Clear();
2044 fontStyleMapSet.Insert( "width", "expanded" );
2046 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2048 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2049 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2050 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2052 // Press Escape to increase coverage
2053 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up ) );
2054 application.SendNotification();
2055 application.Render();
2057 DALI_TEST_CHECK( !field.HasKeyInputFocus() );