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";
101 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
103 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
104 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
106 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
107 const float RENDER_FRAME_INTERVAL = 16.66f;
109 const float TO_MILLISECONDS = 1000.f;
110 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
112 const float SCROLL_THRESHOLD = 10.f;
113 const float SCROLL_SPEED = 300.f;
115 const unsigned int DEFAULT_FONT_SIZE = 1152u;
116 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
118 const int KEY_A_CODE = 38;
119 const int KEY_D_CODE = 40;
121 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
123 static bool gTextChangedCallBackCalled;
124 static bool gMaxCharactersCallBackCalled;
125 static bool gInputStyleChangedCallbackCalled;
126 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
128 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
130 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
131 Integration::ResourcePointer resource(bitmap);
132 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
135 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
139 LoadBitmapResource( app.GetPlatform(), width, height );
141 Property::Map propertyMap;
142 propertyMap["filename"] = "image.png";
143 propertyMap["width"] = width;
144 propertyMap["height"] = height;
145 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
146 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
147 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
148 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
149 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
150 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
151 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
152 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
155 // Generate a PanGestureEvent to send to Core
156 static Integration::PanGestureEvent GeneratePan(
157 Gesture::State state,
158 const Vector2& previousPosition,
159 const Vector2& currentPosition,
160 unsigned long timeDelta,
161 unsigned int numberOfTouches = 1)
163 Integration::PanGestureEvent pan(state);
165 pan.previousPosition = previousPosition;
166 pan.currentPosition = currentPosition;
167 pan.timeDelta = timeDelta;
168 pan.numberOfTouches = numberOfTouches;
174 * Helper to generate PanGestureEvent
176 * @param[in] application Application instance
177 * @param[in] state The Gesture State
178 * @param[in] pos The current position of touch.
180 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
184 if( (state == Gesture::Started) ||
185 (state == Gesture::Possible) )
191 application.ProcessEvent(GeneratePan(state, last, pos, 16));
198 * Simulate time passed by.
200 * @note this will always process at least 1 frame (1/60 sec)
202 * @param application Test application instance
203 * @param duration Time to pass in milliseconds.
204 * @return The actual time passed in milliseconds
206 static int Wait(ToolkitTestApplication& application, int duration = 0)
210 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
212 application.SendNotification();
213 application.Render(RENDER_FRAME_INTERVAL);
214 time += RENDER_FRAME_INTERVAL;
220 Dali::Integration::Point GetPointDownInside( Vector2& pos )
222 Dali::Integration::Point point;
223 point.SetState( PointState::DOWN );
224 point.SetScreenPosition( pos );
228 Dali::Integration::Point GetPointUpInside( Vector2& pos )
230 Dali::Integration::Point point;
231 point.SetState( PointState::UP );
232 point.SetScreenPosition( pos );
236 struct CallbackFunctor
238 CallbackFunctor(bool* callbackFlag)
239 : mCallbackFlag( callbackFlag )
245 *mCallbackFlag = true;
250 static void TestTextChangedCallback( TextField control )
252 tet_infoline(" TestTextChangedCallback");
254 gTextChangedCallBackCalled = true;
257 static void TestMaxLengthReachedCallback( TextField control )
259 tet_infoline(" TestMaxLengthReachedCallback");
261 gMaxCharactersCallBackCalled = true;
264 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
266 tet_infoline(" TestInputStyleChangedCallback");
268 gInputStyleChangedCallbackCalled = true;
269 gInputStyleMask = mask;
272 // Generate a TapGestureEvent to send to Core.
273 Integration::TapGestureEvent GenerateTap(
274 Gesture::State state,
275 unsigned int numberOfTaps,
276 unsigned int numberOfTouches,
279 Integration::TapGestureEvent tap( state );
281 tap.numberOfTaps = numberOfTaps;
282 tap.numberOfTouches = numberOfTouches;
288 Integration::LongPressGestureEvent GenerateLongPress(
289 Gesture::State state,
290 unsigned int numberOfTouches,
293 Integration::LongPressGestureEvent longPress( state );
295 longPress.numberOfTouches = numberOfTouches;
296 longPress.point = point;
300 // Generate a KeyEvent to send to Core.
301 Integration::KeyEvent GenerateKey( const std::string& keyName,
302 const std::string& keyString,
305 unsigned long timeStamp,
306 const Integration::KeyEvent::State& keyState,
307 const std::string& deviceName )
309 return Integration::KeyEvent( keyName,
318 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
320 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
322 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
324 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
326 if( valueGet.first.type == Property::Key::STRING )
328 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
329 if( NULL != valueSet )
331 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
333 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
339 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
345 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
346 if( NULL != valueSet )
348 if( valueGet.second.Get<int>() != valueSet->Get<int>() )
350 tet_printf( " Integer Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
356 tet_printf( " The Int key %d doesn't exist.", valueGet.first.indexKey );
368 int UtcDaliToolkitTextFieldConstructorP(void)
370 ToolkitTestApplication application;
371 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
373 DALI_TEST_CHECK( !textField );
377 int UtcDaliToolkitTextFieldNewP(void)
379 ToolkitTestApplication application;
380 tet_infoline(" UtcDaliToolkitTextFieldNewP");
381 TextField textField = TextField::New();
382 DALI_TEST_CHECK( textField );
386 int UtcDaliToolkitTextFieldDownCastP(void)
388 ToolkitTestApplication application;
389 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
390 TextField textField1 = TextField::New();
391 BaseHandle object( textField1 );
393 TextField textField2 = TextField::DownCast( object );
394 DALI_TEST_CHECK( textField2 );
396 TextField textField3 = DownCast< TextField >( object );
397 DALI_TEST_CHECK( textField3 );
401 int UtcDaliToolkitTextFieldDownCastN(void)
403 ToolkitTestApplication application;
404 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
405 BaseHandle uninitializedObject;
406 TextField textField1 = TextField::DownCast( uninitializedObject );
407 DALI_TEST_CHECK( !textField1 );
409 TextField textField2 = DownCast< TextField >( uninitializedObject );
410 DALI_TEST_CHECK( !textField2 );
414 int UtcDaliToolkitTextFieldCopyConstructorP(void)
416 ToolkitTestApplication application;
417 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
418 TextField textField = TextField::New();
419 textField.SetProperty( TextField::Property::TEXT, "Test" );
421 TextField copy( textField );
422 DALI_TEST_CHECK( copy );
423 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
427 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
429 ToolkitTestApplication application;
430 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
431 TextField textField = TextField::New();
432 textField.SetProperty( TextField::Property::TEXT, "Test" );
434 TextField copy = textField;
435 DALI_TEST_CHECK( copy );
436 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
440 int UtcDaliTextFieldNewP(void)
442 ToolkitTestApplication application;
443 tet_infoline(" UtcDaliToolkitTextFieldNewP");
444 TextField textField = TextField::New();
445 DALI_TEST_CHECK( textField );
449 // Positive test case for a method
450 int UtcDaliTextFieldGetPropertyP(void)
452 ToolkitTestApplication application;
453 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
454 TextField field = TextField::New();
455 DALI_TEST_CHECK( field );
457 // Check Property Indices are correct
458 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
459 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
460 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
461 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
462 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
463 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
464 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
465 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
466 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
467 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
468 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
469 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
470 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
471 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextField::Property::SHADOW_OFFSET );
472 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextField::Property::SHADOW_COLOR );
473 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
474 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
475 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
476 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
477 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
478 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
479 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
480 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
481 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
482 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
483 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
484 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
485 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
486 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
487 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
488 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
489 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
490 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
491 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
492 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
493 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
494 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
495 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
496 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
497 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
498 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
499 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
500 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
501 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
502 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
503 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
504 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
505 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
510 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
513 Property::Map imageMap;
514 imageMap[mapKey] =mapValue;
516 field.SetProperty( property , imageMap );
517 Property::Value propValue = field.GetProperty( property );
518 Property::Map* resultMap = propValue.GetMap();
520 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
528 // Positive test case for a method
529 int UtcDaliTextFieldSetPropertyP(void)
531 ToolkitTestApplication application;
532 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
533 TextField field = TextField::New();
534 DALI_TEST_CHECK( field );
535 Stage::GetCurrent().Add( field );
537 // Note - we can't check the defaults since the stylesheets are platform-specific
539 // Check the render backend property.
540 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
541 DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
543 // Check text property.
544 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
545 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
547 // Check placeholder text properties.
548 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
549 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
551 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
552 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
554 // Check font properties.
555 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
556 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
558 Property::Map fontStyleMapSet;
559 Property::Map fontStyleMapGet;
560 Property::Value* slantValue = NULL;
562 fontStyleMapSet.Insert( "weight", "bold" );
563 fontStyleMapSet.Insert( "width", "condensed" );
564 fontStyleMapSet.Insert( "slant", "italic" );
565 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
567 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
568 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
569 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
571 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
572 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
575 fontStyleMapSet.Clear();
576 fontStyleMapSet.Insert( "weight", "normal" );
577 fontStyleMapSet.Insert( "slant", "oblique" );
578 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
580 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
581 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
582 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
584 fontStyleMapSet.Clear();
585 fontStyleMapSet.Insert( "slant", "roman" );
586 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
587 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
589 // Replace 'roman' for 'normal'.
590 slantValue = fontStyleMapGet.Find( "slant" );
591 if( NULL != slantValue )
593 if( "normal" == slantValue->Get<std::string>() )
595 fontStyleMapGet["slant"] = "roman";
598 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
599 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
601 fontStyleMapSet.Clear();
603 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
604 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
605 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
606 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
608 // Check that the MAX_LENGTH property can be correctly set
609 const int maxNumberOfCharacters = 20;
610 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
611 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
613 // Check exceed policy
614 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
615 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
616 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
617 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
619 // Check that the Alignment properties can be correctly set
620 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
621 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
622 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
623 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
625 // Check text's color property
626 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
627 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
629 // Check placeholder text's color property.
630 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
631 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
633 // Check shadow properties.
634 field.SetProperty( TextField::Property::SHADOW_OFFSET, Vector2( 1.f, 1.f ) );
635 DALI_TEST_EQUALS( field.GetProperty<Vector2>( TextField::Property::SHADOW_OFFSET ), Vector2( 1.f, 1.f ), TEST_LOCATION );
636 field.SetProperty( TextField::Property::SHADOW_COLOR, Color::GREEN );
637 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SHADOW_COLOR ), Color::GREEN, TEST_LOCATION );
639 // Check cursor properties
640 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
641 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
642 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
643 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
645 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
646 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
647 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
648 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
649 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
650 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
651 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
652 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
654 // Check scroll properties.
655 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
656 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
657 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
658 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
660 // Check handle images
661 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
662 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
663 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
664 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
665 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
667 // Check handle images
668 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
669 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
670 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
671 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
672 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
673 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
675 // Check the highlight color
676 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
677 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
679 // Decoration bounding box
680 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
681 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
683 // Check the input method setting
684 Property::Map propertyMap;
685 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
686 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
687 InputMethod::ActionButtonTitle::Type actionButton = InputMethod::ActionButtonTitle::GO;
688 int inputVariation = 1;
689 propertyMap["PANEL_LAYOUT"] = panelLayout;
690 propertyMap["AUTO_CAPITALISE"] = autoCapital;
691 propertyMap["ACTION_BUTTON"] = actionButton;
692 propertyMap["VARIATION"] = inputVariation;
693 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
695 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
697 DALI_TEST_CHECK( value.Get( map ) );
700 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
701 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
704 DALI_TEST_CHECK( map[ "AUTO_CAPITALISE" ].Get( capital ) );
705 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
708 DALI_TEST_CHECK( map[ "ACTION_BUTTON" ].Get( action ) );
709 DALI_TEST_EQUALS( static_cast<int>(actionButton), action, TEST_LOCATION );
712 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
713 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
715 // Check input color property.
716 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
717 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
719 // Check the enable markup property.
720 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
721 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
722 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
724 // Check input font properties.
725 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
726 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
728 fontStyleMapSet.Clear();
729 fontStyleMapSet.Insert( "weight", "bold" );
730 fontStyleMapSet.Insert( "width", "condensed" );
731 fontStyleMapSet.Insert( "slant", "italic" );
733 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
734 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
735 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
736 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
738 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
739 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
741 // Reset input font style.
742 fontStyleMapSet.Clear();
743 fontStyleMapSet.Insert( "weight", "normal" );
744 fontStyleMapSet.Insert( "slant", "oblique" );
746 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
747 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
748 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
749 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
751 fontStyleMapSet.Clear();
752 fontStyleMapSet.Insert( "slant", "roman" );
754 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
755 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
757 // Replace 'roman' for 'normal'.
758 slantValue = fontStyleMapGet.Find( "slant" );
759 if( NULL != slantValue )
761 if( "normal" == slantValue->Get<std::string>() )
763 fontStyleMapGet["slant"] = "roman";
766 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
767 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
769 fontStyleMapSet.Clear();
771 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
772 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
773 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
774 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
776 Property::Map underlineMapSet;
777 Property::Map underlineMapGet;
779 underlineMapSet.Insert( "enable", "true" );
780 underlineMapSet.Insert( "color", "red" );
781 underlineMapSet.Insert( "height", "1" );
783 // Check the underline property
784 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
786 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
787 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
788 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
790 // Check the input underline property
791 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
792 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
794 // Check the shadow property
795 Property::Map shadowMapSet;
796 Property::Map shadowMapGet;
798 shadowMapSet.Insert( "color", "green" );
799 shadowMapSet.Insert( "offset", "2 2" );
801 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
803 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
804 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
805 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
807 // Check the input shadow property
808 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
809 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
811 // Check the emboss property
812 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
813 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
815 // Check the input emboss property
816 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
817 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
819 // Check the outline property
820 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
821 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
823 // Check the input outline property
824 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
825 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
827 // Check the hidden input settings property
828 Property::Map hiddenMapSet;
829 Property::Map hiddenMapGet;
830 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
831 hiddenMapSet[ HiddenInput::Property::SHOW_DURATION ] = 2;
832 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
833 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
834 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
836 hiddenMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
837 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
838 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
843 // Positive Atlas Text Renderer test
844 int utcDaliTextFieldAtlasRenderP(void)
846 ToolkitTestApplication application;
847 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
848 StyleManager styleManager = StyleManager::Get();
849 styleManager.ApplyDefaultTheme();
850 TextField field = TextField::New();
851 DALI_TEST_CHECK( field );
853 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
855 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
857 Stage::GetCurrent().Add( field );
861 // Render some text with the shared atlas backend
862 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
863 application.SendNotification();
864 application.Render();
868 tet_result(TET_FAIL);
873 // Positive test for the textChanged signal.
874 int utcDaliTextFieldTextChangedP(void)
876 ToolkitTestApplication application;
877 tet_infoline(" utcDaliTextFieldTextChangedP");
878 TextField field = TextField::New();
879 DALI_TEST_CHECK( field );
881 Stage::GetCurrent().Add( field );
883 // connect to the text changed signal.
884 ConnectionTracker* testTracker = new ConnectionTracker();
885 field.TextChangedSignal().Connect(&TestTextChangedCallback);
886 bool textChangedSignal = false;
887 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
889 gTextChangedCallBackCalled = false;
890 field.SetProperty( TextField::Property::TEXT, "ABC" );
891 DALI_TEST_CHECK( gTextChangedCallBackCalled );
892 DALI_TEST_CHECK( textChangedSignal );
894 application.SendNotification();
896 field.SetKeyInputFocus();
898 gTextChangedCallBackCalled = false;
899 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
900 DALI_TEST_CHECK( gTextChangedCallBackCalled );
905 // Negative test for the textChanged signal.
906 int utcDaliTextFieldTextChangedN(void)
908 ToolkitTestApplication application;
909 tet_infoline(" utcDaliTextFieldTextChangedN");
910 TextField field = TextField::New();
911 DALI_TEST_CHECK( field );
913 Stage::GetCurrent().Add( field );
915 // connect to the text changed signal.
916 ConnectionTracker* testTracker = new ConnectionTracker();
917 field.TextChangedSignal().Connect(&TestTextChangedCallback);
918 bool textChangedSignal = false;
919 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
921 gTextChangedCallBackCalled = false;
922 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
923 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
924 DALI_TEST_CHECK( !textChangedSignal );
929 // Positive test for Max Characters reached signal.
930 int utcDaliTextFieldMaxCharactersReachedP(void)
932 ToolkitTestApplication application;
933 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
934 TextField field = TextField::New();
935 DALI_TEST_CHECK( field );
937 Stage::GetCurrent().Add( field );
939 const int maxNumberOfCharacters = 1;
940 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
942 field.SetKeyInputFocus();
944 // connect to the text changed signal.
945 ConnectionTracker* testTracker = new ConnectionTracker();
946 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
947 bool maxLengthReachedSignal = false;
948 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
950 gMaxCharactersCallBackCalled = false;
952 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
953 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
955 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
956 DALI_TEST_CHECK( maxLengthReachedSignal );
961 // Negative test for Max Characters reached signal.
962 int utcDaliTextFieldMaxCharactersReachedN(void)
964 ToolkitTestApplication application;
965 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
966 TextField field = TextField::New();
967 DALI_TEST_CHECK( field );
969 Stage::GetCurrent().Add( field );
971 const int maxNumberOfCharacters = 3;
972 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
974 field.SetKeyInputFocus();
976 // connect to the text changed signal.
977 ConnectionTracker* testTracker = new ConnectionTracker();
978 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
979 bool maxLengthReachedSignal = false;
980 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
982 gMaxCharactersCallBackCalled = false;
984 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
985 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
987 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
988 DALI_TEST_CHECK( !maxLengthReachedSignal );
993 int utcDaliTextFieldInputStyleChanged01(void)
995 ToolkitTestApplication application;
996 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
998 // The text-field emits signals when the input style changes. These changes of style are
999 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1000 // can't be emitted during the size negotiation as the callbacks may update the UI.
1001 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1002 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1003 application.CreateAdaptor();
1007 char* pathNamePtr = get_current_dir_name();
1008 const std::string pathName( pathNamePtr );
1009 free( pathNamePtr );
1011 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1012 fontClient.SetDpi( 93u, 93u );
1014 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1015 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1017 TextField field = TextField::New();
1018 DALI_TEST_CHECK( field );
1021 field.SetSize( 300.f, 50.f );
1022 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1023 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1025 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1026 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1028 // connect to the text changed signal.
1029 ConnectionTracker* testTracker = new ConnectionTracker();
1030 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1031 bool inputStyleChangedSignal = false;
1032 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1034 Stage::GetCurrent().Add( field );
1036 // Render and notify
1037 application.SendNotification();
1038 application.Render();
1040 // Executes the idle callbacks added by the text control on the change of input style.
1041 application.RunIdles();
1043 gInputStyleChangedCallbackCalled = false;
1044 gInputStyleMask = TextField::InputStyle::NONE;
1045 inputStyleChangedSignal = false;
1047 // Create a tap event to touch the text field.
1048 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1049 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1051 // Render and notify
1052 application.SendNotification();
1053 application.Render();
1055 // Executes the idle callbacks added by the text control on the change of input style.
1056 application.RunIdles();
1058 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1059 if( gInputStyleChangedCallbackCalled )
1061 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1063 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1064 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1066 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1067 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1069 DALI_TEST_CHECK( inputStyleChangedSignal );
1071 gInputStyleChangedCallbackCalled = false;
1072 gInputStyleMask = TextField::InputStyle::NONE;
1073 inputStyleChangedSignal = false;
1075 // Create a tap event to touch the text field.
1076 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1077 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1079 // Render and notify
1080 application.SendNotification();
1081 application.Render();
1083 // Executes the idle callbacks added by the text control on the change of input style.
1084 application.RunIdles();
1086 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1087 DALI_TEST_CHECK( !inputStyleChangedSignal );
1089 gInputStyleChangedCallbackCalled = false;
1090 gInputStyleMask = TextField::InputStyle::NONE;
1091 inputStyleChangedSignal = false;
1093 // Create a tap event to touch the text field.
1094 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1095 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1097 // Render and notify
1098 application.SendNotification();
1099 application.Render();
1101 // Executes the idle callbacks added by the text control on the change of input style.
1102 application.RunIdles();
1104 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1105 if( gInputStyleChangedCallbackCalled )
1107 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1109 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1110 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1112 DALI_TEST_CHECK( inputStyleChangedSignal );
1114 gInputStyleChangedCallbackCalled = false;
1115 gInputStyleMask = TextField::InputStyle::NONE;
1116 inputStyleChangedSignal = false;
1118 // Create a tap event to touch the text field.
1119 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1120 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1122 // Render and notify
1123 application.SendNotification();
1124 application.Render();
1126 // Executes the idle callbacks added by the text control on the change of input style.
1127 application.RunIdles();
1129 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1130 if( gInputStyleChangedCallbackCalled )
1132 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1134 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1135 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1137 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1139 Property::Map fontStyleMapSet;
1140 fontStyleMapSet.Insert( "weight", "bold" );
1142 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1143 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1145 DALI_TEST_CHECK( inputStyleChangedSignal );
1147 gInputStyleChangedCallbackCalled = false;
1148 gInputStyleMask = TextField::InputStyle::NONE;
1149 inputStyleChangedSignal = false;
1151 // Create a tap event to touch the text field.
1152 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1153 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1155 // Render and notify
1156 application.SendNotification();
1157 application.Render();
1159 // Executes the idle callbacks added by the text control on the change of input style.
1160 application.RunIdles();
1162 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1163 DALI_TEST_CHECK( !inputStyleChangedSignal );
1165 gInputStyleChangedCallbackCalled = false;
1166 gInputStyleMask = TextField::InputStyle::NONE;
1167 inputStyleChangedSignal = false;
1169 // Create a tap event to touch the text field.
1170 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1171 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1173 // Render and notify
1174 application.SendNotification();
1175 application.Render();
1177 // Executes the idle callbacks added by the text control on the change of input style.
1178 application.RunIdles();
1180 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1181 if( gInputStyleChangedCallbackCalled )
1183 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1185 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1186 DALI_TEST_CHECK( style.empty() );
1188 DALI_TEST_CHECK( inputStyleChangedSignal );
1190 gInputStyleChangedCallbackCalled = false;
1191 gInputStyleMask = TextField::InputStyle::NONE;
1192 inputStyleChangedSignal = false;
1194 // Create a tap event to touch the text field.
1195 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1196 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1198 // Render and notify
1199 application.SendNotification();
1200 application.Render();
1202 // Executes the idle callbacks added by the text control on the change of input style.
1203 application.RunIdles();
1205 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1206 DALI_TEST_CHECK( !inputStyleChangedSignal );
1211 int utcDaliTextFieldInputStyleChanged02(void)
1213 ToolkitTestApplication application;
1214 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1216 // The text-field emits signals when the input style changes. These changes of style are
1217 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1218 // can't be emitted during the size negotiation as the callbacks may update the UI.
1219 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1220 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1221 application.CreateAdaptor();
1225 char* pathNamePtr = get_current_dir_name();
1226 const std::string pathName( pathNamePtr );
1227 free( pathNamePtr );
1229 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1230 fontClient.SetDpi( 93u, 93u );
1232 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1233 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1235 TextField field = TextField::New();
1236 DALI_TEST_CHECK( field );
1239 field.SetSize( 300.f, 50.f );
1240 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1241 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1243 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1244 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>" );
1246 // connect to the text changed signal.
1247 ConnectionTracker* testTracker = new ConnectionTracker();
1248 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1249 bool inputStyleChangedSignal = false;
1250 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1252 Stage::GetCurrent().Add( field );
1254 // Render and notify
1255 application.SendNotification();
1256 application.Render();
1258 // Executes the idle callbacks added by the text control on the change of input style.
1259 application.RunIdles();
1261 gInputStyleChangedCallbackCalled = false;
1262 gInputStyleMask = TextField::InputStyle::NONE;
1263 inputStyleChangedSignal = false;
1265 // Create a tap event to touch the text field.
1266 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1267 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1268 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1269 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1271 // Render and notify
1272 application.SendNotification();
1273 application.Render();
1275 // Executes the idle callbacks added by the text control on the change of input style.
1276 application.RunIdles();
1278 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1279 if( gInputStyleChangedCallbackCalled )
1281 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1282 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1283 TextField::InputStyle::POINT_SIZE |
1284 TextField::InputStyle::COLOR ),
1287 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1288 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1290 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1291 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1293 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1294 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1296 DALI_TEST_CHECK( inputStyleChangedSignal );
1298 gInputStyleChangedCallbackCalled = false;
1299 gInputStyleMask = TextField::InputStyle::NONE;
1300 inputStyleChangedSignal = false;
1302 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1304 // Render and notify
1305 application.SendNotification();
1306 application.Render();
1308 // Executes the idle callbacks added by the text control on the change of input style.
1309 application.RunIdles();
1311 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1312 if( gInputStyleChangedCallbackCalled )
1314 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1315 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1318 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1319 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1321 DALI_TEST_CHECK( inputStyleChangedSignal );
1323 gInputStyleChangedCallbackCalled = false;
1324 gInputStyleMask = TextField::InputStyle::NONE;
1325 inputStyleChangedSignal = false;
1327 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1329 // Render and notify
1330 application.SendNotification();
1331 application.Render();
1333 // Executes the idle callbacks added by the text control on the change of input style.
1334 application.RunIdles();
1336 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1337 DALI_TEST_CHECK( !inputStyleChangedSignal );
1339 gInputStyleChangedCallbackCalled = false;
1340 gInputStyleMask = TextField::InputStyle::NONE;
1341 inputStyleChangedSignal = false;
1343 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1345 // Render and notify
1346 application.SendNotification();
1347 application.Render();
1349 // Executes the idle callbacks added by the text control on the change of input style.
1350 application.RunIdles();
1352 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1353 if( gInputStyleChangedCallbackCalled )
1355 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1356 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1359 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1360 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1362 DALI_TEST_CHECK( inputStyleChangedSignal );
1364 gInputStyleChangedCallbackCalled = false;
1365 gInputStyleMask = TextField::InputStyle::NONE;
1366 inputStyleChangedSignal = false;
1368 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1370 Property::Map fontStyleMapSet;
1371 fontStyleMapSet.Insert( "weight", "thin" );
1372 fontStyleMapSet.Insert( "width", "condensed" );
1373 fontStyleMapSet.Insert( "slant", "italic" );
1375 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1376 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1378 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1379 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1380 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1381 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1383 // Render and notify
1384 application.SendNotification();
1385 application.Render();
1387 // Executes the idle callbacks added by the text control on the change of input style.
1388 application.RunIdles();
1390 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1391 DALI_TEST_CHECK( !inputStyleChangedSignal );
1393 // Create a tap event to touch the text field.
1394 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1395 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1397 // Render and notify
1398 application.SendNotification();
1399 application.Render();
1401 // Executes the idle callbacks added by the text control on the change of input style.
1402 application.RunIdles();
1404 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1405 if( gInputStyleChangedCallbackCalled )
1407 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1408 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1409 TextField::InputStyle::POINT_SIZE |
1410 TextField::InputStyle::FONT_STYLE |
1411 TextField::InputStyle::UNDERLINE |
1412 TextField::InputStyle::SHADOW |
1413 TextField::InputStyle::EMBOSS |
1414 TextField::InputStyle::OUTLINE ),
1417 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1418 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1420 DALI_TEST_CHECK( inputStyleChangedSignal );
1425 int utcDaliTextFieldEvent01(void)
1427 ToolkitTestApplication application;
1428 tet_infoline(" utcDaliTextFieldEvent01");
1430 // Creates a tap event. After creating a tap event the text field should
1431 // have the focus and add text with key events should be possible.
1433 TextField field = TextField::New();
1434 DALI_TEST_CHECK( field );
1436 Stage::GetCurrent().Add( field );
1438 field.SetSize( 300.f, 50.f );
1439 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1440 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1442 // Avoid a crash when core load gl resources.
1443 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1445 // Render and notify
1446 application.SendNotification();
1447 application.Render();
1449 // Add a key event but as the text field has not the focus it should do nothing.
1450 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1452 // Render and notify
1453 application.SendNotification();
1454 application.Render();
1456 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1458 // Create a tap event to touch the text field.
1459 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1460 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1462 // Render and notify
1463 application.SendNotification();
1464 application.Render();
1466 // Now the text field has the focus, so it can handle the key events.
1467 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1468 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1470 // Render and notify
1471 application.SendNotification();
1472 application.Render();
1474 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1476 // Create a second text field and send key events to it.
1477 TextField field2 = TextField::New();
1479 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1480 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1481 field2.SetSize( 100.f, 100.f );
1482 field2.SetPosition( 100.f, 100.f );
1484 Stage::GetCurrent().Add( field2 );
1486 // Render and notify
1487 application.SendNotification();
1488 application.Render();
1490 // Create a tap event on the second text field.
1491 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1492 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1494 // Render and notify
1495 application.SendNotification();
1496 application.Render();
1498 // The second text field has the focus. It should handle the key events.
1499 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1500 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1502 // Render and notify
1503 application.SendNotification();
1504 application.Render();
1506 // Check the text has been added to the second text field.
1507 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1512 int utcDaliTextFieldEvent02(void)
1514 ToolkitTestApplication application;
1515 tet_infoline(" utcDaliTextFieldEvent02");
1517 // Checks if the right number of actors are created.
1519 TextField field = TextField::New();
1520 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1521 DALI_TEST_CHECK( field );
1522 LoadMarkerImages(application, field);
1524 Stage::GetCurrent().Add( field );
1526 field.SetSize( 300.f, 50.f );
1527 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1528 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1530 // Avoid a crash when core load gl resources.
1531 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1533 // Render and notify
1534 application.SendNotification();
1535 application.Render();
1537 // Check there are the expected number of children ( stencil ).
1538 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1540 Actor stencil = field.GetChildAt( 0u );
1541 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1543 // Create a tap event to touch the text field.
1544 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1545 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1547 // Render and notify
1548 application.SendNotification();
1549 application.Render();
1551 Actor layer = field.GetChildAt( 1u );
1552 DALI_TEST_CHECK( layer.IsLayer() );
1554 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1555 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1557 // Now the text field has the focus, so it can handle the key events.
1558 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1559 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1561 // Render and notify
1562 application.SendNotification();
1563 application.Render();
1565 // Checks the cursor and the renderer have been created.
1566 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1567 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1569 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1570 DALI_TEST_CHECK( cursor );
1572 // The offscreen root actor has a container with all the actors which contain the text renderers.
1573 Actor container = stencil.GetChildAt( 0u );
1574 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1576 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1577 DALI_TEST_CHECK( renderer );
1580 // Move the cursor and check the position changes.
1581 Vector3 position1 = cursor.GetCurrentPosition();
1583 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1584 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1586 // Render and notify
1587 application.SendNotification();
1588 application.Render();
1590 Vector3 position2 = cursor.GetCurrentPosition();
1592 DALI_TEST_CHECK( position2.x < position1.x );
1594 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1595 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1597 // Render and notify
1598 application.SendNotification();
1599 application.Render();
1601 Vector3 position3 = cursor.GetCurrentPosition();
1603 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1605 // Send some taps and check the cursor positions.
1607 // Try to tap at the beginning.
1608 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1609 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1611 // Render and notify
1612 application.SendNotification();
1613 application.Render();
1615 // Cursor position should be the same than position1.
1616 Vector3 position4 = cursor.GetCurrentPosition();
1618 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1620 // Tap away from the start position.
1621 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1622 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1624 // Render and notify
1625 application.SendNotification();
1626 application.Render();
1628 Vector3 position5 = cursor.GetCurrentPosition();
1630 DALI_TEST_CHECK( position5.x > position4.x );
1632 // Remove all the text.
1633 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1634 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
1635 field.SetProperty( TextField::Property::TEXT, "" );
1637 // Render and notify
1638 application.SendNotification();
1639 application.Render();
1641 // Cursor position should be the same than position2.
1642 Vector3 position6 = cursor.GetCurrentPosition();
1644 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1646 // Should not be a renderer.
1647 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1652 int utcDaliTextFieldEvent03(void)
1654 ToolkitTestApplication application;
1655 tet_infoline(" utcDaliTextFieldEvent03");
1657 // Checks if the highlight actor is created.
1659 TextField field = TextField::New();
1660 DALI_TEST_CHECK( field );
1662 Stage::GetCurrent().Add( field );
1664 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1665 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1666 field.SetSize( 30.f, 50.f );
1667 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1668 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1670 // Avoid a crash when core load gl resources.
1671 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1672 LoadMarkerImages(application, field);
1674 // Render and notify
1675 application.SendNotification();
1676 application.Render();
1678 // Tap first to get the focus.
1679 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1680 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1682 // Render and notify
1683 application.SendNotification();
1684 application.Render();
1686 // Double tap to select a word.
1687 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1688 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1690 // Render and notify
1691 application.SendNotification();
1692 application.Render();
1694 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1695 Actor stencil = field.GetChildAt( 0u );
1697 // The offscreen root actor has a container with all the actors which contain the text renderers.
1698 Actor container = stencil.GetChildAt( 0u );
1699 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1701 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1702 DALI_TEST_CHECK( renderer );
1705 Renderer highlight = stencil.GetChildAt( 1u ).GetRendererAt( 0u );
1706 DALI_TEST_CHECK( highlight );
1711 int utcDaliTextFieldEvent04(void)
1713 ToolkitTestApplication application;
1714 tet_infoline(" utcDaliTextFieldEvent04");
1716 // Checks if the highlight actor is created.
1718 TextField field = TextField::New();
1719 DALI_TEST_CHECK( field );
1720 Stage::GetCurrent().Add( field );
1721 LoadMarkerImages(application, field);
1722 // Render and notify
1723 application.SendNotification();
1724 application.Render();
1726 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1727 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1728 field.SetSize( 300.f, 50.f );
1729 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1730 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1732 // Avoid a crash when core load gl resources.
1733 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1734 // Render and notify
1735 application.SendNotification();
1736 application.Render();
1738 // Create a tap event to touch the text field.
1739 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1740 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1741 // Render and notify
1742 application.SendNotification();
1743 application.Render();
1746 // Tap first to get the focus.
1747 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1748 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1750 // Render and notify
1751 application.SendNotification();
1752 application.Render();
1754 // Double tap to select a word.
1755 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1756 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1758 // Render and notify
1759 application.SendNotification();
1760 application.Render();
1763 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1764 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1768 int utcDaliTextFieldEvent05(void)
1770 ToolkitTestApplication application;
1771 tet_infoline(" utcDaliTextFieldEvent05");
1773 // Checks dragging of cursor/grab handle
1775 TextField field = TextField::New();
1776 DALI_TEST_CHECK( field );
1777 Stage::GetCurrent().Add( field );
1778 LoadMarkerImages(application, field);
1779 // Render and notify
1780 application.SendNotification();
1781 application.Render();
1783 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1784 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1785 field.SetSize( 300.f, 50.f );
1786 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1787 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1789 // Avoid a crash when core load gl resources.
1790 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1791 // Render and notify
1792 application.SendNotification();
1793 application.Render();
1795 // Create a tap event to touch the text field.
1796 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1797 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1798 // Render and notify
1799 application.SendNotification();
1800 application.Render();
1803 // Tap first to get the focus.
1804 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1805 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1807 // Render and notify
1808 application.SendNotification();
1809 application.Render();
1811 // Double tap to select a word.
1812 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1813 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1815 // Render and notify
1816 application.SendNotification();
1817 application.Render();
1819 // drag grab handle right
1820 Vector2 pos(0.0f, 40.0f);
1821 SendPan(application, Gesture::Possible, pos);
1822 SendPan(application, Gesture::Started, pos);
1824 Wait(application, 100);
1826 for(int i = 0;i<20;i++)
1828 SendPan(application, Gesture::Continuing, pos);
1833 SendPan(application, Gesture::Finished, pos);
1834 Wait(application, RENDER_FRAME_INTERVAL);
1836 Actor stencil = field.GetChildAt( 1u );
1840 int utcDaliTextFieldEvent06(void)
1842 ToolkitTestApplication application;
1843 tet_infoline(" utcDaliTextFieldEvent06");
1845 // Checks Longpress when in edit mode
1847 TextField field = TextField::New();
1848 DALI_TEST_CHECK( field );
1849 Stage::GetCurrent().Add( field );
1850 LoadMarkerImages(application, field);
1851 // Render and notify
1852 application.SendNotification();
1853 application.Render();
1855 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1856 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1857 field.SetSize( 300.f, 50.f );
1858 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1859 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1861 // Avoid a crash when core load gl resources.
1862 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1863 // Render and notify
1864 application.SendNotification();
1865 application.Render();
1867 // Create a tap event to touch the text field.
1868 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1869 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1870 // Render and notify
1871 application.SendNotification();
1872 application.Render();
1875 // Tap first to get the focus.
1876 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1877 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1879 // Render and notify
1880 application.SendNotification();
1881 application.Render();
1884 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1885 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1887 // Render and notify
1888 application.SendNotification();
1889 application.Render();
1894 int utcDaliTextFieldEvent07(void)
1896 ToolkitTestApplication application;
1897 tet_infoline(" utcDaliTextFieldEvent07");
1899 // Checks Longpress to start edit mode
1901 TextField field = TextField::New();
1902 DALI_TEST_CHECK( field );
1903 Stage::GetCurrent().Add( field );
1904 LoadMarkerImages(application, field);
1905 // Render and notify
1906 application.SendNotification();
1907 application.Render();
1909 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1910 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1911 field.SetSize( 300.f, 50.f );
1912 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1913 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1914 Property::Map propertyMap;
1915 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
1916 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
1918 // Avoid a crash when core load gl resources.
1919 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1920 // Render and notify
1921 application.SendNotification();
1922 application.Render();
1925 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1926 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1928 // Render and notify
1929 application.SendNotification();
1930 application.Render();
1935 int utcDaliTextFieldEvent08(void)
1937 ToolkitTestApplication application;
1938 tet_infoline(" utcDaliTextFieldEvent08");
1940 Dali::Clipboard clipboard = Clipboard::Get();
1941 clipboard.SetItem("testTextFieldEvent");
1943 // Checks Longpress when only place holder text
1945 TextField field = TextField::New();
1946 DALI_TEST_CHECK( field );
1947 Stage::GetCurrent().Add( field );
1948 LoadMarkerImages(application, field);
1949 // Render and notify
1950 application.SendNotification();
1951 application.Render();
1953 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
1954 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1955 field.SetSize( 300.f, 50.f );
1956 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1957 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1959 // Avoid a crash when core load gl resources.
1960 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1961 // Render and notify
1962 application.SendNotification();
1963 application.Render();
1966 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1967 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1969 // Render and notify
1970 application.SendNotification();
1971 application.Render();
1973 Wait(application, 500);
1976 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1977 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1979 // Render and notify
1980 application.SendNotification();
1981 application.Render();
1983 Wait(application, 500);
1985 Stage stage = Stage::GetCurrent();
1986 Layer layer = stage.GetRootLayer();
1987 Actor actor = layer.FindChildByName("optionPaste");
1991 Vector3 worldPosition = actor.GetCurrentWorldPosition();
1992 Vector2 halfStageSize = stage.GetSize() / 2.0f;
1993 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
1995 Dali::Integration::TouchEvent event;
1996 event = Dali::Integration::TouchEvent();
1997 event.AddPoint( GetPointDownInside( position ) );
1998 application.ProcessEvent( event );
2000 event = Dali::Integration::TouchEvent();
2001 event.AddPoint( GetPointUpInside( position ) );
2002 application.ProcessEvent( event );
2004 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2009 int utcDaliTextFieldEvent09(void)
2011 ToolkitTestApplication application;
2012 tet_infoline(" utcDaliTextFieldEvent09");
2014 TextField field = TextField::New();
2015 DALI_TEST_CHECK( field );
2016 Stage::GetCurrent().Add( field );
2017 LoadMarkerImages(application, field);
2018 // Render and notify
2019 application.SendNotification();
2020 application.Render();
2022 field.SetProperty( TextField::Property::TEXT, "Hello" );
2023 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2024 field.SetSize( 300.f, 50.f );
2025 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2026 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2028 // Avoid a crash when core load gl resources.
2029 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2031 // Create a tap event to touch the text field.
2032 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2033 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2034 application.SendNotification();
2035 application.Render();
2038 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2039 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2040 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2041 application.SendNotification();
2042 application.Render();
2044 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2045 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2046 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2047 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2048 application.SendNotification();
2049 application.Render();
2051 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2052 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2053 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2054 for( unsigned int index = 0u; index < 5u; ++index )
2056 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2057 application.SendNotification();
2058 application.Render();
2061 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2062 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2063 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2064 for( unsigned int index = 0u; index < 5u; ++index )
2066 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2067 application.SendNotification();
2068 application.Render();
2071 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2072 map[ HiddenInput::Property::SHOW_DURATION ] = 0;
2073 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2074 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2075 application.SendNotification();
2076 application.Render();
2077 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2078 application.SendNotification();
2079 application.Render();
2081 map[ HiddenInput::Property::SHOW_DURATION ] = 100;
2082 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2083 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2084 application.SendNotification();
2085 application.Render();
2087 Property::Map mapGet;
2088 mapGet = field.GetProperty<Property::Map>( DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
2089 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2090 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2095 int utcDaliTextFieldStyleWhilstSelected(void)
2097 ToolkitTestApplication application;
2098 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2100 // Change font and styles whilst text is selected whilst word selected
2102 TextField field = TextField::New();
2103 DALI_TEST_CHECK( field );
2104 Stage::GetCurrent().Add( field );
2105 LoadMarkerImages(application, field);
2106 // Render and notify
2107 application.SendNotification();
2108 application.Render();
2110 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2111 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2112 field.SetSize( 300.f, 50.f );
2113 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2114 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2116 // Avoid a crash when core load gl resources.
2117 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2118 // Render and notify
2119 application.SendNotification();
2120 application.Render();
2122 // Create a tap event to touch the text field.
2123 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2124 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2125 // Render and notify
2126 application.SendNotification();
2127 application.Render();
2130 // Tap first to get the focus.
2131 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2132 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2134 // Render and notify
2135 application.SendNotification();
2136 application.Render();
2138 // Double tap to select a word.
2139 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2140 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2142 // Render and notify
2143 application.SendNotification();
2144 application.Render();
2146 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2147 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2149 Property::Map fontStyleMapSet;
2150 Property::Map fontStyleMapGet;
2152 fontStyleMapSet.Insert( "weight", "bold" );
2153 fontStyleMapSet.Insert( "slant", "italic" );
2154 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2156 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2157 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2158 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2160 fontStyleMapSet.Clear();
2161 fontStyleMapSet.Insert( "width", "expanded" );
2162 fontStyleMapSet.Insert( "slant", "italic" );
2163 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2165 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2166 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2167 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2169 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2170 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2172 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2173 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2175 fontStyleMapSet.Clear();
2176 fontStyleMapSet.Insert( "weight", "bold" );
2177 fontStyleMapSet.Insert( "slant", "italic" );
2179 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2181 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2182 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2183 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2185 fontStyleMapSet.Clear();
2186 fontStyleMapSet.Insert( "width", "expanded" );
2188 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2190 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2191 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2192 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2194 // Press Escape to increase coverage
2195 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME ) );
2196 application.SendNotification();
2197 application.Render();
2199 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2204 int utcDaliTextFieldEscKeyLoseFocus(void)
2206 ToolkitTestApplication application;
2207 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2209 // Creates a tap event. After creating a tap event the text field should
2210 // have the focus and add text with key events should be possible.
2212 TextField field = TextField::New();
2213 DALI_TEST_CHECK( field );
2215 Stage::GetCurrent().Add( field );
2217 field.SetSize( 300.f, 50.f );
2218 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2219 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2221 // Avoid a crash when core load gl resources.
2222 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2224 // Render and notify
2225 application.SendNotification();
2226 application.Render();
2228 // Add a key event but as the text field has not the focus it should do nothing.
2229 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2230 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME ) );
2232 // Render and notify
2233 application.SendNotification();
2234 application.Render();
2236 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2238 // Create a tap event to touch the text field.
2239 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2240 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2242 // Render and notify
2243 application.SendNotification();
2244 application.Render();
2246 // Now the text field has the focus, so it can handle the key events.
2247 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2248 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME ) );
2249 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2250 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME ) );
2252 // Render and notify
2253 application.SendNotification();
2254 application.Render();
2256 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2258 // Generate a Esc key event. The text field should lose the focus.
2259 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2260 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME ) );
2262 // Render and notify
2263 application.SendNotification();
2264 application.Render();
2266 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2268 // No more text should be introduced
2269 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2270 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME ) );
2272 // Render and notify
2273 application.SendNotification();
2274 application.Render();
2276 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2281 int utcDaliTextFieldSomeSpecialKeys(void)
2283 ToolkitTestApplication application;
2284 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2286 // Checks some special keys when the text is selected.
2288 TextField field = TextField::New();
2289 DALI_TEST_CHECK( field );
2290 Stage::GetCurrent().Add( field );
2291 LoadMarkerImages(application, field);
2292 // Render and notify
2293 application.SendNotification();
2294 application.Render();
2296 const std::string longText( "This is a long text for the size of the text-field." );
2298 field.SetProperty( TextField::Property::TEXT, longText );
2299 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2300 field.SetSize( 300.f, 50.f );
2301 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2302 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2304 // Avoid a crash when core load gl resources.
2305 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2306 // Render and notify
2307 application.SendNotification();
2308 application.Render();
2310 // Create a tap event to touch the text field.
2311 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2312 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2314 // Render and notify
2315 application.SendNotification();
2316 application.Render();
2318 // Tap first to get the focus.
2319 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2320 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2322 // Render and notify
2323 application.SendNotification();
2324 application.Render();
2326 // Double tap to select a word.
2327 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2328 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2330 // Render and notify
2331 application.SendNotification();
2332 application.Render();
2334 // Generate a Esc key event. The text field should lose the focus.
2335 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2336 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME ) );
2338 // Render and notify
2339 application.SendNotification();
2340 application.Render();
2342 // Generate a Esc key event. The text field should lose the focus.
2343 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2344 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME ) );
2346 // Render and notify
2347 application.SendNotification();
2348 application.Render();
2350 // Generate a Esc key event. The text field should lose the focus.
2351 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME ) );
2352 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME ) );
2354 // Render and notify
2355 application.SendNotification();
2356 application.Render();
2358 // The text shouldn't be deleted.
2359 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );