2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali/public-api/rendering/renderer.h>
23 #include <dali/integration-api/events/key-event-integ.h>
24 #include <dali/integration-api/events/tap-gesture-event.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/integration-api/events/pan-gesture-event.h>
27 #include <dali/integration-api/events/long-press-gesture-event.h>
28 #include <dali-toolkit-test-suite-utils.h>
29 #include <dali-toolkit/dali-toolkit.h>
30 #include "toolkit-clipboard.h"
33 using namespace Toolkit;
35 void dali_textfield_startup(void)
37 test_return_value = TET_UNDEF;
40 void dali_textfield_cleanup(void)
42 test_return_value = TET_PASS;
48 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
49 const char* const PROPERTY_NAME_TEXT = "text";
50 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
51 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
52 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
53 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
54 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
55 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
56 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
57 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
58 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
59 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
60 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
61 const char* const PROPERTY_NAME_SHADOW_OFFSET = "shadowOffset";
62 const char* const PROPERTY_NAME_SHADOW_COLOR = "shadowColor";
63 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
64 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
65 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
66 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
67 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
68 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
69 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
70 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
71 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
72 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
73 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
80 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
81 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
82 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
83 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
84 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
85 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
86 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
88 const char* const PROPERTY_NAME_UNDERLINE = "underline";
89 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
90 const char* const PROPERTY_NAME_SHADOW = "shadow";
91 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
92 const char* const PROPERTY_NAME_EMBOSS = "emboss";
93 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
94 const char* const PROPERTY_NAME_OUTLINE = "outline";
95 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
97 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
98 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
99 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
100 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
101 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
103 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
105 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
106 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
108 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
109 const float RENDER_FRAME_INTERVAL = 16.66f;
111 const float TO_MILLISECONDS = 1000.f;
112 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
114 const float SCROLL_THRESHOLD = 10.f;
115 const float SCROLL_SPEED = 300.f;
117 const unsigned int DEFAULT_FONT_SIZE = 1152u;
118 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
120 const int KEY_A_CODE = 38;
121 const int KEY_D_CODE = 40;
123 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
125 static bool gTextChangedCallBackCalled;
126 static bool gMaxCharactersCallBackCalled;
127 static bool gInputStyleChangedCallbackCalled;
128 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
130 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
132 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
133 Integration::ResourcePointer resource(bitmap);
134 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
137 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
141 LoadBitmapResource( app.GetPlatform(), width, height );
143 Property::Map propertyMap;
144 propertyMap["filename"] = "image.png";
145 propertyMap["width"] = width;
146 propertyMap["height"] = height;
147 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
148 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
149 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
150 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
151 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
152 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
153 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
154 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
157 // Generate a PanGestureEvent to send to Core
158 static Integration::PanGestureEvent GeneratePan(
159 Gesture::State state,
160 const Vector2& previousPosition,
161 const Vector2& currentPosition,
162 unsigned long timeDelta,
163 unsigned int numberOfTouches = 1)
165 Integration::PanGestureEvent pan(state);
167 pan.previousPosition = previousPosition;
168 pan.currentPosition = currentPosition;
169 pan.timeDelta = timeDelta;
170 pan.numberOfTouches = numberOfTouches;
176 * Helper to generate PanGestureEvent
178 * @param[in] application Application instance
179 * @param[in] state The Gesture State
180 * @param[in] pos The current position of touch.
182 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
186 if( (state == Gesture::Started) ||
187 (state == Gesture::Possible) )
193 application.ProcessEvent(GeneratePan(state, last, pos, 16));
200 * Simulate time passed by.
202 * @note this will always process at least 1 frame (1/60 sec)
204 * @param application Test application instance
205 * @param duration Time to pass in milliseconds.
206 * @return The actual time passed in milliseconds
208 static int Wait(ToolkitTestApplication& application, int duration = 0)
212 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
214 application.SendNotification();
215 application.Render(RENDER_FRAME_INTERVAL);
216 time += RENDER_FRAME_INTERVAL;
222 Dali::Integration::Point GetPointDownInside( Vector2& pos )
224 Dali::Integration::Point point;
225 point.SetState( PointState::DOWN );
226 point.SetScreenPosition( pos );
230 Dali::Integration::Point GetPointUpInside( Vector2& pos )
232 Dali::Integration::Point point;
233 point.SetState( PointState::UP );
234 point.SetScreenPosition( pos );
238 struct CallbackFunctor
240 CallbackFunctor(bool* callbackFlag)
241 : mCallbackFlag( callbackFlag )
247 *mCallbackFlag = true;
252 static void TestTextChangedCallback( TextField control )
254 tet_infoline(" TestTextChangedCallback");
256 gTextChangedCallBackCalled = true;
259 static void TestMaxLengthReachedCallback( TextField control )
261 tet_infoline(" TestMaxLengthReachedCallback");
263 gMaxCharactersCallBackCalled = true;
266 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
268 tet_infoline(" TestInputStyleChangedCallback");
270 gInputStyleChangedCallbackCalled = true;
271 gInputStyleMask = mask;
274 // Generate a TapGestureEvent to send to Core.
275 Integration::TapGestureEvent GenerateTap(
276 Gesture::State state,
277 unsigned int numberOfTaps,
278 unsigned int numberOfTouches,
281 Integration::TapGestureEvent tap( state );
283 tap.numberOfTaps = numberOfTaps;
284 tap.numberOfTouches = numberOfTouches;
290 Integration::LongPressGestureEvent GenerateLongPress(
291 Gesture::State state,
292 unsigned int numberOfTouches,
295 Integration::LongPressGestureEvent longPress( state );
297 longPress.numberOfTouches = numberOfTouches;
298 longPress.point = point;
302 // Generate a KeyEvent to send to Core.
303 Integration::KeyEvent GenerateKey( const std::string& keyName,
304 const std::string& keyString,
307 unsigned long timeStamp,
308 const Integration::KeyEvent::State& keyState,
309 const std::string& deviceName = DEFAULT_DEVICE_NAME,
310 const Device::Class::Type& deviceClass = Device::Class::NONE,
311 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
313 return Integration::KeyEvent( keyName,
324 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
326 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
328 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
330 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
332 if( valueGet.first.type == Property::Key::STRING )
334 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
335 if( NULL != valueSet )
337 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
339 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
345 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
351 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
352 if( NULL != valueSet )
354 if( valueGet.second.Get<int>() != valueSet->Get<int>() )
356 tet_printf( " Integer Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
362 tet_printf( " The Int key %d doesn't exist.", valueGet.first.indexKey );
374 int UtcDaliToolkitTextFieldConstructorP(void)
376 ToolkitTestApplication application;
377 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
379 DALI_TEST_CHECK( !textField );
383 int UtcDaliToolkitTextFieldNewP(void)
385 ToolkitTestApplication application;
386 tet_infoline(" UtcDaliToolkitTextFieldNewP");
387 TextField textField = TextField::New();
388 DALI_TEST_CHECK( textField );
392 int UtcDaliToolkitTextFieldDownCastP(void)
394 ToolkitTestApplication application;
395 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
396 TextField textField1 = TextField::New();
397 BaseHandle object( textField1 );
399 TextField textField2 = TextField::DownCast( object );
400 DALI_TEST_CHECK( textField2 );
402 TextField textField3 = DownCast< TextField >( object );
403 DALI_TEST_CHECK( textField3 );
407 int UtcDaliToolkitTextFieldDownCastN(void)
409 ToolkitTestApplication application;
410 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
411 BaseHandle uninitializedObject;
412 TextField textField1 = TextField::DownCast( uninitializedObject );
413 DALI_TEST_CHECK( !textField1 );
415 TextField textField2 = DownCast< TextField >( uninitializedObject );
416 DALI_TEST_CHECK( !textField2 );
420 int UtcDaliToolkitTextFieldCopyConstructorP(void)
422 ToolkitTestApplication application;
423 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
424 TextField textField = TextField::New();
425 textField.SetProperty( TextField::Property::TEXT, "Test" );
427 TextField copy( textField );
428 DALI_TEST_CHECK( copy );
429 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
433 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
435 ToolkitTestApplication application;
436 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
437 TextField textField = TextField::New();
438 textField.SetProperty( TextField::Property::TEXT, "Test" );
440 TextField copy = textField;
441 DALI_TEST_CHECK( copy );
442 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
446 int UtcDaliTextFieldNewP(void)
448 ToolkitTestApplication application;
449 tet_infoline(" UtcDaliToolkitTextFieldNewP");
450 TextField textField = TextField::New();
451 DALI_TEST_CHECK( textField );
455 // Positive test case for a method
456 int UtcDaliTextFieldGetPropertyP(void)
458 ToolkitTestApplication application;
459 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
460 TextField field = TextField::New();
461 DALI_TEST_CHECK( field );
463 // Check Property Indices are correct
464 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
465 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
466 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
467 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
468 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
469 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
470 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
471 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
472 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
473 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
474 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
475 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
476 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
477 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextField::Property::SHADOW_OFFSET );
478 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextField::Property::SHADOW_COLOR );
479 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
480 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
481 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
482 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
483 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
484 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
485 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
486 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
487 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
488 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
489 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
490 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
491 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
492 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
493 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
494 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
495 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
496 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
497 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
498 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
499 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
500 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
501 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
502 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
503 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
504 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
505 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
506 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
507 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
508 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
509 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
510 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
511 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
512 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
513 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
514 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
515 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
520 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
523 Property::Map imageMap;
524 imageMap[mapKey] =mapValue;
526 field.SetProperty( property , imageMap );
527 Property::Value propValue = field.GetProperty( property );
528 Property::Map* resultMap = propValue.GetMap();
530 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
538 // Positive test case for a method
539 int UtcDaliTextFieldSetPropertyP(void)
541 ToolkitTestApplication application;
542 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
543 TextField field = TextField::New();
544 DALI_TEST_CHECK( field );
545 Stage::GetCurrent().Add( field );
547 // Note - we can't check the defaults since the stylesheets are platform-specific
549 // Check the render backend property.
550 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
551 DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
553 // Check text property.
554 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
555 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
557 // Check placeholder text properties.
558 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
559 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
561 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
562 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
564 // Check font properties.
565 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
566 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
568 Property::Map fontStyleMapSet;
569 Property::Map fontStyleMapGet;
570 Property::Value* slantValue = NULL;
572 fontStyleMapSet.Insert( "weight", "bold" );
573 fontStyleMapSet.Insert( "width", "condensed" );
574 fontStyleMapSet.Insert( "slant", "italic" );
575 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
577 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
578 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
579 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
581 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
582 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
585 fontStyleMapSet.Clear();
586 fontStyleMapSet.Insert( "weight", "normal" );
587 fontStyleMapSet.Insert( "slant", "oblique" );
588 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
590 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
591 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
592 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
594 fontStyleMapSet.Clear();
595 fontStyleMapSet.Insert( "slant", "roman" );
596 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
597 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
599 // Replace 'roman' for 'normal'.
600 slantValue = fontStyleMapGet.Find( "slant" );
601 if( NULL != slantValue )
603 if( "normal" == slantValue->Get<std::string>() )
605 fontStyleMapGet["slant"] = "roman";
608 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
609 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
611 fontStyleMapSet.Clear();
613 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
614 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
615 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
616 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
618 // Check that the MAX_LENGTH property can be correctly set
619 const int maxNumberOfCharacters = 20;
620 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
621 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
623 // Check exceed policy
624 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
625 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
626 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
627 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
629 // Check that the Alignment properties can be correctly set
630 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
631 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
632 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
633 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
635 // Check text's color property
636 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
637 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
639 // Check placeholder text's color property.
640 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
641 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
643 // Check shadow properties.
644 field.SetProperty( TextField::Property::SHADOW_OFFSET, Vector2( 1.f, 1.f ) );
645 DALI_TEST_EQUALS( field.GetProperty<Vector2>( TextField::Property::SHADOW_OFFSET ), Vector2( 1.f, 1.f ), TEST_LOCATION );
646 field.SetProperty( TextField::Property::SHADOW_COLOR, Color::GREEN );
647 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SHADOW_COLOR ), Color::GREEN, TEST_LOCATION );
649 // Check cursor properties
650 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
651 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
652 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
653 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
655 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
656 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
657 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
658 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
659 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
660 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
661 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
662 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
664 // Check scroll properties.
665 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
666 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
667 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
668 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
670 // Check handle images
671 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
672 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
673 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
674 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
675 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
677 // Check handle images
678 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
679 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
680 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
681 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
682 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
683 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
685 // Check the highlight color
686 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
687 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
689 // Decoration bounding box
690 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
691 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
693 // Check the input method setting
694 Property::Map propertyMap;
695 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
696 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
697 InputMethod::ActionButtonTitle::Type actionButton = InputMethod::ActionButtonTitle::GO;
698 int inputVariation = 1;
699 propertyMap["PANEL_LAYOUT"] = panelLayout;
700 propertyMap["AUTO_CAPITALISE"] = autoCapital;
701 propertyMap["ACTION_BUTTON"] = actionButton;
702 propertyMap["VARIATION"] = inputVariation;
703 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
705 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
707 DALI_TEST_CHECK( value.Get( map ) );
710 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
711 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
714 DALI_TEST_CHECK( map[ "AUTO_CAPITALISE" ].Get( capital ) );
715 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
718 DALI_TEST_CHECK( map[ "ACTION_BUTTON" ].Get( action ) );
719 DALI_TEST_EQUALS( static_cast<int>(actionButton), action, TEST_LOCATION );
722 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
723 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
725 // Check input color property.
726 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
727 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
729 // Check the enable markup property.
730 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
731 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
732 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
734 // Check input font properties.
735 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
736 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
738 fontStyleMapSet.Clear();
739 fontStyleMapSet.Insert( "weight", "bold" );
740 fontStyleMapSet.Insert( "width", "condensed" );
741 fontStyleMapSet.Insert( "slant", "italic" );
743 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
744 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
745 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
746 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
748 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
749 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
751 // Reset input font style.
752 fontStyleMapSet.Clear();
753 fontStyleMapSet.Insert( "weight", "normal" );
754 fontStyleMapSet.Insert( "slant", "oblique" );
756 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
757 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
758 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
759 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
761 fontStyleMapSet.Clear();
762 fontStyleMapSet.Insert( "slant", "roman" );
764 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
765 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
767 // Replace 'roman' for 'normal'.
768 slantValue = fontStyleMapGet.Find( "slant" );
769 if( NULL != slantValue )
771 if( "normal" == slantValue->Get<std::string>() )
773 fontStyleMapGet["slant"] = "roman";
776 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
777 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
779 fontStyleMapSet.Clear();
781 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
782 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
783 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
784 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
786 Property::Map underlineMapSet;
787 Property::Map underlineMapGet;
789 underlineMapSet.Insert( "enable", "true" );
790 underlineMapSet.Insert( "color", "red" );
791 underlineMapSet.Insert( "height", "1" );
793 // Check the underline property
794 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
796 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
797 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
798 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
800 // Check the input underline property
801 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
802 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
804 // Check the shadow property
805 Property::Map shadowMapSet;
806 Property::Map shadowMapGet;
808 shadowMapSet.Insert( "color", "green" );
809 shadowMapSet.Insert( "offset", "2 2" );
811 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
813 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
814 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
815 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
817 // Check the input shadow property
818 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
819 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
821 // Check the emboss property
822 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
823 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
825 // Check the input emboss property
826 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
827 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
829 // Check the outline property
831 // Test string type first
832 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
833 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
834 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
836 // Then test the property map type
837 Property::Map outlineMapSet;
838 Property::Map outlineMapGet;
840 outlineMapSet["color"] = Color::RED;
841 outlineMapSet["width"] = 2.0f;
843 field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
845 outlineMapSet["color"] = "red";
846 outlineMapSet["width"] = "2";
847 outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
848 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
849 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
851 // Check the input outline property
852 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
853 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
855 // Check the hidden input settings property
856 Property::Map hiddenMapSet;
857 Property::Map hiddenMapGet;
858 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
859 hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
860 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
861 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
862 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
864 hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
865 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
866 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
868 // Check the pixel size of font
869 field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
870 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
872 // Check the enable selection property
873 field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
874 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
876 // Check the placeholder property with pixel size
877 Property::Map placeholderPixelSizeMapSet;
878 Property::Map placeholderPixelSizeMapGet;
879 Property::Map placeholderFontstyleMap;
880 placeholderPixelSizeMapSet["placeholderText"] = "Setting Placeholder Text";
881 placeholderPixelSizeMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused";
882 placeholderPixelSizeMapSet["placeholderColor"] = Color::BLUE;
883 placeholderPixelSizeMapSet["placeholderFontFamily"] = "Arial";
884 placeholderPixelSizeMapSet["placeholderPixelSize"] = 15.0f;
885 placeholderPixelSizeMapSet["placeholderEllipsis"] = true;
887 placeholderFontstyleMap.Insert( "weight", "bold" );
888 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
889 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
891 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
892 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
893 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
895 // Check the placeholder property with point size
896 Property::Map placeholderMapSet;
897 Property::Map placeholderMapGet;
898 placeholderMapSet["placeholderText"] = "Setting Placeholder Text";
899 placeholderMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused";
900 placeholderMapSet["placeholderColor"] = Color::RED;
901 placeholderMapSet["placeholderFontFamily"] = "Arial";
902 placeholderMapSet["placeholderPointSize"] = 12.0f;
903 placeholderMapSet["placeholderEllipsis"] = false;
905 // Check the placeholder font style property
906 placeholderFontstyleMap.Clear();
908 placeholderFontstyleMap.Insert( "weight", "bold" );
909 placeholderFontstyleMap.Insert( "width", "condensed" );
910 placeholderFontstyleMap.Insert( "slant", "italic" );
911 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
912 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
914 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
915 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
916 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
919 placeholderFontstyleMap.Clear();
920 placeholderFontstyleMap.Insert( "weight", "normal" );
921 placeholderFontstyleMap.Insert( "slant", "oblique" );
922 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
923 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
925 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
926 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
927 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
929 placeholderFontstyleMap.Clear();
930 placeholderFontstyleMap.Insert( "slant", "roman" );
931 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
932 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
934 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
936 placeholderFontstyleMap.Clear();
937 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
939 field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
940 placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
941 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
942 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
944 // Check the ellipsis property
945 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
946 field.SetProperty( TextField::Property::ELLIPSIS, true );
947 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
952 // Positive Atlas Text Renderer test
953 int utcDaliTextFieldAtlasRenderP(void)
955 ToolkitTestApplication application;
956 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
957 StyleManager styleManager = StyleManager::Get();
958 styleManager.ApplyDefaultTheme();
959 TextField field = TextField::New();
960 DALI_TEST_CHECK( field );
962 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
964 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
966 Stage::GetCurrent().Add( field );
970 // Render some text with the shared atlas backend
971 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
972 application.SendNotification();
973 application.Render();
977 tet_result(TET_FAIL);
982 // Positive test for the textChanged signal.
983 int utcDaliTextFieldTextChangedP(void)
985 ToolkitTestApplication application;
986 tet_infoline(" utcDaliTextFieldTextChangedP");
987 TextField field = TextField::New();
988 DALI_TEST_CHECK( field );
990 Stage::GetCurrent().Add( field );
992 // connect to the text changed signal.
993 ConnectionTracker* testTracker = new ConnectionTracker();
994 field.TextChangedSignal().Connect(&TestTextChangedCallback);
995 bool textChangedSignal = false;
996 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
998 gTextChangedCallBackCalled = false;
999 field.SetProperty( TextField::Property::TEXT, "ABC" );
1000 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1001 DALI_TEST_CHECK( textChangedSignal );
1003 application.SendNotification();
1005 field.SetKeyInputFocus();
1007 gTextChangedCallBackCalled = false;
1008 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1009 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1014 // Negative test for the textChanged signal.
1015 int utcDaliTextFieldTextChangedN(void)
1017 ToolkitTestApplication application;
1018 tet_infoline(" utcDaliTextFieldTextChangedN");
1019 TextField field = TextField::New();
1020 DALI_TEST_CHECK( field );
1022 Stage::GetCurrent().Add( field );
1024 // connect to the text changed signal.
1025 ConnectionTracker* testTracker = new ConnectionTracker();
1026 field.TextChangedSignal().Connect(&TestTextChangedCallback);
1027 bool textChangedSignal = false;
1028 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1030 gTextChangedCallBackCalled = false;
1031 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1032 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1033 DALI_TEST_CHECK( !textChangedSignal );
1038 // Positive test for Max Characters reached signal.
1039 int utcDaliTextFieldMaxCharactersReachedP(void)
1041 ToolkitTestApplication application;
1042 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1043 TextField field = TextField::New();
1044 DALI_TEST_CHECK( field );
1046 Stage::GetCurrent().Add( field );
1048 const int maxNumberOfCharacters = 1;
1049 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1051 field.SetKeyInputFocus();
1053 // connect to the text changed signal.
1054 ConnectionTracker* testTracker = new ConnectionTracker();
1055 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1056 bool maxLengthReachedSignal = false;
1057 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1059 gMaxCharactersCallBackCalled = false;
1061 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1062 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1064 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1065 DALI_TEST_CHECK( maxLengthReachedSignal );
1070 // Negative test for Max Characters reached signal.
1071 int utcDaliTextFieldMaxCharactersReachedN(void)
1073 ToolkitTestApplication application;
1074 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1075 TextField field = TextField::New();
1076 DALI_TEST_CHECK( field );
1078 Stage::GetCurrent().Add( field );
1080 const int maxNumberOfCharacters = 3;
1081 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1083 field.SetKeyInputFocus();
1085 // connect to the text changed signal.
1086 ConnectionTracker* testTracker = new ConnectionTracker();
1087 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1088 bool maxLengthReachedSignal = false;
1089 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1091 gMaxCharactersCallBackCalled = false;
1093 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1094 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1096 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1097 DALI_TEST_CHECK( !maxLengthReachedSignal );
1102 int utcDaliTextFieldInputStyleChanged01(void)
1104 ToolkitTestApplication application;
1105 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1107 // The text-field emits signals when the input style changes. These changes of style are
1108 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1109 // can't be emitted during the size negotiation as the callbacks may update the UI.
1110 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1111 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1112 application.CreateAdaptor();
1116 char* pathNamePtr = get_current_dir_name();
1117 const std::string pathName( pathNamePtr );
1118 free( pathNamePtr );
1120 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1121 fontClient.SetDpi( 93u, 93u );
1123 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1124 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1126 TextField field = TextField::New();
1127 DALI_TEST_CHECK( field );
1130 field.SetSize( 300.f, 50.f );
1131 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1132 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1134 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1135 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1137 // connect to the text changed signal.
1138 ConnectionTracker* testTracker = new ConnectionTracker();
1139 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1140 bool inputStyleChangedSignal = false;
1141 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1143 Stage::GetCurrent().Add( field );
1145 // Render and notify
1146 application.SendNotification();
1147 application.Render();
1149 // Executes the idle callbacks added by the text control on the change of input style.
1150 application.RunIdles();
1152 gInputStyleChangedCallbackCalled = false;
1153 gInputStyleMask = TextField::InputStyle::NONE;
1154 inputStyleChangedSignal = false;
1156 // Create a tap event to touch the text field.
1157 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1158 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1160 // Render and notify
1161 application.SendNotification();
1162 application.Render();
1164 // Executes the idle callbacks added by the text control on the change of input style.
1165 application.RunIdles();
1167 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1168 if( gInputStyleChangedCallbackCalled )
1170 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1172 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1173 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1175 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1176 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1178 DALI_TEST_CHECK( inputStyleChangedSignal );
1180 gInputStyleChangedCallbackCalled = false;
1181 gInputStyleMask = TextField::InputStyle::NONE;
1182 inputStyleChangedSignal = false;
1184 // Create a tap event to touch the text field.
1185 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1186 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1188 // Render and notify
1189 application.SendNotification();
1190 application.Render();
1192 // Executes the idle callbacks added by the text control on the change of input style.
1193 application.RunIdles();
1195 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1196 DALI_TEST_CHECK( !inputStyleChangedSignal );
1198 gInputStyleChangedCallbackCalled = false;
1199 gInputStyleMask = TextField::InputStyle::NONE;
1200 inputStyleChangedSignal = false;
1202 // Create a tap event to touch the text field.
1203 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1204 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1206 // Render and notify
1207 application.SendNotification();
1208 application.Render();
1210 // Executes the idle callbacks added by the text control on the change of input style.
1211 application.RunIdles();
1213 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1214 if( gInputStyleChangedCallbackCalled )
1216 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1218 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1219 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1221 DALI_TEST_CHECK( inputStyleChangedSignal );
1223 gInputStyleChangedCallbackCalled = false;
1224 gInputStyleMask = TextField::InputStyle::NONE;
1225 inputStyleChangedSignal = false;
1227 // Create a tap event to touch the text field.
1228 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1229 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1231 // Render and notify
1232 application.SendNotification();
1233 application.Render();
1235 // Executes the idle callbacks added by the text control on the change of input style.
1236 application.RunIdles();
1238 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1239 if( gInputStyleChangedCallbackCalled )
1241 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1243 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1244 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1246 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1248 Property::Map fontStyleMapSet;
1249 fontStyleMapSet.Insert( "weight", "bold" );
1251 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1252 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1254 DALI_TEST_CHECK( inputStyleChangedSignal );
1256 gInputStyleChangedCallbackCalled = false;
1257 gInputStyleMask = TextField::InputStyle::NONE;
1258 inputStyleChangedSignal = false;
1260 // Create a tap event to touch the text field.
1261 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1262 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1264 // Render and notify
1265 application.SendNotification();
1266 application.Render();
1268 // Executes the idle callbacks added by the text control on the change of input style.
1269 application.RunIdles();
1271 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1272 DALI_TEST_CHECK( !inputStyleChangedSignal );
1274 gInputStyleChangedCallbackCalled = false;
1275 gInputStyleMask = TextField::InputStyle::NONE;
1276 inputStyleChangedSignal = false;
1278 // Create a tap event to touch the text field.
1279 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1280 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1282 // Render and notify
1283 application.SendNotification();
1284 application.Render();
1286 // Executes the idle callbacks added by the text control on the change of input style.
1287 application.RunIdles();
1289 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1290 if( gInputStyleChangedCallbackCalled )
1292 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1294 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1295 DALI_TEST_CHECK( style.empty() );
1297 DALI_TEST_CHECK( inputStyleChangedSignal );
1299 gInputStyleChangedCallbackCalled = false;
1300 gInputStyleMask = TextField::InputStyle::NONE;
1301 inputStyleChangedSignal = false;
1303 // Create a tap event to touch the text field.
1304 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1305 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1307 // Render and notify
1308 application.SendNotification();
1309 application.Render();
1311 // Executes the idle callbacks added by the text control on the change of input style.
1312 application.RunIdles();
1314 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1315 DALI_TEST_CHECK( !inputStyleChangedSignal );
1320 int utcDaliTextFieldInputStyleChanged02(void)
1322 ToolkitTestApplication application;
1323 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1325 // The text-field emits signals when the input style changes. These changes of style are
1326 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1327 // can't be emitted during the size negotiation as the callbacks may update the UI.
1328 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1329 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1330 application.CreateAdaptor();
1334 char* pathNamePtr = get_current_dir_name();
1335 const std::string pathName( pathNamePtr );
1336 free( pathNamePtr );
1338 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1339 fontClient.SetDpi( 93u, 93u );
1341 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1342 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1344 TextField field = TextField::New();
1345 DALI_TEST_CHECK( field );
1348 field.SetSize( 300.f, 50.f );
1349 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1350 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1352 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1353 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>" );
1355 // connect to the text changed signal.
1356 ConnectionTracker* testTracker = new ConnectionTracker();
1357 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1358 bool inputStyleChangedSignal = false;
1359 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1361 Stage::GetCurrent().Add( field );
1363 // Render and notify
1364 application.SendNotification();
1365 application.Render();
1367 // Executes the idle callbacks added by the text control on the change of input style.
1368 application.RunIdles();
1370 gInputStyleChangedCallbackCalled = false;
1371 gInputStyleMask = TextField::InputStyle::NONE;
1372 inputStyleChangedSignal = false;
1374 // Create a tap event to touch the text field.
1375 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1376 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1377 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1378 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1380 // Render and notify
1381 application.SendNotification();
1382 application.Render();
1384 // Executes the idle callbacks added by the text control on the change of input style.
1385 application.RunIdles();
1387 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1388 if( gInputStyleChangedCallbackCalled )
1390 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1391 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1392 TextField::InputStyle::POINT_SIZE |
1393 TextField::InputStyle::COLOR ),
1396 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1397 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1399 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1400 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1402 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1403 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1405 DALI_TEST_CHECK( inputStyleChangedSignal );
1407 gInputStyleChangedCallbackCalled = false;
1408 gInputStyleMask = TextField::InputStyle::NONE;
1409 inputStyleChangedSignal = false;
1411 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1413 // Render and notify
1414 application.SendNotification();
1415 application.Render();
1417 // Executes the idle callbacks added by the text control on the change of input style.
1418 application.RunIdles();
1420 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1421 if( gInputStyleChangedCallbackCalled )
1423 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1424 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1427 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1428 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
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, Device::Class::NONE, Device::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 DALI_TEST_CHECK( !inputStyleChangedSignal );
1448 gInputStyleChangedCallbackCalled = false;
1449 gInputStyleMask = TextField::InputStyle::NONE;
1450 inputStyleChangedSignal = false;
1452 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1454 // Render and notify
1455 application.SendNotification();
1456 application.Render();
1458 // Executes the idle callbacks added by the text control on the change of input style.
1459 application.RunIdles();
1461 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1462 if( gInputStyleChangedCallbackCalled )
1464 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1465 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1468 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1469 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1471 DALI_TEST_CHECK( inputStyleChangedSignal );
1473 gInputStyleChangedCallbackCalled = false;
1474 gInputStyleMask = TextField::InputStyle::NONE;
1475 inputStyleChangedSignal = false;
1477 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1479 Property::Map fontStyleMapSet;
1480 fontStyleMapSet.Insert( "weight", "thin" );
1481 fontStyleMapSet.Insert( "width", "condensed" );
1482 fontStyleMapSet.Insert( "slant", "italic" );
1484 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1485 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1487 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1488 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1489 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1490 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1492 // Render and notify
1493 application.SendNotification();
1494 application.Render();
1496 // Executes the idle callbacks added by the text control on the change of input style.
1497 application.RunIdles();
1499 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1500 DALI_TEST_CHECK( !inputStyleChangedSignal );
1502 // Create a tap event to touch the text field.
1503 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1504 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1506 // Render and notify
1507 application.SendNotification();
1508 application.Render();
1510 // Executes the idle callbacks added by the text control on the change of input style.
1511 application.RunIdles();
1513 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1514 if( gInputStyleChangedCallbackCalled )
1516 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1517 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1518 TextField::InputStyle::POINT_SIZE |
1519 TextField::InputStyle::FONT_STYLE |
1520 TextField::InputStyle::UNDERLINE |
1521 TextField::InputStyle::SHADOW |
1522 TextField::InputStyle::EMBOSS |
1523 TextField::InputStyle::OUTLINE ),
1526 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1527 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1529 DALI_TEST_CHECK( inputStyleChangedSignal );
1534 int utcDaliTextFieldEvent01(void)
1536 ToolkitTestApplication application;
1537 tet_infoline(" utcDaliTextFieldEvent01");
1539 // Creates a tap event. After creating a tap event the text field should
1540 // have the focus and add text with key events should be possible.
1542 TextField field = TextField::New();
1543 DALI_TEST_CHECK( field );
1545 Stage::GetCurrent().Add( field );
1547 field.SetSize( 300.f, 50.f );
1548 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1549 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1551 // Avoid a crash when core load gl resources.
1552 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1554 // Render and notify
1555 application.SendNotification();
1556 application.Render();
1558 // Add a key event but as the text field has not the focus it should do nothing.
1559 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1561 // Render and notify
1562 application.SendNotification();
1563 application.Render();
1565 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1567 // Create a tap event to touch the text field.
1568 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1569 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1571 // Render and notify
1572 application.SendNotification();
1573 application.Render();
1575 // Now the text field has the focus, so it can handle the key events.
1576 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1577 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1579 // Render and notify
1580 application.SendNotification();
1581 application.Render();
1583 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1585 // Create a second text field and send key events to it.
1586 TextField field2 = TextField::New();
1588 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1589 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1590 field2.SetSize( 100.f, 100.f );
1591 field2.SetPosition( 100.f, 100.f );
1593 Stage::GetCurrent().Add( field2 );
1595 // Render and notify
1596 application.SendNotification();
1597 application.Render();
1599 // Create a tap event on the second text field.
1600 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1601 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1603 // Render and notify
1604 application.SendNotification();
1605 application.Render();
1607 // The second text field has the focus. It should handle the key events.
1608 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1609 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1611 // Render and notify
1612 application.SendNotification();
1613 application.Render();
1615 // Check the text has been added to the second text field.
1616 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1621 int utcDaliTextFieldEvent02(void)
1623 ToolkitTestApplication application;
1624 tet_infoline(" utcDaliTextFieldEvent02");
1626 // Checks if the right number of actors are created.
1628 TextField field = TextField::New();
1629 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1630 DALI_TEST_CHECK( field );
1631 LoadMarkerImages(application, field);
1633 Stage::GetCurrent().Add( field );
1635 field.SetSize( 300.f, 50.f );
1636 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1637 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1639 // Avoid a crash when core load gl resources.
1640 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1642 // Render and notify
1643 application.SendNotification();
1644 application.Render();
1646 // Check there are the expected number of children ( stencil ).
1647 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1649 Actor stencil = field.GetChildAt( 0u );
1650 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1652 // Create a tap event to touch the text field.
1653 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1654 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1656 // Render and notify
1657 application.SendNotification();
1658 application.Render();
1660 Actor layer = field.GetChildAt( 1u );
1661 DALI_TEST_CHECK( layer.IsLayer() );
1663 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1664 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1666 // Now the text field has the focus, so it can handle the key events.
1667 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1668 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1670 // Render and notify
1671 application.SendNotification();
1672 application.Render();
1674 // Checks the cursor and the renderer have been created.
1675 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1676 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1678 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1679 DALI_TEST_CHECK( cursor );
1681 // The offscreen root actor has a container with all the actors which contain the text renderers.
1682 Actor container = stencil.GetChildAt( 0u );
1683 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1685 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1686 DALI_TEST_CHECK( renderer );
1689 // Move the cursor and check the position changes.
1690 Vector3 position1 = cursor.GetCurrentPosition();
1692 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1693 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1695 // Render and notify
1696 application.SendNotification();
1697 application.Render();
1699 Vector3 position2 = cursor.GetCurrentPosition();
1701 DALI_TEST_CHECK( position2.x < position1.x );
1703 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1704 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1706 // Render and notify
1707 application.SendNotification();
1708 application.Render();
1710 Vector3 position3 = cursor.GetCurrentPosition();
1712 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1714 // Send some taps and check the cursor positions.
1716 // Try to tap at the beginning.
1717 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1718 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1720 // Render and notify
1721 application.SendNotification();
1722 application.Render();
1724 // Cursor position should be the same than position1.
1725 Vector3 position4 = cursor.GetCurrentPosition();
1727 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1729 // Tap away from the start position.
1730 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1731 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1733 // Render and notify
1734 application.SendNotification();
1735 application.Render();
1737 Vector3 position5 = cursor.GetCurrentPosition();
1739 DALI_TEST_CHECK( position5.x > position4.x );
1741 // Remove all the text.
1742 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1743 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1744 field.SetProperty( TextField::Property::TEXT, "" );
1746 // Render and notify
1747 application.SendNotification();
1748 application.Render();
1750 // Cursor position should be the same than position2.
1751 Vector3 position6 = cursor.GetCurrentPosition();
1753 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1755 // Should not be a renderer.
1756 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1758 // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
1759 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1760 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
1762 application.SendNotification();
1763 application.Render();
1765 // There are renderer and decorator layer
1766 DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
1771 int utcDaliTextFieldEvent03(void)
1773 ToolkitTestApplication application;
1774 tet_infoline(" utcDaliTextFieldEvent03");
1776 // Checks if the highlight actor is created.
1778 TextField field = TextField::New();
1779 DALI_TEST_CHECK( field );
1781 Stage::GetCurrent().Add( field );
1783 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1784 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1785 field.SetSize( 30.f, 50.f );
1786 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1787 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1789 // Avoid a crash when core load gl resources.
1790 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1791 LoadMarkerImages(application, field);
1793 // Render and notify
1794 application.SendNotification();
1795 application.Render();
1797 // Tap first to get the focus.
1798 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1799 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1801 // Render and notify
1802 application.SendNotification();
1803 application.Render();
1805 // Double tap to select a word.
1806 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1807 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1809 // Render and notify
1810 application.SendNotification();
1811 application.Render();
1813 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1814 Actor stencil = field.GetChildAt( 0u );
1816 // The highlight actor is drawn first, so is the first actor in the list
1817 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1818 DALI_TEST_CHECK( highlight );
1820 // The offscreen root actor has a container with all the actors which contain the text renderers.
1821 Actor container = stencil.GetChildAt( 1u );
1822 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1824 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1825 DALI_TEST_CHECK( renderer );
1831 int utcDaliTextFieldEvent04(void)
1833 ToolkitTestApplication application;
1834 tet_infoline(" utcDaliTextFieldEvent04");
1836 // Checks if the highlight actor is created.
1838 TextField field = TextField::New();
1839 DALI_TEST_CHECK( field );
1840 Stage::GetCurrent().Add( field );
1841 LoadMarkerImages(application, field);
1842 // Render and notify
1843 application.SendNotification();
1844 application.Render();
1846 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1847 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1848 field.SetSize( 300.f, 50.f );
1849 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1850 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1852 // Avoid a crash when core load gl resources.
1853 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1854 // Render and notify
1855 application.SendNotification();
1856 application.Render();
1858 // Create a tap event to touch the text field.
1859 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1860 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1861 // Render and notify
1862 application.SendNotification();
1863 application.Render();
1866 // Tap first to get the focus.
1867 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1868 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1870 // Render and notify
1871 application.SendNotification();
1872 application.Render();
1874 // Double tap to select a word.
1875 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1876 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1878 // Render and notify
1879 application.SendNotification();
1880 application.Render();
1883 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1884 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1888 int utcDaliTextFieldEvent05(void)
1890 ToolkitTestApplication application;
1891 tet_infoline(" utcDaliTextFieldEvent05");
1893 // Checks dragging of cursor/grab handle
1895 TextField field = TextField::New();
1896 DALI_TEST_CHECK( field );
1897 Stage::GetCurrent().Add( field );
1898 LoadMarkerImages(application, field);
1899 // Render and notify
1900 application.SendNotification();
1901 application.Render();
1903 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1904 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1905 field.SetSize( 300.f, 50.f );
1906 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1907 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1909 // Avoid a crash when core load gl resources.
1910 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1911 // Render and notify
1912 application.SendNotification();
1913 application.Render();
1915 // Create a tap event to touch the text field.
1916 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1917 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1918 // Render and notify
1919 application.SendNotification();
1920 application.Render();
1923 // Tap first to get the focus.
1924 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1925 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1927 // Render and notify
1928 application.SendNotification();
1929 application.Render();
1931 // Double tap to select a word.
1932 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1933 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1935 // Render and notify
1936 application.SendNotification();
1937 application.Render();
1939 // drag grab handle right
1940 Vector2 pos(0.0f, 40.0f);
1941 SendPan(application, Gesture::Possible, pos);
1942 SendPan(application, Gesture::Started, pos);
1944 Wait(application, 100);
1946 for(int i = 0;i<20;i++)
1948 SendPan(application, Gesture::Continuing, pos);
1953 SendPan(application, Gesture::Finished, pos);
1954 Wait(application, RENDER_FRAME_INTERVAL);
1956 Actor stencil = field.GetChildAt( 1u );
1960 int utcDaliTextFieldEvent06(void)
1962 ToolkitTestApplication application;
1963 tet_infoline(" utcDaliTextFieldEvent06");
1965 // Checks Longpress when in edit mode
1967 TextField field = TextField::New();
1968 DALI_TEST_CHECK( field );
1969 Stage::GetCurrent().Add( field );
1970 LoadMarkerImages(application, field);
1971 // Render and notify
1972 application.SendNotification();
1973 application.Render();
1975 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1976 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1977 field.SetSize( 300.f, 50.f );
1978 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1979 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1981 // Avoid a crash when core load gl resources.
1982 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1983 // Render and notify
1984 application.SendNotification();
1985 application.Render();
1987 // Create a tap event to touch the text field.
1988 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1989 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1990 // Render and notify
1991 application.SendNotification();
1992 application.Render();
1995 // Tap first to get the focus.
1996 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1997 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1999 // Render and notify
2000 application.SendNotification();
2001 application.Render();
2004 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2005 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2007 // Render and notify
2008 application.SendNotification();
2009 application.Render();
2014 int utcDaliTextFieldEvent07(void)
2016 ToolkitTestApplication application;
2017 tet_infoline(" utcDaliTextFieldEvent07");
2019 // Checks Longpress to start edit mode
2021 TextField field = TextField::New();
2022 DALI_TEST_CHECK( field );
2023 Stage::GetCurrent().Add( field );
2024 LoadMarkerImages(application, field);
2025 // Render and notify
2026 application.SendNotification();
2027 application.Render();
2029 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2030 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2031 field.SetSize( 300.f, 50.f );
2032 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2033 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2034 Property::Map propertyMap;
2035 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2036 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2038 // Avoid a crash when core load gl resources.
2039 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2040 // Render and notify
2041 application.SendNotification();
2042 application.Render();
2045 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2046 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2048 // Render and notify
2049 application.SendNotification();
2050 application.Render();
2055 int utcDaliTextFieldEvent08(void)
2057 ToolkitTestApplication application;
2058 tet_infoline(" utcDaliTextFieldEvent08");
2060 Dali::Clipboard clipboard = Clipboard::Get();
2061 clipboard.SetItem("testTextFieldEvent");
2063 // Checks Longpress when only place holder text
2065 TextField field = TextField::New();
2066 DALI_TEST_CHECK( field );
2067 Stage::GetCurrent().Add( field );
2068 LoadMarkerImages(application, field);
2069 // Render and notify
2070 application.SendNotification();
2071 application.Render();
2073 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2074 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2075 field.SetSize( 300.f, 50.f );
2076 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2077 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2079 // Avoid a crash when core load gl resources.
2080 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2081 // Render and notify
2082 application.SendNotification();
2083 application.Render();
2086 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2087 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2089 // Render and notify
2090 application.SendNotification();
2091 application.Render();
2093 Wait(application, 500);
2096 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2097 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2099 // Render and notify
2100 application.SendNotification();
2101 application.Render();
2103 Wait(application, 500);
2105 Stage stage = Stage::GetCurrent();
2106 Layer layer = stage.GetRootLayer();
2107 Actor actor = layer.FindChildByName("optionPaste");
2111 Vector3 worldPosition = actor.GetCurrentWorldPosition();
2112 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2113 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2115 Dali::Integration::TouchEvent event;
2116 event = Dali::Integration::TouchEvent();
2117 event.AddPoint( GetPointDownInside( position ) );
2118 application.ProcessEvent( event );
2120 event = Dali::Integration::TouchEvent();
2121 event.AddPoint( GetPointUpInside( position ) );
2122 application.ProcessEvent( event );
2124 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2129 int utcDaliTextFieldEvent09(void)
2131 ToolkitTestApplication application;
2132 tet_infoline(" utcDaliTextFieldEvent09");
2134 TextField field = TextField::New();
2135 DALI_TEST_CHECK( field );
2136 Stage::GetCurrent().Add( field );
2137 LoadMarkerImages(application, field);
2138 // Render and notify
2139 application.SendNotification();
2140 application.Render();
2142 field.SetProperty( TextField::Property::TEXT, "Hello" );
2143 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2144 field.SetSize( 300.f, 50.f );
2145 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2146 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2148 // Avoid a crash when core load gl resources.
2149 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2151 // Create a tap event to touch the text field.
2152 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2153 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2154 application.SendNotification();
2155 application.Render();
2158 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2159 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2160 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2161 application.SendNotification();
2162 application.Render();
2164 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2165 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2166 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2167 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2168 application.SendNotification();
2169 application.Render();
2171 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2172 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2173 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2174 for( unsigned int index = 0u; index < 5u; ++index )
2176 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2177 application.SendNotification();
2178 application.Render();
2181 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2182 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2183 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2184 for( unsigned int index = 0u; index < 5u; ++index )
2186 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2187 application.SendNotification();
2188 application.Render();
2191 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2192 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2193 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2194 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2195 application.SendNotification();
2196 application.Render();
2197 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2198 application.SendNotification();
2199 application.Render();
2201 map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2202 field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2203 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2204 application.SendNotification();
2205 application.Render();
2207 Property::Map mapGet;
2208 mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2209 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2210 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2215 int utcDaliTextFieldStyleWhilstSelected(void)
2217 ToolkitTestApplication application;
2218 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2220 // Change font and styles whilst text is selected whilst word selected
2222 TextField field = TextField::New();
2223 DALI_TEST_CHECK( field );
2224 Stage::GetCurrent().Add( field );
2225 LoadMarkerImages(application, field);
2226 // Render and notify
2227 application.SendNotification();
2228 application.Render();
2230 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2231 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2232 field.SetSize( 300.f, 50.f );
2233 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2234 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2236 // Avoid a crash when core load gl resources.
2237 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2238 // Render and notify
2239 application.SendNotification();
2240 application.Render();
2242 // Create a tap event to touch the text field.
2243 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2244 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2245 // Render and notify
2246 application.SendNotification();
2247 application.Render();
2250 // Tap first to get the focus.
2251 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2252 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2254 // Render and notify
2255 application.SendNotification();
2256 application.Render();
2258 // Double tap to select a word.
2259 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2260 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2262 // Render and notify
2263 application.SendNotification();
2264 application.Render();
2266 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2267 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2269 Property::Map fontStyleMapSet;
2270 Property::Map fontStyleMapGet;
2272 fontStyleMapSet.Insert( "weight", "bold" );
2273 fontStyleMapSet.Insert( "slant", "italic" );
2274 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2276 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2277 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2278 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2280 fontStyleMapSet.Clear();
2281 fontStyleMapSet.Insert( "width", "expanded" );
2282 fontStyleMapSet.Insert( "slant", "italic" );
2283 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2285 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2286 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2287 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2289 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2290 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2292 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2293 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2295 fontStyleMapSet.Clear();
2296 fontStyleMapSet.Insert( "weight", "bold" );
2297 fontStyleMapSet.Insert( "slant", "italic" );
2299 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2301 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2302 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2303 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2305 fontStyleMapSet.Clear();
2306 fontStyleMapSet.Insert( "width", "expanded" );
2308 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2310 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2311 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2312 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2314 // Press Escape to increase coverage
2315 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2316 application.SendNotification();
2317 application.Render();
2319 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2324 int utcDaliTextFieldEscKeyLoseFocus(void)
2326 ToolkitTestApplication application;
2327 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2329 // Creates a tap event. After creating a tap event the text field should
2330 // have the focus and add text with key events should be possible.
2332 TextField field = TextField::New();
2333 DALI_TEST_CHECK( field );
2335 Stage::GetCurrent().Add( field );
2337 field.SetSize( 300.f, 50.f );
2338 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2339 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2341 // Avoid a crash when core load gl resources.
2342 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2344 // Render and notify
2345 application.SendNotification();
2346 application.Render();
2348 // Add a key event but as the text field has not the focus it should do nothing.
2349 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2350 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2352 // Render and notify
2353 application.SendNotification();
2354 application.Render();
2356 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2358 // Create a tap event to touch the text field.
2359 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2360 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2362 // Render and notify
2363 application.SendNotification();
2364 application.Render();
2366 // Now the text field has the focus, so it can handle the key events.
2367 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2368 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2369 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2370 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2372 // Render and notify
2373 application.SendNotification();
2374 application.Render();
2376 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2378 // Generate a Esc key event. The text field should lose the focus.
2379 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2380 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2382 // Render and notify
2383 application.SendNotification();
2384 application.Render();
2386 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2388 // No more text should be introduced
2389 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2390 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2392 // Render and notify
2393 application.SendNotification();
2394 application.Render();
2396 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2401 int utcDaliTextFieldSomeSpecialKeys(void)
2403 ToolkitTestApplication application;
2404 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2406 // Checks some special keys when the text is selected.
2408 TextField field = TextField::New();
2409 DALI_TEST_CHECK( field );
2410 Stage::GetCurrent().Add( field );
2411 LoadMarkerImages(application, field);
2412 // Render and notify
2413 application.SendNotification();
2414 application.Render();
2416 const std::string longText( "This is a long text for the size of the text-field." );
2418 field.SetProperty( TextField::Property::TEXT, longText );
2419 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2420 field.SetSize( 300.f, 50.f );
2421 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2422 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2424 // Avoid a crash when core load gl resources.
2425 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2426 // Render and notify
2427 application.SendNotification();
2428 application.Render();
2430 // Create a tap event to touch the text field.
2431 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2432 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2434 // Render and notify
2435 application.SendNotification();
2436 application.Render();
2438 // Tap first to get the focus.
2439 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2440 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2442 // Render and notify
2443 application.SendNotification();
2444 application.Render();
2446 // Double tap to select a word.
2447 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2448 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
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( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2456 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2458 // Render and notify
2459 application.SendNotification();
2460 application.Render();
2462 // Generate a Esc key event. The text field should lose the focus.
2463 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2464 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2466 // Render and notify
2467 application.SendNotification();
2468 application.Render();
2470 // Generate a Esc key event. The text field should lose the focus.
2471 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2472 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2474 // Render and notify
2475 application.SendNotification();
2476 application.Render();
2478 // The text shouldn't be deleted.
2479 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
2484 int utcDaliTextFieldSizeUpdate(void)
2486 ToolkitTestApplication application;
2487 tet_infoline("utcDaliTextFieldSizeUpdate");
2489 // Checks some special keys when the text is selected.
2490 TextField field = TextField::New();
2491 DALI_TEST_CHECK( field );
2492 Stage::GetCurrent().Add( field );
2494 float previousHeight = 0.0f;
2495 float currentHeight = 0.0f;
2496 const float fieldWidth = 1920.0f;
2499 // "ㅁ" is bigger then "ኢ"
2500 field.SetSize( Vector2( fieldWidth ,10.0f ) );
2501 field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
2502 field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
2504 field.SetProperty( TextField::Property::TEXT, "ኢ");
2505 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2506 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2508 field.SetKeyboardFocusable(true);
2509 KeyboardFocusManager::Get().SetCurrentFocusActor( field );
2511 application.SendNotification();
2512 application.Render();
2514 previousHeight = field.GetHeightForWidth( fieldWidth );
2515 DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
2517 // Add another script characters ( glyph height is defferent )
2518 application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2519 application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2521 application.SendNotification();
2522 application.Render();
2524 currentHeight = field.GetHeightForWidth( fieldWidth );
2525 DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
2526 DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
2531 int utcDaliTextFieldExtremlyLargePointSize(void)
2533 ToolkitTestApplication application;
2534 tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
2536 TextField field = TextField::New();
2538 field.SetProperty( TextField::Property::TEXT, "Text" );
2539 field.SetSize( 300.f, 50.f );
2540 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2541 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2542 Stage::GetCurrent().Add( field );
2546 field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
2547 application.SendNotification();
2548 DALI_TEST_CHECK( field );
2552 tet_result(TET_FAIL);
2557 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
2559 ToolkitTestApplication application;
2560 tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
2561 TextField field = TextField::New();
2562 DALI_TEST_CHECK( field );
2563 Stage::GetCurrent().Add( field );
2565 Property::Map fontStyleMapGet;
2567 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2569 Property::Value* weightValue = NULL;
2570 Property::Value* widthValue = NULL;
2571 Property::Value* slantValue = NULL;
2572 weightValue = fontStyleMapGet.Find( "weight" );
2573 widthValue = fontStyleMapGet.Find( "width" );
2574 slantValue = fontStyleMapGet.Find( "slant" );
2575 DALI_TEST_CHECK( !weightValue );
2576 DALI_TEST_CHECK( !widthValue );
2577 DALI_TEST_CHECK( !slantValue );