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 <dali-toolkit/devel-api/controls/text-controls/hidden-input-properties.h>
31 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
32 #include "toolkit-clipboard.h"
35 using namespace Toolkit;
37 void dali_textfield_startup(void)
39 test_return_value = TET_UNDEF;
42 void dali_textfield_cleanup(void)
44 test_return_value = TET_PASS;
50 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
51 const char* const PROPERTY_NAME_TEXT = "text";
52 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
53 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
54 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
55 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
56 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
57 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
58 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
59 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
60 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
61 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
62 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
63 const char* const PROPERTY_NAME_SHADOW_OFFSET = "shadowOffset";
64 const char* const PROPERTY_NAME_SHADOW_COLOR = "shadowColor";
65 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
66 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
67 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
68 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
69 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
70 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
71 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
72 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
73 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
74 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
80 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
81 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
82 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
83 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
84 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
85 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
86 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
87 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
88 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
90 const char* const PROPERTY_NAME_UNDERLINE = "underline";
91 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
92 const char* const PROPERTY_NAME_SHADOW = "shadow";
93 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
94 const char* const PROPERTY_NAME_EMBOSS = "emboss";
95 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
96 const char* const PROPERTY_NAME_OUTLINE = "outline";
97 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
99 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
100 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
102 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
104 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
105 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
107 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
108 const float RENDER_FRAME_INTERVAL = 16.66f;
110 const float TO_MILLISECONDS = 1000.f;
111 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
113 const float SCROLL_THRESHOLD = 10.f;
114 const float SCROLL_SPEED = 300.f;
116 const unsigned int DEFAULT_FONT_SIZE = 1152u;
117 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
119 const int KEY_A_CODE = 38;
120 const int KEY_D_CODE = 40;
122 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
124 static bool gTextChangedCallBackCalled;
125 static bool gMaxCharactersCallBackCalled;
126 static bool gInputStyleChangedCallbackCalled;
127 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
129 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
131 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
132 Integration::ResourcePointer resource(bitmap);
133 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
136 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
140 LoadBitmapResource( app.GetPlatform(), width, height );
142 Property::Map propertyMap;
143 propertyMap["filename"] = "image.png";
144 propertyMap["width"] = width;
145 propertyMap["height"] = height;
146 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
147 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
148 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
149 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
150 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
151 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
152 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
153 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
156 // Generate a PanGestureEvent to send to Core
157 static Integration::PanGestureEvent GeneratePan(
158 Gesture::State state,
159 const Vector2& previousPosition,
160 const Vector2& currentPosition,
161 unsigned long timeDelta,
162 unsigned int numberOfTouches = 1)
164 Integration::PanGestureEvent pan(state);
166 pan.previousPosition = previousPosition;
167 pan.currentPosition = currentPosition;
168 pan.timeDelta = timeDelta;
169 pan.numberOfTouches = numberOfTouches;
175 * Helper to generate PanGestureEvent
177 * @param[in] application Application instance
178 * @param[in] state The Gesture State
179 * @param[in] pos The current position of touch.
181 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
185 if( (state == Gesture::Started) ||
186 (state == Gesture::Possible) )
192 application.ProcessEvent(GeneratePan(state, last, pos, 16));
199 * Simulate time passed by.
201 * @note this will always process at least 1 frame (1/60 sec)
203 * @param application Test application instance
204 * @param duration Time to pass in milliseconds.
205 * @return The actual time passed in milliseconds
207 static int Wait(ToolkitTestApplication& application, int duration = 0)
211 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
213 application.SendNotification();
214 application.Render(RENDER_FRAME_INTERVAL);
215 time += RENDER_FRAME_INTERVAL;
221 Dali::Integration::Point GetPointDownInside( Vector2& pos )
223 Dali::Integration::Point point;
224 point.SetState( PointState::DOWN );
225 point.SetScreenPosition( pos );
229 Dali::Integration::Point GetPointUpInside( Vector2& pos )
231 Dali::Integration::Point point;
232 point.SetState( PointState::UP );
233 point.SetScreenPosition( pos );
237 struct CallbackFunctor
239 CallbackFunctor(bool* callbackFlag)
240 : mCallbackFlag( callbackFlag )
246 *mCallbackFlag = true;
251 static void TestTextChangedCallback( TextField control )
253 tet_infoline(" TestTextChangedCallback");
255 gTextChangedCallBackCalled = true;
258 static void TestMaxLengthReachedCallback( TextField control )
260 tet_infoline(" TestMaxLengthReachedCallback");
262 gMaxCharactersCallBackCalled = true;
265 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
267 tet_infoline(" TestInputStyleChangedCallback");
269 gInputStyleChangedCallbackCalled = true;
270 gInputStyleMask = mask;
273 // Generate a TapGestureEvent to send to Core.
274 Integration::TapGestureEvent GenerateTap(
275 Gesture::State state,
276 unsigned int numberOfTaps,
277 unsigned int numberOfTouches,
280 Integration::TapGestureEvent tap( state );
282 tap.numberOfTaps = numberOfTaps;
283 tap.numberOfTouches = numberOfTouches;
289 Integration::LongPressGestureEvent GenerateLongPress(
290 Gesture::State state,
291 unsigned int numberOfTouches,
294 Integration::LongPressGestureEvent longPress( state );
296 longPress.numberOfTouches = numberOfTouches;
297 longPress.point = point;
301 // Generate a KeyEvent to send to Core.
302 Integration::KeyEvent GenerateKey( const std::string& keyName,
303 const std::string& keyString,
306 unsigned long timeStamp,
307 const Integration::KeyEvent::State& keyState,
308 const std::string& deviceName )
310 return Integration::KeyEvent( keyName,
319 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
321 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
323 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
325 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
327 if( valueGet.first.type == Property::Key::STRING )
329 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
330 if( NULL != valueSet )
332 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
334 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
340 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
346 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
347 if( NULL != valueSet )
349 if( valueGet.second.Get<int>() != valueSet->Get<int>() )
351 tet_printf( " Integer Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
357 tet_printf( " The Int key %d doesn't exist.", valueGet.first.indexKey );
369 int UtcDaliToolkitTextFieldConstructorP(void)
371 ToolkitTestApplication application;
372 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
374 DALI_TEST_CHECK( !textField );
378 int UtcDaliToolkitTextFieldNewP(void)
380 ToolkitTestApplication application;
381 tet_infoline(" UtcDaliToolkitTextFieldNewP");
382 TextField textField = TextField::New();
383 DALI_TEST_CHECK( textField );
387 int UtcDaliToolkitTextFieldDownCastP(void)
389 ToolkitTestApplication application;
390 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
391 TextField textField1 = TextField::New();
392 BaseHandle object( textField1 );
394 TextField textField2 = TextField::DownCast( object );
395 DALI_TEST_CHECK( textField2 );
397 TextField textField3 = DownCast< TextField >( object );
398 DALI_TEST_CHECK( textField3 );
402 int UtcDaliToolkitTextFieldDownCastN(void)
404 ToolkitTestApplication application;
405 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
406 BaseHandle uninitializedObject;
407 TextField textField1 = TextField::DownCast( uninitializedObject );
408 DALI_TEST_CHECK( !textField1 );
410 TextField textField2 = DownCast< TextField >( uninitializedObject );
411 DALI_TEST_CHECK( !textField2 );
415 int UtcDaliToolkitTextFieldCopyConstructorP(void)
417 ToolkitTestApplication application;
418 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
419 TextField textField = TextField::New();
420 textField.SetProperty( TextField::Property::TEXT, "Test" );
422 TextField copy( textField );
423 DALI_TEST_CHECK( copy );
424 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
428 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
430 ToolkitTestApplication application;
431 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
432 TextField textField = TextField::New();
433 textField.SetProperty( TextField::Property::TEXT, "Test" );
435 TextField copy = textField;
436 DALI_TEST_CHECK( copy );
437 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
441 int UtcDaliTextFieldNewP(void)
443 ToolkitTestApplication application;
444 tet_infoline(" UtcDaliToolkitTextFieldNewP");
445 TextField textField = TextField::New();
446 DALI_TEST_CHECK( textField );
450 // Positive test case for a method
451 int UtcDaliTextFieldGetPropertyP(void)
453 ToolkitTestApplication application;
454 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
455 TextField field = TextField::New();
456 DALI_TEST_CHECK( field );
458 // Check Property Indices are correct
459 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
460 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
461 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
462 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
463 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
464 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
465 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
466 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
467 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
468 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
469 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
470 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
471 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
472 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextField::Property::SHADOW_OFFSET );
473 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextField::Property::SHADOW_COLOR );
474 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
475 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
476 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
477 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
478 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
479 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
480 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
481 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
482 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
483 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
484 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
485 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
486 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
487 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
488 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
489 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
490 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
491 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
492 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
493 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
494 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
495 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
496 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
497 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
498 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
499 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
500 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
501 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
502 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
503 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
504 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
505 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
506 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
507 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == DevelTextField::Property::PIXEL_SIZE );
512 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
515 Property::Map imageMap;
516 imageMap[mapKey] =mapValue;
518 field.SetProperty( property , imageMap );
519 Property::Value propValue = field.GetProperty( property );
520 Property::Map* resultMap = propValue.GetMap();
522 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
530 // Positive test case for a method
531 int UtcDaliTextFieldSetPropertyP(void)
533 ToolkitTestApplication application;
534 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
535 TextField field = TextField::New();
536 DALI_TEST_CHECK( field );
537 Stage::GetCurrent().Add( field );
539 // Note - we can't check the defaults since the stylesheets are platform-specific
541 // Check the render backend property.
542 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
543 DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
545 // Check text property.
546 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
547 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
549 // Check placeholder text properties.
550 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
551 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
553 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
554 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
556 // Check font properties.
557 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
558 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
560 Property::Map fontStyleMapSet;
561 Property::Map fontStyleMapGet;
562 Property::Value* slantValue = NULL;
564 fontStyleMapSet.Insert( "weight", "bold" );
565 fontStyleMapSet.Insert( "width", "condensed" );
566 fontStyleMapSet.Insert( "slant", "italic" );
567 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
569 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
570 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
571 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
573 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
574 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
577 fontStyleMapSet.Clear();
578 fontStyleMapSet.Insert( "weight", "normal" );
579 fontStyleMapSet.Insert( "slant", "oblique" );
580 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
582 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
583 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
584 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
586 fontStyleMapSet.Clear();
587 fontStyleMapSet.Insert( "slant", "roman" );
588 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
589 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
591 // Replace 'roman' for 'normal'.
592 slantValue = fontStyleMapGet.Find( "slant" );
593 if( NULL != slantValue )
595 if( "normal" == slantValue->Get<std::string>() )
597 fontStyleMapGet["slant"] = "roman";
600 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
601 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
603 fontStyleMapSet.Clear();
605 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
606 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
607 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
608 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
610 // Check that the MAX_LENGTH property can be correctly set
611 const int maxNumberOfCharacters = 20;
612 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
613 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
615 // Check exceed policy
616 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
617 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
618 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
619 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
621 // Check that the Alignment properties can be correctly set
622 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
623 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
624 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
625 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
627 // Check text's color property
628 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
629 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
631 // Check placeholder text's color property.
632 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
633 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
635 // Check shadow properties.
636 field.SetProperty( TextField::Property::SHADOW_OFFSET, Vector2( 1.f, 1.f ) );
637 DALI_TEST_EQUALS( field.GetProperty<Vector2>( TextField::Property::SHADOW_OFFSET ), Vector2( 1.f, 1.f ), TEST_LOCATION );
638 field.SetProperty( TextField::Property::SHADOW_COLOR, Color::GREEN );
639 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SHADOW_COLOR ), Color::GREEN, TEST_LOCATION );
641 // Check cursor properties
642 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
643 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
644 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
645 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
647 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
648 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
649 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
650 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
651 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
652 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
653 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
654 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
656 // Check scroll properties.
657 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
658 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
659 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
660 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
662 // Check handle images
663 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
664 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
665 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
666 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
667 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
669 // Check handle images
670 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
671 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
672 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
673 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
674 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
675 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
677 // Check the highlight color
678 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
679 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
681 // Decoration bounding box
682 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
683 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
685 // Check the input method setting
686 Property::Map propertyMap;
687 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
688 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
689 InputMethod::ActionButtonTitle::Type actionButton = InputMethod::ActionButtonTitle::GO;
690 int inputVariation = 1;
691 propertyMap["PANEL_LAYOUT"] = panelLayout;
692 propertyMap["AUTO_CAPITALISE"] = autoCapital;
693 propertyMap["ACTION_BUTTON"] = actionButton;
694 propertyMap["VARIATION"] = inputVariation;
695 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
697 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
699 DALI_TEST_CHECK( value.Get( map ) );
702 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
703 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
706 DALI_TEST_CHECK( map[ "AUTO_CAPITALISE" ].Get( capital ) );
707 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
710 DALI_TEST_CHECK( map[ "ACTION_BUTTON" ].Get( action ) );
711 DALI_TEST_EQUALS( static_cast<int>(actionButton), action, TEST_LOCATION );
714 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
715 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
717 // Check input color property.
718 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
719 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
721 // Check the enable markup property.
722 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
723 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
724 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
726 // Check input font properties.
727 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
728 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
730 fontStyleMapSet.Clear();
731 fontStyleMapSet.Insert( "weight", "bold" );
732 fontStyleMapSet.Insert( "width", "condensed" );
733 fontStyleMapSet.Insert( "slant", "italic" );
735 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
736 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
737 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
738 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
740 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
741 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
743 // Reset input font style.
744 fontStyleMapSet.Clear();
745 fontStyleMapSet.Insert( "weight", "normal" );
746 fontStyleMapSet.Insert( "slant", "oblique" );
748 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
749 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
750 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
751 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
753 fontStyleMapSet.Clear();
754 fontStyleMapSet.Insert( "slant", "roman" );
756 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
757 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
759 // Replace 'roman' for 'normal'.
760 slantValue = fontStyleMapGet.Find( "slant" );
761 if( NULL != slantValue )
763 if( "normal" == slantValue->Get<std::string>() )
765 fontStyleMapGet["slant"] = "roman";
768 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
769 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
771 fontStyleMapSet.Clear();
773 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
774 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
775 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
776 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
778 Property::Map underlineMapSet;
779 Property::Map underlineMapGet;
781 underlineMapSet.Insert( "enable", "true" );
782 underlineMapSet.Insert( "color", "red" );
783 underlineMapSet.Insert( "height", "1" );
785 // Check the underline property
786 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
788 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
789 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
790 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
792 // Check the input underline property
793 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
794 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
796 // Check the shadow property
797 Property::Map shadowMapSet;
798 Property::Map shadowMapGet;
800 shadowMapSet.Insert( "color", "green" );
801 shadowMapSet.Insert( "offset", "2 2" );
803 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
805 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
806 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
807 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
809 // Check the input shadow property
810 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
811 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
813 // Check the emboss property
814 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
815 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
817 // Check the input emboss property
818 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
819 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
821 // Check the outline property
822 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
823 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
825 // Check the input outline property
826 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
827 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
829 // Check the hidden input settings property
830 Property::Map hiddenMapSet;
831 Property::Map hiddenMapGet;
832 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
833 hiddenMapSet[ HiddenInput::Property::SHOW_DURATION ] = 2;
834 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
835 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
836 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
838 hiddenMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
839 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
840 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
842 // Check the pixel size of font
843 field.SetProperty( DevelTextField::Property::PIXEL_SIZE, 20.f );
844 DALI_TEST_EQUALS( field.GetProperty<float>( DevelTextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
849 // Positive Atlas Text Renderer test
850 int utcDaliTextFieldAtlasRenderP(void)
852 ToolkitTestApplication application;
853 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
854 StyleManager styleManager = StyleManager::Get();
855 styleManager.ApplyDefaultTheme();
856 TextField field = TextField::New();
857 DALI_TEST_CHECK( field );
859 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
861 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
863 Stage::GetCurrent().Add( field );
867 // Render some text with the shared atlas backend
868 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
869 application.SendNotification();
870 application.Render();
874 tet_result(TET_FAIL);
879 // Positive test for the textChanged signal.
880 int utcDaliTextFieldTextChangedP(void)
882 ToolkitTestApplication application;
883 tet_infoline(" utcDaliTextFieldTextChangedP");
884 TextField field = TextField::New();
885 DALI_TEST_CHECK( field );
887 Stage::GetCurrent().Add( field );
889 // connect to the text changed signal.
890 ConnectionTracker* testTracker = new ConnectionTracker();
891 field.TextChangedSignal().Connect(&TestTextChangedCallback);
892 bool textChangedSignal = false;
893 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
895 gTextChangedCallBackCalled = false;
896 field.SetProperty( TextField::Property::TEXT, "ABC" );
897 DALI_TEST_CHECK( gTextChangedCallBackCalled );
898 DALI_TEST_CHECK( textChangedSignal );
900 application.SendNotification();
902 field.SetKeyInputFocus();
904 gTextChangedCallBackCalled = false;
905 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
906 DALI_TEST_CHECK( gTextChangedCallBackCalled );
911 // Negative test for the textChanged signal.
912 int utcDaliTextFieldTextChangedN(void)
914 ToolkitTestApplication application;
915 tet_infoline(" utcDaliTextFieldTextChangedN");
916 TextField field = TextField::New();
917 DALI_TEST_CHECK( field );
919 Stage::GetCurrent().Add( field );
921 // connect to the text changed signal.
922 ConnectionTracker* testTracker = new ConnectionTracker();
923 field.TextChangedSignal().Connect(&TestTextChangedCallback);
924 bool textChangedSignal = false;
925 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
927 gTextChangedCallBackCalled = false;
928 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
929 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
930 DALI_TEST_CHECK( !textChangedSignal );
935 // Positive test for Max Characters reached signal.
936 int utcDaliTextFieldMaxCharactersReachedP(void)
938 ToolkitTestApplication application;
939 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
940 TextField field = TextField::New();
941 DALI_TEST_CHECK( field );
943 Stage::GetCurrent().Add( field );
945 const int maxNumberOfCharacters = 1;
946 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
948 field.SetKeyInputFocus();
950 // connect to the text changed signal.
951 ConnectionTracker* testTracker = new ConnectionTracker();
952 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
953 bool maxLengthReachedSignal = false;
954 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
956 gMaxCharactersCallBackCalled = false;
958 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
959 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
961 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
962 DALI_TEST_CHECK( maxLengthReachedSignal );
967 // Negative test for Max Characters reached signal.
968 int utcDaliTextFieldMaxCharactersReachedN(void)
970 ToolkitTestApplication application;
971 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
972 TextField field = TextField::New();
973 DALI_TEST_CHECK( field );
975 Stage::GetCurrent().Add( field );
977 const int maxNumberOfCharacters = 3;
978 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
980 field.SetKeyInputFocus();
982 // connect to the text changed signal.
983 ConnectionTracker* testTracker = new ConnectionTracker();
984 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
985 bool maxLengthReachedSignal = false;
986 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
988 gMaxCharactersCallBackCalled = false;
990 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
991 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
993 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
994 DALI_TEST_CHECK( !maxLengthReachedSignal );
999 int utcDaliTextFieldInputStyleChanged01(void)
1001 ToolkitTestApplication application;
1002 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1004 // The text-field emits signals when the input style changes. These changes of style are
1005 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1006 // can't be emitted during the size negotiation as the callbacks may update the UI.
1007 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1008 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1009 application.CreateAdaptor();
1013 char* pathNamePtr = get_current_dir_name();
1014 const std::string pathName( pathNamePtr );
1015 free( pathNamePtr );
1017 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1018 fontClient.SetDpi( 93u, 93u );
1020 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1021 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1023 TextField field = TextField::New();
1024 DALI_TEST_CHECK( field );
1027 field.SetSize( 300.f, 50.f );
1028 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1029 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1031 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1032 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1034 // connect to the text changed signal.
1035 ConnectionTracker* testTracker = new ConnectionTracker();
1036 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1037 bool inputStyleChangedSignal = false;
1038 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1040 Stage::GetCurrent().Add( field );
1042 // Render and notify
1043 application.SendNotification();
1044 application.Render();
1046 // Executes the idle callbacks added by the text control on the change of input style.
1047 application.RunIdles();
1049 gInputStyleChangedCallbackCalled = false;
1050 gInputStyleMask = TextField::InputStyle::NONE;
1051 inputStyleChangedSignal = false;
1053 // Create a tap event to touch the text field.
1054 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1055 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1057 // Render and notify
1058 application.SendNotification();
1059 application.Render();
1061 // Executes the idle callbacks added by the text control on the change of input style.
1062 application.RunIdles();
1064 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1065 if( gInputStyleChangedCallbackCalled )
1067 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1069 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1070 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1072 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1073 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1075 DALI_TEST_CHECK( inputStyleChangedSignal );
1077 gInputStyleChangedCallbackCalled = false;
1078 gInputStyleMask = TextField::InputStyle::NONE;
1079 inputStyleChangedSignal = false;
1081 // Create a tap event to touch the text field.
1082 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1083 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1085 // Render and notify
1086 application.SendNotification();
1087 application.Render();
1089 // Executes the idle callbacks added by the text control on the change of input style.
1090 application.RunIdles();
1092 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1093 DALI_TEST_CHECK( !inputStyleChangedSignal );
1095 gInputStyleChangedCallbackCalled = false;
1096 gInputStyleMask = TextField::InputStyle::NONE;
1097 inputStyleChangedSignal = false;
1099 // Create a tap event to touch the text field.
1100 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1101 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1103 // Render and notify
1104 application.SendNotification();
1105 application.Render();
1107 // Executes the idle callbacks added by the text control on the change of input style.
1108 application.RunIdles();
1110 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1111 if( gInputStyleChangedCallbackCalled )
1113 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1115 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1116 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
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( 88.f, 25.f ) ) );
1126 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.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::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1140 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1141 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1143 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1145 Property::Map fontStyleMapSet;
1146 fontStyleMapSet.Insert( "weight", "bold" );
1148 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1149 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1151 DALI_TEST_CHECK( inputStyleChangedSignal );
1153 gInputStyleChangedCallbackCalled = false;
1154 gInputStyleMask = TextField::InputStyle::NONE;
1155 inputStyleChangedSignal = false;
1157 // Create a tap event to touch the text field.
1158 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1159 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1161 // Render and notify
1162 application.SendNotification();
1163 application.Render();
1165 // Executes the idle callbacks added by the text control on the change of input style.
1166 application.RunIdles();
1168 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1169 DALI_TEST_CHECK( !inputStyleChangedSignal );
1171 gInputStyleChangedCallbackCalled = false;
1172 gInputStyleMask = TextField::InputStyle::NONE;
1173 inputStyleChangedSignal = false;
1175 // Create a tap event to touch the text field.
1176 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1177 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1179 // Render and notify
1180 application.SendNotification();
1181 application.Render();
1183 // Executes the idle callbacks added by the text control on the change of input style.
1184 application.RunIdles();
1186 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1187 if( gInputStyleChangedCallbackCalled )
1189 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1191 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1192 DALI_TEST_CHECK( style.empty() );
1194 DALI_TEST_CHECK( inputStyleChangedSignal );
1196 gInputStyleChangedCallbackCalled = false;
1197 gInputStyleMask = TextField::InputStyle::NONE;
1198 inputStyleChangedSignal = false;
1200 // Create a tap event to touch the text field.
1201 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1202 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1204 // Render and notify
1205 application.SendNotification();
1206 application.Render();
1208 // Executes the idle callbacks added by the text control on the change of input style.
1209 application.RunIdles();
1211 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1212 DALI_TEST_CHECK( !inputStyleChangedSignal );
1217 int utcDaliTextFieldInputStyleChanged02(void)
1219 ToolkitTestApplication application;
1220 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1222 // The text-field emits signals when the input style changes. These changes of style are
1223 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1224 // can't be emitted during the size negotiation as the callbacks may update the UI.
1225 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1226 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1227 application.CreateAdaptor();
1231 char* pathNamePtr = get_current_dir_name();
1232 const std::string pathName( pathNamePtr );
1233 free( pathNamePtr );
1235 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1236 fontClient.SetDpi( 93u, 93u );
1238 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1239 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1241 TextField field = TextField::New();
1242 DALI_TEST_CHECK( field );
1245 field.SetSize( 300.f, 50.f );
1246 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1247 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1249 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1250 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>" );
1252 // connect to the text changed signal.
1253 ConnectionTracker* testTracker = new ConnectionTracker();
1254 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1255 bool inputStyleChangedSignal = false;
1256 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1258 Stage::GetCurrent().Add( field );
1260 // Render and notify
1261 application.SendNotification();
1262 application.Render();
1264 // Executes the idle callbacks added by the text control on the change of input style.
1265 application.RunIdles();
1267 gInputStyleChangedCallbackCalled = false;
1268 gInputStyleMask = TextField::InputStyle::NONE;
1269 inputStyleChangedSignal = false;
1271 // Create a tap event to touch the text field.
1272 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1273 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1274 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1275 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1277 // Render and notify
1278 application.SendNotification();
1279 application.Render();
1281 // Executes the idle callbacks added by the text control on the change of input style.
1282 application.RunIdles();
1284 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1285 if( gInputStyleChangedCallbackCalled )
1287 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1288 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1289 TextField::InputStyle::POINT_SIZE |
1290 TextField::InputStyle::COLOR ),
1293 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1294 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1296 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1297 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1299 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1300 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1302 DALI_TEST_CHECK( inputStyleChangedSignal );
1304 gInputStyleChangedCallbackCalled = false;
1305 gInputStyleMask = TextField::InputStyle::NONE;
1306 inputStyleChangedSignal = false;
1308 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1310 // Render and notify
1311 application.SendNotification();
1312 application.Render();
1314 // Executes the idle callbacks added by the text control on the change of input style.
1315 application.RunIdles();
1317 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1318 if( gInputStyleChangedCallbackCalled )
1320 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1321 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1324 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1325 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1327 DALI_TEST_CHECK( inputStyleChangedSignal );
1329 gInputStyleChangedCallbackCalled = false;
1330 gInputStyleMask = TextField::InputStyle::NONE;
1331 inputStyleChangedSignal = false;
1333 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1335 // Render and notify
1336 application.SendNotification();
1337 application.Render();
1339 // Executes the idle callbacks added by the text control on the change of input style.
1340 application.RunIdles();
1342 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1343 DALI_TEST_CHECK( !inputStyleChangedSignal );
1345 gInputStyleChangedCallbackCalled = false;
1346 gInputStyleMask = TextField::InputStyle::NONE;
1347 inputStyleChangedSignal = false;
1349 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1351 // Render and notify
1352 application.SendNotification();
1353 application.Render();
1355 // Executes the idle callbacks added by the text control on the change of input style.
1356 application.RunIdles();
1358 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1359 if( gInputStyleChangedCallbackCalled )
1361 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1362 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1365 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1366 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1368 DALI_TEST_CHECK( inputStyleChangedSignal );
1370 gInputStyleChangedCallbackCalled = false;
1371 gInputStyleMask = TextField::InputStyle::NONE;
1372 inputStyleChangedSignal = false;
1374 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1376 Property::Map fontStyleMapSet;
1377 fontStyleMapSet.Insert( "weight", "thin" );
1378 fontStyleMapSet.Insert( "width", "condensed" );
1379 fontStyleMapSet.Insert( "slant", "italic" );
1381 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1382 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1384 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1385 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1386 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1387 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1389 // Render and notify
1390 application.SendNotification();
1391 application.Render();
1393 // Executes the idle callbacks added by the text control on the change of input style.
1394 application.RunIdles();
1396 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1397 DALI_TEST_CHECK( !inputStyleChangedSignal );
1399 // Create a tap event to touch the text field.
1400 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1401 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1403 // Render and notify
1404 application.SendNotification();
1405 application.Render();
1407 // Executes the idle callbacks added by the text control on the change of input style.
1408 application.RunIdles();
1410 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1411 if( gInputStyleChangedCallbackCalled )
1413 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1414 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1415 TextField::InputStyle::POINT_SIZE |
1416 TextField::InputStyle::FONT_STYLE |
1417 TextField::InputStyle::UNDERLINE |
1418 TextField::InputStyle::SHADOW |
1419 TextField::InputStyle::EMBOSS |
1420 TextField::InputStyle::OUTLINE ),
1423 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1424 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1426 DALI_TEST_CHECK( inputStyleChangedSignal );
1431 int utcDaliTextFieldEvent01(void)
1433 ToolkitTestApplication application;
1434 tet_infoline(" utcDaliTextFieldEvent01");
1436 // Creates a tap event. After creating a tap event the text field should
1437 // have the focus and add text with key events should be possible.
1439 TextField field = TextField::New();
1440 DALI_TEST_CHECK( field );
1442 Stage::GetCurrent().Add( field );
1444 field.SetSize( 300.f, 50.f );
1445 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1446 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1448 // Avoid a crash when core load gl resources.
1449 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1451 // Render and notify
1452 application.SendNotification();
1453 application.Render();
1455 // Add a key event but as the text field has not the focus it should do nothing.
1456 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1458 // Render and notify
1459 application.SendNotification();
1460 application.Render();
1462 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1464 // Create a tap event to touch the text field.
1465 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1466 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1468 // Render and notify
1469 application.SendNotification();
1470 application.Render();
1472 // Now the text field has the focus, so it can handle the key events.
1473 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1474 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1476 // Render and notify
1477 application.SendNotification();
1478 application.Render();
1480 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1482 // Create a second text field and send key events to it.
1483 TextField field2 = TextField::New();
1485 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1486 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1487 field2.SetSize( 100.f, 100.f );
1488 field2.SetPosition( 100.f, 100.f );
1490 Stage::GetCurrent().Add( field2 );
1492 // Render and notify
1493 application.SendNotification();
1494 application.Render();
1496 // Create a tap event on the second text field.
1497 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1498 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1500 // Render and notify
1501 application.SendNotification();
1502 application.Render();
1504 // The second text field has the focus. It should handle the key events.
1505 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1506 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1508 // Render and notify
1509 application.SendNotification();
1510 application.Render();
1512 // Check the text has been added to the second text field.
1513 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1518 int utcDaliTextFieldEvent02(void)
1520 ToolkitTestApplication application;
1521 tet_infoline(" utcDaliTextFieldEvent02");
1523 // Checks if the right number of actors are created.
1525 TextField field = TextField::New();
1526 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1527 DALI_TEST_CHECK( field );
1528 LoadMarkerImages(application, field);
1530 Stage::GetCurrent().Add( field );
1532 field.SetSize( 300.f, 50.f );
1533 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1534 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1536 // Avoid a crash when core load gl resources.
1537 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1539 // Render and notify
1540 application.SendNotification();
1541 application.Render();
1543 // Check there are the expected number of children ( stencil ).
1544 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1546 Actor stencil = field.GetChildAt( 0u );
1547 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1549 // Create a tap event to touch the text field.
1550 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1551 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1553 // Render and notify
1554 application.SendNotification();
1555 application.Render();
1557 Actor layer = field.GetChildAt( 1u );
1558 DALI_TEST_CHECK( layer.IsLayer() );
1560 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1561 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1563 // Now the text field has the focus, so it can handle the key events.
1564 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1565 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1567 // Render and notify
1568 application.SendNotification();
1569 application.Render();
1571 // Checks the cursor and the renderer have been created.
1572 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1573 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1575 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1576 DALI_TEST_CHECK( cursor );
1578 // The offscreen root actor has a container with all the actors which contain the text renderers.
1579 Actor container = stencil.GetChildAt( 0u );
1580 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1582 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1583 DALI_TEST_CHECK( renderer );
1586 // Move the cursor and check the position changes.
1587 Vector3 position1 = cursor.GetCurrentPosition();
1589 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1590 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1592 // Render and notify
1593 application.SendNotification();
1594 application.Render();
1596 Vector3 position2 = cursor.GetCurrentPosition();
1598 DALI_TEST_CHECK( position2.x < position1.x );
1600 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1601 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1603 // Render and notify
1604 application.SendNotification();
1605 application.Render();
1607 Vector3 position3 = cursor.GetCurrentPosition();
1609 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1611 // Send some taps and check the cursor positions.
1613 // Try to tap at the beginning.
1614 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1615 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1617 // Render and notify
1618 application.SendNotification();
1619 application.Render();
1621 // Cursor position should be the same than position1.
1622 Vector3 position4 = cursor.GetCurrentPosition();
1624 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1626 // Tap away from the start position.
1627 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1628 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1630 // Render and notify
1631 application.SendNotification();
1632 application.Render();
1634 Vector3 position5 = cursor.GetCurrentPosition();
1636 DALI_TEST_CHECK( position5.x > position4.x );
1638 // Remove all the text.
1639 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1640 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1641 field.SetProperty( TextField::Property::TEXT, "" );
1643 // Render and notify
1644 application.SendNotification();
1645 application.Render();
1647 // Cursor position should be the same than position2.
1648 Vector3 position6 = cursor.GetCurrentPosition();
1650 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1652 // Should not be a renderer.
1653 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1658 int utcDaliTextFieldEvent03(void)
1660 ToolkitTestApplication application;
1661 tet_infoline(" utcDaliTextFieldEvent03");
1663 // Checks if the highlight actor is created.
1665 TextField field = TextField::New();
1666 DALI_TEST_CHECK( field );
1668 Stage::GetCurrent().Add( field );
1670 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1671 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1672 field.SetSize( 30.f, 50.f );
1673 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1674 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1676 // Avoid a crash when core load gl resources.
1677 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1678 LoadMarkerImages(application, field);
1680 // Render and notify
1681 application.SendNotification();
1682 application.Render();
1684 // Tap first to get the focus.
1685 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1686 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1688 // Render and notify
1689 application.SendNotification();
1690 application.Render();
1692 // Double tap to select a word.
1693 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1694 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1696 // Render and notify
1697 application.SendNotification();
1698 application.Render();
1700 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1701 Actor stencil = field.GetChildAt( 0u );
1703 // The offscreen root actor has a container with all the actors which contain the text renderers.
1704 Actor container = stencil.GetChildAt( 0u );
1705 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1707 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1708 DALI_TEST_CHECK( renderer );
1711 Renderer highlight = stencil.GetChildAt( 1u ).GetRendererAt( 0u );
1712 DALI_TEST_CHECK( highlight );
1717 int utcDaliTextFieldEvent04(void)
1719 ToolkitTestApplication application;
1720 tet_infoline(" utcDaliTextFieldEvent04");
1722 // Checks if the highlight actor is created.
1724 TextField field = TextField::New();
1725 DALI_TEST_CHECK( field );
1726 Stage::GetCurrent().Add( field );
1727 LoadMarkerImages(application, field);
1728 // Render and notify
1729 application.SendNotification();
1730 application.Render();
1732 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1733 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1734 field.SetSize( 300.f, 50.f );
1735 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1736 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1738 // Avoid a crash when core load gl resources.
1739 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1740 // Render and notify
1741 application.SendNotification();
1742 application.Render();
1744 // Create a tap event to touch the text field.
1745 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1746 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1747 // Render and notify
1748 application.SendNotification();
1749 application.Render();
1752 // Tap first to get the focus.
1753 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1754 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1756 // Render and notify
1757 application.SendNotification();
1758 application.Render();
1760 // Double tap to select a word.
1761 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1762 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1764 // Render and notify
1765 application.SendNotification();
1766 application.Render();
1769 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1770 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1774 int utcDaliTextFieldEvent05(void)
1776 ToolkitTestApplication application;
1777 tet_infoline(" utcDaliTextFieldEvent05");
1779 // Checks dragging of cursor/grab handle
1781 TextField field = TextField::New();
1782 DALI_TEST_CHECK( field );
1783 Stage::GetCurrent().Add( field );
1784 LoadMarkerImages(application, field);
1785 // Render and notify
1786 application.SendNotification();
1787 application.Render();
1789 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1790 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1791 field.SetSize( 300.f, 50.f );
1792 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1793 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1795 // Avoid a crash when core load gl resources.
1796 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1797 // Render and notify
1798 application.SendNotification();
1799 application.Render();
1801 // Create a tap event to touch the text field.
1802 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1803 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1804 // Render and notify
1805 application.SendNotification();
1806 application.Render();
1809 // Tap first to get the focus.
1810 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1811 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1813 // Render and notify
1814 application.SendNotification();
1815 application.Render();
1817 // Double tap to select a word.
1818 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1819 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1821 // Render and notify
1822 application.SendNotification();
1823 application.Render();
1825 // drag grab handle right
1826 Vector2 pos(0.0f, 40.0f);
1827 SendPan(application, Gesture::Possible, pos);
1828 SendPan(application, Gesture::Started, pos);
1830 Wait(application, 100);
1832 for(int i = 0;i<20;i++)
1834 SendPan(application, Gesture::Continuing, pos);
1839 SendPan(application, Gesture::Finished, pos);
1840 Wait(application, RENDER_FRAME_INTERVAL);
1842 Actor stencil = field.GetChildAt( 1u );
1846 int utcDaliTextFieldEvent06(void)
1848 ToolkitTestApplication application;
1849 tet_infoline(" utcDaliTextFieldEvent06");
1851 // Checks Longpress when in edit mode
1853 TextField field = TextField::New();
1854 DALI_TEST_CHECK( field );
1855 Stage::GetCurrent().Add( field );
1856 LoadMarkerImages(application, field);
1857 // Render and notify
1858 application.SendNotification();
1859 application.Render();
1861 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1862 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1863 field.SetSize( 300.f, 50.f );
1864 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1865 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1867 // Avoid a crash when core load gl resources.
1868 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1869 // Render and notify
1870 application.SendNotification();
1871 application.Render();
1873 // Create a tap event to touch the text field.
1874 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1875 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1876 // Render and notify
1877 application.SendNotification();
1878 application.Render();
1881 // Tap first to get the focus.
1882 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1883 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1885 // Render and notify
1886 application.SendNotification();
1887 application.Render();
1890 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1891 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1893 // Render and notify
1894 application.SendNotification();
1895 application.Render();
1900 int utcDaliTextFieldEvent07(void)
1902 ToolkitTestApplication application;
1903 tet_infoline(" utcDaliTextFieldEvent07");
1905 // Checks Longpress to start edit mode
1907 TextField field = TextField::New();
1908 DALI_TEST_CHECK( field );
1909 Stage::GetCurrent().Add( field );
1910 LoadMarkerImages(application, field);
1911 // Render and notify
1912 application.SendNotification();
1913 application.Render();
1915 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1916 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1917 field.SetSize( 300.f, 50.f );
1918 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1919 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1920 Property::Map propertyMap;
1921 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
1922 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
1924 // Avoid a crash when core load gl resources.
1925 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1926 // Render and notify
1927 application.SendNotification();
1928 application.Render();
1931 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1932 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1934 // Render and notify
1935 application.SendNotification();
1936 application.Render();
1941 int utcDaliTextFieldEvent08(void)
1943 ToolkitTestApplication application;
1944 tet_infoline(" utcDaliTextFieldEvent08");
1946 Dali::Clipboard clipboard = Clipboard::Get();
1947 clipboard.SetItem("testTextFieldEvent");
1949 // Checks Longpress when only place holder text
1951 TextField field = TextField::New();
1952 DALI_TEST_CHECK( field );
1953 Stage::GetCurrent().Add( field );
1954 LoadMarkerImages(application, field);
1955 // Render and notify
1956 application.SendNotification();
1957 application.Render();
1959 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
1960 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1961 field.SetSize( 300.f, 50.f );
1962 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1963 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1965 // Avoid a crash when core load gl resources.
1966 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1967 // Render and notify
1968 application.SendNotification();
1969 application.Render();
1972 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1973 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1975 // Render and notify
1976 application.SendNotification();
1977 application.Render();
1979 Wait(application, 500);
1982 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1983 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1985 // Render and notify
1986 application.SendNotification();
1987 application.Render();
1989 Wait(application, 500);
1991 Stage stage = Stage::GetCurrent();
1992 Layer layer = stage.GetRootLayer();
1993 Actor actor = layer.FindChildByName("optionPaste");
1997 Vector3 worldPosition = actor.GetCurrentWorldPosition();
1998 Vector2 halfStageSize = stage.GetSize() / 2.0f;
1999 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2001 Dali::Integration::TouchEvent event;
2002 event = Dali::Integration::TouchEvent();
2003 event.AddPoint( GetPointDownInside( position ) );
2004 application.ProcessEvent( event );
2006 event = Dali::Integration::TouchEvent();
2007 event.AddPoint( GetPointUpInside( position ) );
2008 application.ProcessEvent( event );
2010 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2015 int utcDaliTextFieldEvent09(void)
2017 ToolkitTestApplication application;
2018 tet_infoline(" utcDaliTextFieldEvent09");
2020 TextField field = TextField::New();
2021 DALI_TEST_CHECK( field );
2022 Stage::GetCurrent().Add( field );
2023 LoadMarkerImages(application, field);
2024 // Render and notify
2025 application.SendNotification();
2026 application.Render();
2028 field.SetProperty( TextField::Property::TEXT, "Hello" );
2029 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2030 field.SetSize( 300.f, 50.f );
2031 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2032 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2034 // Avoid a crash when core load gl resources.
2035 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2037 // Create a tap event to touch the text field.
2038 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2039 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2040 application.SendNotification();
2041 application.Render();
2044 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2045 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2046 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2047 application.SendNotification();
2048 application.Render();
2050 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2051 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2052 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2053 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2054 application.SendNotification();
2055 application.Render();
2057 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2058 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2059 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2060 for( unsigned int index = 0u; index < 5u; ++index )
2062 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2063 application.SendNotification();
2064 application.Render();
2067 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2068 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2069 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2070 for( unsigned int index = 0u; index < 5u; ++index )
2072 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2073 application.SendNotification();
2074 application.Render();
2077 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2078 map[ HiddenInput::Property::SHOW_DURATION ] = 0;
2079 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2080 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2081 application.SendNotification();
2082 application.Render();
2083 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2084 application.SendNotification();
2085 application.Render();
2087 map[ HiddenInput::Property::SHOW_DURATION ] = 100;
2088 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2089 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2090 application.SendNotification();
2091 application.Render();
2093 Property::Map mapGet;
2094 mapGet = field.GetProperty<Property::Map>( DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
2095 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2096 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2101 int utcDaliTextFieldStyleWhilstSelected(void)
2103 ToolkitTestApplication application;
2104 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2106 // Change font and styles whilst text is selected whilst word selected
2108 TextField field = TextField::New();
2109 DALI_TEST_CHECK( field );
2110 Stage::GetCurrent().Add( field );
2111 LoadMarkerImages(application, field);
2112 // Render and notify
2113 application.SendNotification();
2114 application.Render();
2116 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2117 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2118 field.SetSize( 300.f, 50.f );
2119 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2120 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2122 // Avoid a crash when core load gl resources.
2123 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2124 // Render and notify
2125 application.SendNotification();
2126 application.Render();
2128 // Create a tap event to touch the text field.
2129 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2130 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2131 // Render and notify
2132 application.SendNotification();
2133 application.Render();
2136 // Tap first to get the focus.
2137 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2138 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2140 // Render and notify
2141 application.SendNotification();
2142 application.Render();
2144 // Double tap to select a word.
2145 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2146 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2148 // Render and notify
2149 application.SendNotification();
2150 application.Render();
2152 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2153 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2155 Property::Map fontStyleMapSet;
2156 Property::Map fontStyleMapGet;
2158 fontStyleMapSet.Insert( "weight", "bold" );
2159 fontStyleMapSet.Insert( "slant", "italic" );
2160 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2162 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2163 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2164 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2166 fontStyleMapSet.Clear();
2167 fontStyleMapSet.Insert( "width", "expanded" );
2168 fontStyleMapSet.Insert( "slant", "italic" );
2169 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2171 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2172 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2173 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2175 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2176 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2178 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2179 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2181 fontStyleMapSet.Clear();
2182 fontStyleMapSet.Insert( "weight", "bold" );
2183 fontStyleMapSet.Insert( "slant", "italic" );
2185 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2187 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2188 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2189 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2191 fontStyleMapSet.Clear();
2192 fontStyleMapSet.Insert( "width", "expanded" );
2194 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2196 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2197 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2198 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2200 // Press Escape to increase coverage
2201 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME ) );
2202 application.SendNotification();
2203 application.Render();
2205 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2210 int utcDaliTextFieldEscKeyLoseFocus(void)
2212 ToolkitTestApplication application;
2213 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2215 // Creates a tap event. After creating a tap event the text field should
2216 // have the focus and add text with key events should be possible.
2218 TextField field = TextField::New();
2219 DALI_TEST_CHECK( field );
2221 Stage::GetCurrent().Add( field );
2223 field.SetSize( 300.f, 50.f );
2224 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2225 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2227 // Avoid a crash when core load gl resources.
2228 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2230 // Render and notify
2231 application.SendNotification();
2232 application.Render();
2234 // Add a key event but as the text field has not the focus it should do nothing.
2235 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2236 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME ) );
2238 // Render and notify
2239 application.SendNotification();
2240 application.Render();
2242 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2244 // Create a tap event to touch the text field.
2245 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2246 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2248 // Render and notify
2249 application.SendNotification();
2250 application.Render();
2252 // Now the text field has the focus, so it can handle the key events.
2253 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2254 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME ) );
2255 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2256 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME ) );
2258 // Render and notify
2259 application.SendNotification();
2260 application.Render();
2262 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2264 // Generate a Esc key event. The text field should lose the focus.
2265 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2266 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME ) );
2268 // Render and notify
2269 application.SendNotification();
2270 application.Render();
2272 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2274 // No more text should be introduced
2275 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2276 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME ) );
2278 // Render and notify
2279 application.SendNotification();
2280 application.Render();
2282 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2287 int utcDaliTextFieldSomeSpecialKeys(void)
2289 ToolkitTestApplication application;
2290 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2292 // Checks some special keys when the text is selected.
2294 TextField field = TextField::New();
2295 DALI_TEST_CHECK( field );
2296 Stage::GetCurrent().Add( field );
2297 LoadMarkerImages(application, field);
2298 // Render and notify
2299 application.SendNotification();
2300 application.Render();
2302 const std::string longText( "This is a long text for the size of the text-field." );
2304 field.SetProperty( TextField::Property::TEXT, longText );
2305 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2306 field.SetSize( 300.f, 50.f );
2307 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2308 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2310 // Avoid a crash when core load gl resources.
2311 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2312 // Render and notify
2313 application.SendNotification();
2314 application.Render();
2316 // Create a tap event to touch the text field.
2317 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2318 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2320 // Render and notify
2321 application.SendNotification();
2322 application.Render();
2324 // Tap first to get the focus.
2325 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2326 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2328 // Render and notify
2329 application.SendNotification();
2330 application.Render();
2332 // Double tap to select a word.
2333 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2334 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2336 // Render and notify
2337 application.SendNotification();
2338 application.Render();
2340 // Generate a Esc key event. The text field should lose the focus.
2341 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2342 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME ) );
2344 // Render and notify
2345 application.SendNotification();
2346 application.Render();
2348 // Generate a Esc key event. The text field should lose the focus.
2349 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2350 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME ) );
2352 // Render and notify
2353 application.SendNotification();
2354 application.Render();
2356 // Generate a Esc key event. The text field should lose the focus.
2357 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2358 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME ) );
2360 // Render and notify
2361 application.SendNotification();
2362 application.Render();
2364 // The text shouldn't be deleted.
2365 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );