2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali/public-api/rendering/renderer.h>
23 #include <dali/integration-api/events/key-event-integ.h>
24 #include <dali/integration-api/events/tap-gesture-event.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/integration-api/events/pan-gesture-event.h>
27 #include <dali/integration-api/events/long-press-gesture-event.h>
28 #include <dali-toolkit-test-suite-utils.h>
29 #include <dali-toolkit/dali-toolkit.h>
30 #include "toolkit-clipboard.h"
33 using namespace Toolkit;
35 void dali_textfield_startup(void)
37 test_return_value = TET_UNDEF;
40 void dali_textfield_cleanup(void)
42 test_return_value = TET_PASS;
48 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
49 const char* const PROPERTY_NAME_TEXT = "text";
50 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
51 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
52 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
53 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
54 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
55 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
56 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
57 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
58 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
59 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
60 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
61 const char* const PROPERTY_NAME_SHADOW_OFFSET = "shadowOffset";
62 const char* const PROPERTY_NAME_SHADOW_COLOR = "shadowColor";
63 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
64 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
65 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
66 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
67 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
68 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
69 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
70 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
71 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
72 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
73 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
79 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
80 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
81 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
82 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
83 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
84 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
85 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
86 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
88 const char* const PROPERTY_NAME_UNDERLINE = "underline";
89 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
90 const char* const PROPERTY_NAME_SHADOW = "shadow";
91 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
92 const char* const PROPERTY_NAME_EMBOSS = "emboss";
93 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
94 const char* const PROPERTY_NAME_OUTLINE = "outline";
95 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
97 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
99 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
100 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
102 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
103 const float RENDER_FRAME_INTERVAL = 16.66f;
105 const float TO_MILLISECONDS = 1000.f;
106 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
108 const float SCROLL_THRESHOLD = 10.f;
109 const float SCROLL_SPEED = 300.f;
111 const unsigned int DEFAULT_FONT_SIZE = 1152u;
112 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
114 const int KEY_A_CODE = 38;
115 const int KEY_D_CODE = 40;
117 static bool gTextChangedCallBackCalled;
118 static bool gMaxCharactersCallBackCalled;
119 static bool gInputStyleChangedCallbackCalled;
120 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
122 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
124 Integration::ResourceRequest* request = platform.GetRequest();
125 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
126 Integration::ResourcePointer resource(bitmap);
127 bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
131 platform.SetResourceLoaded(request->GetId(), request->GetType()->id, resource);
135 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
139 LoadBitmapResource( app.GetPlatform(), width, height );
141 Property::Map propertyMap;
142 propertyMap["filename"] = "image.png";
143 propertyMap["width"] = width;
144 propertyMap["height"] = height;
145 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
146 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
147 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
148 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
149 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
150 textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
151 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
152 textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
155 // Generate a PanGestureEvent to send to Core
156 static Integration::PanGestureEvent GeneratePan(
157 Gesture::State state,
158 const Vector2& previousPosition,
159 const Vector2& currentPosition,
160 unsigned long timeDelta,
161 unsigned int numberOfTouches = 1)
163 Integration::PanGestureEvent pan(state);
165 pan.previousPosition = previousPosition;
166 pan.currentPosition = currentPosition;
167 pan.timeDelta = timeDelta;
168 pan.numberOfTouches = numberOfTouches;
174 * Helper to generate PanGestureEvent
176 * @param[in] application Application instance
177 * @param[in] state The Gesture State
178 * @param[in] pos The current position of touch.
180 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
184 if( (state == Gesture::Started) ||
185 (state == Gesture::Possible) )
191 application.ProcessEvent(GeneratePan(state, last, pos, 16));
198 * Simulate time passed by.
200 * @note this will always process at least 1 frame (1/60 sec)
202 * @param application Test application instance
203 * @param duration Time to pass in milliseconds.
204 * @return The actual time passed in milliseconds
206 static int Wait(ToolkitTestApplication& application, int duration = 0)
210 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
212 application.SendNotification();
213 application.Render(RENDER_FRAME_INTERVAL);
214 time += RENDER_FRAME_INTERVAL;
220 Dali::Integration::Point GetPointDownInside( Vector2& pos )
222 Dali::Integration::Point point;
223 point.SetState( PointState::DOWN );
224 point.SetScreenPosition( pos );
228 Dali::Integration::Point GetPointUpInside( Vector2& pos )
230 Dali::Integration::Point point;
231 point.SetState( PointState::UP );
232 point.SetScreenPosition( pos );
236 struct CallbackFunctor
238 CallbackFunctor(bool* callbackFlag)
239 : mCallbackFlag( callbackFlag )
245 *mCallbackFlag = true;
250 static void TestTextChangedCallback( TextField control )
252 tet_infoline(" TestTextChangedCallback");
254 gTextChangedCallBackCalled = true;
257 static void TestMaxLengthReachedCallback( TextField control )
259 tet_infoline(" TestMaxLengthReachedCallback");
261 gMaxCharactersCallBackCalled = true;
264 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
266 tet_infoline(" TestInputStyleChangedCallback");
268 gInputStyleChangedCallbackCalled = true;
269 gInputStyleMask = mask;
272 // Generate a TapGestureEvent to send to Core.
273 Integration::TapGestureEvent GenerateTap(
274 Gesture::State state,
275 unsigned int numberOfTaps,
276 unsigned int numberOfTouches,
279 Integration::TapGestureEvent tap( state );
281 tap.numberOfTaps = numberOfTaps;
282 tap.numberOfTouches = numberOfTouches;
289 Integration::LongPressGestureEvent GenerateLongPress(
290 Gesture::State state,
291 unsigned int numberOfTouches,
294 Integration::LongPressGestureEvent longPress( state );
296 longPress.numberOfTouches = numberOfTouches;
297 longPress.point = point;
301 // Generate a KeyEvent to send to Core.
302 Integration::KeyEvent GenerateKey( const std::string& keyName,
303 const std::string& keyString,
306 unsigned long timeStamp,
307 const Integration::KeyEvent::State& keyState )
309 return Integration::KeyEvent( keyName,
319 int UtcDaliToolkitTextFieldConstructorP(void)
321 ToolkitTestApplication application;
322 tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
324 DALI_TEST_CHECK( !textField );
328 int UtcDaliToolkitTextFieldNewP(void)
330 ToolkitTestApplication application;
331 tet_infoline(" UtcDaliToolkitTextFieldNewP");
332 TextField textField = TextField::New();
333 DALI_TEST_CHECK( textField );
337 int UtcDaliToolkitTextFieldDownCastP(void)
339 ToolkitTestApplication application;
340 tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
341 TextField textField1 = TextField::New();
342 BaseHandle object( textField1 );
344 TextField textField2 = TextField::DownCast( object );
345 DALI_TEST_CHECK( textField2 );
347 TextField textField3 = DownCast< TextField >( object );
348 DALI_TEST_CHECK( textField3 );
352 int UtcDaliToolkitTextFieldDownCastN(void)
354 ToolkitTestApplication application;
355 tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
356 BaseHandle uninitializedObject;
357 TextField textField1 = TextField::DownCast( uninitializedObject );
358 DALI_TEST_CHECK( !textField1 );
360 TextField textField2 = DownCast< TextField >( uninitializedObject );
361 DALI_TEST_CHECK( !textField2 );
365 int UtcDaliToolkitTextFieldCopyConstructorP(void)
367 ToolkitTestApplication application;
368 tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
369 TextField textField = TextField::New();
370 textField.SetProperty( TextField::Property::TEXT, "Test" );
372 TextField copy( textField );
373 DALI_TEST_CHECK( copy );
374 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
378 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
380 ToolkitTestApplication application;
381 tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
382 TextField textField = TextField::New();
383 textField.SetProperty( TextField::Property::TEXT, "Test" );
385 TextField copy = textField;
386 DALI_TEST_CHECK( copy );
387 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
391 int UtcDaliTextFieldNewP(void)
393 ToolkitTestApplication application;
394 tet_infoline(" UtcDaliToolkitTextFieldNewP");
395 TextField textField = TextField::New();
396 DALI_TEST_CHECK( textField );
400 // Positive test case for a method
401 int UtcDaliTextFieldGetPropertyP(void)
403 ToolkitTestApplication application;
404 tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
405 TextField field = TextField::New();
406 DALI_TEST_CHECK( field );
408 // Check Property Indices are correct
409 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
410 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
411 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
412 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
413 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
414 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
415 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
416 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
417 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
418 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
419 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
420 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
421 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
422 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextField::Property::SHADOW_OFFSET );
423 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextField::Property::SHADOW_COLOR );
424 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
425 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
426 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
427 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
428 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
429 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
430 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
431 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
432 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
433 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
434 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
435 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
436 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
437 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
438 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
439 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
440 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
441 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
442 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
443 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
444 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
445 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
446 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
447 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
448 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
449 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
450 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
451 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
452 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
453 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
454 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
455 DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
460 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
463 Property::Map imageMap;
464 imageMap[mapKey] =mapValue;
466 field.SetProperty( property , imageMap );
467 Property::Value propValue = field.GetProperty( property );
468 Property::Map* resultMap = propValue.GetMap();
470 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
478 // Positive test case for a method
479 int UtcDaliTextFieldSetPropertyP(void)
481 ToolkitTestApplication application;
482 tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
483 TextField field = TextField::New();
484 DALI_TEST_CHECK( field );
485 Stage::GetCurrent().Add( field );
487 // Note - we can't check the defaults since the stylesheets are platform-specific
489 // Check the render backend property.
490 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
491 DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
493 // Check text property.
494 field.SetProperty( TextField::Property::TEXT, "Setting Text" );
495 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
497 // Check placeholder text properties.
498 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
499 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
501 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
502 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
504 // Check font properties.
505 field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
506 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
507 field.SetProperty( TextField::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
508 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_STYLE ), std::string("{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}"), TEST_LOCATION );
509 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
510 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
513 field.SetProperty( TextField::Property::FONT_STYLE, "{\"weight\":\"normal\",\"slant\":\"oblique\"}" );
514 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_STYLE ), std::string("{\"weight\":\"normal\",\"slant\":\"oblique\"}"), TEST_LOCATION );
515 field.SetProperty( TextField::Property::FONT_STYLE, "{\"slant\":\"roman\"}" );
516 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_STYLE ), std::string("{\"slant\":\"normal\"}"), TEST_LOCATION );
517 field.SetProperty( TextField::Property::FONT_STYLE, "" );
518 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_STYLE ), std::string(""), TEST_LOCATION );
520 // Check that the MAX_LENGTH property can be correctly set
521 const int maxNumberOfCharacters = 20;
522 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
523 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
525 // Check exceed policy
526 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
527 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
528 field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
529 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
531 // Check that the Alignment properties can be correctly set
532 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
533 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
534 field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
535 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
537 // Check text's color property
538 field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
539 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
541 // Check placeholder text's color property.
542 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
543 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
545 // Check shadow properties.
546 field.SetProperty( TextField::Property::SHADOW_OFFSET, Vector2( 1.f, 1.f ) );
547 DALI_TEST_EQUALS( field.GetProperty<Vector2>( TextField::Property::SHADOW_OFFSET ), Vector2( 1.f, 1.f ), TEST_LOCATION );
548 field.SetProperty( TextField::Property::SHADOW_COLOR, Color::GREEN );
549 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SHADOW_COLOR ), Color::GREEN, TEST_LOCATION );
551 // Check cursor properties
552 field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
553 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
554 field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
555 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
557 field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
558 DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
559 field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
560 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
561 field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
562 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
563 field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
564 DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
566 // Check scroll properties.
567 field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
568 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
569 field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
570 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
572 // Check handle images
573 field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
574 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
575 field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
576 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
577 field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
579 // Check handle images
580 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
581 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
582 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
583 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
584 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
585 DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
587 // Check the highlight color
588 field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
589 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
591 // Decoration bounding box
592 field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
593 DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
595 // Check input color property.
596 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
597 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
599 // Check the enable markup property.
600 DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
601 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
602 DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
604 // Check input font properties.
605 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
606 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
607 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
608 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_STYLE ), "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}", TEST_LOCATION );
609 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
610 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
612 // Reset input font style.
613 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"weight\":\"normal\",\"slant\":\"oblique\"}" );
614 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_STYLE ), std::string("{\"weight\":\"normal\",\"slant\":\"oblique\"}"), TEST_LOCATION );
615 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"slant\":\"roman\"}" );
616 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_STYLE ), std::string("{\"slant\":\"normal\"}"), TEST_LOCATION );
617 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "" );
618 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_STYLE ), std::string(""), TEST_LOCATION );
620 // Check the underline property
621 field.SetProperty( TextField::Property::UNDERLINE, "Underline properties" );
622 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::UNDERLINE ), std::string("Underline properties"), TEST_LOCATION );
624 // Check the input underline property
625 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
626 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
628 // Check the shadow property
629 field.SetProperty( TextField::Property::SHADOW, "Shadow properties" );
630 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::SHADOW ), std::string("Shadow properties"), TEST_LOCATION );
632 // Check the input shadow property
633 field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
634 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
636 // Check the emboss property
637 field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
638 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
640 // Check the input emboss property
641 field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
642 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
644 // Check the outline property
645 field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
646 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
648 // Check the input outline property
649 field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
650 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
655 // Positive Atlas Text Renderer test
656 int utcDaliTextFieldAtlasRenderP(void)
658 ToolkitTestApplication application;
659 tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
660 StyleManager styleManager = StyleManager::Get();
661 styleManager.ApplyDefaultTheme();
662 TextField field = TextField::New();
663 DALI_TEST_CHECK( field );
665 field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
667 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
669 Stage::GetCurrent().Add( field );
673 // Render some text with the shared atlas backend
674 field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
675 application.SendNotification();
676 application.Render();
680 tet_result(TET_FAIL);
685 // Positive test for the textChanged signal.
686 int utcDaliTextFieldTextChangedP(void)
688 ToolkitTestApplication application;
689 tet_infoline(" utcDaliTextFieldTextChangedP");
690 TextField field = TextField::New();
691 DALI_TEST_CHECK( field );
693 Stage::GetCurrent().Add( field );
695 // connect to the text changed signal.
696 ConnectionTracker* testTracker = new ConnectionTracker();
697 field.TextChangedSignal().Connect(&TestTextChangedCallback);
698 bool textChangedSignal = false;
699 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
701 gTextChangedCallBackCalled = false;
702 field.SetProperty( TextField::Property::TEXT, "ABC" );
703 DALI_TEST_CHECK( gTextChangedCallBackCalled );
704 DALI_TEST_CHECK( textChangedSignal );
706 application.SendNotification();
708 field.SetKeyInputFocus();
710 gTextChangedCallBackCalled = false;
711 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down ) );
712 DALI_TEST_CHECK( gTextChangedCallBackCalled );
717 // Negative test for the textChanged signal.
718 int utcDaliTextFieldTextChangedN(void)
720 ToolkitTestApplication application;
721 tet_infoline(" utcDaliTextFieldTextChangedN");
722 TextField field = TextField::New();
723 DALI_TEST_CHECK( field );
725 Stage::GetCurrent().Add( field );
727 // connect to the text changed signal.
728 ConnectionTracker* testTracker = new ConnectionTracker();
729 field.TextChangedSignal().Connect(&TestTextChangedCallback);
730 bool textChangedSignal = false;
731 field.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
733 gTextChangedCallBackCalled = false;
734 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
735 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
736 DALI_TEST_CHECK( !textChangedSignal );
741 // Positive test for Max Characters reached signal.
742 int utcDaliTextFieldMaxCharactersReachedP(void)
744 ToolkitTestApplication application;
745 tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
746 TextField field = TextField::New();
747 DALI_TEST_CHECK( field );
749 Stage::GetCurrent().Add( field );
751 const int maxNumberOfCharacters = 1;
752 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
754 field.SetKeyInputFocus();
756 // connect to the text changed signal.
757 ConnectionTracker* testTracker = new ConnectionTracker();
758 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
759 bool maxLengthReachedSignal = false;
760 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
762 gMaxCharactersCallBackCalled = false;
764 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
765 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
767 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
768 DALI_TEST_CHECK( maxLengthReachedSignal );
773 // Negative test for Max Characters reached signal.
774 int utcDaliTextFieldMaxCharactersReachedN(void)
776 ToolkitTestApplication application;
777 tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
778 TextField field = TextField::New();
779 DALI_TEST_CHECK( field );
781 Stage::GetCurrent().Add( field );
783 const int maxNumberOfCharacters = 3;
784 field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
786 field.SetKeyInputFocus();
788 // connect to the text changed signal.
789 ConnectionTracker* testTracker = new ConnectionTracker();
790 field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
791 bool maxLengthReachedSignal = false;
792 field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
794 gMaxCharactersCallBackCalled = false;
796 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
797 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
799 DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
800 DALI_TEST_CHECK( !maxLengthReachedSignal );
805 int utcDaliTextFieldInputStyleChanged01(void)
807 ToolkitTestApplication application;
808 tet_infoline(" utcDaliTextFieldInputStyleChanged01");
810 // The text-field emits signals when the input style changes. These changes of style are
811 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
812 // can't be emitted during the size negotiation as the callbacks may update the UI.
813 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
814 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
815 application.CreateAdaptor();
819 char* pathNamePtr = get_current_dir_name();
820 const std::string pathName( pathNamePtr );
823 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
824 fontClient.SetDpi( 93u, 93u );
826 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
827 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
829 TextField field = TextField::New();
830 DALI_TEST_CHECK( field );
833 field.SetSize( 300.f, 50.f );
834 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
835 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
837 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
838 field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
840 // connect to the text changed signal.
841 ConnectionTracker* testTracker = new ConnectionTracker();
842 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
843 bool inputStyleChangedSignal = false;
844 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
846 Stage::GetCurrent().Add( field );
849 application.SendNotification();
850 application.Render();
852 // Executes the idle callbacks added by the text control on the change of input style.
853 application.RunIdles();
855 gInputStyleChangedCallbackCalled = false;
856 gInputStyleMask = TextField::InputStyle::NONE;
857 inputStyleChangedSignal = false;
859 // Create a tap event to touch the text field.
860 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
861 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
864 application.SendNotification();
865 application.Render();
867 // Executes the idle callbacks added by the text control on the change of input style.
868 application.RunIdles();
870 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
871 if( gInputStyleChangedCallbackCalled )
873 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
875 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
876 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
878 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
879 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
881 DALI_TEST_CHECK( inputStyleChangedSignal );
883 gInputStyleChangedCallbackCalled = false;
884 gInputStyleMask = TextField::InputStyle::NONE;
885 inputStyleChangedSignal = false;
887 // Create a tap event to touch the text field.
888 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
889 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
892 application.SendNotification();
893 application.Render();
895 // Executes the idle callbacks added by the text control on the change of input style.
896 application.RunIdles();
898 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
899 DALI_TEST_CHECK( !inputStyleChangedSignal );
901 gInputStyleChangedCallbackCalled = false;
902 gInputStyleMask = TextField::InputStyle::NONE;
903 inputStyleChangedSignal = false;
905 // Create a tap event to touch the text field.
906 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
907 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
910 application.SendNotification();
911 application.Render();
913 // Executes the idle callbacks added by the text control on the change of input style.
914 application.RunIdles();
916 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
917 if( gInputStyleChangedCallbackCalled )
919 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
921 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
922 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
924 DALI_TEST_CHECK( inputStyleChangedSignal );
926 gInputStyleChangedCallbackCalled = false;
927 gInputStyleMask = TextField::InputStyle::NONE;
928 inputStyleChangedSignal = false;
930 // Create a tap event to touch the text field.
931 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
932 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
935 application.SendNotification();
936 application.Render();
938 // Executes the idle callbacks added by the text control on the change of input style.
939 application.RunIdles();
941 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
942 if( gInputStyleChangedCallbackCalled )
944 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
946 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
947 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
949 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
950 DALI_TEST_EQUALS( style, "{\"weight\":\"bold\"}", TEST_LOCATION );
952 DALI_TEST_CHECK( inputStyleChangedSignal );
954 gInputStyleChangedCallbackCalled = false;
955 gInputStyleMask = TextField::InputStyle::NONE;
956 inputStyleChangedSignal = false;
958 // Create a tap event to touch the text field.
959 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
960 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
963 application.SendNotification();
964 application.Render();
966 // Executes the idle callbacks added by the text control on the change of input style.
967 application.RunIdles();
969 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
970 DALI_TEST_CHECK( !inputStyleChangedSignal );
972 gInputStyleChangedCallbackCalled = false;
973 gInputStyleMask = TextField::InputStyle::NONE;
974 inputStyleChangedSignal = false;
976 // Create a tap event to touch the text field.
977 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
978 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
981 application.SendNotification();
982 application.Render();
984 // Executes the idle callbacks added by the text control on the change of input style.
985 application.RunIdles();
987 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
988 if( gInputStyleChangedCallbackCalled )
990 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
992 const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
993 DALI_TEST_CHECK( style.empty() );
995 DALI_TEST_CHECK( inputStyleChangedSignal );
997 gInputStyleChangedCallbackCalled = false;
998 gInputStyleMask = TextField::InputStyle::NONE;
999 inputStyleChangedSignal = false;
1001 // Create a tap event to touch the text field.
1002 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1003 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1005 // Render and notify
1006 application.SendNotification();
1007 application.Render();
1009 // Executes the idle callbacks added by the text control on the change of input style.
1010 application.RunIdles();
1012 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1013 DALI_TEST_CHECK( !inputStyleChangedSignal );
1018 int utcDaliTextFieldInputStyleChanged02(void)
1020 ToolkitTestApplication application;
1021 tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1023 // The text-field emits signals when the input style changes. These changes of style are
1024 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1025 // can't be emitted during the size negotiation as the callbacks may update the UI.
1026 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1027 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1028 application.CreateAdaptor();
1032 char* pathNamePtr = get_current_dir_name();
1033 const std::string pathName( pathNamePtr );
1034 free( pathNamePtr );
1036 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1037 fontClient.SetDpi( 93u, 93u );
1039 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1040 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1042 TextField field = TextField::New();
1043 DALI_TEST_CHECK( field );
1046 field.SetSize( 300.f, 50.f );
1047 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1048 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1050 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1051 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>" );
1053 // connect to the text changed signal.
1054 ConnectionTracker* testTracker = new ConnectionTracker();
1055 field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1056 bool inputStyleChangedSignal = false;
1057 field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1059 Stage::GetCurrent().Add( field );
1061 // Render and notify
1062 application.SendNotification();
1063 application.Render();
1065 // Executes the idle callbacks added by the text control on the change of input style.
1066 application.RunIdles();
1068 gInputStyleChangedCallbackCalled = false;
1069 gInputStyleMask = TextField::InputStyle::NONE;
1070 inputStyleChangedSignal = false;
1072 // Create a tap event to touch the text field.
1073 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1074 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1075 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1076 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1078 // Render and notify
1079 application.SendNotification();
1080 application.Render();
1082 // Executes the idle callbacks added by the text control on the change of input style.
1083 application.RunIdles();
1085 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1086 if( gInputStyleChangedCallbackCalled )
1088 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1089 static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
1090 TextField::InputStyle::POINT_SIZE |
1091 TextField::InputStyle::COLOR ),
1094 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1095 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1097 const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1098 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1100 const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1101 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1103 DALI_TEST_CHECK( inputStyleChangedSignal );
1105 gInputStyleChangedCallbackCalled = false;
1106 gInputStyleMask = TextField::InputStyle::NONE;
1107 inputStyleChangedSignal = false;
1109 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1111 // Render and notify
1112 application.SendNotification();
1113 application.Render();
1115 // Executes the idle callbacks added by the text control on the change of input style.
1116 application.RunIdles();
1118 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1119 if( gInputStyleChangedCallbackCalled )
1121 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1122 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1125 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1126 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1128 DALI_TEST_CHECK( inputStyleChangedSignal );
1130 gInputStyleChangedCallbackCalled = false;
1131 gInputStyleMask = TextField::InputStyle::NONE;
1132 inputStyleChangedSignal = false;
1134 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1136 // Render and notify
1137 application.SendNotification();
1138 application.Render();
1140 // Executes the idle callbacks added by the text control on the change of input style.
1141 application.RunIdles();
1143 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1144 DALI_TEST_CHECK( !inputStyleChangedSignal );
1146 gInputStyleChangedCallbackCalled = false;
1147 gInputStyleMask = TextField::InputStyle::NONE;
1148 inputStyleChangedSignal = false;
1150 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1152 // Render and notify
1153 application.SendNotification();
1154 application.Render();
1156 // Executes the idle callbacks added by the text control on the change of input style.
1157 application.RunIdles();
1159 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1160 if( gInputStyleChangedCallbackCalled )
1162 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1163 static_cast<unsigned int>( TextField::InputStyle::COLOR ),
1166 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1167 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1169 DALI_TEST_CHECK( inputStyleChangedSignal );
1171 gInputStyleChangedCallbackCalled = false;
1172 gInputStyleMask = TextField::InputStyle::NONE;
1173 inputStyleChangedSignal = false;
1175 field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
1177 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
1178 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
1180 field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
1181 field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
1182 field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
1183 field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
1185 // Render and notify
1186 application.SendNotification();
1187 application.Render();
1189 // Executes the idle callbacks added by the text control on the change of input style.
1190 application.RunIdles();
1192 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1193 DALI_TEST_CHECK( !inputStyleChangedSignal );
1195 // Create a tap event to touch the text field.
1196 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1197 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1199 // Render and notify
1200 application.SendNotification();
1201 application.Render();
1203 // Executes the idle callbacks added by the text control on the change of input style.
1204 application.RunIdles();
1206 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1207 if( gInputStyleChangedCallbackCalled )
1209 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1210 static_cast<unsigned int>( TextField::InputStyle::COLOR |
1211 TextField::InputStyle::POINT_SIZE |
1212 TextField::InputStyle::FONT_STYLE |
1213 TextField::InputStyle::UNDERLINE |
1214 TextField::InputStyle::SHADOW |
1215 TextField::InputStyle::EMBOSS |
1216 TextField::InputStyle::OUTLINE ),
1219 const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1220 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1222 DALI_TEST_CHECK( inputStyleChangedSignal );
1227 int utcDaliTextFieldEvent01(void)
1229 ToolkitTestApplication application;
1230 tet_infoline(" utcDaliTextFieldEvent01");
1232 // Creates a tap event. After creating a tap event the text field should
1233 // have the focus and add text with key events should be possible.
1235 TextField field = TextField::New();
1236 DALI_TEST_CHECK( field );
1238 Stage::GetCurrent().Add( field );
1240 field.SetSize( 300.f, 50.f );
1241 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1242 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1244 // Avoid a crash when core load gl resources.
1245 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1247 // Render and notify
1248 application.SendNotification();
1249 application.Render();
1251 // Add a key event but as the text field has not the focus it should do nothing.
1252 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
1254 // Render and notify
1255 application.SendNotification();
1256 application.Render();
1258 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
1260 // Create a tap event to touch the text field.
1261 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1262 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1264 // Render and notify
1265 application.SendNotification();
1266 application.Render();
1268 // Now the text field has the focus, so it can handle the key events.
1269 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
1270 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
1272 // Render and notify
1273 application.SendNotification();
1274 application.Render();
1276 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1278 // Create a second text field and send key events to it.
1279 TextField field2 = TextField::New();
1281 field2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1282 field2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1283 field2.SetSize( 100.f, 100.f );
1284 field2.SetPosition( 100.f, 100.f );
1286 Stage::GetCurrent().Add( field2 );
1288 // Render and notify
1289 application.SendNotification();
1290 application.Render();
1292 // Create a tap event on the second text field.
1293 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1294 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1296 // Render and notify
1297 application.SendNotification();
1298 application.Render();
1300 // The second text field has the focus. It should handle the key events.
1301 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
1302 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
1304 // Render and notify
1305 application.SendNotification();
1306 application.Render();
1308 // Check the text has been added to the second text field.
1309 DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1314 int utcDaliTextFieldEvent02(void)
1316 ToolkitTestApplication application;
1317 tet_infoline(" utcDaliTextFieldEvent02");
1319 // Checks if the right number of actors are created.
1321 TextField field = TextField::New();
1322 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1323 DALI_TEST_CHECK( field );
1324 LoadMarkerImages(application, field);
1326 Stage::GetCurrent().Add( field );
1328 field.SetSize( 300.f, 50.f );
1329 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1330 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1332 // Avoid a crash when core load gl resources.
1333 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1335 // Render and notify
1336 application.SendNotification();
1337 application.Render();
1339 // Check there are the expected number of children ( stencil ).
1340 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1342 Actor stencil = field.GetChildAt( 0u );
1343 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1345 // Create a tap event to touch the text field.
1346 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1347 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1349 // Render and notify
1350 application.SendNotification();
1351 application.Render();
1353 Actor layer = field.GetChildAt( 1u );
1354 DALI_TEST_CHECK( layer.IsLayer() );
1356 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1357 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1359 // Now the text field has the focus, so it can handle the key events.
1360 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
1361 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
1363 // Render and notify
1364 application.SendNotification();
1365 application.Render();
1367 // Checks the cursor and the renderer have been created.
1368 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1369 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1371 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1372 DALI_TEST_CHECK( cursor );
1374 // The offscreen root actor has a container with all the actors which contain the text renderers.
1375 Actor container = stencil.GetChildAt( 0u );
1376 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1378 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1379 DALI_TEST_CHECK( renderer );
1382 // Move the cursor and check the position changes.
1383 Vector3 position1 = cursor.GetCurrentPosition();
1385 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1386 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1388 // Render and notify
1389 application.SendNotification();
1390 application.Render();
1392 Vector3 position2 = cursor.GetCurrentPosition();
1394 DALI_TEST_CHECK( position2.x < position1.x );
1396 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1397 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1399 // Render and notify
1400 application.SendNotification();
1401 application.Render();
1403 Vector3 position3 = cursor.GetCurrentPosition();
1405 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1407 // Send some taps and check the cursor positions.
1409 // Try to tap at the beginning.
1410 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1411 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1413 // Render and notify
1414 application.SendNotification();
1415 application.Render();
1417 // Cursor position should be the same than position1.
1418 Vector3 position4 = cursor.GetCurrentPosition();
1420 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1422 // Tap away from the start position.
1423 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1424 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1426 // Render and notify
1427 application.SendNotification();
1428 application.Render();
1430 Vector3 position5 = cursor.GetCurrentPosition();
1432 DALI_TEST_CHECK( position5.x > position4.x );
1434 // Remove all the text.
1435 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1436 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1437 field.SetProperty( TextField::Property::TEXT, "" );
1439 // Render and notify
1440 application.SendNotification();
1441 application.Render();
1443 // Cursor position should be the same than position2.
1444 Vector3 position6 = cursor.GetCurrentPosition();
1446 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1448 // Should not be a renderer.
1449 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1454 int utcDaliTextFieldEvent03(void)
1456 ToolkitTestApplication application;
1457 tet_infoline(" utcDaliTextFieldEvent03");
1459 // Checks if the highlight actor is created.
1461 TextField field = TextField::New();
1462 DALI_TEST_CHECK( field );
1464 Stage::GetCurrent().Add( field );
1466 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1467 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1468 field.SetSize( 30.f, 50.f );
1469 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1470 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1472 // Avoid a crash when core load gl resources.
1473 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1474 LoadMarkerImages(application, field);
1476 // Render and notify
1477 application.SendNotification();
1478 application.Render();
1480 // Tap first to get the focus.
1481 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1482 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1484 // Render and notify
1485 application.SendNotification();
1486 application.Render();
1488 // Double tap to select a word.
1489 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1490 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1492 // Render and notify
1493 application.SendNotification();
1494 application.Render();
1496 // The offscreen root actor should have two actors: the renderer and the highlight actor.
1497 Actor stencil = field.GetChildAt( 0u );
1499 // The offscreen root actor has a container with all the actors which contain the text renderers.
1500 Actor container = stencil.GetChildAt( 0u );
1501 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1503 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1504 DALI_TEST_CHECK( renderer );
1507 Renderer highlight = stencil.GetChildAt( 1u ).GetRendererAt( 0u );
1508 DALI_TEST_CHECK( highlight );
1513 int utcDaliTextFieldEvent04(void)
1515 ToolkitTestApplication application;
1516 tet_infoline(" utcDaliTextFieldEvent04");
1518 // Checks if the highlight actor is created.
1520 TextField field = TextField::New();
1521 DALI_TEST_CHECK( field );
1522 Stage::GetCurrent().Add( field );
1523 LoadMarkerImages(application, field);
1524 // Render and notify
1525 application.SendNotification();
1526 application.Render();
1528 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1529 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1530 field.SetSize( 300.f, 50.f );
1531 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1532 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1534 // Avoid a crash when core load gl resources.
1535 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1536 // Render and notify
1537 application.SendNotification();
1538 application.Render();
1540 // Create a tap event to touch the text field.
1541 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1542 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1543 // Render and notify
1544 application.SendNotification();
1545 application.Render();
1548 // Tap first to get the focus.
1549 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1550 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1552 // Render and notify
1553 application.SendNotification();
1554 application.Render();
1556 // Double tap to select a word.
1557 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1558 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1560 // Render and notify
1561 application.SendNotification();
1562 application.Render();
1565 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1566 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) );
1570 int utcDaliTextFieldEvent05(void)
1572 ToolkitTestApplication application;
1573 tet_infoline(" utcDaliTextFieldEvent05");
1575 // Checks dragging of cursor/grab handle
1577 TextField field = TextField::New();
1578 DALI_TEST_CHECK( field );
1579 Stage::GetCurrent().Add( field );
1580 LoadMarkerImages(application, field);
1581 // Render and notify
1582 application.SendNotification();
1583 application.Render();
1585 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1586 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1587 field.SetSize( 300.f, 50.f );
1588 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1589 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1591 // Avoid a crash when core load gl resources.
1592 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1593 // Render and notify
1594 application.SendNotification();
1595 application.Render();
1597 // Create a tap event to touch the text field.
1598 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1599 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1600 // Render and notify
1601 application.SendNotification();
1602 application.Render();
1605 // Tap first to get the focus.
1606 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1607 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1609 // Render and notify
1610 application.SendNotification();
1611 application.Render();
1613 // Double tap to select a word.
1614 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1615 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1617 // Render and notify
1618 application.SendNotification();
1619 application.Render();
1621 // drag grab handle right
1622 Vector2 pos(0.0f, 40.0f);
1623 SendPan(application, Gesture::Possible, pos);
1624 SendPan(application, Gesture::Started, pos);
1626 Wait(application, 100);
1628 for(int i = 0;i<20;i++)
1630 SendPan(application, Gesture::Continuing, pos);
1635 SendPan(application, Gesture::Finished, pos);
1636 Wait(application, RENDER_FRAME_INTERVAL);
1638 Actor stencil = field.GetChildAt( 1u );
1642 int utcDaliTextFieldEvent06(void)
1644 ToolkitTestApplication application;
1645 tet_infoline(" utcDaliTextFieldEvent06");
1647 // Checks Longpress when in edit mode
1649 TextField field = TextField::New();
1650 DALI_TEST_CHECK( field );
1651 Stage::GetCurrent().Add( field );
1652 LoadMarkerImages(application, field);
1653 // Render and notify
1654 application.SendNotification();
1655 application.Render();
1657 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1658 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1659 field.SetSize( 300.f, 50.f );
1660 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1661 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1663 // Avoid a crash when core load gl resources.
1664 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1665 // Render and notify
1666 application.SendNotification();
1667 application.Render();
1669 // Create a tap event to touch the text field.
1670 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1671 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1672 // Render and notify
1673 application.SendNotification();
1674 application.Render();
1677 // Tap first to get the focus.
1678 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1679 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1681 // Render and notify
1682 application.SendNotification();
1683 application.Render();
1686 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1687 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1689 // Render and notify
1690 application.SendNotification();
1691 application.Render();
1696 int utcDaliTextFieldEvent07(void)
1698 ToolkitTestApplication application;
1699 tet_infoline(" utcDaliTextFieldEvent07");
1701 // Checks Longpress to start edit mode
1703 TextField field = TextField::New();
1704 DALI_TEST_CHECK( field );
1705 Stage::GetCurrent().Add( field );
1706 LoadMarkerImages(application, field);
1707 // Render and notify
1708 application.SendNotification();
1709 application.Render();
1711 field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
1712 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1713 field.SetSize( 300.f, 50.f );
1714 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1715 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1717 // Avoid a crash when core load gl resources.
1718 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1719 // Render and notify
1720 application.SendNotification();
1721 application.Render();
1724 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1725 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1727 // Render and notify
1728 application.SendNotification();
1729 application.Render();
1734 int utcDaliTextFieldEvent08(void)
1736 ToolkitTestApplication application;
1737 tet_infoline(" utcDaliTextFieldEvent08");
1739 Dali::Clipboard clipboard = Clipboard::Get();
1740 clipboard.SetItem("testTextFieldEvent");
1742 // Checks Longpress when only place holder text
1744 TextField field = TextField::New();
1745 DALI_TEST_CHECK( field );
1746 Stage::GetCurrent().Add( field );
1747 LoadMarkerImages(application, field);
1748 // Render and notify
1749 application.SendNotification();
1750 application.Render();
1752 field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
1753 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1754 field.SetSize( 300.f, 50.f );
1755 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1756 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1758 // Avoid a crash when core load gl resources.
1759 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1760 // Render and notify
1761 application.SendNotification();
1762 application.Render();
1765 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1766 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1768 // Render and notify
1769 application.SendNotification();
1770 application.Render();
1772 Wait(application, 500);
1774 Stage stage = Stage::GetCurrent();
1775 Layer layer = stage.GetRootLayer();
1776 Actor actor = layer.FindChildByName("optionPaste");
1780 Vector3 worldPosition = actor.GetCurrentWorldPosition();
1781 Vector2 halfStageSize = stage.GetSize() / 2.0f;
1782 Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
1784 Dali::Integration::TouchEvent event;
1785 event = Dali::Integration::TouchEvent();
1786 event.AddPoint( GetPointDownInside( position ) );
1787 application.ProcessEvent( event );
1789 event = Dali::Integration::TouchEvent();
1790 event.AddPoint( GetPointUpInside( position ) );
1791 application.ProcessEvent( event );
1793 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
1797 int utcDaliTextFieldStyleWhilstSelected(void)
1799 ToolkitTestApplication application;
1800 tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
1802 // Change font and styles whilst text is selected whilst word selected
1804 TextField field = TextField::New();
1805 DALI_TEST_CHECK( field );
1806 Stage::GetCurrent().Add( field );
1807 LoadMarkerImages(application, field);
1808 // Render and notify
1809 application.SendNotification();
1810 application.Render();
1812 field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
1813 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1814 field.SetSize( 300.f, 50.f );
1815 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1816 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1818 // Avoid a crash when core load gl resources.
1819 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1820 // Render and notify
1821 application.SendNotification();
1822 application.Render();
1824 // Create a tap event to touch the text field.
1825 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1826 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1827 // Render and notify
1828 application.SendNotification();
1829 application.Render();
1832 // Tap first to get the focus.
1833 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1834 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1836 // Render and notify
1837 application.SendNotification();
1838 application.Render();
1840 // Double tap to select a word.
1841 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1842 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) );
1844 // Render and notify
1845 application.SendNotification();
1846 application.Render();
1848 field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
1849 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
1851 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"weight\":\"bold\",\"slant\":\"italic\"}" );
1852 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_STYLE ), "{\"weight\":\"bold\",\"slant\":\"italic\"}", TEST_LOCATION );
1854 field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"width\":\"expanded\",\"slant\":\"italic\"}" );
1855 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_STYLE ), "{\"width\":\"expanded\",\"slant\":\"italic\"}", TEST_LOCATION );
1857 field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
1858 DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1860 field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
1861 DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
1863 field.SetProperty( TextField::Property::FONT_STYLE, "{\"weight\":\"bold\",\"slant\":\"italic\"}" );
1864 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_STYLE ), "{\"weight\":\"bold\",\"slant\":\"italic\"}", TEST_LOCATION );
1866 field.SetProperty( TextField::Property::FONT_STYLE, "{\"width\":\"expanded\"}" );
1867 DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_STYLE ), "{\"width\":\"expanded\"}", TEST_LOCATION );
1872 int utcDaliTextFieldCursorVisibility(void)
1874 ToolkitTestApplication application;
1875 tet_infoline(" utcDaliTextFieldCursorVisibility");
1879 char* pathNamePtr = get_current_dir_name();
1880 const std::string pathName( pathNamePtr );
1881 free( pathNamePtr );
1883 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1884 fontClient.SetDpi( 93u, 93u );
1886 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf" );
1887 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf" );
1889 // Checks if the right number of actors are created.
1891 TextField field = TextField::New();
1892 field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
1893 DALI_TEST_CHECK( field );
1895 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1896 field.SetProperty( TextField::Property::TEXT, "<font family='TizenSans' size='18'>Hello <font family='TizenSansHebrew' size='18'>שלום עולם</font> world</font>" );
1898 Stage::GetCurrent().Add( field );
1900 field.SetSize( 300.f, 30.f );
1901 field.SetParentOrigin( ParentOrigin::TOP_LEFT );
1902 field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1904 // Avoid a crash when core load gl resources.
1905 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1907 // Render and notify
1908 application.SendNotification();
1909 application.Render();
1911 // Check there are the expected number of children ( stencil ).
1912 DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
1914 Actor stencil = field.GetChildAt( 0u );
1915 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The text renderer.
1917 // Create a tap event to touch the text field.
1918 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 56.0f, 25.0f ) ) );
1919 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 56.0f, 25.0f ) ) );
1921 // Render and notify
1922 application.SendNotification();
1923 application.Render();
1925 Actor layer = field.GetChildAt( 1u );
1926 DALI_TEST_CHECK( layer.IsLayer() );
1928 DALI_TEST_EQUALS( layer.GetChildCount(), 2u, TEST_LOCATION ); // The two cursors.
1929 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The text renderer.
1931 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1932 DALI_TEST_CHECK( cursor );
1934 Vector3 size = cursor.GetCurrentSize();
1935 Vector3 position = cursor.GetCurrentPosition();
1937 DALI_TEST_EQUALS( position, Vector3(56.f, 0.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1938 DALI_TEST_EQUALS( size, Vector3(1.f, 14.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1940 // Change the size of the control (with a height smaller than the size of the cursor).
1941 field.SetSize( 300.f, 20.f );
1943 // Create a tap event to touch the text field.
1944 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 56.0f, 15.0f ) ) );
1945 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 56.0f, 15.0f ) ) );
1947 // Render and notify
1948 application.SendNotification();
1949 application.Render();
1951 size = cursor.GetCurrentSize();
1952 position = cursor.GetCurrentPosition();
1954 // Checks the size of the cursor fits the control's height.
1955 DALI_TEST_EQUALS( position, Vector3(56.f, 0.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1956 DALI_TEST_EQUALS( size, Vector3(1.f, 5.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1958 // Change the size of the control (with a height smaller than the size of the secondary cursor).
1959 field.SetSize( 300.f, 10.f );
1961 // Create a tap event to touch the text field.
1962 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 56.0f, 5.0f ) ) );
1963 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 56.0f, 5.0f ) ) );
1965 // Render and notify
1966 application.SendNotification();
1967 application.Render();
1969 Control cursor2 = Control::DownCast( layer.GetChildAt( 1u ) );
1970 DALI_TEST_CHECK( cursor2 );
1972 size = cursor2.GetCurrentSize();
1973 position = cursor2.GetCurrentPosition();
1975 // Checks the size of the cursor fits the control's height.
1976 DALI_TEST_EQUALS( position, Vector3(155.f, 0.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1977 DALI_TEST_EQUALS( size, Vector3(1.f, 10.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION );