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::ResourceRequest* request = platform.GetRequest();
122 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
123 Integration::ResourcePointer resource(bitmap);
124 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
128 platform.SetResourceLoaded(request->GetId(), request->GetType()->id, resource);
132 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
136 LoadBitmapResource( app.GetPlatform(), width, height );
138 Property::Map propertyMap;
139 propertyMap["filename"] = "image.png";
140 propertyMap["width"] = width;
141 propertyMap["height"] = height;
142 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
143 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
144 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
145 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
146 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
147 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
148 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
149 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
152 // Generate a PanGestureEvent to send to Core
153 static Integration::PanGestureEvent GeneratePan(
154 Gesture::State state,
155 const Vector2& previousPosition,
156 const Vector2& currentPosition,
157 unsigned long timeDelta,
158 unsigned int numberOfTouches = 1)
160 Integration::PanGestureEvent pan(state);
162 pan.previousPosition = previousPosition;
163 pan.currentPosition = currentPosition;
164 pan.timeDelta = timeDelta;
165 pan.numberOfTouches = numberOfTouches;
171 * Helper to generate PanGestureEvent
173 * @param[in] application Application instance
174 * @param[in] state The Gesture State
175 * @param[in] pos The current position of touch.
177 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
181 if( (state == Gesture::Started) ||
182 (state == Gesture::Possible) )
188 application.ProcessEvent(GeneratePan(state, last, pos, 16));
195 * Simulate time passed by.
197 * @note this will always process at least 1 frame (1/60 sec)
199 * @param application Test application instance
200 * @param duration Time to pass in milliseconds.
201 * @return The actual time passed in milliseconds
203 static int Wait(ToolkitTestApplication& application, int duration = 0)
207 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
209 application.SendNotification();
210 application.Render(RENDER_FRAME_INTERVAL);
211 time += RENDER_FRAME_INTERVAL;
217 Dali::Integration::Point GetPointDownInside( Vector2& pos )
219 Dali::Integration::Point point;
220 point.SetState( PointState::DOWN );
221 point.SetScreenPosition( pos );
225 Dali::Integration::Point GetPointUpInside( Vector2& pos )
227 Dali::Integration::Point point;
228 point.SetState( PointState::UP );
229 point.SetScreenPosition( pos );
233 struct CallbackFunctor
235 CallbackFunctor(bool* callbackFlag)
236 : mCallbackFlag( callbackFlag )
242 *mCallbackFlag = true;
247 static void TestTextChangedCallback( TextField control )
249 tet_infoline(" TestTextChangedCallback");
251 gTextChangedCallBackCalled = true;
254 static void TestMaxLengthReachedCallback( TextField control )
256 tet_infoline(" TestMaxLengthReachedCallback");
258 gMaxCharactersCallBackCalled = true;
261 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
263 tet_infoline(" TestInputStyleChangedCallback");
265 gInputStyleChangedCallbackCalled = true;
266 gInputStyleMask = mask;
269 // Generate a TapGestureEvent to send to Core.
270 Integration::TapGestureEvent GenerateTap(
271 Gesture::State state,
272 unsigned int numberOfTaps,
273 unsigned int numberOfTouches,
276 Integration::TapGestureEvent tap( state );
278 tap.numberOfTaps = numberOfTaps;
279 tap.numberOfTouches = numberOfTouches;
285 Integration::LongPressGestureEvent GenerateLongPress(
286 Gesture::State state,
287 unsigned int numberOfTouches,
290 Integration::LongPressGestureEvent longPress( state );
292 longPress.numberOfTouches = numberOfTouches;
293 longPress.point = point;
297 // Generate a KeyEvent to send to Core.
298 Integration::KeyEvent GenerateKey( const std::string& keyName,
299 const std::string& keyString,
302 unsigned long timeStamp,
303 const Integration::KeyEvent::State& keyState )
305 return Integration::KeyEvent( keyName,
313 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
315 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
317 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
319 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
321 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
322 if( NULL != valueSet )
324 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
326 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
332 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
343 int UtcDaliToolkitTextFieldConstructorP(void)
345 ToolkitTestApplication application;
346 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
348 DALI_TEST_CHECK( !textField );
352 int UtcDaliToolkitTextFieldNewP(void)
354 ToolkitTestApplication application;
355 tet_infoline(" UtcDaliToolkitTextFieldNewP");
356 TextField textField = TextField::New();
357 DALI_TEST_CHECK( textField );
361 int UtcDaliToolkitTextFieldDownCastP(void)
363 ToolkitTestApplication application;
364 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
365 TextField textField1 = TextField::New();
366 BaseHandle object( textField1 );
368 TextField textField2 = TextField::DownCast( object );
369 DALI_TEST_CHECK( textField2 );
371 TextField textField3 = DownCast< TextField >( object );
372 DALI_TEST_CHECK( textField3 );
376 int UtcDaliToolkitTextFieldDownCastN(void)
378 ToolkitTestApplication application;
379 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
380 BaseHandle uninitializedObject;
381 TextField textField1 = TextField::DownCast( uninitializedObject );
382 DALI_TEST_CHECK( !textField1 );
384 TextField textField2 = DownCast< TextField >( uninitializedObject );
385 DALI_TEST_CHECK( !textField2 );
389 int UtcDaliToolkitTextFieldCopyConstructorP(void)
391 ToolkitTestApplication application;
392 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
393 TextField textField = TextField::New();
394 textField.SetProperty( TextField::Property::TEXT, "Test" );
396 TextField copy( textField );
397 DALI_TEST_CHECK( copy );
398 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
402 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
404 ToolkitTestApplication application;
405 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
406 TextField textField = TextField::New();
407 textField.SetProperty( TextField::Property::TEXT, "Test" );
409 TextField copy = textField;
410 DALI_TEST_CHECK( copy );
411 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
415 int UtcDaliTextFieldNewP(void)
417 ToolkitTestApplication application;
418 tet_infoline(" UtcDaliToolkitTextFieldNewP");
419 TextField textField = TextField::New();
420 DALI_TEST_CHECK( textField );
424 // Positive test case for a method
425 int UtcDaliTextFieldGetPropertyP(void)
427 ToolkitTestApplication application;
428 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
429 TextField field = TextField::New();
430 DALI_TEST_CHECK( field );
432 // Check Property Indices are correct
433 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
434 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
435 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
436 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
437 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
438 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
439 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
440 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
441 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
442 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
443 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
444 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
445 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
446 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextField::Property::SHADOW_OFFSET );
447 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextField::Property::SHADOW_COLOR );
448 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
449 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
450 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
451 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
452 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
453 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
454 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
455 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
456 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
457 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
458 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
459 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
460 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
461 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
462 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
463 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
464 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
465 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
466 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
467 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
468 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
469 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
470 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
471 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
472 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
473 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
474 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
475 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
476 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
477 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
478 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
479 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
484 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
487 Property::Map imageMap;
488 imageMap[mapKey] =mapValue;
490 field.SetProperty( property , imageMap );
491 Property::Value propValue = field.GetProperty( property );
492 Property::Map* resultMap = propValue.GetMap();
494 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
502 // Positive test case for a method
503 int UtcDaliTextFieldSetPropertyP(void)
505 ToolkitTestApplication application;
506 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
507 TextField field = TextField::New();
508 DALI_TEST_CHECK( field );
509 Stage::GetCurrent().Add( field );
511 // Note - we can't check the defaults since the stylesheets are platform-specific
513 // Check the render backend property.
514 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
515 DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
517 // Check text property.
518 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
519 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
521 // Check placeholder text properties.
522 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
523 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
525 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
526 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
528 // Check font properties.
529 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
530 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
532 Property::Map fontStyleMapSet;
533 Property::Map fontStyleMapGet;
534 Property::Value* slantValue = NULL;
536 fontStyleMapSet.Insert( "weight", "bold" );
537 fontStyleMapSet.Insert( "width", "condensed" );
538 fontStyleMapSet.Insert( "slant", "italic" );
539 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
541 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
542 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
543 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
545 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
546 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
549 fontStyleMapSet.Clear();
550 fontStyleMapSet.Insert( "weight", "normal" );
551 fontStyleMapSet.Insert( "slant", "oblique" );
552 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
554 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
555 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
556 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
558 fontStyleMapSet.Clear();
559 fontStyleMapSet.Insert( "slant", "roman" );
560 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
561 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
563 // Replace 'roman' for 'normal'.
564 slantValue = fontStyleMapGet.Find( "slant" );
565 if( NULL != slantValue )
567 if( "normal" == slantValue->Get<std::string>() )
569 fontStyleMapGet["slant"] = "roman";
572 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
573 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
575 fontStyleMapSet.Clear();
577 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
578 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
579 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
580 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
582 // Check that the MAX_LENGTH property can be correctly set
583 const int maxNumberOfCharacters = 20;
584 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
585 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
587 // Check exceed policy
588 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
589 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
590 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
591 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
593 // Check that the Alignment properties can be correctly set
594 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
595 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
596 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
597 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
599 // Check text's color property
600 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
601 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
603 // Check placeholder text's color property.
604 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
605 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
607 // Check shadow properties.
608 field.SetProperty( TextField::Property::SHADOW_OFFSET, Vector2( 1.f, 1.f ) );
609 DALI_TEST_EQUALS( field.GetProperty<Vector2>( TextField::Property::SHADOW_OFFSET ), Vector2( 1.f, 1.f ), TEST_LOCATION );
610 field.SetProperty( TextField::Property::SHADOW_COLOR, Color::GREEN );
611 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SHADOW_COLOR ), Color::GREEN, TEST_LOCATION );
613 // Check cursor properties
614 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
615 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
616 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
617 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
619 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
620 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
621 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
622 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
623 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
624 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
625 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
626 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
628 // Check scroll properties.
629 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
630 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
631 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
632 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
634 // Check handle images
635 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
636 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
637 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
638 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
639 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
641 // Check handle images
642 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
643 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
644 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
645 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
646 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
647 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
649 // Check the highlight color
650 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
651 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
653 // Decoration bounding box
654 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
655 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
657 // Check the input method setting
658 Property::Map propertyMap;
659 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
660 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
661 InputMethod::ActionButtonTitle::Type actionButton = InputMethod::ActionButtonTitle::GO;
662 int inputVariation = 1;
663 propertyMap["PANEL_LAYOUT"] = panelLayout;
664 propertyMap["AUTO_CAPITALISE"] = autoCapital;
665 propertyMap["ACTION_BUTTON"] = actionButton;
666 propertyMap["VARIATION"] = inputVariation;
667 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
669 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
671 DALI_TEST_CHECK( value.Get( map ) );
674 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
675 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
678 DALI_TEST_CHECK( map[ "AUTO_CAPITALISE" ].Get( capital ) );
679 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
682 DALI_TEST_CHECK( map[ "ACTION_BUTTON" ].Get( action ) );
683 DALI_TEST_EQUALS( static_cast<int>(actionButton), action, TEST_LOCATION );
686 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
687 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
689 // Check input color property.
690 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
691 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
693 // Check the enable markup property.
694 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
695 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
696 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
698 // Check input font properties.
699 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
700 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
702 fontStyleMapSet.Clear();
703 fontStyleMapSet.Insert( "weight", "bold" );
704 fontStyleMapSet.Insert( "width", "condensed" );
705 fontStyleMapSet.Insert( "slant", "italic" );
707 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
708 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
709 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
710 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
712 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
713 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
715 // Reset input font style.
716 fontStyleMapSet.Clear();
717 fontStyleMapSet.Insert( "weight", "normal" );
718 fontStyleMapSet.Insert( "slant", "oblique" );
720 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
721 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
722 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
723 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
725 fontStyleMapSet.Clear();
726 fontStyleMapSet.Insert( "slant", "roman" );
728 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
729 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
731 // Replace 'roman' for 'normal'.
732 slantValue = fontStyleMapGet.Find( "slant" );
733 if( NULL != slantValue )
735 if( "normal" == slantValue->Get<std::string>() )
737 fontStyleMapGet["slant"] = "roman";
740 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
741 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
743 fontStyleMapSet.Clear();
745 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
746 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
747 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
748 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
750 Property::Map underlineMapSet;
751 Property::Map underlineMapGet;
753 underlineMapSet.Insert( "enable", "true" );
754 underlineMapSet.Insert( "color", "red" );
755 underlineMapSet.Insert( "height", "1" );
757 // Check the underline property
758 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
760 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
761 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
762 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
764 // Check the input underline property
765 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
766 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
768 // Check the shadow property
769 Property::Map shadowMapSet;
770 Property::Map shadowMapGet;
772 shadowMapSet.Insert( "color", "green" );
773 shadowMapSet.Insert( "offset", "2 2" );
775 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
777 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
778 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
779 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
781 // Check the input shadow property
782 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
783 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
785 // Check the emboss property
786 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
787 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
789 // Check the input emboss property
790 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
791 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
793 // Check the outline property
794 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
795 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
797 // Check the input outline property
798 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
799 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
804 // Positive Atlas Text Renderer test
805 int utcDaliTextFieldAtlasRenderP(void)
807 ToolkitTestApplication application;
808 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
809 StyleManager styleManager = StyleManager::Get();
810 styleManager.ApplyDefaultTheme();
811 TextField field = TextField::New();
812 DALI_TEST_CHECK( field );
814 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
816 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
818 Stage::GetCurrent().Add( field );
822 // Render some text with the shared atlas backend
823 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
824 application.SendNotification();
825 application.Render();
829 tet_result(TET_FAIL);
834 // Positive test for the textChanged signal.
835 int utcDaliTextFieldTextChangedP(void)
837 ToolkitTestApplication application;
838 tet_infoline(" utcDaliTextFieldTextChangedP");
839 TextField field = TextField::New();
840 DALI_TEST_CHECK( field );
842 Stage::GetCurrent().Add( field );
844 // connect to the text changed signal.
845 ConnectionTracker* testTracker = new ConnectionTracker();
846 field.TextChangedSignal().Connect(&TestTextChangedCallback);
847 bool textChangedSignal = false;
848 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
850 gTextChangedCallBackCalled = false;
851 field.SetProperty( TextField::Property::TEXT, "ABC" );
852 DALI_TEST_CHECK( gTextChangedCallBackCalled );
853 DALI_TEST_CHECK( textChangedSignal );
855 application.SendNotification();
857 field.SetKeyInputFocus();
859 gTextChangedCallBackCalled = false;
860 application.ProcessEvent( GenerateKey( "D", "D", 0, 0, 0, Integration::KeyEvent::Down ) );
861 DALI_TEST_CHECK( gTextChangedCallBackCalled );
866 // Negative test for the textChanged signal.
867 int utcDaliTextFieldTextChangedN(void)
869 ToolkitTestApplication application;
870 tet_infoline(" utcDaliTextFieldTextChangedN");
871 TextField field = TextField::New();
872 DALI_TEST_CHECK( field );
874 Stage::GetCurrent().Add( field );
876 // connect to the text changed signal.
877 ConnectionTracker* testTracker = new ConnectionTracker();
878 field.TextChangedSignal().Connect(&TestTextChangedCallback);
879 bool textChangedSignal = false;
880 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
882 gTextChangedCallBackCalled = false;
883 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
884 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
885 DALI_TEST_CHECK( !textChangedSignal );
890 // Positive test for Max Characters reached signal.
891 int utcDaliTextFieldMaxCharactersReachedP(void)
893 ToolkitTestApplication application;
894 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
895 TextField field = TextField::New();
896 DALI_TEST_CHECK( field );
898 Stage::GetCurrent().Add( field );
900 const int maxNumberOfCharacters = 1;
901 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
903 field.SetKeyInputFocus();
905 // connect to the text changed signal.
906 ConnectionTracker* testTracker = new ConnectionTracker();
907 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
908 bool maxLengthReachedSignal = false;
909 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
911 gMaxCharactersCallBackCalled = false;
913 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
914 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
916 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
917 DALI_TEST_CHECK( maxLengthReachedSignal );
922 // Negative test for Max Characters reached signal.
923 int utcDaliTextFieldMaxCharactersReachedN(void)
925 ToolkitTestApplication application;
926 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
927 TextField field = TextField::New();
928 DALI_TEST_CHECK( field );
930 Stage::GetCurrent().Add( field );
932 const int maxNumberOfCharacters = 3;
933 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
935 field.SetKeyInputFocus();
937 // connect to the text changed signal.
938 ConnectionTracker* testTracker = new ConnectionTracker();
939 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
940 bool maxLengthReachedSignal = false;
941 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
943 gMaxCharactersCallBackCalled = false;
945 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
946 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
948 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
949 DALI_TEST_CHECK( !maxLengthReachedSignal );
954 int utcDaliTextFieldInputStyleChanged01(void)
956 ToolkitTestApplication application;
957 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
959 // The text-field emits signals when the input style changes. These changes of style are
960 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
961 // can't be emitted during the size negotiation as the callbacks may update the UI.
962 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
963 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
964 application.CreateAdaptor();
968 char* pathNamePtr = get_current_dir_name();
969 const std::string pathName( pathNamePtr );
972 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
973 fontClient.SetDpi( 93u, 93u );
975 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
976 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
978 TextField field = TextField::New();
979 DALI_TEST_CHECK( field );
982 field.SetSize( 300.f, 50.f );
983 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
984 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
986 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
987 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
989 // connect to the text changed signal.
990 ConnectionTracker* testTracker = new ConnectionTracker();
991 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
992 bool inputStyleChangedSignal = false;
993 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
995 Stage::GetCurrent().Add( field );
998 application.SendNotification();
999 application.Render();
1001 // Executes the idle callbacks added by the text control on the change of input style.
1002 application.RunIdles();
1004 gInputStyleChangedCallbackCalled = false;
1005 gInputStyleMask = TextField::InputStyle::NONE;
1006 inputStyleChangedSignal = false;
1008 // Create a tap event to touch the text field.
1009 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1010 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1012 // Render and notify
1013 application.SendNotification();
1014 application.Render();
1016 // Executes the idle callbacks added by the text control on the change of input style.
1017 application.RunIdles();
1019 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1020 if( gInputStyleChangedCallbackCalled )
1022 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1024 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1025 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1027 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1028 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1030 DALI_TEST_CHECK( inputStyleChangedSignal );
1032 gInputStyleChangedCallbackCalled = false;
1033 gInputStyleMask = TextField::InputStyle::NONE;
1034 inputStyleChangedSignal = false;
1036 // Create a tap event to touch the text field.
1037 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1038 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1040 // Render and notify
1041 application.SendNotification();
1042 application.Render();
1044 // Executes the idle callbacks added by the text control on the change of input style.
1045 application.RunIdles();
1047 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1048 DALI_TEST_CHECK( !inputStyleChangedSignal );
1050 gInputStyleChangedCallbackCalled = false;
1051 gInputStyleMask = TextField::InputStyle::NONE;
1052 inputStyleChangedSignal = false;
1054 // Create a tap event to touch the text field.
1055 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1056 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1058 // Render and notify
1059 application.SendNotification();
1060 application.Render();
1062 // Executes the idle callbacks added by the text control on the change of input style.
1063 application.RunIdles();
1065 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1066 if( gInputStyleChangedCallbackCalled )
1068 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1070 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1071 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1073 DALI_TEST_CHECK( inputStyleChangedSignal );
1075 gInputStyleChangedCallbackCalled = false;
1076 gInputStyleMask = TextField::InputStyle::NONE;
1077 inputStyleChangedSignal = false;
1079 // Create a tap event to touch the text field.
1080 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1081 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1083 // Render and notify
1084 application.SendNotification();
1085 application.Render();
1087 // Executes the idle callbacks added by the text control on the change of input style.
1088 application.RunIdles();
1090 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1091 if( gInputStyleChangedCallbackCalled )
1093 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1095 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1096 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1098 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1100 Property::Map fontStyleMapSet;
1101 fontStyleMapSet.Insert( "weight", "bold" );
1103 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1104 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1106 DALI_TEST_CHECK( inputStyleChangedSignal );
1108 gInputStyleChangedCallbackCalled = false;
1109 gInputStyleMask = TextField::InputStyle::NONE;
1110 inputStyleChangedSignal = false;
1112 // Create a tap event to touch the text field.
1113 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1114 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1116 // Render and notify
1117 application.SendNotification();
1118 application.Render();
1120 // Executes the idle callbacks added by the text control on the change of input style.
1121 application.RunIdles();
1123 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1124 DALI_TEST_CHECK( !inputStyleChangedSignal );
1126 gInputStyleChangedCallbackCalled = false;
1127 gInputStyleMask = TextField::InputStyle::NONE;
1128 inputStyleChangedSignal = false;
1130 // Create a tap event to touch the text field.
1131 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1132 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1134 // Render and notify
1135 application.SendNotification();
1136 application.Render();
1138 // Executes the idle callbacks added by the text control on the change of input style.
1139 application.RunIdles();
1141 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1142 if( gInputStyleChangedCallbackCalled )
1144 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1146 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1147 DALI_TEST_CHECK( style.empty() );
1149 DALI_TEST_CHECK( inputStyleChangedSignal );
1151 gInputStyleChangedCallbackCalled = false;
1152 gInputStyleMask = TextField::InputStyle::NONE;
1153 inputStyleChangedSignal = false;
1155 // Create a tap event to touch the text field.
1156 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1157 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1159 // Render and notify
1160 application.SendNotification();
1161 application.Render();
1163 // Executes the idle callbacks added by the text control on the change of input style.
1164 application.RunIdles();
1166 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1167 DALI_TEST_CHECK( !inputStyleChangedSignal );
1172 int utcDaliTextFieldInputStyleChanged02(void)
1174 ToolkitTestApplication application;
1175 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1177 // The text-field emits signals when the input style changes. These changes of style are
1178 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1179 // can't be emitted during the size negotiation as the callbacks may update the UI.
1180 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1181 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1182 application.CreateAdaptor();
1186 char* pathNamePtr = get_current_dir_name();
1187 const std::string pathName( pathNamePtr );
1188 free( pathNamePtr );
1190 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1191 fontClient.SetDpi( 93u, 93u );
1193 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1194 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1196 TextField field = TextField::New();
1197 DALI_TEST_CHECK( field );
1200 field.SetSize( 300.f, 50.f );
1201 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1202 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1204 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1205 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>" );
1207 // connect to the text changed signal.
1208 ConnectionTracker* testTracker = new ConnectionTracker();
1209 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1210 bool inputStyleChangedSignal = false;
1211 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1213 Stage::GetCurrent().Add( field );
1215 // Render and notify
1216 application.SendNotification();
1217 application.Render();
1219 // Executes the idle callbacks added by the text control on the change of input style.
1220 application.RunIdles();
1222 gInputStyleChangedCallbackCalled = false;
1223 gInputStyleMask = TextField::InputStyle::NONE;
1224 inputStyleChangedSignal = false;
1226 // Create a tap event to touch the text field.
1227 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1228 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1229 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1230 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1232 // Render and notify
1233 application.SendNotification();
1234 application.Render();
1236 // Executes the idle callbacks added by the text control on the change of input style.
1237 application.RunIdles();
1239 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1240 if( gInputStyleChangedCallbackCalled )
1242 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1243 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1244 TextField::InputStyle::POINT_SIZE |
1245 TextField::InputStyle::COLOR ),
1248 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1249 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1251 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1252 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1254 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1255 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1257 DALI_TEST_CHECK( inputStyleChangedSignal );
1259 gInputStyleChangedCallbackCalled = false;
1260 gInputStyleMask = TextField::InputStyle::NONE;
1261 inputStyleChangedSignal = false;
1263 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1265 // Render and notify
1266 application.SendNotification();
1267 application.Render();
1269 // Executes the idle callbacks added by the text control on the change of input style.
1270 application.RunIdles();
1272 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1273 if( gInputStyleChangedCallbackCalled )
1275 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1276 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1279 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1280 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1282 DALI_TEST_CHECK( inputStyleChangedSignal );
1284 gInputStyleChangedCallbackCalled = false;
1285 gInputStyleMask = TextField::InputStyle::NONE;
1286 inputStyleChangedSignal = false;
1288 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1290 // Render and notify
1291 application.SendNotification();
1292 application.Render();
1294 // Executes the idle callbacks added by the text control on the change of input style.
1295 application.RunIdles();
1297 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1298 DALI_TEST_CHECK( !inputStyleChangedSignal );
1300 gInputStyleChangedCallbackCalled = false;
1301 gInputStyleMask = TextField::InputStyle::NONE;
1302 inputStyleChangedSignal = false;
1304 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1306 // Render and notify
1307 application.SendNotification();
1308 application.Render();
1310 // Executes the idle callbacks added by the text control on the change of input style.
1311 application.RunIdles();
1313 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1314 if( gInputStyleChangedCallbackCalled )
1316 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1317 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1320 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1321 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1323 DALI_TEST_CHECK( inputStyleChangedSignal );
1325 gInputStyleChangedCallbackCalled = false;
1326 gInputStyleMask = TextField::InputStyle::NONE;
1327 inputStyleChangedSignal = false;
1329 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1331 Property::Map fontStyleMapSet;
1332 fontStyleMapSet.Insert( "weight", "thin" );
1333 fontStyleMapSet.Insert( "width", "condensed" );
1334 fontStyleMapSet.Insert( "slant", "italic" );
1336 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1337 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1339 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1340 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1341 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1342 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1344 // Render and notify
1345 application.SendNotification();
1346 application.Render();
1348 // Executes the idle callbacks added by the text control on the change of input style.
1349 application.RunIdles();
1351 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1352 DALI_TEST_CHECK( !inputStyleChangedSignal );
1354 // Create a tap event to touch the text field.
1355 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1356 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1358 // Render and notify
1359 application.SendNotification();
1360 application.Render();
1362 // Executes the idle callbacks added by the text control on the change of input style.
1363 application.RunIdles();
1365 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1366 if( gInputStyleChangedCallbackCalled )
1368 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1369 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1370 TextField::InputStyle::POINT_SIZE |
1371 TextField::InputStyle::FONT_STYLE |
1372 TextField::InputStyle::UNDERLINE |
1373 TextField::InputStyle::SHADOW |
1374 TextField::InputStyle::EMBOSS |
1375 TextField::InputStyle::OUTLINE ),
1378 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1379 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1381 DALI_TEST_CHECK( inputStyleChangedSignal );
1386 int utcDaliTextFieldEvent01(void)
1388 ToolkitTestApplication application;
1389 tet_infoline(" utcDaliTextFieldEvent01");
1391 // Creates a tap event. After creating a tap event the text field should
1392 // have the focus and add text with key events should be possible.
1394 TextField field = TextField::New();
1395 DALI_TEST_CHECK( field );
1397 Stage::GetCurrent().Add( field );
1399 field.SetSize( 300.f, 50.f );
1400 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1401 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1403 // Avoid a crash when core load gl resources.
1404 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1406 // Render and notify
1407 application.SendNotification();
1408 application.Render();
1410 // Add a key event but as the text field has not the focus it should do nothing.
1411 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1413 // Render and notify
1414 application.SendNotification();
1415 application.Render();
1417 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1419 // Create a tap event to touch the text field.
1420 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1421 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1423 // Render and notify
1424 application.SendNotification();
1425 application.Render();
1427 // Now the text field has the focus, so it can handle the key events.
1428 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1429 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1431 // Render and notify
1432 application.SendNotification();
1433 application.Render();
1435 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1437 // Create a second text field and send key events to it.
1438 TextField field2 = TextField::New();
1440 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1441 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1442 field2.SetSize( 100.f, 100.f );
1443 field2.SetPosition( 100.f, 100.f );
1445 Stage::GetCurrent().Add( field2 );
1447 // Render and notify
1448 application.SendNotification();
1449 application.Render();
1451 // Create a tap event on the second text field.
1452 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1453 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1455 // Render and notify
1456 application.SendNotification();
1457 application.Render();
1459 // The second text field has the focus. It should handle the key events.
1460 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1461 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1463 // Render and notify
1464 application.SendNotification();
1465 application.Render();
1467 // Check the text has been added to the second text field.
1468 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1473 int utcDaliTextFieldEvent02(void)
1475 ToolkitTestApplication application;
1476 tet_infoline(" utcDaliTextFieldEvent02");
1478 // Checks if the right number of actors are created.
1480 TextField field = TextField::New();
1481 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1482 DALI_TEST_CHECK( field );
1483 LoadMarkerImages(application, field);
1485 Stage::GetCurrent().Add( field );
1487 field.SetSize( 300.f, 50.f );
1488 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1489 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1491 // Avoid a crash when core load gl resources.
1492 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1494 // Render and notify
1495 application.SendNotification();
1496 application.Render();
1498 // Check there are the expected number of children ( stencil ).
1499 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1501 Actor stencil = field.GetChildAt( 0u );
1502 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1504 // Create a tap event to touch the text field.
1505 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1506 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1508 // Render and notify
1509 application.SendNotification();
1510 application.Render();
1512 Actor layer = field.GetChildAt( 1u );
1513 DALI_TEST_CHECK( layer.IsLayer() );
1515 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1516 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1518 // Now the text field has the focus, so it can handle the key events.
1519 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1520 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1522 // Render and notify
1523 application.SendNotification();
1524 application.Render();
1526 // Checks the cursor and the renderer have been created.
1527 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1528 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1530 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1531 DALI_TEST_CHECK( cursor );
1533 // The offscreen root actor has a container with all the actors which contain the text renderers.
1534 Actor container = stencil.GetChildAt( 0u );
1535 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1537 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1538 DALI_TEST_CHECK( renderer );
1541 // Move the cursor and check the position changes.
1542 Vector3 position1 = cursor.GetCurrentPosition();
1544 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1545 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1547 // Render and notify
1548 application.SendNotification();
1549 application.Render();
1551 Vector3 position2 = cursor.GetCurrentPosition();
1553 DALI_TEST_CHECK( position2.x < position1.x );
1555 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1556 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1558 // Render and notify
1559 application.SendNotification();
1560 application.Render();
1562 Vector3 position3 = cursor.GetCurrentPosition();
1564 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1566 // Send some taps and check the cursor positions.
1568 // Try to tap at the beginning.
1569 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1570 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1572 // Render and notify
1573 application.SendNotification();
1574 application.Render();
1576 // Cursor position should be the same than position1.
1577 Vector3 position4 = cursor.GetCurrentPosition();
1579 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1581 // Tap away from the start position.
1582 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1583 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1585 // Render and notify
1586 application.SendNotification();
1587 application.Render();
1589 Vector3 position5 = cursor.GetCurrentPosition();
1591 DALI_TEST_CHECK( position5.x > position4.x );
1593 // Remove all the text.
1594 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1595 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1596 field.SetProperty( TextField::Property::TEXT, "" );
1598 // Render and notify
1599 application.SendNotification();
1600 application.Render();
1602 // Cursor position should be the same than position2.
1603 Vector3 position6 = cursor.GetCurrentPosition();
1605 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1607 // Should not be a renderer.
1608 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1613 int utcDaliTextFieldEvent03(void)
1615 ToolkitTestApplication application;
1616 tet_infoline(" utcDaliTextFieldEvent03");
1618 // Checks if the highlight actor is created.
1620 TextField field = TextField::New();
1621 DALI_TEST_CHECK( field );
1623 Stage::GetCurrent().Add( field );
1625 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1626 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1627 field.SetSize( 30.f, 50.f );
1628 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1629 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1631 // Avoid a crash when core load gl resources.
1632 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1633 LoadMarkerImages(application, field);
1635 // Render and notify
1636 application.SendNotification();
1637 application.Render();
1639 // Tap first to get the focus.
1640 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1641 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1643 // Render and notify
1644 application.SendNotification();
1645 application.Render();
1647 // Double tap to select a word.
1648 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1649 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1651 // Render and notify
1652 application.SendNotification();
1653 application.Render();
1655 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1656 Actor stencil = field.GetChildAt( 0u );
1658 // The offscreen root actor has a container with all the actors which contain the text renderers.
1659 Actor container = stencil.GetChildAt( 0u );
1660 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1662 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1663 DALI_TEST_CHECK( renderer );
1666 Renderer highlight = stencil.GetChildAt( 1u ).GetRendererAt( 0u );
1667 DALI_TEST_CHECK( highlight );
1672 int utcDaliTextFieldEvent04(void)
1674 ToolkitTestApplication application;
1675 tet_infoline(" utcDaliTextFieldEvent04");
1677 // Checks if the highlight actor is created.
1679 TextField field = TextField::New();
1680 DALI_TEST_CHECK( field );
1681 Stage::GetCurrent().Add( field );
1682 LoadMarkerImages(application, field);
1683 // Render and notify
1684 application.SendNotification();
1685 application.Render();
1687 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1688 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1689 field.SetSize( 300.f, 50.f );
1690 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1691 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1693 // Avoid a crash when core load gl resources.
1694 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1695 // Render and notify
1696 application.SendNotification();
1697 application.Render();
1699 // Create a tap event to touch the text field.
1700 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1701 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1702 // Render and notify
1703 application.SendNotification();
1704 application.Render();
1707 // Tap first to get the focus.
1708 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1709 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1711 // Render and notify
1712 application.SendNotification();
1713 application.Render();
1715 // Double tap to select a word.
1716 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1717 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1719 // Render and notify
1720 application.SendNotification();
1721 application.Render();
1724 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1725 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1729 int utcDaliTextFieldEvent05(void)
1731 ToolkitTestApplication application;
1732 tet_infoline(" utcDaliTextFieldEvent05");
1734 // Checks dragging of cursor/grab handle
1736 TextField field = TextField::New();
1737 DALI_TEST_CHECK( field );
1738 Stage::GetCurrent().Add( field );
1739 LoadMarkerImages(application, field);
1740 // Render and notify
1741 application.SendNotification();
1742 application.Render();
1744 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1745 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1746 field.SetSize( 300.f, 50.f );
1747 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1748 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1750 // Avoid a crash when core load gl resources.
1751 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1752 // Render and notify
1753 application.SendNotification();
1754 application.Render();
1756 // Create a tap event to touch the text field.
1757 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1758 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1759 // Render and notify
1760 application.SendNotification();
1761 application.Render();
1764 // Tap first to get the focus.
1765 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1766 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1768 // Render and notify
1769 application.SendNotification();
1770 application.Render();
1772 // Double tap to select a word.
1773 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1774 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1776 // Render and notify
1777 application.SendNotification();
1778 application.Render();
1780 // drag grab handle right
1781 Vector2 pos(0.0f, 40.0f);
1782 SendPan(application, Gesture::Possible, pos);
1783 SendPan(application, Gesture::Started, pos);
1785 Wait(application, 100);
1787 for(int i = 0;i<20;i++)
1789 SendPan(application, Gesture::Continuing, pos);
1794 SendPan(application, Gesture::Finished, pos);
1795 Wait(application, RENDER_FRAME_INTERVAL);
1797 Actor stencil = field.GetChildAt( 1u );
1801 int utcDaliTextFieldEvent06(void)
1803 ToolkitTestApplication application;
1804 tet_infoline(" utcDaliTextFieldEvent06");
1806 // Checks Longpress when in edit mode
1808 TextField field = TextField::New();
1809 DALI_TEST_CHECK( field );
1810 Stage::GetCurrent().Add( field );
1811 LoadMarkerImages(application, field);
1812 // Render and notify
1813 application.SendNotification();
1814 application.Render();
1816 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1817 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1818 field.SetSize( 300.f, 50.f );
1819 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1820 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1822 // Avoid a crash when core load gl resources.
1823 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1824 // Render and notify
1825 application.SendNotification();
1826 application.Render();
1828 // Create a tap event to touch the text field.
1829 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1830 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1831 // Render and notify
1832 application.SendNotification();
1833 application.Render();
1836 // Tap first to get the focus.
1837 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1838 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1840 // Render and notify
1841 application.SendNotification();
1842 application.Render();
1845 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1846 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1848 // Render and notify
1849 application.SendNotification();
1850 application.Render();
1855 int utcDaliTextFieldEvent07(void)
1857 ToolkitTestApplication application;
1858 tet_infoline(" utcDaliTextFieldEvent07");
1860 // Checks Longpress to start edit mode
1862 TextField field = TextField::New();
1863 DALI_TEST_CHECK( field );
1864 Stage::GetCurrent().Add( field );
1865 LoadMarkerImages(application, field);
1866 // Render and notify
1867 application.SendNotification();
1868 application.Render();
1870 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1871 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1872 field.SetSize( 300.f, 50.f );
1873 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1874 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1875 Property::Map propertyMap;
1876 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
1877 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
1879 // Avoid a crash when core load gl resources.
1880 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1881 // Render and notify
1882 application.SendNotification();
1883 application.Render();
1886 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1887 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1889 // Render and notify
1890 application.SendNotification();
1891 application.Render();
1896 int utcDaliTextFieldEvent08(void)
1898 ToolkitTestApplication application;
1899 tet_infoline(" utcDaliTextFieldEvent08");
1901 Dali::Clipboard clipboard = Clipboard::Get();
1902 clipboard.SetItem("testTextFieldEvent");
1904 // Checks Longpress when only place holder text
1906 TextField field = TextField::New();
1907 DALI_TEST_CHECK( field );
1908 Stage::GetCurrent().Add( field );
1909 LoadMarkerImages(application, field);
1910 // Render and notify
1911 application.SendNotification();
1912 application.Render();
1914 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
1915 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1916 field.SetSize( 300.f, 50.f );
1917 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1918 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1920 // Avoid a crash when core load gl resources.
1921 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1922 // Render and notify
1923 application.SendNotification();
1924 application.Render();
1927 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1928 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1930 // Render and notify
1931 application.SendNotification();
1932 application.Render();
1934 Wait(application, 500);
1936 Stage stage = Stage::GetCurrent();
1937 Layer layer = stage.GetRootLayer();
1938 Actor actor = layer.FindChildByName("optionPaste");
1942 Vector3 worldPosition = actor.GetCurrentWorldPosition();
1943 Vector2 halfStageSize = stage.GetSize() / 2.0f;
1944 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
1946 Dali::Integration::TouchEvent event;
1947 event = Dali::Integration::TouchEvent();
1948 event.AddPoint( GetPointDownInside( position ) );
1949 application.ProcessEvent( event );
1951 event = Dali::Integration::TouchEvent();
1952 event.AddPoint( GetPointUpInside( position ) );
1953 application.ProcessEvent( event );
1955 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
1959 int utcDaliTextFieldStyleWhilstSelected(void)
1961 ToolkitTestApplication application;
1962 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
1964 // Change font and styles whilst text is selected whilst word selected
1966 TextField field = TextField::New();
1967 DALI_TEST_CHECK( field );
1968 Stage::GetCurrent().Add( field );
1969 LoadMarkerImages(application, field);
1970 // Render and notify
1971 application.SendNotification();
1972 application.Render();
1974 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1975 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1976 field.SetSize( 300.f, 50.f );
1977 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1978 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1980 // Avoid a crash when core load gl resources.
1981 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1982 // Render and notify
1983 application.SendNotification();
1984 application.Render();
1986 // Create a tap event to touch the text field.
1987 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1988 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1989 // Render and notify
1990 application.SendNotification();
1991 application.Render();
1994 // Tap first to get the focus.
1995 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1996 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1998 // Render and notify
1999 application.SendNotification();
2000 application.Render();
2002 // Double tap to select a word.
2003 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2004 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2006 // Render and notify
2007 application.SendNotification();
2008 application.Render();
2010 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2011 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2013 Property::Map fontStyleMapSet;
2014 Property::Map fontStyleMapGet;
2016 fontStyleMapSet.Insert( "weight", "bold" );
2017 fontStyleMapSet.Insert( "slant", "italic" );
2018 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2020 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2021 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2022 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2024 fontStyleMapSet.Clear();
2025 fontStyleMapSet.Insert( "width", "expanded" );
2026 fontStyleMapSet.Insert( "slant", "italic" );
2027 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2029 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2030 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2031 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2033 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2034 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2036 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2037 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2039 fontStyleMapSet.Clear();
2040 fontStyleMapSet.Insert( "weight", "bold" );
2041 fontStyleMapSet.Insert( "slant", "italic" );
2043 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2045 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2046 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2047 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2049 fontStyleMapSet.Clear();
2050 fontStyleMapSet.Insert( "width", "expanded" );
2052 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2054 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2055 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2056 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );