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 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
833 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
835 // Check the input outline property
836 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
837 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
839 // Check the hidden input settings property
840 Property::Map hiddenMapSet;
841 Property::Map hiddenMapGet;
842 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
843 hiddenMapSet[ HiddenInput::Property::SHOW_DURATION ] = 2;
844 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
845 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
846 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
848 hiddenMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
849 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
850 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
852 // Check the pixel size of font
853 field.SetProperty( DevelTextField::Property::PIXEL_SIZE, 20.f );
854 DALI_TEST_EQUALS( field.GetProperty<float>( DevelTextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
856 // Check the enable selection property
857 field.SetProperty( DevelTextField::Property::ENABLE_SELECTION, false );
858 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
860 // Check the placeholder property with pixel size
861 Property::Map placeholderPixelSizeMapSet;
862 Property::Map placeholderPixelSizeMapGet;
863 Property::Map placeholderFontstyleMap;
864 placeholderPixelSizeMapSet["placeholderText"] = "Setting Placeholder Text";
865 placeholderPixelSizeMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused";
866 placeholderPixelSizeMapSet["placeholderColor"] = Color::BLUE;
867 placeholderPixelSizeMapSet["placeholderFontFamily"] = "Arial";
868 placeholderPixelSizeMapSet["placeholderPixelSize"] = 15.0f;
869 placeholderPixelSizeMapSet["placeholderEllipsis"] = true;
871 placeholderFontstyleMap.Insert( "weight", "bold" );
872 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
873 field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
875 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
876 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
877 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
879 // Check the placeholder property with point size
880 Property::Map placeholderMapSet;
881 Property::Map placeholderMapGet;
882 placeholderMapSet["placeholderText"] = "Setting Placeholder Text";
883 placeholderMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused";
884 placeholderMapSet["placeholderColor"] = Color::RED;
885 placeholderMapSet["placeholderFontFamily"] = "Arial";
886 placeholderMapSet["placeholderPointSize"] = 12.0f;
887 placeholderMapSet["placeholderEllipsis"] = false;
889 // Check the placeholder font style property
890 placeholderFontstyleMap.Clear();
892 placeholderFontstyleMap.Insert( "weight", "bold" );
893 placeholderFontstyleMap.Insert( "width", "condensed" );
894 placeholderFontstyleMap.Insert( "slant", "italic" );
895 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
896 field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
898 placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
899 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
900 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
903 placeholderFontstyleMap.Clear();
904 placeholderFontstyleMap.Insert( "weight", "normal" );
905 placeholderFontstyleMap.Insert( "slant", "oblique" );
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 );
913 placeholderFontstyleMap.Clear();
914 placeholderFontstyleMap.Insert( "slant", "roman" );
915 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
916 field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
918 placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
920 placeholderFontstyleMap.Clear();
921 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
923 field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
924 placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
925 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
926 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
928 // Check the ellipsis property
929 DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ELLIPSIS ) );
930 field.SetProperty( DevelTextField::Property::ELLIPSIS, true );
931 DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ELLIPSIS ) );
936 // Positive Atlas Text Renderer test
937 int utcDaliTextFieldAtlasRenderP(void)
939 ToolkitTestApplication application;
940 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
941 StyleManager styleManager = StyleManager::Get();
942 styleManager.ApplyDefaultTheme();
943 TextField field = TextField::New();
944 DALI_TEST_CHECK( field );
946 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
948 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
950 Stage::GetCurrent().Add( field );
954 // Render some text with the shared atlas backend
955 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
956 application.SendNotification();
957 application.Render();
961 tet_result(TET_FAIL);
966 // Positive test for the textChanged signal.
967 int utcDaliTextFieldTextChangedP(void)
969 ToolkitTestApplication application;
970 tet_infoline(" utcDaliTextFieldTextChangedP");
971 TextField field = TextField::New();
972 DALI_TEST_CHECK( field );
974 Stage::GetCurrent().Add( field );
976 // connect to the text changed signal.
977 ConnectionTracker* testTracker = new ConnectionTracker();
978 field.TextChangedSignal().Connect(&TestTextChangedCallback);
979 bool textChangedSignal = false;
980 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
982 gTextChangedCallBackCalled = false;
983 field.SetProperty( TextField::Property::TEXT, "ABC" );
984 DALI_TEST_CHECK( gTextChangedCallBackCalled );
985 DALI_TEST_CHECK( textChangedSignal );
987 application.SendNotification();
989 field.SetKeyInputFocus();
991 gTextChangedCallBackCalled = false;
992 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
993 DALI_TEST_CHECK( gTextChangedCallBackCalled );
998 // Negative test for the textChanged signal.
999 int utcDaliTextFieldTextChangedN(void)
1001 ToolkitTestApplication application;
1002 tet_infoline(" utcDaliTextFieldTextChangedN");
1003 TextField field = TextField::New();
1004 DALI_TEST_CHECK( field );
1006 Stage::GetCurrent().Add( field );
1008 // connect to the text changed signal.
1009 ConnectionTracker* testTracker = new ConnectionTracker();
1010 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1011 bool textChangedSignal = false;
1012 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1014 gTextChangedCallBackCalled = false;
1015 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1016 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1017 DALI_TEST_CHECK( !textChangedSignal );
1022 // Positive test for Max Characters reached signal.
1023 int utcDaliTextFieldMaxCharactersReachedP(void)
1025 ToolkitTestApplication application;
1026 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1027 TextField field = TextField::New();
1028 DALI_TEST_CHECK( field );
1030 Stage::GetCurrent().Add( field );
1032 const int maxNumberOfCharacters = 1;
1033 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1035 field.SetKeyInputFocus();
1037 // connect to the text changed signal.
1038 ConnectionTracker* testTracker = new ConnectionTracker();
1039 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1040 bool maxLengthReachedSignal = false;
1041 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1043 gMaxCharactersCallBackCalled = false;
1045 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1046 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1048 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1049 DALI_TEST_CHECK( maxLengthReachedSignal );
1054 // Negative test for Max Characters reached signal.
1055 int utcDaliTextFieldMaxCharactersReachedN(void)
1057 ToolkitTestApplication application;
1058 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1059 TextField field = TextField::New();
1060 DALI_TEST_CHECK( field );
1062 Stage::GetCurrent().Add( field );
1064 const int maxNumberOfCharacters = 3;
1065 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1067 field.SetKeyInputFocus();
1069 // connect to the text changed signal.
1070 ConnectionTracker* testTracker = new ConnectionTracker();
1071 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1072 bool maxLengthReachedSignal = false;
1073 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1075 gMaxCharactersCallBackCalled = false;
1077 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1078 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1080 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1081 DALI_TEST_CHECK( !maxLengthReachedSignal );
1086 int utcDaliTextFieldInputStyleChanged01(void)
1088 ToolkitTestApplication application;
1089 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1091 // The text-field emits signals when the input style changes. These changes of style are
1092 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1093 // can't be emitted during the size negotiation as the callbacks may update the UI.
1094 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1095 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1096 application.CreateAdaptor();
1100 char* pathNamePtr = get_current_dir_name();
1101 const std::string pathName( pathNamePtr );
1102 free( pathNamePtr );
1104 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1105 fontClient.SetDpi( 93u, 93u );
1107 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1108 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1110 TextField field = TextField::New();
1111 DALI_TEST_CHECK( field );
1114 field.SetSize( 300.f, 50.f );
1115 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1116 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1118 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1119 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1121 // connect to the text changed signal.
1122 ConnectionTracker* testTracker = new ConnectionTracker();
1123 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1124 bool inputStyleChangedSignal = false;
1125 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1127 Stage::GetCurrent().Add( field );
1129 // Render and notify
1130 application.SendNotification();
1131 application.Render();
1133 // Executes the idle callbacks added by the text control on the change of input style.
1134 application.RunIdles();
1136 gInputStyleChangedCallbackCalled = false;
1137 gInputStyleMask = TextField::InputStyle::NONE;
1138 inputStyleChangedSignal = false;
1140 // Create a tap event to touch the text field.
1141 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1142 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1144 // Render and notify
1145 application.SendNotification();
1146 application.Render();
1148 // Executes the idle callbacks added by the text control on the change of input style.
1149 application.RunIdles();
1151 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1152 if( gInputStyleChangedCallbackCalled )
1154 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1156 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1157 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1159 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1160 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1162 DALI_TEST_CHECK( inputStyleChangedSignal );
1164 gInputStyleChangedCallbackCalled = false;
1165 gInputStyleMask = TextField::InputStyle::NONE;
1166 inputStyleChangedSignal = false;
1168 // Create a tap event to touch the text field.
1169 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1170 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1172 // Render and notify
1173 application.SendNotification();
1174 application.Render();
1176 // Executes the idle callbacks added by the text control on the change of input style.
1177 application.RunIdles();
1179 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1180 DALI_TEST_CHECK( !inputStyleChangedSignal );
1182 gInputStyleChangedCallbackCalled = false;
1183 gInputStyleMask = TextField::InputStyle::NONE;
1184 inputStyleChangedSignal = false;
1186 // Create a tap event to touch the text field.
1187 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1188 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1190 // Render and notify
1191 application.SendNotification();
1192 application.Render();
1194 // Executes the idle callbacks added by the text control on the change of input style.
1195 application.RunIdles();
1197 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1198 if( gInputStyleChangedCallbackCalled )
1200 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1202 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1203 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1205 DALI_TEST_CHECK( inputStyleChangedSignal );
1207 gInputStyleChangedCallbackCalled = false;
1208 gInputStyleMask = TextField::InputStyle::NONE;
1209 inputStyleChangedSignal = false;
1211 // Create a tap event to touch the text field.
1212 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1213 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1215 // Render and notify
1216 application.SendNotification();
1217 application.Render();
1219 // Executes the idle callbacks added by the text control on the change of input style.
1220 application.RunIdles();
1222 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1223 if( gInputStyleChangedCallbackCalled )
1225 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1227 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1228 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1230 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1232 Property::Map fontStyleMapSet;
1233 fontStyleMapSet.Insert( "weight", "bold" );
1235 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1236 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1238 DALI_TEST_CHECK( inputStyleChangedSignal );
1240 gInputStyleChangedCallbackCalled = false;
1241 gInputStyleMask = TextField::InputStyle::NONE;
1242 inputStyleChangedSignal = false;
1244 // Create a tap event to touch the text field.
1245 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1246 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1248 // Render and notify
1249 application.SendNotification();
1250 application.Render();
1252 // Executes the idle callbacks added by the text control on the change of input style.
1253 application.RunIdles();
1255 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1256 DALI_TEST_CHECK( !inputStyleChangedSignal );
1258 gInputStyleChangedCallbackCalled = false;
1259 gInputStyleMask = TextField::InputStyle::NONE;
1260 inputStyleChangedSignal = false;
1262 // Create a tap event to touch the text field.
1263 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1264 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1266 // Render and notify
1267 application.SendNotification();
1268 application.Render();
1270 // Executes the idle callbacks added by the text control on the change of input style.
1271 application.RunIdles();
1273 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1274 if( gInputStyleChangedCallbackCalled )
1276 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1278 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1279 DALI_TEST_CHECK( style.empty() );
1281 DALI_TEST_CHECK( inputStyleChangedSignal );
1283 gInputStyleChangedCallbackCalled = false;
1284 gInputStyleMask = TextField::InputStyle::NONE;
1285 inputStyleChangedSignal = false;
1287 // Create a tap event to touch the text field.
1288 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1289 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1291 // Render and notify
1292 application.SendNotification();
1293 application.Render();
1295 // Executes the idle callbacks added by the text control on the change of input style.
1296 application.RunIdles();
1298 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1299 DALI_TEST_CHECK( !inputStyleChangedSignal );
1304 int utcDaliTextFieldInputStyleChanged02(void)
1306 ToolkitTestApplication application;
1307 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1309 // The text-field emits signals when the input style changes. These changes of style are
1310 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1311 // can't be emitted during the size negotiation as the callbacks may update the UI.
1312 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1313 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1314 application.CreateAdaptor();
1318 char* pathNamePtr = get_current_dir_name();
1319 const std::string pathName( pathNamePtr );
1320 free( pathNamePtr );
1322 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1323 fontClient.SetDpi( 93u, 93u );
1325 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1326 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1328 TextField field = TextField::New();
1329 DALI_TEST_CHECK( field );
1332 field.SetSize( 300.f, 50.f );
1333 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1334 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1336 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1337 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>" );
1339 // connect to the text changed signal.
1340 ConnectionTracker* testTracker = new ConnectionTracker();
1341 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1342 bool inputStyleChangedSignal = false;
1343 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1345 Stage::GetCurrent().Add( field );
1347 // Render and notify
1348 application.SendNotification();
1349 application.Render();
1351 // Executes the idle callbacks added by the text control on the change of input style.
1352 application.RunIdles();
1354 gInputStyleChangedCallbackCalled = false;
1355 gInputStyleMask = TextField::InputStyle::NONE;
1356 inputStyleChangedSignal = false;
1358 // Create a tap event to touch the text field.
1359 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1360 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1361 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1362 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1364 // Render and notify
1365 application.SendNotification();
1366 application.Render();
1368 // Executes the idle callbacks added by the text control on the change of input style.
1369 application.RunIdles();
1371 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1372 if( gInputStyleChangedCallbackCalled )
1374 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1375 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1376 TextField::InputStyle::POINT_SIZE |
1377 TextField::InputStyle::COLOR ),
1380 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1381 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1383 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1384 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1386 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1387 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1389 DALI_TEST_CHECK( inputStyleChangedSignal );
1391 gInputStyleChangedCallbackCalled = false;
1392 gInputStyleMask = TextField::InputStyle::NONE;
1393 inputStyleChangedSignal = false;
1395 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1397 // Render and notify
1398 application.SendNotification();
1399 application.Render();
1401 // Executes the idle callbacks added by the text control on the change of input style.
1402 application.RunIdles();
1404 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1405 if( gInputStyleChangedCallbackCalled )
1407 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1408 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1411 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1412 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1414 DALI_TEST_CHECK( inputStyleChangedSignal );
1416 gInputStyleChangedCallbackCalled = false;
1417 gInputStyleMask = TextField::InputStyle::NONE;
1418 inputStyleChangedSignal = false;
1420 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1422 // Render and notify
1423 application.SendNotification();
1424 application.Render();
1426 // Executes the idle callbacks added by the text control on the change of input style.
1427 application.RunIdles();
1429 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1430 DALI_TEST_CHECK( !inputStyleChangedSignal );
1432 gInputStyleChangedCallbackCalled = false;
1433 gInputStyleMask = TextField::InputStyle::NONE;
1434 inputStyleChangedSignal = false;
1436 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1438 // Render and notify
1439 application.SendNotification();
1440 application.Render();
1442 // Executes the idle callbacks added by the text control on the change of input style.
1443 application.RunIdles();
1445 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1446 if( gInputStyleChangedCallbackCalled )
1448 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1449 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1452 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1453 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1455 DALI_TEST_CHECK( inputStyleChangedSignal );
1457 gInputStyleChangedCallbackCalled = false;
1458 gInputStyleMask = TextField::InputStyle::NONE;
1459 inputStyleChangedSignal = false;
1461 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1463 Property::Map fontStyleMapSet;
1464 fontStyleMapSet.Insert( "weight", "thin" );
1465 fontStyleMapSet.Insert( "width", "condensed" );
1466 fontStyleMapSet.Insert( "slant", "italic" );
1468 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1469 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1471 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1472 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1473 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1474 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1476 // Render and notify
1477 application.SendNotification();
1478 application.Render();
1480 // Executes the idle callbacks added by the text control on the change of input style.
1481 application.RunIdles();
1483 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1484 DALI_TEST_CHECK( !inputStyleChangedSignal );
1486 // Create a tap event to touch the text field.
1487 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1488 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1490 // Render and notify
1491 application.SendNotification();
1492 application.Render();
1494 // Executes the idle callbacks added by the text control on the change of input style.
1495 application.RunIdles();
1497 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1498 if( gInputStyleChangedCallbackCalled )
1500 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1501 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1502 TextField::InputStyle::POINT_SIZE |
1503 TextField::InputStyle::FONT_STYLE |
1504 TextField::InputStyle::UNDERLINE |
1505 TextField::InputStyle::SHADOW |
1506 TextField::InputStyle::EMBOSS |
1507 TextField::InputStyle::OUTLINE ),
1510 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1511 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1513 DALI_TEST_CHECK( inputStyleChangedSignal );
1518 int utcDaliTextFieldEvent01(void)
1520 ToolkitTestApplication application;
1521 tet_infoline(" utcDaliTextFieldEvent01");
1523 // Creates a tap event. After creating a tap event the text field should
1524 // have the focus and add text with key events should be possible.
1526 TextField field = TextField::New();
1527 DALI_TEST_CHECK( field );
1529 Stage::GetCurrent().Add( field );
1531 field.SetSize( 300.f, 50.f );
1532 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1533 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1535 // Avoid a crash when core load gl resources.
1536 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1538 // Render and notify
1539 application.SendNotification();
1540 application.Render();
1542 // Add a key event but as the text field has not the focus it should do nothing.
1543 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1545 // Render and notify
1546 application.SendNotification();
1547 application.Render();
1549 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1551 // Create a tap event to touch the text field.
1552 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1553 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1555 // Render and notify
1556 application.SendNotification();
1557 application.Render();
1559 // Now the text field has the focus, so it can handle the key events.
1560 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1561 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1563 // Render and notify
1564 application.SendNotification();
1565 application.Render();
1567 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1569 // Create a second text field and send key events to it.
1570 TextField field2 = TextField::New();
1572 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1573 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1574 field2.SetSize( 100.f, 100.f );
1575 field2.SetPosition( 100.f, 100.f );
1577 Stage::GetCurrent().Add( field2 );
1579 // Render and notify
1580 application.SendNotification();
1581 application.Render();
1583 // Create a tap event on the second text field.
1584 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1585 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1587 // Render and notify
1588 application.SendNotification();
1589 application.Render();
1591 // The second text field has the focus. It should handle the key events.
1592 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1593 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1595 // Render and notify
1596 application.SendNotification();
1597 application.Render();
1599 // Check the text has been added to the second text field.
1600 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1605 int utcDaliTextFieldEvent02(void)
1607 ToolkitTestApplication application;
1608 tet_infoline(" utcDaliTextFieldEvent02");
1610 // Checks if the right number of actors are created.
1612 TextField field = TextField::New();
1613 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1614 DALI_TEST_CHECK( field );
1615 LoadMarkerImages(application, field);
1617 Stage::GetCurrent().Add( field );
1619 field.SetSize( 300.f, 50.f );
1620 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1621 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1623 // Avoid a crash when core load gl resources.
1624 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1626 // Render and notify
1627 application.SendNotification();
1628 application.Render();
1630 // Check there are the expected number of children ( stencil ).
1631 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1633 Actor stencil = field.GetChildAt( 0u );
1634 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1636 // Create a tap event to touch the text field.
1637 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1638 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1640 // Render and notify
1641 application.SendNotification();
1642 application.Render();
1644 Actor layer = field.GetChildAt( 1u );
1645 DALI_TEST_CHECK( layer.IsLayer() );
1647 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1648 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1650 // Now the text field has the focus, so it can handle the key events.
1651 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1652 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1654 // Render and notify
1655 application.SendNotification();
1656 application.Render();
1658 // Checks the cursor and the renderer have been created.
1659 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1660 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1662 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1663 DALI_TEST_CHECK( cursor );
1665 // The offscreen root actor has a container with all the actors which contain the text renderers.
1666 Actor container = stencil.GetChildAt( 0u );
1667 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1669 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1670 DALI_TEST_CHECK( renderer );
1673 // Move the cursor and check the position changes.
1674 Vector3 position1 = cursor.GetCurrentPosition();
1676 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1677 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1679 // Render and notify
1680 application.SendNotification();
1681 application.Render();
1683 Vector3 position2 = cursor.GetCurrentPosition();
1685 DALI_TEST_CHECK( position2.x < position1.x );
1687 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1688 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 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 position3 = cursor.GetCurrentPosition();
1696 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1698 // Send some taps and check the cursor positions.
1700 // Try to tap at the beginning.
1701 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1702 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1704 // Render and notify
1705 application.SendNotification();
1706 application.Render();
1708 // Cursor position should be the same than position1.
1709 Vector3 position4 = cursor.GetCurrentPosition();
1711 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1713 // Tap away from the start position.
1714 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1715 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1717 // Render and notify
1718 application.SendNotification();
1719 application.Render();
1721 Vector3 position5 = cursor.GetCurrentPosition();
1723 DALI_TEST_CHECK( position5.x > position4.x );
1725 // Remove all the text.
1726 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1727 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1728 field.SetProperty( TextField::Property::TEXT, "" );
1730 // Render and notify
1731 application.SendNotification();
1732 application.Render();
1734 // Cursor position should be the same than position2.
1735 Vector3 position6 = cursor.GetCurrentPosition();
1737 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1739 // Should not be a renderer.
1740 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1742 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1743 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1744 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1746 application.SendNotification();
1747 application.Render();
1749 // There are renderer and decorator layer
1750 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1755 int utcDaliTextFieldEvent03(void)
1757 ToolkitTestApplication application;
1758 tet_infoline(" utcDaliTextFieldEvent03");
1760 // Checks if the highlight actor is created.
1762 TextField field = TextField::New();
1763 DALI_TEST_CHECK( field );
1765 Stage::GetCurrent().Add( field );
1767 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1768 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1769 field.SetSize( 30.f, 50.f );
1770 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1771 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1773 // Avoid a crash when core load gl resources.
1774 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1775 LoadMarkerImages(application, field);
1777 // Render and notify
1778 application.SendNotification();
1779 application.Render();
1781 // Tap first to get the focus.
1782 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1783 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1785 // Render and notify
1786 application.SendNotification();
1787 application.Render();
1789 // Double tap to select a word.
1790 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1791 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1793 // Render and notify
1794 application.SendNotification();
1795 application.Render();
1797 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1798 Actor stencil = field.GetChildAt( 0u );
1800 // The highlight actor is drawn first, so is the first actor in the list
1801 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1802 DALI_TEST_CHECK( highlight );
1804 // The offscreen root actor has a container with all the actors which contain the text renderers.
1805 Actor container = stencil.GetChildAt( 1u );
1806 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1808 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1809 DALI_TEST_CHECK( renderer );
1815 int utcDaliTextFieldEvent04(void)
1817 ToolkitTestApplication application;
1818 tet_infoline(" utcDaliTextFieldEvent04");
1820 // Checks if the highlight actor is created.
1822 TextField field = TextField::New();
1823 DALI_TEST_CHECK( field );
1824 Stage::GetCurrent().Add( field );
1825 LoadMarkerImages(application, field);
1826 // Render and notify
1827 application.SendNotification();
1828 application.Render();
1830 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1831 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1832 field.SetSize( 300.f, 50.f );
1833 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1834 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1836 // Avoid a crash when core load gl resources.
1837 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1838 // Render and notify
1839 application.SendNotification();
1840 application.Render();
1842 // Create a tap event to touch the text field.
1843 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1844 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1845 // Render and notify
1846 application.SendNotification();
1847 application.Render();
1850 // Tap first to get the focus.
1851 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1852 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1854 // Render and notify
1855 application.SendNotification();
1856 application.Render();
1858 // Double tap to select a word.
1859 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1860 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1862 // Render and notify
1863 application.SendNotification();
1864 application.Render();
1867 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1868 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1872 int utcDaliTextFieldEvent05(void)
1874 ToolkitTestApplication application;
1875 tet_infoline(" utcDaliTextFieldEvent05");
1877 // Checks dragging of cursor/grab handle
1879 TextField field = TextField::New();
1880 DALI_TEST_CHECK( field );
1881 Stage::GetCurrent().Add( field );
1882 LoadMarkerImages(application, field);
1883 // Render and notify
1884 application.SendNotification();
1885 application.Render();
1887 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1888 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1889 field.SetSize( 300.f, 50.f );
1890 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1891 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1893 // Avoid a crash when core load gl resources.
1894 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1895 // Render and notify
1896 application.SendNotification();
1897 application.Render();
1899 // Create a tap event to touch the text field.
1900 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1901 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1902 // Render and notify
1903 application.SendNotification();
1904 application.Render();
1907 // Tap first to get the focus.
1908 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1909 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1911 // Render and notify
1912 application.SendNotification();
1913 application.Render();
1915 // Double tap to select a word.
1916 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1917 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1919 // Render and notify
1920 application.SendNotification();
1921 application.Render();
1923 // drag grab handle right
1924 Vector2 pos(0.0f, 40.0f);
1925 SendPan(application, Gesture::Possible, pos);
1926 SendPan(application, Gesture::Started, pos);
1928 Wait(application, 100);
1930 for(int i = 0;i<20;i++)
1932 SendPan(application, Gesture::Continuing, pos);
1937 SendPan(application, Gesture::Finished, pos);
1938 Wait(application, RENDER_FRAME_INTERVAL);
1940 Actor stencil = field.GetChildAt( 1u );
1944 int utcDaliTextFieldEvent06(void)
1946 ToolkitTestApplication application;
1947 tet_infoline(" utcDaliTextFieldEvent06");
1949 // Checks Longpress when in edit mode
1951 TextField field = TextField::New();
1952 DALI_TEST_CHECK( field );
1953 Stage::GetCurrent().Add( field );
1954 LoadMarkerImages(application, field);
1955 // Render and notify
1956 application.SendNotification();
1957 application.Render();
1959 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1960 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1961 field.SetSize( 300.f, 50.f );
1962 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1963 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1965 // Avoid a crash when core load gl resources.
1966 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1967 // Render and notify
1968 application.SendNotification();
1969 application.Render();
1971 // Create a tap event to touch the text field.
1972 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1973 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1974 // Render and notify
1975 application.SendNotification();
1976 application.Render();
1979 // Tap first to get the focus.
1980 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1981 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1983 // Render and notify
1984 application.SendNotification();
1985 application.Render();
1988 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1989 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1991 // Render and notify
1992 application.SendNotification();
1993 application.Render();
1998 int utcDaliTextFieldEvent07(void)
2000 ToolkitTestApplication application;
2001 tet_infoline(" utcDaliTextFieldEvent07");
2003 // Checks Longpress to start edit mode
2005 TextField field = TextField::New();
2006 DALI_TEST_CHECK( field );
2007 Stage::GetCurrent().Add( field );
2008 LoadMarkerImages(application, field);
2009 // Render and notify
2010 application.SendNotification();
2011 application.Render();
2013 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2014 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2015 field.SetSize( 300.f, 50.f );
2016 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2017 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2018 Property::Map propertyMap;
2019 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2020 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2022 // Avoid a crash when core load gl resources.
2023 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2024 // Render and notify
2025 application.SendNotification();
2026 application.Render();
2029 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2030 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2032 // Render and notify
2033 application.SendNotification();
2034 application.Render();
2039 int utcDaliTextFieldEvent08(void)
2041 ToolkitTestApplication application;
2042 tet_infoline(" utcDaliTextFieldEvent08");
2044 Dali::Clipboard clipboard = Clipboard::Get();
2045 clipboard.SetItem("testTextFieldEvent");
2047 // Checks Longpress when only place holder text
2049 TextField field = TextField::New();
2050 DALI_TEST_CHECK( field );
2051 Stage::GetCurrent().Add( field );
2052 LoadMarkerImages(application, field);
2053 // Render and notify
2054 application.SendNotification();
2055 application.Render();
2057 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2058 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2059 field.SetSize( 300.f, 50.f );
2060 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2061 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2063 // Avoid a crash when core load gl resources.
2064 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2065 // Render and notify
2066 application.SendNotification();
2067 application.Render();
2070 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2071 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2073 // Render and notify
2074 application.SendNotification();
2075 application.Render();
2077 Wait(application, 500);
2080 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2081 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2083 // Render and notify
2084 application.SendNotification();
2085 application.Render();
2087 Wait(application, 500);
2089 Stage stage = Stage::GetCurrent();
2090 Layer layer = stage.GetRootLayer();
2091 Actor actor = layer.FindChildByName("optionPaste");
2095 Vector3 worldPosition = actor.GetCurrentWorldPosition();
2096 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2097 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2099 Dali::Integration::TouchEvent event;
2100 event = Dali::Integration::TouchEvent();
2101 event.AddPoint( GetPointDownInside( position ) );
2102 application.ProcessEvent( event );
2104 event = Dali::Integration::TouchEvent();
2105 event.AddPoint( GetPointUpInside( position ) );
2106 application.ProcessEvent( event );
2108 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2113 int utcDaliTextFieldEvent09(void)
2115 ToolkitTestApplication application;
2116 tet_infoline(" utcDaliTextFieldEvent09");
2118 TextField field = TextField::New();
2119 DALI_TEST_CHECK( field );
2120 Stage::GetCurrent().Add( field );
2121 LoadMarkerImages(application, field);
2122 // Render and notify
2123 application.SendNotification();
2124 application.Render();
2126 field.SetProperty( TextField::Property::TEXT, "Hello" );
2127 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2128 field.SetSize( 300.f, 50.f );
2129 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2130 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2132 // Avoid a crash when core load gl resources.
2133 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2135 // Create a tap event to touch the text field.
2136 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2137 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2138 application.SendNotification();
2139 application.Render();
2142 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2143 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2144 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2145 application.SendNotification();
2146 application.Render();
2148 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2149 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2150 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2151 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2152 application.SendNotification();
2153 application.Render();
2155 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2156 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2157 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2158 for( unsigned int index = 0u; index < 5u; ++index )
2160 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2161 application.SendNotification();
2162 application.Render();
2165 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2166 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2167 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2168 for( unsigned int index = 0u; index < 5u; ++index )
2170 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2171 application.SendNotification();
2172 application.Render();
2175 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2176 map[ HiddenInput::Property::SHOW_DURATION ] = 0;
2177 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2178 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2179 application.SendNotification();
2180 application.Render();
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();
2185 map[ HiddenInput::Property::SHOW_DURATION ] = 100;
2186 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2187 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2188 application.SendNotification();
2189 application.Render();
2191 Property::Map mapGet;
2192 mapGet = field.GetProperty<Property::Map>( DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
2193 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2194 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2199 int utcDaliTextFieldStyleWhilstSelected(void)
2201 ToolkitTestApplication application;
2202 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2204 // Change font and styles whilst text is selected whilst word selected
2206 TextField field = TextField::New();
2207 DALI_TEST_CHECK( field );
2208 Stage::GetCurrent().Add( field );
2209 LoadMarkerImages(application, field);
2210 // Render and notify
2211 application.SendNotification();
2212 application.Render();
2214 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2215 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2216 field.SetSize( 300.f, 50.f );
2217 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2218 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2220 // Avoid a crash when core load gl resources.
2221 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2222 // Render and notify
2223 application.SendNotification();
2224 application.Render();
2226 // Create a tap event to touch the text field.
2227 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2228 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2229 // Render and notify
2230 application.SendNotification();
2231 application.Render();
2234 // Tap first to get the focus.
2235 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2236 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2238 // Render and notify
2239 application.SendNotification();
2240 application.Render();
2242 // Double tap to select a word.
2243 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2244 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2246 // Render and notify
2247 application.SendNotification();
2248 application.Render();
2250 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2251 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2253 Property::Map fontStyleMapSet;
2254 Property::Map fontStyleMapGet;
2256 fontStyleMapSet.Insert( "weight", "bold" );
2257 fontStyleMapSet.Insert( "slant", "italic" );
2258 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2260 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2261 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2262 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2264 fontStyleMapSet.Clear();
2265 fontStyleMapSet.Insert( "width", "expanded" );
2266 fontStyleMapSet.Insert( "slant", "italic" );
2267 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2269 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2270 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2271 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2273 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2274 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2276 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2277 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2279 fontStyleMapSet.Clear();
2280 fontStyleMapSet.Insert( "weight", "bold" );
2281 fontStyleMapSet.Insert( "slant", "italic" );
2283 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2285 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2286 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2287 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2289 fontStyleMapSet.Clear();
2290 fontStyleMapSet.Insert( "width", "expanded" );
2292 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2294 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2295 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2296 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2298 // Press Escape to increase coverage
2299 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2300 application.SendNotification();
2301 application.Render();
2303 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2308 int utcDaliTextFieldEscKeyLoseFocus(void)
2310 ToolkitTestApplication application;
2311 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2313 // Creates a tap event. After creating a tap event the text field should
2314 // have the focus and add text with key events should be possible.
2316 TextField field = TextField::New();
2317 DALI_TEST_CHECK( field );
2319 Stage::GetCurrent().Add( field );
2321 field.SetSize( 300.f, 50.f );
2322 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2323 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2325 // Avoid a crash when core load gl resources.
2326 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2328 // Render and notify
2329 application.SendNotification();
2330 application.Render();
2332 // Add a key event but as the text field has not the focus it should do nothing.
2333 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2334 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2336 // Render and notify
2337 application.SendNotification();
2338 application.Render();
2340 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2342 // Create a tap event to touch the text field.
2343 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2344 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2346 // Render and notify
2347 application.SendNotification();
2348 application.Render();
2350 // Now the text field has the focus, so it can handle the key events.
2351 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2352 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2353 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2354 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2356 // Render and notify
2357 application.SendNotification();
2358 application.Render();
2360 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2362 // Generate a Esc key event. The text field should lose the focus.
2363 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2364 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2366 // Render and notify
2367 application.SendNotification();
2368 application.Render();
2370 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2372 // No more text should be introduced
2373 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2374 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2376 // Render and notify
2377 application.SendNotification();
2378 application.Render();
2380 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2385 int utcDaliTextFieldSomeSpecialKeys(void)
2387 ToolkitTestApplication application;
2388 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2390 // Checks some special keys when the text is selected.
2392 TextField field = TextField::New();
2393 DALI_TEST_CHECK( field );
2394 Stage::GetCurrent().Add( field );
2395 LoadMarkerImages(application, field);
2396 // Render and notify
2397 application.SendNotification();
2398 application.Render();
2400 const std::string longText( "This is a long text for the size of the text-field." );
2402 field.SetProperty( TextField::Property::TEXT, longText );
2403 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2404 field.SetSize( 300.f, 50.f );
2405 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2406 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2408 // Avoid a crash when core load gl resources.
2409 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2410 // Render and notify
2411 application.SendNotification();
2412 application.Render();
2414 // Create a tap event to touch the text field.
2415 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2416 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2418 // Render and notify
2419 application.SendNotification();
2420 application.Render();
2422 // Tap first to get the focus.
2423 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2424 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2426 // Render and notify
2427 application.SendNotification();
2428 application.Render();
2430 // Double tap to select a word.
2431 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2432 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2434 // Render and notify
2435 application.SendNotification();
2436 application.Render();
2438 // Generate a Esc key event. The text field should lose the focus.
2439 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2440 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2442 // Render and notify
2443 application.SendNotification();
2444 application.Render();
2446 // Generate a Esc key event. The text field should lose the focus.
2447 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2448 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2450 // Render and notify
2451 application.SendNotification();
2452 application.Render();
2454 // Generate a Esc key event. The text field should lose the focus.
2455 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2456 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2458 // Render and notify
2459 application.SendNotification();
2460 application.Render();
2462 // The text shouldn't be deleted.
2463 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2468 int utcDaliTextFieldSizeUpdate(void)
2470 ToolkitTestApplication application;
2471 tet_infoline("utcDaliTextFieldSizeUpdate");
2473 // Checks some special keys when the text is selected.
2474 TextField field = TextField::New();
2475 DALI_TEST_CHECK( field );
2476 Stage::GetCurrent().Add( field );
2478 float previousHeight = 0.0f;
2479 float currentHeight = 0.0f;
2480 const float fieldWidth = 1920.0f;
2483 // "ㅁ" is bigger then "ኢ"
2484 field.SetSize( Vector2( fieldWidth ,10.0f ) );
2485 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2486 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2488 field.SetProperty( TextField::Property::TEXT, "ኢ");
2489 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2490 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2492 field.SetKeyboardFocusable(true);
2493 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2495 application.SendNotification();
2496 application.Render();
2498 previousHeight = field.GetHeightForWidth( fieldWidth );
2499 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2501 // Add another script characters ( glyph height is defferent )
2502 application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2503 application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
2505 application.SendNotification();
2506 application.Render();
2508 currentHeight = field.GetHeightForWidth( fieldWidth );
2509 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2510 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2515 int utcDaliTextFieldExtremlyLargePointSize(void)
2517 ToolkitTestApplication application;
2518 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2520 TextField field = TextField::New();
2522 field.SetProperty( TextField::Property::TEXT, "Text" );
2523 field.SetSize( 300.f, 50.f );
2524 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2525 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2526 Stage::GetCurrent().Add( field );
2530 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2531 application.SendNotification();
2532 DALI_TEST_CHECK( field );
2536 tet_result(TET_FAIL);
2541 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2543 ToolkitTestApplication application;
2544 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2545 TextField field = TextField::New();
2546 DALI_TEST_CHECK( field );
2547 Stage::GetCurrent().Add( field );
2549 Property::Map fontStyleMapGet;
2551 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2553 Property::Value* weightValue = NULL;
2554 Property::Value* widthValue = NULL;
2555 Property::Value* slantValue = NULL;
2556 weightValue = fontStyleMapGet.Find( "weight" );
2557 widthValue = fontStyleMapGet.Find( "width" );
2558 slantValue = fontStyleMapGet.Find( "slant" );
2559 DALI_TEST_CHECK( !weightValue );
2560 DALI_TEST_CHECK( !widthValue );
2561 DALI_TEST_CHECK( !slantValue );