2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali/public-api/rendering/renderer.h>
23 #include <dali/integration-api/events/key-event-integ.h>
24 #include <dali/integration-api/events/tap-gesture-event.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/integration-api/events/pan-gesture-event.h>
27 #include <dali/integration-api/events/long-press-gesture-event.h>
28 #include <dali-toolkit-test-suite-utils.h>
29 #include <dali-toolkit/dali-toolkit.h>
30 #include <dali-toolkit/devel-api/controls/text-controls/hidden-input-properties.h>
31 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
32 #include "toolkit-clipboard.h"
35 using namespace Toolkit;
37 void dali_textfield_startup(void)
39 test_return_value = TET_UNDEF;
42 void dali_textfield_cleanup(void)
44 test_return_value = TET_PASS;
50 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
51 const char* const PROPERTY_NAME_TEXT = "text";
52 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
53 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
54 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
55 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
56 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
57 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
58 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
59 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
60 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
61 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
62 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
63 const char* const PROPERTY_NAME_SHADOW_OFFSET = "shadowOffset";
64 const char* const PROPERTY_NAME_SHADOW_COLOR = "shadowColor";
65 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
66 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
67 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
68 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
69 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
70 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
71 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
72 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
73 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
74 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
80 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
81 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
82 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
83 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
84 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
85 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
86 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
87 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
88 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
90 const char* const PROPERTY_NAME_UNDERLINE = "underline";
91 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
92 const char* const PROPERTY_NAME_SHADOW = "shadow";
93 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
94 const char* const PROPERTY_NAME_EMBOSS = "emboss";
95 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
96 const char* const PROPERTY_NAME_OUTLINE = "outline";
97 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
99 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
100 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
101 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
102 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
103 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
105 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
107 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
108 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
110 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
111 const float RENDER_FRAME_INTERVAL = 16.66f;
113 const float TO_MILLISECONDS = 1000.f;
114 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
116 const float SCROLL_THRESHOLD = 10.f;
117 const float SCROLL_SPEED = 300.f;
119 const unsigned int DEFAULT_FONT_SIZE = 1152u;
120 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
122 const int KEY_A_CODE = 38;
123 const int KEY_D_CODE = 40;
125 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
127 static bool gTextChangedCallBackCalled;
128 static bool gMaxCharactersCallBackCalled;
129 static bool gInputStyleChangedCallbackCalled;
130 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
132 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
134 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
135 Integration::ResourcePointer resource(bitmap);
136 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
139 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
143 LoadBitmapResource( app.GetPlatform(), width, height );
145 Property::Map propertyMap;
146 propertyMap["filename"] = "image.png";
147 propertyMap["width"] = width;
148 propertyMap["height"] = height;
149 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
150 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
151 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
152 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
153 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
154 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
155 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
156 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
159 // Generate a PanGestureEvent to send to Core
160 static Integration::PanGestureEvent GeneratePan(
161 Gesture::State state,
162 const Vector2& previousPosition,
163 const Vector2& currentPosition,
164 unsigned long timeDelta,
165 unsigned int numberOfTouches = 1)
167 Integration::PanGestureEvent pan(state);
169 pan.previousPosition = previousPosition;
170 pan.currentPosition = currentPosition;
171 pan.timeDelta = timeDelta;
172 pan.numberOfTouches = numberOfTouches;
178 * Helper to generate PanGestureEvent
180 * @param[in] application Application instance
181 * @param[in] state The Gesture State
182 * @param[in] pos The current position of touch.
184 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
188 if( (state == Gesture::Started) ||
189 (state == Gesture::Possible) )
195 application.ProcessEvent(GeneratePan(state, last, pos, 16));
202 * Simulate time passed by.
204 * @note this will always process at least 1 frame (1/60 sec)
206 * @param application Test application instance
207 * @param duration Time to pass in milliseconds.
208 * @return The actual time passed in milliseconds
210 static int Wait(ToolkitTestApplication& application, int duration = 0)
214 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
216 application.SendNotification();
217 application.Render(RENDER_FRAME_INTERVAL);
218 time += RENDER_FRAME_INTERVAL;
224 Dali::Integration::Point GetPointDownInside( Vector2& pos )
226 Dali::Integration::Point point;
227 point.SetState( PointState::DOWN );
228 point.SetScreenPosition( pos );
232 Dali::Integration::Point GetPointUpInside( Vector2& pos )
234 Dali::Integration::Point point;
235 point.SetState( PointState::UP );
236 point.SetScreenPosition( pos );
240 struct CallbackFunctor
242 CallbackFunctor(bool* callbackFlag)
243 : mCallbackFlag( callbackFlag )
249 *mCallbackFlag = true;
254 static void TestTextChangedCallback( TextField control )
256 tet_infoline(" TestTextChangedCallback");
258 gTextChangedCallBackCalled = true;
261 static void TestMaxLengthReachedCallback( TextField control )
263 tet_infoline(" TestMaxLengthReachedCallback");
265 gMaxCharactersCallBackCalled = true;
268 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
270 tet_infoline(" TestInputStyleChangedCallback");
272 gInputStyleChangedCallbackCalled = true;
273 gInputStyleMask = mask;
276 // Generate a TapGestureEvent to send to Core.
277 Integration::TapGestureEvent GenerateTap(
278 Gesture::State state,
279 unsigned int numberOfTaps,
280 unsigned int numberOfTouches,
283 Integration::TapGestureEvent tap( state );
285 tap.numberOfTaps = numberOfTaps;
286 tap.numberOfTouches = numberOfTouches;
292 Integration::LongPressGestureEvent GenerateLongPress(
293 Gesture::State state,
294 unsigned int numberOfTouches,
297 Integration::LongPressGestureEvent longPress( state );
299 longPress.numberOfTouches = numberOfTouches;
300 longPress.point = point;
304 // Generate a KeyEvent to send to Core.
305 Integration::KeyEvent GenerateKey( const std::string& keyName,
306 const std::string& keyString,
309 unsigned long timeStamp,
310 const Integration::KeyEvent::State& keyState,
311 const std::string& deviceName = DEFAULT_DEVICE_NAME,
312 const DevelDevice::Class::Type& deviceClass = DevelDevice::Class::NONE,
313 const DevelDevice::Subclass::Type& deviceSubclass = DevelDevice::Subclass::NONE )
315 return Integration::KeyEvent( keyName,
326 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
328 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
330 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
332 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
334 if( valueGet.first.type == Property::Key::STRING )
336 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
337 if( NULL != valueSet )
339 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
341 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
347 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
353 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
354 if( NULL != valueSet )
356 if( valueGet.second.Get<int>() != valueSet->Get<int>() )
358 tet_printf( " Integer Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
364 tet_printf( " The Int key %d doesn't exist.", valueGet.first.indexKey );
376 int UtcDaliToolkitTextFieldConstructorP(void)
378 ToolkitTestApplication application;
379 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
381 DALI_TEST_CHECK( !textField );
385 int UtcDaliToolkitTextFieldNewP(void)
387 ToolkitTestApplication application;
388 tet_infoline(" UtcDaliToolkitTextFieldNewP");
389 TextField textField = TextField::New();
390 DALI_TEST_CHECK( textField );
394 int UtcDaliToolkitTextFieldDownCastP(void)
396 ToolkitTestApplication application;
397 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
398 TextField textField1 = TextField::New();
399 BaseHandle object( textField1 );
401 TextField textField2 = TextField::DownCast( object );
402 DALI_TEST_CHECK( textField2 );
404 TextField textField3 = DownCast< TextField >( object );
405 DALI_TEST_CHECK( textField3 );
409 int UtcDaliToolkitTextFieldDownCastN(void)
411 ToolkitTestApplication application;
412 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
413 BaseHandle uninitializedObject;
414 TextField textField1 = TextField::DownCast( uninitializedObject );
415 DALI_TEST_CHECK( !textField1 );
417 TextField textField2 = DownCast< TextField >( uninitializedObject );
418 DALI_TEST_CHECK( !textField2 );
422 int UtcDaliToolkitTextFieldCopyConstructorP(void)
424 ToolkitTestApplication application;
425 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
426 TextField textField = TextField::New();
427 textField.SetProperty( TextField::Property::TEXT, "Test" );
429 TextField copy( textField );
430 DALI_TEST_CHECK( copy );
431 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
435 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
437 ToolkitTestApplication application;
438 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
439 TextField textField = TextField::New();
440 textField.SetProperty( TextField::Property::TEXT, "Test" );
442 TextField copy = textField;
443 DALI_TEST_CHECK( copy );
444 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
448 int UtcDaliTextFieldNewP(void)
450 ToolkitTestApplication application;
451 tet_infoline(" UtcDaliToolkitTextFieldNewP");
452 TextField textField = TextField::New();
453 DALI_TEST_CHECK( textField );
457 // Positive test case for a method
458 int UtcDaliTextFieldGetPropertyP(void)
460 ToolkitTestApplication application;
461 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
462 TextField field = TextField::New();
463 DALI_TEST_CHECK( field );
465 // Check Property Indices are correct
466 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
467 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
468 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
469 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
470 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
471 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
472 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
473 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
474 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
475 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
476 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
477 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
478 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
479 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextField::Property::SHADOW_OFFSET );
480 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextField::Property::SHADOW_COLOR );
481 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
482 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
483 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
484 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
485 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
486 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
487 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
488 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
489 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
490 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
491 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
492 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
493 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
494 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
495 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
496 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
497 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
498 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
499 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
500 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
501 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
502 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
503 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
504 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
505 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
506 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
507 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
508 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
509 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
510 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
511 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
512 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
513 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
514 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == DevelTextField::Property::PIXEL_SIZE );
515 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == DevelTextField::Property::ENABLE_SELECTION );
516 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == DevelTextField::Property::PLACEHOLDER );
517 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == DevelTextField::Property::ELLIPSIS );
522 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
525 Property::Map imageMap;
526 imageMap[mapKey] =mapValue;
528 field.SetProperty( property , imageMap );
529 Property::Value propValue = field.GetProperty( property );
530 Property::Map* resultMap = propValue.GetMap();
532 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
540 // Positive test case for a method
541 int UtcDaliTextFieldSetPropertyP(void)
543 ToolkitTestApplication application;
544 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
545 TextField field = TextField::New();
546 DALI_TEST_CHECK( field );
547 Stage::GetCurrent().Add( field );
549 // Note - we can't check the defaults since the stylesheets are platform-specific
551 // Check the render backend property.
552 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
553 DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
555 // Check text property.
556 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
557 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
559 // Check placeholder text properties.
560 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
561 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
563 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
564 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
566 // Check font properties.
567 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
568 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
570 Property::Map fontStyleMapSet;
571 Property::Map fontStyleMapGet;
572 Property::Value* slantValue = NULL;
574 fontStyleMapSet.Insert( "weight", "bold" );
575 fontStyleMapSet.Insert( "width", "condensed" );
576 fontStyleMapSet.Insert( "slant", "italic" );
577 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
579 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
580 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
581 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
583 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
584 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
587 fontStyleMapSet.Clear();
588 fontStyleMapSet.Insert( "weight", "normal" );
589 fontStyleMapSet.Insert( "slant", "oblique" );
590 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
592 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
593 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
594 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
596 fontStyleMapSet.Clear();
597 fontStyleMapSet.Insert( "slant", "roman" );
598 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
599 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
601 // Replace 'roman' for 'normal'.
602 slantValue = fontStyleMapGet.Find( "slant" );
603 if( NULL != slantValue )
605 if( "normal" == slantValue->Get<std::string>() )
607 fontStyleMapGet["slant"] = "roman";
610 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
611 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
613 fontStyleMapSet.Clear();
615 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
616 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
617 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
618 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
620 // Check that the MAX_LENGTH property can be correctly set
621 const int maxNumberOfCharacters = 20;
622 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
623 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
625 // Check exceed policy
626 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
627 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
628 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
629 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
631 // Check that the Alignment properties can be correctly set
632 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
633 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
634 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
635 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
637 // Check text's color property
638 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
639 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
641 // Check placeholder text's color property.
642 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
643 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
645 // Check shadow properties.
646 field.SetProperty( TextField::Property::SHADOW_OFFSET, Vector2( 1.f, 1.f ) );
647 DALI_TEST_EQUALS( field.GetProperty<Vector2>( TextField::Property::SHADOW_OFFSET ), Vector2( 1.f, 1.f ), TEST_LOCATION );
648 field.SetProperty( TextField::Property::SHADOW_COLOR, Color::GREEN );
649 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SHADOW_COLOR ), Color::GREEN, TEST_LOCATION );
651 // Check cursor properties
652 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
653 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
654 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
655 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
657 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
658 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
659 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
660 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
661 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
662 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
663 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
664 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
666 // Check scroll properties.
667 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
668 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
669 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
670 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
672 // Check handle images
673 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
674 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
675 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
676 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
677 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
679 // Check handle images
680 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
681 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
682 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
683 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
684 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
685 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
687 // Check the highlight color
688 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
689 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
691 // Decoration bounding box
692 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
693 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
695 // Check the input method setting
696 Property::Map propertyMap;
697 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
698 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
699 InputMethod::ActionButtonTitle::Type actionButton = InputMethod::ActionButtonTitle::GO;
700 int inputVariation = 1;
701 propertyMap["PANEL_LAYOUT"] = panelLayout;
702 propertyMap["AUTO_CAPITALISE"] = autoCapital;
703 propertyMap["ACTION_BUTTON"] = actionButton;
704 propertyMap["VARIATION"] = inputVariation;
705 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
707 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
709 DALI_TEST_CHECK( value.Get( map ) );
712 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
713 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
716 DALI_TEST_CHECK( map[ "AUTO_CAPITALISE" ].Get( capital ) );
717 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
720 DALI_TEST_CHECK( map[ "ACTION_BUTTON" ].Get( action ) );
721 DALI_TEST_EQUALS( static_cast<int>(actionButton), action, TEST_LOCATION );
724 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
725 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
727 // Check input color property.
728 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
729 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
731 // Check the enable markup property.
732 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
733 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
734 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
736 // Check input font properties.
737 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
738 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
740 fontStyleMapSet.Clear();
741 fontStyleMapSet.Insert( "weight", "bold" );
742 fontStyleMapSet.Insert( "width", "condensed" );
743 fontStyleMapSet.Insert( "slant", "italic" );
745 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
746 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
747 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
748 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
750 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
751 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
753 // Reset input font style.
754 fontStyleMapSet.Clear();
755 fontStyleMapSet.Insert( "weight", "normal" );
756 fontStyleMapSet.Insert( "slant", "oblique" );
758 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
759 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
760 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
761 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
763 fontStyleMapSet.Clear();
764 fontStyleMapSet.Insert( "slant", "roman" );
766 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
767 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
769 // Replace 'roman' for 'normal'.
770 slantValue = fontStyleMapGet.Find( "slant" );
771 if( NULL != slantValue )
773 if( "normal" == slantValue->Get<std::string>() )
775 fontStyleMapGet["slant"] = "roman";
778 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
779 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
781 fontStyleMapSet.Clear();
783 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
784 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
785 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
786 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
788 Property::Map underlineMapSet;
789 Property::Map underlineMapGet;
791 underlineMapSet.Insert( "enable", "true" );
792 underlineMapSet.Insert( "color", "red" );
793 underlineMapSet.Insert( "height", "1" );
795 // Check the underline property
796 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
798 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
799 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
800 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
802 // Check the input underline property
803 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
804 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
806 // Check the shadow property
807 Property::Map shadowMapSet;
808 Property::Map shadowMapGet;
810 shadowMapSet.Insert( "color", "green" );
811 shadowMapSet.Insert( "offset", "2 2" );
813 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
815 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
816 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
817 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
819 // Check the input shadow property
820 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
821 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
823 // Check the emboss property
824 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
825 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
827 // Check the input emboss property
828 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
829 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
831 // Check the outline property
832 Property::Map outlineMapSet;
833 Property::Map outlineMapGet;
835 outlineMapSet["color"] = Color::RED;
836 outlineMapSet["width"] = 2.0f;
838 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
840 outlineMapSet["color"] = "red";
841 outlineMapSet["width"] = "2";
842 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
843 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
844 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
846 // Check the input outline property
847 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
848 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
850 // Check the hidden input settings property
851 Property::Map hiddenMapSet;
852 Property::Map hiddenMapGet;
853 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
854 hiddenMapSet[ HiddenInput::Property::SHOW_DURATION ] = 2;
855 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
856 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
857 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
859 hiddenMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
860 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
861 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
863 // Check the pixel size of font
864 field.SetProperty( DevelTextField::Property::PIXEL_SIZE, 20.f );
865 DALI_TEST_EQUALS( field.GetProperty<float>( DevelTextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
867 // Check the enable selection property
868 field.SetProperty( DevelTextField::Property::ENABLE_SELECTION, false );
869 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
871 // Check the placeholder property with pixel size
872 Property::Map placeholderPixelSizeMapSet;
873 Property::Map placeholderPixelSizeMapGet;
874 Property::Map placeholderFontstyleMap;
875 placeholderPixelSizeMapSet["placeholderText"] = "Setting Placeholder Text";
876 placeholderPixelSizeMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused";
877 placeholderPixelSizeMapSet["placeholderColor"] = Color::BLUE;
878 placeholderPixelSizeMapSet["placeholderFontFamily"] = "Arial";
879 placeholderPixelSizeMapSet["placeholderPixelSize"] = 15.0f;
880 placeholderPixelSizeMapSet["placeholderEllipsis"] = true;
882 placeholderFontstyleMap.Insert( "weight", "bold" );
883 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
884 field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
886 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
887 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
888 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
890 // Check the placeholder property with point size
891 Property::Map placeholderMapSet;
892 Property::Map placeholderMapGet;
893 placeholderMapSet["placeholderText"] = "Setting Placeholder Text";
894 placeholderMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused";
895 placeholderMapSet["placeholderColor"] = Color::RED;
896 placeholderMapSet["placeholderFontFamily"] = "Arial";
897 placeholderMapSet["placeholderPointSize"] = 12.0f;
898 placeholderMapSet["placeholderEllipsis"] = false;
900 // Check the placeholder font style property
901 placeholderFontstyleMap.Clear();
903 placeholderFontstyleMap.Insert( "weight", "bold" );
904 placeholderFontstyleMap.Insert( "width", "condensed" );
905 placeholderFontstyleMap.Insert( "slant", "italic" );
906 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
907 field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
909 placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
910 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
911 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
914 placeholderFontstyleMap.Clear();
915 placeholderFontstyleMap.Insert( "weight", "normal" );
916 placeholderFontstyleMap.Insert( "slant", "oblique" );
917 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
918 field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
920 placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
921 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
922 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
924 placeholderFontstyleMap.Clear();
925 placeholderFontstyleMap.Insert( "slant", "roman" );
926 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
927 field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
929 placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
931 placeholderFontstyleMap.Clear();
932 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
934 field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
935 placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
936 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
937 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
939 // Check the ellipsis property
940 DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ELLIPSIS ) );
941 field.SetProperty( DevelTextField::Property::ELLIPSIS, true );
942 DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ELLIPSIS ) );
947 // Positive Atlas Text Renderer test
948 int utcDaliTextFieldAtlasRenderP(void)
950 ToolkitTestApplication application;
951 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
952 StyleManager styleManager = StyleManager::Get();
953 styleManager.ApplyDefaultTheme();
954 TextField field = TextField::New();
955 DALI_TEST_CHECK( field );
957 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
959 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
961 Stage::GetCurrent().Add( field );
965 // Render some text with the shared atlas backend
966 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
967 application.SendNotification();
968 application.Render();
972 tet_result(TET_FAIL);
977 // Positive test for the textChanged signal.
978 int utcDaliTextFieldTextChangedP(void)
980 ToolkitTestApplication application;
981 tet_infoline(" utcDaliTextFieldTextChangedP");
982 TextField field = TextField::New();
983 DALI_TEST_CHECK( field );
985 Stage::GetCurrent().Add( field );
987 // connect to the text changed signal.
988 ConnectionTracker* testTracker = new ConnectionTracker();
989 field.TextChangedSignal().Connect(&TestTextChangedCallback);
990 bool textChangedSignal = false;
991 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
993 gTextChangedCallBackCalled = false;
994 field.SetProperty( TextField::Property::TEXT, "ABC" );
995 DALI_TEST_CHECK( gTextChangedCallBackCalled );
996 DALI_TEST_CHECK( textChangedSignal );
998 application.SendNotification();
1000 field.SetKeyInputFocus();
1002 gTextChangedCallBackCalled = false;
1003 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1004 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1009 // Negative test for the textChanged signal.
1010 int utcDaliTextFieldTextChangedN(void)
1012 ToolkitTestApplication application;
1013 tet_infoline(" utcDaliTextFieldTextChangedN");
1014 TextField field = TextField::New();
1015 DALI_TEST_CHECK( field );
1017 Stage::GetCurrent().Add( field );
1019 // connect to the text changed signal.
1020 ConnectionTracker* testTracker = new ConnectionTracker();
1021 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1022 bool textChangedSignal = false;
1023 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1025 gTextChangedCallBackCalled = false;
1026 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1027 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1028 DALI_TEST_CHECK( !textChangedSignal );
1033 // Positive test for Max Characters reached signal.
1034 int utcDaliTextFieldMaxCharactersReachedP(void)
1036 ToolkitTestApplication application;
1037 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1038 TextField field = TextField::New();
1039 DALI_TEST_CHECK( field );
1041 Stage::GetCurrent().Add( field );
1043 const int maxNumberOfCharacters = 1;
1044 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1046 field.SetKeyInputFocus();
1048 // connect to the text changed signal.
1049 ConnectionTracker* testTracker = new ConnectionTracker();
1050 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1051 bool maxLengthReachedSignal = false;
1052 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1054 gMaxCharactersCallBackCalled = false;
1056 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1057 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1059 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1060 DALI_TEST_CHECK( maxLengthReachedSignal );
1065 // Negative test for Max Characters reached signal.
1066 int utcDaliTextFieldMaxCharactersReachedN(void)
1068 ToolkitTestApplication application;
1069 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1070 TextField field = TextField::New();
1071 DALI_TEST_CHECK( field );
1073 Stage::GetCurrent().Add( field );
1075 const int maxNumberOfCharacters = 3;
1076 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1078 field.SetKeyInputFocus();
1080 // connect to the text changed signal.
1081 ConnectionTracker* testTracker = new ConnectionTracker();
1082 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1083 bool maxLengthReachedSignal = false;
1084 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1086 gMaxCharactersCallBackCalled = false;
1088 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1089 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1091 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1092 DALI_TEST_CHECK( !maxLengthReachedSignal );
1097 int utcDaliTextFieldInputStyleChanged01(void)
1099 ToolkitTestApplication application;
1100 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1102 // The text-field emits signals when the input style changes. These changes of style are
1103 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1104 // can't be emitted during the size negotiation as the callbacks may update the UI.
1105 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1106 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1107 application.CreateAdaptor();
1111 char* pathNamePtr = get_current_dir_name();
1112 const std::string pathName( pathNamePtr );
1113 free( pathNamePtr );
1115 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1116 fontClient.SetDpi( 93u, 93u );
1118 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1119 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1121 TextField field = TextField::New();
1122 DALI_TEST_CHECK( field );
1125 field.SetSize( 300.f, 50.f );
1126 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1127 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1129 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1130 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1132 // connect to the text changed signal.
1133 ConnectionTracker* testTracker = new ConnectionTracker();
1134 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1135 bool inputStyleChangedSignal = false;
1136 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1138 Stage::GetCurrent().Add( field );
1140 // Render and notify
1141 application.SendNotification();
1142 application.Render();
1144 // Executes the idle callbacks added by the text control on the change of input style.
1145 application.RunIdles();
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( 18.f, 25.f ) ) );
1153 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.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 if( gInputStyleChangedCallbackCalled )
1165 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1167 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1168 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1170 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1171 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1173 DALI_TEST_CHECK( inputStyleChangedSignal );
1175 gInputStyleChangedCallbackCalled = false;
1176 gInputStyleMask = TextField::InputStyle::NONE;
1177 inputStyleChangedSignal = false;
1179 // Create a tap event to touch the text field.
1180 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1181 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1183 // Render and notify
1184 application.SendNotification();
1185 application.Render();
1187 // Executes the idle callbacks added by the text control on the change of input style.
1188 application.RunIdles();
1190 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1191 DALI_TEST_CHECK( !inputStyleChangedSignal );
1193 gInputStyleChangedCallbackCalled = false;
1194 gInputStyleMask = TextField::InputStyle::NONE;
1195 inputStyleChangedSignal = false;
1197 // Create a tap event to touch the text field.
1198 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1199 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1201 // Render and notify
1202 application.SendNotification();
1203 application.Render();
1205 // Executes the idle callbacks added by the text control on the change of input style.
1206 application.RunIdles();
1208 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1209 if( gInputStyleChangedCallbackCalled )
1211 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1213 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1214 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1216 DALI_TEST_CHECK( inputStyleChangedSignal );
1218 gInputStyleChangedCallbackCalled = false;
1219 gInputStyleMask = TextField::InputStyle::NONE;
1220 inputStyleChangedSignal = false;
1222 // Create a tap event to touch the text field.
1223 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1224 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1226 // Render and notify
1227 application.SendNotification();
1228 application.Render();
1230 // Executes the idle callbacks added by the text control on the change of input style.
1231 application.RunIdles();
1233 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1234 if( gInputStyleChangedCallbackCalled )
1236 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1238 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1239 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1241 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1243 Property::Map fontStyleMapSet;
1244 fontStyleMapSet.Insert( "weight", "bold" );
1246 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1247 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1249 DALI_TEST_CHECK( inputStyleChangedSignal );
1251 gInputStyleChangedCallbackCalled = false;
1252 gInputStyleMask = TextField::InputStyle::NONE;
1253 inputStyleChangedSignal = false;
1255 // Create a tap event to touch the text field.
1256 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1257 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1259 // Render and notify
1260 application.SendNotification();
1261 application.Render();
1263 // Executes the idle callbacks added by the text control on the change of input style.
1264 application.RunIdles();
1266 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1267 DALI_TEST_CHECK( !inputStyleChangedSignal );
1269 gInputStyleChangedCallbackCalled = false;
1270 gInputStyleMask = TextField::InputStyle::NONE;
1271 inputStyleChangedSignal = false;
1273 // Create a tap event to touch the text field.
1274 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1275 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1277 // Render and notify
1278 application.SendNotification();
1279 application.Render();
1281 // Executes the idle callbacks added by the text control on the change of input style.
1282 application.RunIdles();
1284 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1285 if( gInputStyleChangedCallbackCalled )
1287 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1289 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1290 DALI_TEST_CHECK( style.empty() );
1292 DALI_TEST_CHECK( inputStyleChangedSignal );
1294 gInputStyleChangedCallbackCalled = false;
1295 gInputStyleMask = TextField::InputStyle::NONE;
1296 inputStyleChangedSignal = false;
1298 // Create a tap event to touch the text field.
1299 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1300 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1302 // Render and notify
1303 application.SendNotification();
1304 application.Render();
1306 // Executes the idle callbacks added by the text control on the change of input style.
1307 application.RunIdles();
1309 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1310 DALI_TEST_CHECK( !inputStyleChangedSignal );
1315 int utcDaliTextFieldInputStyleChanged02(void)
1317 ToolkitTestApplication application;
1318 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1320 // The text-field emits signals when the input style changes. These changes of style are
1321 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1322 // can't be emitted during the size negotiation as the callbacks may update the UI.
1323 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1324 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1325 application.CreateAdaptor();
1329 char* pathNamePtr = get_current_dir_name();
1330 const std::string pathName( pathNamePtr );
1331 free( pathNamePtr );
1333 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1334 fontClient.SetDpi( 93u, 93u );
1336 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1337 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1339 TextField field = TextField::New();
1340 DALI_TEST_CHECK( field );
1343 field.SetSize( 300.f, 50.f );
1344 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1345 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1347 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1348 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>" );
1350 // connect to the text changed signal.
1351 ConnectionTracker* testTracker = new ConnectionTracker();
1352 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1353 bool inputStyleChangedSignal = false;
1354 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1356 Stage::GetCurrent().Add( field );
1358 // Render and notify
1359 application.SendNotification();
1360 application.Render();
1362 // Executes the idle callbacks added by the text control on the change of input style.
1363 application.RunIdles();
1365 gInputStyleChangedCallbackCalled = false;
1366 gInputStyleMask = TextField::InputStyle::NONE;
1367 inputStyleChangedSignal = false;
1369 // Create a tap event to touch the text field.
1370 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1371 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1372 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1373 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1375 // Render and notify
1376 application.SendNotification();
1377 application.Render();
1379 // Executes the idle callbacks added by the text control on the change of input style.
1380 application.RunIdles();
1382 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1383 if( gInputStyleChangedCallbackCalled )
1385 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1386 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1387 TextField::InputStyle::POINT_SIZE |
1388 TextField::InputStyle::COLOR ),
1391 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1392 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1394 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1395 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1397 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1398 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1400 DALI_TEST_CHECK( inputStyleChangedSignal );
1402 gInputStyleChangedCallbackCalled = false;
1403 gInputStyleMask = TextField::InputStyle::NONE;
1404 inputStyleChangedSignal = false;
1406 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1408 // Render and notify
1409 application.SendNotification();
1410 application.Render();
1412 // Executes the idle callbacks added by the text control on the change of input style.
1413 application.RunIdles();
1415 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1416 if( gInputStyleChangedCallbackCalled )
1418 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1419 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1422 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1423 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1425 DALI_TEST_CHECK( inputStyleChangedSignal );
1427 gInputStyleChangedCallbackCalled = false;
1428 gInputStyleMask = TextField::InputStyle::NONE;
1429 inputStyleChangedSignal = false;
1431 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1433 // Render and notify
1434 application.SendNotification();
1435 application.Render();
1437 // Executes the idle callbacks added by the text control on the change of input style.
1438 application.RunIdles();
1440 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1441 DALI_TEST_CHECK( !inputStyleChangedSignal );
1443 gInputStyleChangedCallbackCalled = false;
1444 gInputStyleMask = TextField::InputStyle::NONE;
1445 inputStyleChangedSignal = false;
1447 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1449 // Render and notify
1450 application.SendNotification();
1451 application.Render();
1453 // Executes the idle callbacks added by the text control on the change of input style.
1454 application.RunIdles();
1456 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1457 if( gInputStyleChangedCallbackCalled )
1459 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1460 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1463 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1464 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1466 DALI_TEST_CHECK( inputStyleChangedSignal );
1468 gInputStyleChangedCallbackCalled = false;
1469 gInputStyleMask = TextField::InputStyle::NONE;
1470 inputStyleChangedSignal = false;
1472 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1474 Property::Map fontStyleMapSet;
1475 fontStyleMapSet.Insert( "weight", "thin" );
1476 fontStyleMapSet.Insert( "width", "condensed" );
1477 fontStyleMapSet.Insert( "slant", "italic" );
1479 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1480 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1482 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1483 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1484 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1485 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1487 // Render and notify
1488 application.SendNotification();
1489 application.Render();
1491 // Executes the idle callbacks added by the text control on the change of input style.
1492 application.RunIdles();
1494 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1495 DALI_TEST_CHECK( !inputStyleChangedSignal );
1497 // Create a tap event to touch the text field.
1498 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1499 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1501 // Render and notify
1502 application.SendNotification();
1503 application.Render();
1505 // Executes the idle callbacks added by the text control on the change of input style.
1506 application.RunIdles();
1508 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1509 if( gInputStyleChangedCallbackCalled )
1511 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1512 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1513 TextField::InputStyle::POINT_SIZE |
1514 TextField::InputStyle::FONT_STYLE |
1515 TextField::InputStyle::UNDERLINE |
1516 TextField::InputStyle::SHADOW |
1517 TextField::InputStyle::EMBOSS |
1518 TextField::InputStyle::OUTLINE ),
1521 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1522 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1524 DALI_TEST_CHECK( inputStyleChangedSignal );
1529 int utcDaliTextFieldEvent01(void)
1531 ToolkitTestApplication application;
1532 tet_infoline(" utcDaliTextFieldEvent01");
1534 // Creates a tap event. After creating a tap event the text field should
1535 // have the focus and add text with key events should be possible.
1537 TextField field = TextField::New();
1538 DALI_TEST_CHECK( field );
1540 Stage::GetCurrent().Add( field );
1542 field.SetSize( 300.f, 50.f );
1543 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1544 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1546 // Avoid a crash when core load gl resources.
1547 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1549 // Render and notify
1550 application.SendNotification();
1551 application.Render();
1553 // Add a key event but as the text field has not the focus it should do nothing.
1554 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1556 // Render and notify
1557 application.SendNotification();
1558 application.Render();
1560 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1562 // Create a tap event to touch the text field.
1563 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1564 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1566 // Render and notify
1567 application.SendNotification();
1568 application.Render();
1570 // Now the text field has the focus, so it can handle the key events.
1571 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1572 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1574 // Render and notify
1575 application.SendNotification();
1576 application.Render();
1578 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1580 // Create a second text field and send key events to it.
1581 TextField field2 = TextField::New();
1583 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1584 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1585 field2.SetSize( 100.f, 100.f );
1586 field2.SetPosition( 100.f, 100.f );
1588 Stage::GetCurrent().Add( field2 );
1590 // Render and notify
1591 application.SendNotification();
1592 application.Render();
1594 // Create a tap event on the second text field.
1595 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1596 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1598 // Render and notify
1599 application.SendNotification();
1600 application.Render();
1602 // The second text field has the focus. It should handle the key events.
1603 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1604 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1606 // Render and notify
1607 application.SendNotification();
1608 application.Render();
1610 // Check the text has been added to the second text field.
1611 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1616 int utcDaliTextFieldEvent02(void)
1618 ToolkitTestApplication application;
1619 tet_infoline(" utcDaliTextFieldEvent02");
1621 // Checks if the right number of actors are created.
1623 TextField field = TextField::New();
1624 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1625 DALI_TEST_CHECK( field );
1626 LoadMarkerImages(application, field);
1628 Stage::GetCurrent().Add( field );
1630 field.SetSize( 300.f, 50.f );
1631 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1632 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1634 // Avoid a crash when core load gl resources.
1635 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1637 // Render and notify
1638 application.SendNotification();
1639 application.Render();
1641 // Check there are the expected number of children ( stencil ).
1642 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1644 Actor stencil = field.GetChildAt( 0u );
1645 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1647 // Create a tap event to touch the text field.
1648 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1649 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1651 // Render and notify
1652 application.SendNotification();
1653 application.Render();
1655 Actor layer = field.GetChildAt( 1u );
1656 DALI_TEST_CHECK( layer.IsLayer() );
1658 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1659 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1661 // Now the text field has the focus, so it can handle the key events.
1662 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1663 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1665 // Render and notify
1666 application.SendNotification();
1667 application.Render();
1669 // Checks the cursor and the renderer have been created.
1670 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1671 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1673 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1674 DALI_TEST_CHECK( cursor );
1676 // The offscreen root actor has a container with all the actors which contain the text renderers.
1677 Actor container = stencil.GetChildAt( 0u );
1678 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1680 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1681 DALI_TEST_CHECK( renderer );
1684 // Move the cursor and check the position changes.
1685 Vector3 position1 = cursor.GetCurrentPosition();
1687 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1688 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1690 // Render and notify
1691 application.SendNotification();
1692 application.Render();
1694 Vector3 position2 = cursor.GetCurrentPosition();
1696 DALI_TEST_CHECK( position2.x < position1.x );
1698 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1699 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1701 // Render and notify
1702 application.SendNotification();
1703 application.Render();
1705 Vector3 position3 = cursor.GetCurrentPosition();
1707 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1709 // Send some taps and check the cursor positions.
1711 // Try to tap at the beginning.
1712 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1713 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1715 // Render and notify
1716 application.SendNotification();
1717 application.Render();
1719 // Cursor position should be the same than position1.
1720 Vector3 position4 = cursor.GetCurrentPosition();
1722 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1724 // Tap away from the start position.
1725 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1726 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1728 // Render and notify
1729 application.SendNotification();
1730 application.Render();
1732 Vector3 position5 = cursor.GetCurrentPosition();
1734 DALI_TEST_CHECK( position5.x > position4.x );
1736 // Remove all the text.
1737 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1738 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1739 field.SetProperty( TextField::Property::TEXT, "" );
1741 // Render and notify
1742 application.SendNotification();
1743 application.Render();
1745 // Cursor position should be the same than position2.
1746 Vector3 position6 = cursor.GetCurrentPosition();
1748 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1750 // Should not be a renderer.
1751 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1753 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1754 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1755 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1757 application.SendNotification();
1758 application.Render();
1760 // There are renderer and decorator layer
1761 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1766 int utcDaliTextFieldEvent03(void)
1768 ToolkitTestApplication application;
1769 tet_infoline(" utcDaliTextFieldEvent03");
1771 // Checks if the highlight actor is created.
1773 TextField field = TextField::New();
1774 DALI_TEST_CHECK( field );
1776 Stage::GetCurrent().Add( field );
1778 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1779 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1780 field.SetSize( 30.f, 50.f );
1781 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1782 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1784 // Avoid a crash when core load gl resources.
1785 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1786 LoadMarkerImages(application, field);
1788 // Render and notify
1789 application.SendNotification();
1790 application.Render();
1792 // Tap first to get the focus.
1793 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1794 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1796 // Render and notify
1797 application.SendNotification();
1798 application.Render();
1800 // Double tap to select a word.
1801 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1802 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1804 // Render and notify
1805 application.SendNotification();
1806 application.Render();
1808 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1809 Actor stencil = field.GetChildAt( 0u );
1811 // The highlight actor is drawn first, so is the first actor in the list
1812 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1813 DALI_TEST_CHECK( highlight );
1815 // The offscreen root actor has a container with all the actors which contain the text renderers.
1816 Actor container = stencil.GetChildAt( 1u );
1817 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1819 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1820 DALI_TEST_CHECK( renderer );
1826 int utcDaliTextFieldEvent04(void)
1828 ToolkitTestApplication application;
1829 tet_infoline(" utcDaliTextFieldEvent04");
1831 // Checks if the highlight actor is created.
1833 TextField field = TextField::New();
1834 DALI_TEST_CHECK( field );
1835 Stage::GetCurrent().Add( field );
1836 LoadMarkerImages(application, field);
1837 // Render and notify
1838 application.SendNotification();
1839 application.Render();
1841 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1842 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1843 field.SetSize( 300.f, 50.f );
1844 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1845 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1847 // Avoid a crash when core load gl resources.
1848 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1849 // Render and notify
1850 application.SendNotification();
1851 application.Render();
1853 // Create a tap event to touch the text field.
1854 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1855 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1856 // Render and notify
1857 application.SendNotification();
1858 application.Render();
1861 // Tap first to get the focus.
1862 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1863 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1865 // Render and notify
1866 application.SendNotification();
1867 application.Render();
1869 // Double tap to select a word.
1870 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1871 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1873 // Render and notify
1874 application.SendNotification();
1875 application.Render();
1878 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1879 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1883 int utcDaliTextFieldEvent05(void)
1885 ToolkitTestApplication application;
1886 tet_infoline(" utcDaliTextFieldEvent05");
1888 // Checks dragging of cursor/grab handle
1890 TextField field = TextField::New();
1891 DALI_TEST_CHECK( field );
1892 Stage::GetCurrent().Add( field );
1893 LoadMarkerImages(application, field);
1894 // Render and notify
1895 application.SendNotification();
1896 application.Render();
1898 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1899 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1900 field.SetSize( 300.f, 50.f );
1901 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1902 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1904 // Avoid a crash when core load gl resources.
1905 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1906 // Render and notify
1907 application.SendNotification();
1908 application.Render();
1910 // Create a tap event to touch the text field.
1911 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1912 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1913 // Render and notify
1914 application.SendNotification();
1915 application.Render();
1918 // Tap first to get the focus.
1919 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1920 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1922 // Render and notify
1923 application.SendNotification();
1924 application.Render();
1926 // Double tap to select a word.
1927 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1928 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1930 // Render and notify
1931 application.SendNotification();
1932 application.Render();
1934 // drag grab handle right
1935 Vector2 pos(0.0f, 40.0f);
1936 SendPan(application, Gesture::Possible, pos);
1937 SendPan(application, Gesture::Started, pos);
1939 Wait(application, 100);
1941 for(int i = 0;i<20;i++)
1943 SendPan(application, Gesture::Continuing, pos);
1948 SendPan(application, Gesture::Finished, pos);
1949 Wait(application, RENDER_FRAME_INTERVAL);
1951 Actor stencil = field.GetChildAt( 1u );
1955 int utcDaliTextFieldEvent06(void)
1957 ToolkitTestApplication application;
1958 tet_infoline(" utcDaliTextFieldEvent06");
1960 // Checks Longpress when in edit mode
1962 TextField field = TextField::New();
1963 DALI_TEST_CHECK( field );
1964 Stage::GetCurrent().Add( field );
1965 LoadMarkerImages(application, field);
1966 // Render and notify
1967 application.SendNotification();
1968 application.Render();
1970 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1971 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1972 field.SetSize( 300.f, 50.f );
1973 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1974 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1976 // Avoid a crash when core load gl resources.
1977 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1978 // Render and notify
1979 application.SendNotification();
1980 application.Render();
1982 // Create a tap event to touch the text field.
1983 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1984 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1985 // Render and notify
1986 application.SendNotification();
1987 application.Render();
1990 // Tap first to get the focus.
1991 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1992 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1994 // Render and notify
1995 application.SendNotification();
1996 application.Render();
1999 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2000 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2002 // Render and notify
2003 application.SendNotification();
2004 application.Render();
2009 int utcDaliTextFieldEvent07(void)
2011 ToolkitTestApplication application;
2012 tet_infoline(" utcDaliTextFieldEvent07");
2014 // Checks Longpress to start edit mode
2016 TextField field = TextField::New();
2017 DALI_TEST_CHECK( field );
2018 Stage::GetCurrent().Add( field );
2019 LoadMarkerImages(application, field);
2020 // Render and notify
2021 application.SendNotification();
2022 application.Render();
2024 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2025 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2026 field.SetSize( 300.f, 50.f );
2027 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2028 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2029 Property::Map propertyMap;
2030 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2031 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2033 // Avoid a crash when core load gl resources.
2034 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2035 // Render and notify
2036 application.SendNotification();
2037 application.Render();
2040 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2041 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2043 // Render and notify
2044 application.SendNotification();
2045 application.Render();
2050 int utcDaliTextFieldEvent08(void)
2052 ToolkitTestApplication application;
2053 tet_infoline(" utcDaliTextFieldEvent08");
2055 Dali::Clipboard clipboard = Clipboard::Get();
2056 clipboard.SetItem("testTextFieldEvent");
2058 // Checks Longpress when only place holder text
2060 TextField field = TextField::New();
2061 DALI_TEST_CHECK( field );
2062 Stage::GetCurrent().Add( field );
2063 LoadMarkerImages(application, field);
2064 // Render and notify
2065 application.SendNotification();
2066 application.Render();
2068 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2069 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2070 field.SetSize( 300.f, 50.f );
2071 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2072 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2074 // Avoid a crash when core load gl resources.
2075 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2076 // Render and notify
2077 application.SendNotification();
2078 application.Render();
2081 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2082 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2084 // Render and notify
2085 application.SendNotification();
2086 application.Render();
2088 Wait(application, 500);
2091 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2092 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2094 // Render and notify
2095 application.SendNotification();
2096 application.Render();
2098 Wait(application, 500);
2100 Stage stage = Stage::GetCurrent();
2101 Layer layer = stage.GetRootLayer();
2102 Actor actor = layer.FindChildByName("optionPaste");
2106 Vector3 worldPosition = actor.GetCurrentWorldPosition();
2107 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2108 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2110 Dali::Integration::TouchEvent event;
2111 event = Dali::Integration::TouchEvent();
2112 event.AddPoint( GetPointDownInside( position ) );
2113 application.ProcessEvent( event );
2115 event = Dali::Integration::TouchEvent();
2116 event.AddPoint( GetPointUpInside( position ) );
2117 application.ProcessEvent( event );
2119 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2124 int utcDaliTextFieldEvent09(void)
2126 ToolkitTestApplication application;
2127 tet_infoline(" utcDaliTextFieldEvent09");
2129 TextField field = TextField::New();
2130 DALI_TEST_CHECK( field );
2131 Stage::GetCurrent().Add( field );
2132 LoadMarkerImages(application, field);
2133 // Render and notify
2134 application.SendNotification();
2135 application.Render();
2137 field.SetProperty( TextField::Property::TEXT, "Hello" );
2138 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2139 field.SetSize( 300.f, 50.f );
2140 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2141 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2143 // Avoid a crash when core load gl resources.
2144 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2146 // Create a tap event to touch the text field.
2147 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2148 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2149 application.SendNotification();
2150 application.Render();
2153 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2154 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2155 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2156 application.SendNotification();
2157 application.Render();
2159 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2160 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2161 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2162 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2163 application.SendNotification();
2164 application.Render();
2166 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2167 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2168 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2169 for( unsigned int index = 0u; index < 5u; ++index )
2171 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2172 application.SendNotification();
2173 application.Render();
2176 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2177 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2178 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2179 for( unsigned int index = 0u; index < 5u; ++index )
2181 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2182 application.SendNotification();
2183 application.Render();
2186 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2187 map[ HiddenInput::Property::SHOW_DURATION ] = 0;
2188 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2189 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2190 application.SendNotification();
2191 application.Render();
2192 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2193 application.SendNotification();
2194 application.Render();
2196 map[ HiddenInput::Property::SHOW_DURATION ] = 100;
2197 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2198 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2199 application.SendNotification();
2200 application.Render();
2202 Property::Map mapGet;
2203 mapGet = field.GetProperty<Property::Map>( DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
2204 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2205 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2210 int utcDaliTextFieldStyleWhilstSelected(void)
2212 ToolkitTestApplication application;
2213 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2215 // Change font and styles whilst text is selected whilst word selected
2217 TextField field = TextField::New();
2218 DALI_TEST_CHECK( field );
2219 Stage::GetCurrent().Add( field );
2220 LoadMarkerImages(application, field);
2221 // Render and notify
2222 application.SendNotification();
2223 application.Render();
2225 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2226 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2227 field.SetSize( 300.f, 50.f );
2228 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2229 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2231 // Avoid a crash when core load gl resources.
2232 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2233 // Render and notify
2234 application.SendNotification();
2235 application.Render();
2237 // Create a tap event to touch the text field.
2238 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2239 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2240 // Render and notify
2241 application.SendNotification();
2242 application.Render();
2245 // Tap first to get the focus.
2246 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2247 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2249 // Render and notify
2250 application.SendNotification();
2251 application.Render();
2253 // Double tap to select a word.
2254 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2255 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2257 // Render and notify
2258 application.SendNotification();
2259 application.Render();
2261 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2262 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2264 Property::Map fontStyleMapSet;
2265 Property::Map fontStyleMapGet;
2267 fontStyleMapSet.Insert( "weight", "bold" );
2268 fontStyleMapSet.Insert( "slant", "italic" );
2269 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2271 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2272 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2273 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2275 fontStyleMapSet.Clear();
2276 fontStyleMapSet.Insert( "width", "expanded" );
2277 fontStyleMapSet.Insert( "slant", "italic" );
2278 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2280 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2281 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2282 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2284 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2285 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2287 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2288 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2290 fontStyleMapSet.Clear();
2291 fontStyleMapSet.Insert( "weight", "bold" );
2292 fontStyleMapSet.Insert( "slant", "italic" );
2294 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2296 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2297 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2298 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2300 fontStyleMapSet.Clear();
2301 fontStyleMapSet.Insert( "width", "expanded" );
2303 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2305 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2306 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2307 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2309 // Press Escape to increase coverage
2310 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2311 application.SendNotification();
2312 application.Render();
2314 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2319 int utcDaliTextFieldEscKeyLoseFocus(void)
2321 ToolkitTestApplication application;
2322 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2324 // Creates a tap event. After creating a tap event the text field should
2325 // have the focus and add text with key events should be possible.
2327 TextField field = TextField::New();
2328 DALI_TEST_CHECK( field );
2330 Stage::GetCurrent().Add( field );
2332 field.SetSize( 300.f, 50.f );
2333 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2334 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2336 // Avoid a crash when core load gl resources.
2337 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2339 // Render and notify
2340 application.SendNotification();
2341 application.Render();
2343 // Add a key event but as the text field has not the focus it should do nothing.
2344 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2345 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2347 // Render and notify
2348 application.SendNotification();
2349 application.Render();
2351 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2353 // Create a tap event to touch the text field.
2354 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2355 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2357 // Render and notify
2358 application.SendNotification();
2359 application.Render();
2361 // Now the text field has the focus, so it can handle the key events.
2362 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2363 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2364 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2365 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2367 // Render and notify
2368 application.SendNotification();
2369 application.Render();
2371 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2373 // Generate a Esc key event. The text field should lose the focus.
2374 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2375 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2377 // Render and notify
2378 application.SendNotification();
2379 application.Render();
2381 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2383 // No more text should be introduced
2384 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2385 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2387 // Render and notify
2388 application.SendNotification();
2389 application.Render();
2391 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2396 int utcDaliTextFieldSomeSpecialKeys(void)
2398 ToolkitTestApplication application;
2399 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2401 // Checks some special keys when the text is selected.
2403 TextField field = TextField::New();
2404 DALI_TEST_CHECK( field );
2405 Stage::GetCurrent().Add( field );
2406 LoadMarkerImages(application, field);
2407 // Render and notify
2408 application.SendNotification();
2409 application.Render();
2411 const std::string longText( "This is a long text for the size of the text-field." );
2413 field.SetProperty( TextField::Property::TEXT, longText );
2414 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2415 field.SetSize( 300.f, 50.f );
2416 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2417 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2419 // Avoid a crash when core load gl resources.
2420 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2421 // Render and notify
2422 application.SendNotification();
2423 application.Render();
2425 // Create a tap event to touch the text field.
2426 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2427 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2429 // Render and notify
2430 application.SendNotification();
2431 application.Render();
2433 // Tap first to get the focus.
2434 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2435 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2437 // Render and notify
2438 application.SendNotification();
2439 application.Render();
2441 // Double tap to select a word.
2442 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2443 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2445 // Render and notify
2446 application.SendNotification();
2447 application.Render();
2449 // Generate a Esc key event. The text field should lose the focus.
2450 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2451 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2453 // Render and notify
2454 application.SendNotification();
2455 application.Render();
2457 // Generate a Esc key event. The text field should lose the focus.
2458 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2459 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2461 // Render and notify
2462 application.SendNotification();
2463 application.Render();
2465 // Generate a Esc key event. The text field should lose the focus.
2466 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2467 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2469 // Render and notify
2470 application.SendNotification();
2471 application.Render();
2473 // The text shouldn't be deleted.
2474 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2479 int utcDaliTextFieldSizeUpdate(void)
2481 ToolkitTestApplication application;
2482 tet_infoline("utcDaliTextFieldSizeUpdate");
2484 // Checks some special keys when the text is selected.
2485 TextField field = TextField::New();
2486 DALI_TEST_CHECK( field );
2487 Stage::GetCurrent().Add( field );
2489 float previousHeight = 0.0f;
2490 float currentHeight = 0.0f;
2491 const float fieldWidth = 1920.0f;
2494 // "ㅁ" is bigger then "ኢ"
2495 field.SetSize( Vector2( fieldWidth ,10.0f ) );
2496 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2497 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2499 field.SetProperty( TextField::Property::TEXT, "ኢ");
2500 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2501 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2503 field.SetKeyboardFocusable(true);
2504 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2506 application.SendNotification();
2507 application.Render();
2509 previousHeight = field.GetHeightForWidth( fieldWidth );
2510 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2512 // Add another script characters ( glyph height is defferent )
2513 application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2514 application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2516 application.SendNotification();
2517 application.Render();
2519 currentHeight = field.GetHeightForWidth( fieldWidth );
2520 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2521 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2526 int utcDaliTextFieldExtremlyLargePointSize(void)
2528 ToolkitTestApplication application;
2529 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2531 TextField field = TextField::New();
2533 field.SetProperty( TextField::Property::TEXT, "Text" );
2534 field.SetSize( 300.f, 50.f );
2535 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2536 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2537 Stage::GetCurrent().Add( field );
2541 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2542 application.SendNotification();
2543 DALI_TEST_CHECK( field );
2547 tet_result(TET_FAIL);
2552 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2554 ToolkitTestApplication application;
2555 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2556 TextField field = TextField::New();
2557 DALI_TEST_CHECK( field );
2558 Stage::GetCurrent().Add( field );
2560 Property::Map fontStyleMapGet;
2562 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2564 Property::Value* weightValue = NULL;
2565 Property::Value* widthValue = NULL;
2566 Property::Value* slantValue = NULL;
2567 weightValue = fontStyleMapGet.Find( "weight" );
2568 widthValue = fontStyleMapGet.Find( "width" );
2569 slantValue = fontStyleMapGet.Find( "slant" );
2570 DALI_TEST_CHECK( !weightValue );
2571 DALI_TEST_CHECK( !widthValue );
2572 DALI_TEST_CHECK( !slantValue );