2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali/public-api/rendering/renderer.h>
23 #include <dali/integration-api/events/key-event-integ.h>
24 #include <dali/integration-api/events/tap-gesture-event.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/integration-api/events/pan-gesture-event.h>
27 #include <dali/integration-api/events/long-press-gesture-event.h>
28 #include <dali-toolkit-test-suite-utils.h>
29 #include <dali-toolkit/dali-toolkit.h>
30 #include <dali-toolkit/devel-api/controls/text-controls/hidden-input-properties.h>
31 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
32 #include "toolkit-clipboard.h"
35 using namespace Toolkit;
37 void dali_textfield_startup(void)
39 test_return_value = TET_UNDEF;
42 void dali_textfield_cleanup(void)
44 test_return_value = TET_PASS;
50 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
51 const char* const PROPERTY_NAME_TEXT = "text";
52 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
53 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
54 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
55 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
56 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
57 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
58 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
59 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
60 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
61 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
62 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
63 const char* const PROPERTY_NAME_SHADOW_OFFSET = "shadowOffset";
64 const char* const PROPERTY_NAME_SHADOW_COLOR = "shadowColor";
65 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
66 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
67 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
68 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
69 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
70 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
71 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
72 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
73 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
74 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
80 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
81 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
82 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
83 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
84 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
85 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
86 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
87 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
88 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
90 const char* const PROPERTY_NAME_UNDERLINE = "underline";
91 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
92 const char* const PROPERTY_NAME_SHADOW = "shadow";
93 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
94 const char* const PROPERTY_NAME_EMBOSS = "emboss";
95 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
96 const char* const PROPERTY_NAME_OUTLINE = "outline";
97 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
99 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
100 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
101 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
102 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
104 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
106 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
107 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
109 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
110 const float RENDER_FRAME_INTERVAL = 16.66f;
112 const float TO_MILLISECONDS = 1000.f;
113 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
115 const float SCROLL_THRESHOLD = 10.f;
116 const float SCROLL_SPEED = 300.f;
118 const unsigned int DEFAULT_FONT_SIZE = 1152u;
119 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
121 const int KEY_A_CODE = 38;
122 const int KEY_D_CODE = 40;
124 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
126 static bool gTextChangedCallBackCalled;
127 static bool gMaxCharactersCallBackCalled;
128 static bool gInputStyleChangedCallbackCalled;
129 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
131 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
133 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
134 Integration::ResourcePointer resource(bitmap);
135 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
138 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
142 LoadBitmapResource( app.GetPlatform(), width, height );
144 Property::Map propertyMap;
145 propertyMap["filename"] = "image.png";
146 propertyMap["width"] = width;
147 propertyMap["height"] = height;
148 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
149 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
150 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
151 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
152 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
153 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
154 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
155 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
158 // Generate a PanGestureEvent to send to Core
159 static Integration::PanGestureEvent GeneratePan(
160 Gesture::State state,
161 const Vector2& previousPosition,
162 const Vector2& currentPosition,
163 unsigned long timeDelta,
164 unsigned int numberOfTouches = 1)
166 Integration::PanGestureEvent pan(state);
168 pan.previousPosition = previousPosition;
169 pan.currentPosition = currentPosition;
170 pan.timeDelta = timeDelta;
171 pan.numberOfTouches = numberOfTouches;
177 * Helper to generate PanGestureEvent
179 * @param[in] application Application instance
180 * @param[in] state The Gesture State
181 * @param[in] pos The current position of touch.
183 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
187 if( (state == Gesture::Started) ||
188 (state == Gesture::Possible) )
194 application.ProcessEvent(GeneratePan(state, last, pos, 16));
201 * Simulate time passed by.
203 * @note this will always process at least 1 frame (1/60 sec)
205 * @param application Test application instance
206 * @param duration Time to pass in milliseconds.
207 * @return The actual time passed in milliseconds
209 static int Wait(ToolkitTestApplication& application, int duration = 0)
213 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
215 application.SendNotification();
216 application.Render(RENDER_FRAME_INTERVAL);
217 time += RENDER_FRAME_INTERVAL;
223 Dali::Integration::Point GetPointDownInside( Vector2& pos )
225 Dali::Integration::Point point;
226 point.SetState( PointState::DOWN );
227 point.SetScreenPosition( pos );
231 Dali::Integration::Point GetPointUpInside( Vector2& pos )
233 Dali::Integration::Point point;
234 point.SetState( PointState::UP );
235 point.SetScreenPosition( pos );
239 struct CallbackFunctor
241 CallbackFunctor(bool* callbackFlag)
242 : mCallbackFlag( callbackFlag )
248 *mCallbackFlag = true;
253 static void TestTextChangedCallback( TextField control )
255 tet_infoline(" TestTextChangedCallback");
257 gTextChangedCallBackCalled = true;
260 static void TestMaxLengthReachedCallback( TextField control )
262 tet_infoline(" TestMaxLengthReachedCallback");
264 gMaxCharactersCallBackCalled = true;
267 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
269 tet_infoline(" TestInputStyleChangedCallback");
271 gInputStyleChangedCallbackCalled = true;
272 gInputStyleMask = mask;
275 // Generate a TapGestureEvent to send to Core.
276 Integration::TapGestureEvent GenerateTap(
277 Gesture::State state,
278 unsigned int numberOfTaps,
279 unsigned int numberOfTouches,
282 Integration::TapGestureEvent tap( state );
284 tap.numberOfTaps = numberOfTaps;
285 tap.numberOfTouches = numberOfTouches;
291 Integration::LongPressGestureEvent GenerateLongPress(
292 Gesture::State state,
293 unsigned int numberOfTouches,
296 Integration::LongPressGestureEvent longPress( state );
298 longPress.numberOfTouches = numberOfTouches;
299 longPress.point = point;
303 // Generate a KeyEvent to send to Core.
304 Integration::KeyEvent GenerateKey( const std::string& keyName,
305 const std::string& keyString,
308 unsigned long timeStamp,
309 const Integration::KeyEvent::State& keyState,
310 const std::string& deviceName,
311 const DevelKeyEvent::DeviceClass::Type& deviceClass )
313 return Integration::KeyEvent( keyName,
323 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
325 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
327 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
329 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
331 if( valueGet.first.type == Property::Key::STRING )
333 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
334 if( NULL != valueSet )
336 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
338 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
344 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
350 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
351 if( NULL != valueSet )
353 if( valueGet.second.Get<int>() != valueSet->Get<int>() )
355 tet_printf( " Integer Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
361 tet_printf( " The Int key %d doesn't exist.", valueGet.first.indexKey );
373 int UtcDaliToolkitTextFieldConstructorP(void)
375 ToolkitTestApplication application;
376 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
378 DALI_TEST_CHECK( !textField );
382 int UtcDaliToolkitTextFieldNewP(void)
384 ToolkitTestApplication application;
385 tet_infoline(" UtcDaliToolkitTextFieldNewP");
386 TextField textField = TextField::New();
387 DALI_TEST_CHECK( textField );
391 int UtcDaliToolkitTextFieldDownCastP(void)
393 ToolkitTestApplication application;
394 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
395 TextField textField1 = TextField::New();
396 BaseHandle object( textField1 );
398 TextField textField2 = TextField::DownCast( object );
399 DALI_TEST_CHECK( textField2 );
401 TextField textField3 = DownCast< TextField >( object );
402 DALI_TEST_CHECK( textField3 );
406 int UtcDaliToolkitTextFieldDownCastN(void)
408 ToolkitTestApplication application;
409 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
410 BaseHandle uninitializedObject;
411 TextField textField1 = TextField::DownCast( uninitializedObject );
412 DALI_TEST_CHECK( !textField1 );
414 TextField textField2 = DownCast< TextField >( uninitializedObject );
415 DALI_TEST_CHECK( !textField2 );
419 int UtcDaliToolkitTextFieldCopyConstructorP(void)
421 ToolkitTestApplication application;
422 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
423 TextField textField = TextField::New();
424 textField.SetProperty( TextField::Property::TEXT, "Test" );
426 TextField copy( textField );
427 DALI_TEST_CHECK( copy );
428 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
432 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
434 ToolkitTestApplication application;
435 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
436 TextField textField = TextField::New();
437 textField.SetProperty( TextField::Property::TEXT, "Test" );
439 TextField copy = textField;
440 DALI_TEST_CHECK( copy );
441 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
445 int UtcDaliTextFieldNewP(void)
447 ToolkitTestApplication application;
448 tet_infoline(" UtcDaliToolkitTextFieldNewP");
449 TextField textField = TextField::New();
450 DALI_TEST_CHECK( textField );
454 // Positive test case for a method
455 int UtcDaliTextFieldGetPropertyP(void)
457 ToolkitTestApplication application;
458 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
459 TextField field = TextField::New();
460 DALI_TEST_CHECK( field );
462 // Check Property Indices are correct
463 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
464 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
465 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
466 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
467 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
468 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
469 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
470 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
471 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
472 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
473 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
474 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
475 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
476 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextField::Property::SHADOW_OFFSET );
477 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextField::Property::SHADOW_COLOR );
478 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
479 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
480 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
481 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
482 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
483 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
484 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
485 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
486 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
487 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
488 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
489 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
490 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
491 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
492 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
493 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
494 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
495 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
496 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
497 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
498 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
499 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
500 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
501 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
502 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
503 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
504 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
505 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
506 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
507 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
508 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
509 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
510 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
511 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == DevelTextField::Property::PIXEL_SIZE );
512 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == DevelTextField::Property::ENABLE_SELECTION );
513 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == DevelTextField::Property::PLACEHOLDER );
518 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
521 Property::Map imageMap;
522 imageMap[mapKey] =mapValue;
524 field.SetProperty( property , imageMap );
525 Property::Value propValue = field.GetProperty( property );
526 Property::Map* resultMap = propValue.GetMap();
528 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
536 // Positive test case for a method
537 int UtcDaliTextFieldSetPropertyP(void)
539 ToolkitTestApplication application;
540 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
541 TextField field = TextField::New();
542 DALI_TEST_CHECK( field );
543 Stage::GetCurrent().Add( field );
545 // Note - we can't check the defaults since the stylesheets are platform-specific
547 // Check the render backend property.
548 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
549 DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
551 // Check text property.
552 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
553 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
555 // Check placeholder text properties.
556 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
557 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
559 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
560 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
562 // Check font properties.
563 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
564 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
566 Property::Map fontStyleMapSet;
567 Property::Map fontStyleMapGet;
568 Property::Value* slantValue = NULL;
570 fontStyleMapSet.Insert( "weight", "bold" );
571 fontStyleMapSet.Insert( "width", "condensed" );
572 fontStyleMapSet.Insert( "slant", "italic" );
573 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
575 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
576 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
577 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
579 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
580 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
583 fontStyleMapSet.Clear();
584 fontStyleMapSet.Insert( "weight", "normal" );
585 fontStyleMapSet.Insert( "slant", "oblique" );
586 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
588 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
589 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
590 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
592 fontStyleMapSet.Clear();
593 fontStyleMapSet.Insert( "slant", "roman" );
594 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
595 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
597 // Replace 'roman' for 'normal'.
598 slantValue = fontStyleMapGet.Find( "slant" );
599 if( NULL != slantValue )
601 if( "normal" == slantValue->Get<std::string>() )
603 fontStyleMapGet["slant"] = "roman";
606 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
607 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
609 fontStyleMapSet.Clear();
611 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
612 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
613 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
614 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
616 // Check that the MAX_LENGTH property can be correctly set
617 const int maxNumberOfCharacters = 20;
618 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
619 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
621 // Check exceed policy
622 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
623 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
624 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
625 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
627 // Check that the Alignment properties can be correctly set
628 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
629 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
630 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
631 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
633 // Check text's color property
634 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
635 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
637 // Check placeholder text's color property.
638 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
639 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
641 // Check shadow properties.
642 field.SetProperty( TextField::Property::SHADOW_OFFSET, Vector2( 1.f, 1.f ) );
643 DALI_TEST_EQUALS( field.GetProperty<Vector2>( TextField::Property::SHADOW_OFFSET ), Vector2( 1.f, 1.f ), TEST_LOCATION );
644 field.SetProperty( TextField::Property::SHADOW_COLOR, Color::GREEN );
645 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SHADOW_COLOR ), Color::GREEN, TEST_LOCATION );
647 // Check cursor properties
648 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
649 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
650 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
651 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
653 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
654 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
655 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
656 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
657 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
658 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
659 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
660 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
662 // Check scroll properties.
663 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
664 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
665 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
666 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
668 // Check handle images
669 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
670 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
671 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
672 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
673 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
675 // Check handle images
676 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
677 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
678 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
679 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
680 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
681 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
683 // Check the highlight color
684 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
685 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
687 // Decoration bounding box
688 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
689 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
691 // Check the input method setting
692 Property::Map propertyMap;
693 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
694 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
695 InputMethod::ActionButtonTitle::Type actionButton = InputMethod::ActionButtonTitle::GO;
696 int inputVariation = 1;
697 propertyMap["PANEL_LAYOUT"] = panelLayout;
698 propertyMap["AUTO_CAPITALISE"] = autoCapital;
699 propertyMap["ACTION_BUTTON"] = actionButton;
700 propertyMap["VARIATION"] = inputVariation;
701 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
703 Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
705 DALI_TEST_CHECK( value.Get( map ) );
708 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
709 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
712 DALI_TEST_CHECK( map[ "AUTO_CAPITALISE" ].Get( capital ) );
713 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
716 DALI_TEST_CHECK( map[ "ACTION_BUTTON" ].Get( action ) );
717 DALI_TEST_EQUALS( static_cast<int>(actionButton), action, TEST_LOCATION );
720 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
721 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
723 // Check input color property.
724 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
725 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
727 // Check the enable markup property.
728 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
729 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
730 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
732 // Check input font properties.
733 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
734 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
736 fontStyleMapSet.Clear();
737 fontStyleMapSet.Insert( "weight", "bold" );
738 fontStyleMapSet.Insert( "width", "condensed" );
739 fontStyleMapSet.Insert( "slant", "italic" );
741 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
742 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
743 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
744 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
746 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
747 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
749 // Reset input font style.
750 fontStyleMapSet.Clear();
751 fontStyleMapSet.Insert( "weight", "normal" );
752 fontStyleMapSet.Insert( "slant", "oblique" );
754 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
755 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
756 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
757 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
759 fontStyleMapSet.Clear();
760 fontStyleMapSet.Insert( "slant", "roman" );
762 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
763 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
765 // Replace 'roman' for 'normal'.
766 slantValue = fontStyleMapGet.Find( "slant" );
767 if( NULL != slantValue )
769 if( "normal" == slantValue->Get<std::string>() )
771 fontStyleMapGet["slant"] = "roman";
774 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
775 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
777 fontStyleMapSet.Clear();
779 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
780 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
781 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
782 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
784 Property::Map underlineMapSet;
785 Property::Map underlineMapGet;
787 underlineMapSet.Insert( "enable", "true" );
788 underlineMapSet.Insert( "color", "red" );
789 underlineMapSet.Insert( "height", "1" );
791 // Check the underline property
792 field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
794 underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
795 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
796 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
798 // Check the input underline property
799 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
800 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
802 // Check the shadow property
803 Property::Map shadowMapSet;
804 Property::Map shadowMapGet;
806 shadowMapSet.Insert( "color", "green" );
807 shadowMapSet.Insert( "offset", "2 2" );
809 field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
811 shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
812 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
813 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
815 // Check the input shadow property
816 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
817 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
819 // Check the emboss property
820 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
821 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
823 // Check the input emboss property
824 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
825 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
827 // Check the outline property
828 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
829 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
831 // Check the input outline property
832 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
833 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
835 // Check the hidden input settings property
836 Property::Map hiddenMapSet;
837 Property::Map hiddenMapGet;
838 hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
839 hiddenMapSet[ HiddenInput::Property::SHOW_DURATION ] = 2;
840 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
841 hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
842 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
844 hiddenMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
845 DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
846 DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
848 // Check the pixel size of font
849 field.SetProperty( DevelTextField::Property::PIXEL_SIZE, 20.f );
850 DALI_TEST_EQUALS( field.GetProperty<float>( DevelTextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
852 // Check the enable selection property
853 field.SetProperty( DevelTextField::Property::ENABLE_SELECTION, false );
854 DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
856 // Check the placeholder property with pixel size
857 Property::Map placeholderPixelSizeMapSet;
858 Property::Map placeholderPixelSizeMapGet;
859 Property::Map placeholderFontstyleMap;
860 placeholderPixelSizeMapSet["placeholderText"] = "Setting Placeholder Text";
861 placeholderPixelSizeMapSet["placeholderColor"] = Color::BLUE;
862 placeholderPixelSizeMapSet["placeholderFontFamily"] = "Arial";
863 placeholderPixelSizeMapSet["placeholderPixelSize"] = 15.0f;
865 placeholderFontstyleMap.Insert( "weight", "bold" );
866 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
867 field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
869 placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
870 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
871 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
873 // Check the placeholder property with point size
874 Property::Map placeholderMapSet;
875 Property::Map placeholderMapGet;
876 placeholderMapSet["placeholderText"] = "Setting Placeholder Text";
877 placeholderMapSet["placeholderColor"] = Color::RED;
878 placeholderMapSet["placeholderFontFamily"] = "Arial";
879 placeholderMapSet["placeholderPointSize"] = 12.0f;
881 // Check the placeholder font style property
882 placeholderFontstyleMap.Clear();
884 placeholderFontstyleMap.Insert( "weight", "bold" );
885 placeholderFontstyleMap.Insert( "width", "condensed" );
886 placeholderFontstyleMap.Insert( "slant", "italic" );
887 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
888 field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
890 placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
891 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
892 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
895 placeholderFontstyleMap.Clear();
896 placeholderFontstyleMap.Insert( "weight", "normal" );
897 placeholderFontstyleMap.Insert( "slant", "oblique" );
898 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
899 field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
901 placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
902 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
903 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
905 placeholderFontstyleMap.Clear();
906 placeholderFontstyleMap.Insert( "slant", "roman" );
907 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
908 field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
910 placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
912 placeholderFontstyleMap.Clear();
913 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
915 field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
916 placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
917 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
918 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
923 // Positive Atlas Text Renderer test
924 int utcDaliTextFieldAtlasRenderP(void)
926 ToolkitTestApplication application;
927 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
928 StyleManager styleManager = StyleManager::Get();
929 styleManager.ApplyDefaultTheme();
930 TextField field = TextField::New();
931 DALI_TEST_CHECK( field );
933 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
935 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
937 Stage::GetCurrent().Add( field );
941 // Render some text with the shared atlas backend
942 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
943 application.SendNotification();
944 application.Render();
948 tet_result(TET_FAIL);
953 // Positive test for the textChanged signal.
954 int utcDaliTextFieldTextChangedP(void)
956 ToolkitTestApplication application;
957 tet_infoline(" utcDaliTextFieldTextChangedP");
958 TextField field = TextField::New();
959 DALI_TEST_CHECK( field );
961 Stage::GetCurrent().Add( field );
963 // connect to the text changed signal.
964 ConnectionTracker* testTracker = new ConnectionTracker();
965 field.TextChangedSignal().Connect(&TestTextChangedCallback);
966 bool textChangedSignal = false;
967 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
969 gTextChangedCallBackCalled = false;
970 field.SetProperty( TextField::Property::TEXT, "ABC" );
971 DALI_TEST_CHECK( gTextChangedCallBackCalled );
972 DALI_TEST_CHECK( textChangedSignal );
974 application.SendNotification();
976 field.SetKeyInputFocus();
978 gTextChangedCallBackCalled = false;
979 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
980 DALI_TEST_CHECK( gTextChangedCallBackCalled );
985 // Negative test for the textChanged signal.
986 int utcDaliTextFieldTextChangedN(void)
988 ToolkitTestApplication application;
989 tet_infoline(" utcDaliTextFieldTextChangedN");
990 TextField field = TextField::New();
991 DALI_TEST_CHECK( field );
993 Stage::GetCurrent().Add( field );
995 // connect to the text changed signal.
996 ConnectionTracker* testTracker = new ConnectionTracker();
997 field.TextChangedSignal().Connect(&TestTextChangedCallback);
998 bool textChangedSignal = false;
999 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1001 gTextChangedCallBackCalled = false;
1002 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1003 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1004 DALI_TEST_CHECK( !textChangedSignal );
1009 // Positive test for Max Characters reached signal.
1010 int utcDaliTextFieldMaxCharactersReachedP(void)
1012 ToolkitTestApplication application;
1013 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1014 TextField field = TextField::New();
1015 DALI_TEST_CHECK( field );
1017 Stage::GetCurrent().Add( field );
1019 const int maxNumberOfCharacters = 1;
1020 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1022 field.SetKeyInputFocus();
1024 // connect to the text changed signal.
1025 ConnectionTracker* testTracker = new ConnectionTracker();
1026 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1027 bool maxLengthReachedSignal = false;
1028 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1030 gMaxCharactersCallBackCalled = false;
1032 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1033 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1035 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1036 DALI_TEST_CHECK( maxLengthReachedSignal );
1041 // Negative test for Max Characters reached signal.
1042 int utcDaliTextFieldMaxCharactersReachedN(void)
1044 ToolkitTestApplication application;
1045 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1046 TextField field = TextField::New();
1047 DALI_TEST_CHECK( field );
1049 Stage::GetCurrent().Add( field );
1051 const int maxNumberOfCharacters = 3;
1052 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1054 field.SetKeyInputFocus();
1056 // connect to the text changed signal.
1057 ConnectionTracker* testTracker = new ConnectionTracker();
1058 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1059 bool maxLengthReachedSignal = false;
1060 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
1062 gMaxCharactersCallBackCalled = false;
1064 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1065 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1067 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1068 DALI_TEST_CHECK( !maxLengthReachedSignal );
1073 int utcDaliTextFieldInputStyleChanged01(void)
1075 ToolkitTestApplication application;
1076 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1078 // The text-field emits signals when the input style changes. These changes of style are
1079 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1080 // can't be emitted during the size negotiation as the callbacks may update the UI.
1081 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1082 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1083 application.CreateAdaptor();
1087 char* pathNamePtr = get_current_dir_name();
1088 const std::string pathName( pathNamePtr );
1089 free( pathNamePtr );
1091 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1092 fontClient.SetDpi( 93u, 93u );
1094 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1095 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1097 TextField field = TextField::New();
1098 DALI_TEST_CHECK( field );
1101 field.SetSize( 300.f, 50.f );
1102 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1103 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1105 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1106 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1108 // connect to the text changed signal.
1109 ConnectionTracker* testTracker = new ConnectionTracker();
1110 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1111 bool inputStyleChangedSignal = false;
1112 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1114 Stage::GetCurrent().Add( field );
1116 // Render and notify
1117 application.SendNotification();
1118 application.Render();
1120 // Executes the idle callbacks added by the text control on the change of input style.
1121 application.RunIdles();
1123 gInputStyleChangedCallbackCalled = false;
1124 gInputStyleMask = TextField::InputStyle::NONE;
1125 inputStyleChangedSignal = false;
1127 // Create a tap event to touch the text field.
1128 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1129 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1131 // Render and notify
1132 application.SendNotification();
1133 application.Render();
1135 // Executes the idle callbacks added by the text control on the change of input style.
1136 application.RunIdles();
1138 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1139 if( gInputStyleChangedCallbackCalled )
1141 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1143 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1144 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1146 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1147 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1149 DALI_TEST_CHECK( inputStyleChangedSignal );
1151 gInputStyleChangedCallbackCalled = false;
1152 gInputStyleMask = TextField::InputStyle::NONE;
1153 inputStyleChangedSignal = false;
1155 // Create a tap event to touch the text field.
1156 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1157 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1159 // Render and notify
1160 application.SendNotification();
1161 application.Render();
1163 // Executes the idle callbacks added by the text control on the change of input style.
1164 application.RunIdles();
1166 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1167 DALI_TEST_CHECK( !inputStyleChangedSignal );
1169 gInputStyleChangedCallbackCalled = false;
1170 gInputStyleMask = TextField::InputStyle::NONE;
1171 inputStyleChangedSignal = false;
1173 // Create a tap event to touch the text field.
1174 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1175 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1177 // Render and notify
1178 application.SendNotification();
1179 application.Render();
1181 // Executes the idle callbacks added by the text control on the change of input style.
1182 application.RunIdles();
1184 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1185 if( gInputStyleChangedCallbackCalled )
1187 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1189 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1190 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1192 DALI_TEST_CHECK( inputStyleChangedSignal );
1194 gInputStyleChangedCallbackCalled = false;
1195 gInputStyleMask = TextField::InputStyle::NONE;
1196 inputStyleChangedSignal = false;
1198 // Create a tap event to touch the text field.
1199 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1200 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1202 // Render and notify
1203 application.SendNotification();
1204 application.Render();
1206 // Executes the idle callbacks added by the text control on the change of input style.
1207 application.RunIdles();
1209 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1210 if( gInputStyleChangedCallbackCalled )
1212 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1214 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1215 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1217 const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1219 Property::Map fontStyleMapSet;
1220 fontStyleMapSet.Insert( "weight", "bold" );
1222 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1223 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1225 DALI_TEST_CHECK( inputStyleChangedSignal );
1227 gInputStyleChangedCallbackCalled = false;
1228 gInputStyleMask = TextField::InputStyle::NONE;
1229 inputStyleChangedSignal = false;
1231 // Create a tap event to touch the text field.
1232 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1233 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1235 // Render and notify
1236 application.SendNotification();
1237 application.Render();
1239 // Executes the idle callbacks added by the text control on the change of input style.
1240 application.RunIdles();
1242 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1243 DALI_TEST_CHECK( !inputStyleChangedSignal );
1245 gInputStyleChangedCallbackCalled = false;
1246 gInputStyleMask = TextField::InputStyle::NONE;
1247 inputStyleChangedSignal = false;
1249 // Create a tap event to touch the text field.
1250 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1251 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1253 // Render and notify
1254 application.SendNotification();
1255 application.Render();
1257 // Executes the idle callbacks added by the text control on the change of input style.
1258 application.RunIdles();
1260 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1261 if( gInputStyleChangedCallbackCalled )
1263 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1265 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1266 DALI_TEST_CHECK( style.empty() );
1268 DALI_TEST_CHECK( inputStyleChangedSignal );
1270 gInputStyleChangedCallbackCalled = false;
1271 gInputStyleMask = TextField::InputStyle::NONE;
1272 inputStyleChangedSignal = false;
1274 // Create a tap event to touch the text field.
1275 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1276 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1278 // Render and notify
1279 application.SendNotification();
1280 application.Render();
1282 // Executes the idle callbacks added by the text control on the change of input style.
1283 application.RunIdles();
1285 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1286 DALI_TEST_CHECK( !inputStyleChangedSignal );
1291 int utcDaliTextFieldInputStyleChanged02(void)
1293 ToolkitTestApplication application;
1294 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1296 // The text-field emits signals when the input style changes. These changes of style are
1297 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1298 // can't be emitted during the size negotiation as the callbacks may update the UI.
1299 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1300 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1301 application.CreateAdaptor();
1305 char* pathNamePtr = get_current_dir_name();
1306 const std::string pathName( pathNamePtr );
1307 free( pathNamePtr );
1309 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1310 fontClient.SetDpi( 93u, 93u );
1312 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1313 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1315 TextField field = TextField::New();
1316 DALI_TEST_CHECK( field );
1319 field.SetSize( 300.f, 50.f );
1320 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1321 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1323 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1324 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>" );
1326 // connect to the text changed signal.
1327 ConnectionTracker* testTracker = new ConnectionTracker();
1328 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1329 bool inputStyleChangedSignal = false;
1330 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1332 Stage::GetCurrent().Add( field );
1334 // Render and notify
1335 application.SendNotification();
1336 application.Render();
1338 // Executes the idle callbacks added by the text control on the change of input style.
1339 application.RunIdles();
1341 gInputStyleChangedCallbackCalled = false;
1342 gInputStyleMask = TextField::InputStyle::NONE;
1343 inputStyleChangedSignal = false;
1345 // Create a tap event to touch the text field.
1346 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1347 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1348 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1349 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1351 // Render and notify
1352 application.SendNotification();
1353 application.Render();
1355 // Executes the idle callbacks added by the text control on the change of input style.
1356 application.RunIdles();
1358 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1359 if( gInputStyleChangedCallbackCalled )
1361 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1362 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1363 TextField::InputStyle::POINT_SIZE |
1364 TextField::InputStyle::COLOR ),
1367 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1368 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1370 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1371 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1373 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1374 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1376 DALI_TEST_CHECK( inputStyleChangedSignal );
1378 gInputStyleChangedCallbackCalled = false;
1379 gInputStyleMask = TextField::InputStyle::NONE;
1380 inputStyleChangedSignal = false;
1382 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1384 // Render and notify
1385 application.SendNotification();
1386 application.Render();
1388 // Executes the idle callbacks added by the text control on the change of input style.
1389 application.RunIdles();
1391 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1392 if( gInputStyleChangedCallbackCalled )
1394 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1395 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1398 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1399 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1401 DALI_TEST_CHECK( inputStyleChangedSignal );
1403 gInputStyleChangedCallbackCalled = false;
1404 gInputStyleMask = TextField::InputStyle::NONE;
1405 inputStyleChangedSignal = false;
1407 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1409 // Render and notify
1410 application.SendNotification();
1411 application.Render();
1413 // Executes the idle callbacks added by the text control on the change of input style.
1414 application.RunIdles();
1416 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1417 DALI_TEST_CHECK( !inputStyleChangedSignal );
1419 gInputStyleChangedCallbackCalled = false;
1420 gInputStyleMask = TextField::InputStyle::NONE;
1421 inputStyleChangedSignal = false;
1423 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1425 // Render and notify
1426 application.SendNotification();
1427 application.Render();
1429 // Executes the idle callbacks added by the text control on the change of input style.
1430 application.RunIdles();
1432 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1433 if( gInputStyleChangedCallbackCalled )
1435 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1436 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1439 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1440 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1442 DALI_TEST_CHECK( inputStyleChangedSignal );
1444 gInputStyleChangedCallbackCalled = false;
1445 gInputStyleMask = TextField::InputStyle::NONE;
1446 inputStyleChangedSignal = false;
1448 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1450 Property::Map fontStyleMapSet;
1451 fontStyleMapSet.Insert( "weight", "thin" );
1452 fontStyleMapSet.Insert( "width", "condensed" );
1453 fontStyleMapSet.Insert( "slant", "italic" );
1455 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1456 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1458 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1459 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1460 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1461 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1463 // Render and notify
1464 application.SendNotification();
1465 application.Render();
1467 // Executes the idle callbacks added by the text control on the change of input style.
1468 application.RunIdles();
1470 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1471 DALI_TEST_CHECK( !inputStyleChangedSignal );
1473 // Create a tap event to touch the text field.
1474 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1475 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1477 // Render and notify
1478 application.SendNotification();
1479 application.Render();
1481 // Executes the idle callbacks added by the text control on the change of input style.
1482 application.RunIdles();
1484 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1485 if( gInputStyleChangedCallbackCalled )
1487 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1488 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1489 TextField::InputStyle::POINT_SIZE |
1490 TextField::InputStyle::FONT_STYLE |
1491 TextField::InputStyle::UNDERLINE |
1492 TextField::InputStyle::SHADOW |
1493 TextField::InputStyle::EMBOSS |
1494 TextField::InputStyle::OUTLINE ),
1497 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1498 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1500 DALI_TEST_CHECK( inputStyleChangedSignal );
1505 int utcDaliTextFieldEvent01(void)
1507 ToolkitTestApplication application;
1508 tet_infoline(" utcDaliTextFieldEvent01");
1510 // Creates a tap event. After creating a tap event the text field should
1511 // have the focus and add text with key events should be possible.
1513 TextField field = TextField::New();
1514 DALI_TEST_CHECK( field );
1516 Stage::GetCurrent().Add( field );
1518 field.SetSize( 300.f, 50.f );
1519 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1520 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1522 // Avoid a crash when core load gl resources.
1523 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1525 // Render and notify
1526 application.SendNotification();
1527 application.Render();
1529 // Add a key event but as the text field has not the focus it should do nothing.
1530 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1532 // Render and notify
1533 application.SendNotification();
1534 application.Render();
1536 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1538 // Create a tap event to touch the text field.
1539 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1540 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1542 // Render and notify
1543 application.SendNotification();
1544 application.Render();
1546 // Now the text field has the focus, so it can handle the key events.
1547 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1548 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1550 // Render and notify
1551 application.SendNotification();
1552 application.Render();
1554 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1556 // Create a second text field and send key events to it.
1557 TextField field2 = TextField::New();
1559 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1560 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1561 field2.SetSize( 100.f, 100.f );
1562 field2.SetPosition( 100.f, 100.f );
1564 Stage::GetCurrent().Add( field2 );
1566 // Render and notify
1567 application.SendNotification();
1568 application.Render();
1570 // Create a tap event on the second text field.
1571 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1572 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1574 // Render and notify
1575 application.SendNotification();
1576 application.Render();
1578 // The second text field has the focus. It should handle the key events.
1579 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1580 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1582 // Render and notify
1583 application.SendNotification();
1584 application.Render();
1586 // Check the text has been added to the second text field.
1587 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1592 int utcDaliTextFieldEvent02(void)
1594 ToolkitTestApplication application;
1595 tet_infoline(" utcDaliTextFieldEvent02");
1597 // Checks if the right number of actors are created.
1599 TextField field = TextField::New();
1600 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1601 DALI_TEST_CHECK( field );
1602 LoadMarkerImages(application, field);
1604 Stage::GetCurrent().Add( field );
1606 field.SetSize( 300.f, 50.f );
1607 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1608 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1610 // Avoid a crash when core load gl resources.
1611 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1613 // Render and notify
1614 application.SendNotification();
1615 application.Render();
1617 // Check there are the expected number of children ( stencil ).
1618 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1620 Actor stencil = field.GetChildAt( 0u );
1621 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1623 // Create a tap event to touch the text field.
1624 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1625 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1627 // Render and notify
1628 application.SendNotification();
1629 application.Render();
1631 Actor layer = field.GetChildAt( 1u );
1632 DALI_TEST_CHECK( layer.IsLayer() );
1634 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1635 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1637 // Now the text field has the focus, so it can handle the key events.
1638 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1639 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1641 // Render and notify
1642 application.SendNotification();
1643 application.Render();
1645 // Checks the cursor and the renderer have been created.
1646 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1647 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1649 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1650 DALI_TEST_CHECK( cursor );
1652 // The offscreen root actor has a container with all the actors which contain the text renderers.
1653 Actor container = stencil.GetChildAt( 0u );
1654 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1656 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1657 DALI_TEST_CHECK( renderer );
1660 // Move the cursor and check the position changes.
1661 Vector3 position1 = cursor.GetCurrentPosition();
1663 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1664 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1666 // Render and notify
1667 application.SendNotification();
1668 application.Render();
1670 Vector3 position2 = cursor.GetCurrentPosition();
1672 DALI_TEST_CHECK( position2.x < position1.x );
1674 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1675 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1677 // Render and notify
1678 application.SendNotification();
1679 application.Render();
1681 Vector3 position3 = cursor.GetCurrentPosition();
1683 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1685 // Send some taps and check the cursor positions.
1687 // Try to tap at the beginning.
1688 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1689 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1691 // Render and notify
1692 application.SendNotification();
1693 application.Render();
1695 // Cursor position should be the same than position1.
1696 Vector3 position4 = cursor.GetCurrentPosition();
1698 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1700 // Tap away from the start position.
1701 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1702 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1704 // Render and notify
1705 application.SendNotification();
1706 application.Render();
1708 Vector3 position5 = cursor.GetCurrentPosition();
1710 DALI_TEST_CHECK( position5.x > position4.x );
1712 // Remove all the text.
1713 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1714 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1715 field.SetProperty( TextField::Property::TEXT, "" );
1717 // Render and notify
1718 application.SendNotification();
1719 application.Render();
1721 // Cursor position should be the same than position2.
1722 Vector3 position6 = cursor.GetCurrentPosition();
1724 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1726 // Should not be a renderer.
1727 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1732 int utcDaliTextFieldEvent03(void)
1734 ToolkitTestApplication application;
1735 tet_infoline(" utcDaliTextFieldEvent03");
1737 // Checks if the highlight actor is created.
1739 TextField field = TextField::New();
1740 DALI_TEST_CHECK( field );
1742 Stage::GetCurrent().Add( field );
1744 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1745 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1746 field.SetSize( 30.f, 50.f );
1747 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1748 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1750 // Avoid a crash when core load gl resources.
1751 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1752 LoadMarkerImages(application, field);
1754 // Render and notify
1755 application.SendNotification();
1756 application.Render();
1758 // Tap first to get the focus.
1759 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1760 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1762 // Render and notify
1763 application.SendNotification();
1764 application.Render();
1766 // Double tap to select a word.
1767 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1768 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1770 // Render and notify
1771 application.SendNotification();
1772 application.Render();
1774 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1775 Actor stencil = field.GetChildAt( 0u );
1777 // The highlight actor is drawn first, so is the first actor in the list
1778 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1779 DALI_TEST_CHECK( highlight );
1781 // The offscreen root actor has a container with all the actors which contain the text renderers.
1782 Actor container = stencil.GetChildAt( 1u );
1783 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1785 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1786 DALI_TEST_CHECK( renderer );
1792 int utcDaliTextFieldEvent04(void)
1794 ToolkitTestApplication application;
1795 tet_infoline(" utcDaliTextFieldEvent04");
1797 // Checks if the highlight actor is created.
1799 TextField field = TextField::New();
1800 DALI_TEST_CHECK( field );
1801 Stage::GetCurrent().Add( field );
1802 LoadMarkerImages(application, field);
1803 // Render and notify
1804 application.SendNotification();
1805 application.Render();
1807 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1808 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1809 field.SetSize( 300.f, 50.f );
1810 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1811 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1813 // Avoid a crash when core load gl resources.
1814 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1815 // Render and notify
1816 application.SendNotification();
1817 application.Render();
1819 // Create a tap event to touch the text field.
1820 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1821 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1822 // Render and notify
1823 application.SendNotification();
1824 application.Render();
1827 // Tap first to get the focus.
1828 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1829 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1831 // Render and notify
1832 application.SendNotification();
1833 application.Render();
1835 // Double tap to select a word.
1836 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1837 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1839 // Render and notify
1840 application.SendNotification();
1841 application.Render();
1844 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1845 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1849 int utcDaliTextFieldEvent05(void)
1851 ToolkitTestApplication application;
1852 tet_infoline(" utcDaliTextFieldEvent05");
1854 // Checks dragging of cursor/grab handle
1856 TextField field = TextField::New();
1857 DALI_TEST_CHECK( field );
1858 Stage::GetCurrent().Add( field );
1859 LoadMarkerImages(application, field);
1860 // Render and notify
1861 application.SendNotification();
1862 application.Render();
1864 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1865 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1866 field.SetSize( 300.f, 50.f );
1867 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1868 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1870 // Avoid a crash when core load gl resources.
1871 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1872 // Render and notify
1873 application.SendNotification();
1874 application.Render();
1876 // Create a tap event to touch the text field.
1877 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1878 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1879 // Render and notify
1880 application.SendNotification();
1881 application.Render();
1884 // Tap first to get the focus.
1885 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1886 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1888 // Render and notify
1889 application.SendNotification();
1890 application.Render();
1892 // Double tap to select a word.
1893 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1894 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1896 // Render and notify
1897 application.SendNotification();
1898 application.Render();
1900 // drag grab handle right
1901 Vector2 pos(0.0f, 40.0f);
1902 SendPan(application, Gesture::Possible, pos);
1903 SendPan(application, Gesture::Started, pos);
1905 Wait(application, 100);
1907 for(int i = 0;i<20;i++)
1909 SendPan(application, Gesture::Continuing, pos);
1914 SendPan(application, Gesture::Finished, pos);
1915 Wait(application, RENDER_FRAME_INTERVAL);
1917 Actor stencil = field.GetChildAt( 1u );
1921 int utcDaliTextFieldEvent06(void)
1923 ToolkitTestApplication application;
1924 tet_infoline(" utcDaliTextFieldEvent06");
1926 // Checks Longpress when in edit mode
1928 TextField field = TextField::New();
1929 DALI_TEST_CHECK( field );
1930 Stage::GetCurrent().Add( field );
1931 LoadMarkerImages(application, field);
1932 // Render and notify
1933 application.SendNotification();
1934 application.Render();
1936 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1937 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1938 field.SetSize( 300.f, 50.f );
1939 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1940 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1942 // Avoid a crash when core load gl resources.
1943 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1944 // Render and notify
1945 application.SendNotification();
1946 application.Render();
1948 // Create a tap event to touch the text field.
1949 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1950 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1951 // Render and notify
1952 application.SendNotification();
1953 application.Render();
1956 // Tap first to get the focus.
1957 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1958 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1960 // Render and notify
1961 application.SendNotification();
1962 application.Render();
1965 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1966 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1968 // Render and notify
1969 application.SendNotification();
1970 application.Render();
1975 int utcDaliTextFieldEvent07(void)
1977 ToolkitTestApplication application;
1978 tet_infoline(" utcDaliTextFieldEvent07");
1980 // Checks Longpress to start edit mode
1982 TextField field = TextField::New();
1983 DALI_TEST_CHECK( field );
1984 Stage::GetCurrent().Add( field );
1985 LoadMarkerImages(application, field);
1986 // Render and notify
1987 application.SendNotification();
1988 application.Render();
1990 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1991 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1992 field.SetSize( 300.f, 50.f );
1993 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1994 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1995 Property::Map propertyMap;
1996 propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
1997 field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
1999 // Avoid a crash when core load gl resources.
2000 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2001 // Render and notify
2002 application.SendNotification();
2003 application.Render();
2006 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2007 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2009 // Render and notify
2010 application.SendNotification();
2011 application.Render();
2016 int utcDaliTextFieldEvent08(void)
2018 ToolkitTestApplication application;
2019 tet_infoline(" utcDaliTextFieldEvent08");
2021 Dali::Clipboard clipboard = Clipboard::Get();
2022 clipboard.SetItem("testTextFieldEvent");
2024 // Checks Longpress when only place holder text
2026 TextField field = TextField::New();
2027 DALI_TEST_CHECK( field );
2028 Stage::GetCurrent().Add( field );
2029 LoadMarkerImages(application, field);
2030 // Render and notify
2031 application.SendNotification();
2032 application.Render();
2034 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2035 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2036 field.SetSize( 300.f, 50.f );
2037 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2038 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2040 // Avoid a crash when core load gl resources.
2041 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2042 // Render and notify
2043 application.SendNotification();
2044 application.Render();
2047 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2048 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2050 // Render and notify
2051 application.SendNotification();
2052 application.Render();
2054 Wait(application, 500);
2057 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
2058 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
2060 // Render and notify
2061 application.SendNotification();
2062 application.Render();
2064 Wait(application, 500);
2066 Stage stage = Stage::GetCurrent();
2067 Layer layer = stage.GetRootLayer();
2068 Actor actor = layer.FindChildByName("optionPaste");
2072 Vector3 worldPosition = actor.GetCurrentWorldPosition();
2073 Vector2 halfStageSize = stage.GetSize() / 2.0f;
2074 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2076 Dali::Integration::TouchEvent event;
2077 event = Dali::Integration::TouchEvent();
2078 event.AddPoint( GetPointDownInside( position ) );
2079 application.ProcessEvent( event );
2081 event = Dali::Integration::TouchEvent();
2082 event.AddPoint( GetPointUpInside( position ) );
2083 application.ProcessEvent( event );
2085 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2090 int utcDaliTextFieldEvent09(void)
2092 ToolkitTestApplication application;
2093 tet_infoline(" utcDaliTextFieldEvent09");
2095 TextField field = TextField::New();
2096 DALI_TEST_CHECK( field );
2097 Stage::GetCurrent().Add( field );
2098 LoadMarkerImages(application, field);
2099 // Render and notify
2100 application.SendNotification();
2101 application.Render();
2103 field.SetProperty( TextField::Property::TEXT, "Hello" );
2104 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2105 field.SetSize( 300.f, 50.f );
2106 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2107 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2109 // Avoid a crash when core load gl resources.
2110 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2112 // Create a tap event to touch the text field.
2113 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2114 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2115 application.SendNotification();
2116 application.Render();
2119 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2120 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2121 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2122 application.SendNotification();
2123 application.Render();
2125 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2126 map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2127 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2128 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2129 application.SendNotification();
2130 application.Render();
2132 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2133 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2134 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2135 for( unsigned int index = 0u; index < 5u; ++index )
2137 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2138 application.SendNotification();
2139 application.Render();
2142 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2143 map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2144 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2145 for( unsigned int index = 0u; index < 5u; ++index )
2147 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2148 application.SendNotification();
2149 application.Render();
2152 map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2153 map[ HiddenInput::Property::SHOW_DURATION ] = 0;
2154 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2155 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2156 application.SendNotification();
2157 application.Render();
2158 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2159 application.SendNotification();
2160 application.Render();
2162 map[ HiddenInput::Property::SHOW_DURATION ] = 100;
2163 field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
2164 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2165 application.SendNotification();
2166 application.Render();
2168 Property::Map mapGet;
2169 mapGet = field.GetProperty<Property::Map>( DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
2170 DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2171 DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2176 int utcDaliTextFieldStyleWhilstSelected(void)
2178 ToolkitTestApplication application;
2179 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2181 // Change font and styles whilst text is selected whilst word selected
2183 TextField field = TextField::New();
2184 DALI_TEST_CHECK( field );
2185 Stage::GetCurrent().Add( field );
2186 LoadMarkerImages(application, field);
2187 // Render and notify
2188 application.SendNotification();
2189 application.Render();
2191 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2192 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2193 field.SetSize( 300.f, 50.f );
2194 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2195 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2197 // Avoid a crash when core load gl resources.
2198 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2199 // Render and notify
2200 application.SendNotification();
2201 application.Render();
2203 // Create a tap event to touch the text field.
2204 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2205 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2206 // Render and notify
2207 application.SendNotification();
2208 application.Render();
2211 // Tap first to get the focus.
2212 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2213 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2215 // Render and notify
2216 application.SendNotification();
2217 application.Render();
2219 // Double tap to select a word.
2220 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2221 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2223 // Render and notify
2224 application.SendNotification();
2225 application.Render();
2227 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2228 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2230 Property::Map fontStyleMapSet;
2231 Property::Map fontStyleMapGet;
2233 fontStyleMapSet.Insert( "weight", "bold" );
2234 fontStyleMapSet.Insert( "slant", "italic" );
2235 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2237 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2238 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2239 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2241 fontStyleMapSet.Clear();
2242 fontStyleMapSet.Insert( "width", "expanded" );
2243 fontStyleMapSet.Insert( "slant", "italic" );
2244 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2246 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2247 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2248 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2250 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2251 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2253 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2254 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2256 fontStyleMapSet.Clear();
2257 fontStyleMapSet.Insert( "weight", "bold" );
2258 fontStyleMapSet.Insert( "slant", "italic" );
2260 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2262 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2263 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2264 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2266 fontStyleMapSet.Clear();
2267 fontStyleMapSet.Insert( "width", "expanded" );
2269 field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2271 fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2272 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2273 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2275 // Press Escape to increase coverage
2276 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2277 application.SendNotification();
2278 application.Render();
2280 DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2285 int utcDaliTextFieldEscKeyLoseFocus(void)
2287 ToolkitTestApplication application;
2288 tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2290 // Creates a tap event. After creating a tap event the text field should
2291 // have the focus and add text with key events should be possible.
2293 TextField field = TextField::New();
2294 DALI_TEST_CHECK( field );
2296 Stage::GetCurrent().Add( field );
2298 field.SetSize( 300.f, 50.f );
2299 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2300 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2302 // Avoid a crash when core load gl resources.
2303 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2305 // Render and notify
2306 application.SendNotification();
2307 application.Render();
2309 // Add a key event but as the text field has not the focus it should do nothing.
2310 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2311 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2313 // Render and notify
2314 application.SendNotification();
2315 application.Render();
2317 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2319 // Create a tap event to touch the text field.
2320 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2321 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2323 // Render and notify
2324 application.SendNotification();
2325 application.Render();
2327 // Now the text field has the focus, so it can handle the key events.
2328 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2329 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2330 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2331 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2333 // Render and notify
2334 application.SendNotification();
2335 application.Render();
2337 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2339 // Generate a Esc key event. The text field should lose the focus.
2340 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2341 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2343 // Render and notify
2344 application.SendNotification();
2345 application.Render();
2347 DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2349 // No more text should be introduced
2350 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2351 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2353 // Render and notify
2354 application.SendNotification();
2355 application.Render();
2357 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2362 int utcDaliTextFieldSomeSpecialKeys(void)
2364 ToolkitTestApplication application;
2365 tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
2367 // Checks some special keys when the text is selected.
2369 TextField field = TextField::New();
2370 DALI_TEST_CHECK( field );
2371 Stage::GetCurrent().Add( field );
2372 LoadMarkerImages(application, field);
2373 // Render and notify
2374 application.SendNotification();
2375 application.Render();
2377 const std::string longText( "This is a long text for the size of the text-field." );
2379 field.SetProperty( TextField::Property::TEXT, longText );
2380 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2381 field.SetSize( 300.f, 50.f );
2382 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
2383 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2385 // Avoid a crash when core load gl resources.
2386 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2387 // Render and notify
2388 application.SendNotification();
2389 application.Render();
2391 // Create a tap event to touch the text field.
2392 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2393 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
2395 // Render and notify
2396 application.SendNotification();
2397 application.Render();
2399 // Tap first to get the focus.
2400 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2401 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
2403 // Render and notify
2404 application.SendNotification();
2405 application.Render();
2407 // Double tap to select a word.
2408 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2409 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
2411 // Render and notify
2412 application.SendNotification();
2413 application.Render();
2415 // Generate a Esc key event. The text field should lose the focus.
2416 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2417 application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2419 // Render and notify
2420 application.SendNotification();
2421 application.Render();
2423 // Generate a Esc key event. The text field should lose the focus.
2424 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2425 application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2427 // Render and notify
2428 application.SendNotification();
2429 application.Render();
2431 // Generate a Esc key event. The text field should lose the focus.
2432 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2433 application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
2435 // Render and notify
2436 application.SendNotification();
2437 application.Render();
2439 // The text shouldn't be deleted.
2440 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );