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.
21 #include <dali/public-api/rendering/renderer.h>
22 #include <dali/devel-api/adaptor-framework/clipboard.h>
23 #include <dali/integration-api/events/key-event-integ.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
25 #include <dali/integration-api/events/tap-gesture-event.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/text-editor-devel.h>
33 using namespace Toolkit;
35 void dali_texteditor_startup(void)
37 test_return_value = TET_UNDEF;
40 void dali_texteditor_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_TEXT_COLOR = "textColor";
51 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
52 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
53 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
54 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
55 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
56 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
57 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
58 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
59 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
60 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
61 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
62 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
63 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
64 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
65 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
66 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
71 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
72 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
73 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
74 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
75 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
76 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
77 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
79 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
80 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
81 const char* const PROPERTY_NAME_UNDERLINE = "underline";
82 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
83 const char* const PROPERTY_NAME_SHADOW = "shadow";
84 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
85 const char* const PROPERTY_NAME_EMBOSS = "emboss";
86 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
87 const char* const PROPERTY_NAME_OUTLINE = "outline";
88 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
90 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
91 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
92 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
93 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
94 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
95 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
96 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
97 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
98 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
99 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
100 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
102 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
104 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
105 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
107 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
108 const float TO_MILLISECONDS = 1000.f;
109 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
110 const float RENDER_FRAME_INTERVAL = 16.66f;
112 const float SCROLL_THRESHOLD = 10.f;
113 const float SCROLL_SPEED = 300.f;
115 const unsigned int DEFAULT_FONT_SIZE = 1152u;
116 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
118 const int KEY_A_CODE = 38;
119 const int KEY_D_CODE = 40;
120 const int KEY_WHITE_SPACE_CODE = 65;
122 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
124 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
126 static bool gTextChangedCallBackCalled;
127 static bool gInputStyleChangedCallbackCalled;
128 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
130 struct CallbackFunctor
132 CallbackFunctor(bool* callbackFlag)
133 : mCallbackFlag( callbackFlag )
139 *mCallbackFlag = true;
144 static void TestTextChangedCallback( TextEditor control )
146 tet_infoline(" TestTextChangedCallback");
148 gTextChangedCallBackCalled = true;
151 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
153 tet_infoline(" TestInputStyleChangedCallback");
155 gInputStyleChangedCallbackCalled = true;
156 gInputStyleMask = mask;
159 // Generate a TapGestureEvent to send to Core.
160 Integration::TapGestureEvent GenerateTap(
161 Gesture::State state,
162 unsigned int numberOfTaps,
163 unsigned int numberOfTouches,
166 Integration::TapGestureEvent tap( state );
168 tap.numberOfTaps = numberOfTaps;
169 tap.numberOfTouches = numberOfTouches;
175 Integration::LongPressGestureEvent GenerateLongPress(
176 Gesture::State state,
177 unsigned int numberOfTouches,
180 Integration::LongPressGestureEvent longPress( state );
182 longPress.numberOfTouches = numberOfTouches;
183 longPress.point = point;
187 // Generate a PanGestureEvent to send to Core
188 Integration::PanGestureEvent GeneratePan( Gesture::State state,
189 const Vector2& previousPosition,
190 const Vector2& currentPosition,
191 unsigned long timeDelta,
192 unsigned int numberOfTouches = 1u )
194 Integration::PanGestureEvent pan(state);
196 pan.previousPosition = previousPosition;
197 pan.currentPosition = currentPosition;
198 pan.timeDelta = timeDelta;
199 pan.numberOfTouches = numberOfTouches;
204 // Generate a KeyEvent to send to Core.
205 Integration::KeyEvent GenerateKey( const std::string& keyName,
206 const std::string& keyString,
209 unsigned long timeStamp,
210 const Integration::KeyEvent::State& keyState,
211 const std::string& deviceName = DEFAULT_DEVICE_NAME,
212 const Device::Class::Type& deviceClass = Device::Class::NONE,
213 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
215 return Integration::KeyEvent( keyName,
227 * Helper to generate PanGestureEvent
229 * @param[in] application Application instance
230 * @param[in] state The Gesture State
231 * @param[in] pos The current position of touch.
233 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
237 if( (state == Gesture::Started) ||
238 (state == Gesture::Possible) )
244 application.ProcessEvent( GeneratePan( state, last, pos, 16 ) );
251 * Simulate time passed by.
253 * @note this will always process at least 1 frame (1/60 sec)
255 * @param application Test application instance
256 * @param duration Time to pass in milliseconds.
257 * @return The actual time passed in milliseconds
259 static int Wait(ToolkitTestApplication& application, int duration = 0)
263 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
265 application.SendNotification();
266 application.Render(RENDER_FRAME_INTERVAL);
267 time += RENDER_FRAME_INTERVAL;
273 Dali::Integration::Point GetPointDownInside( Vector2& pos )
275 Dali::Integration::Point point;
276 point.SetState( PointState::DOWN );
277 point.SetScreenPosition( pos );
281 Dali::Integration::Point GetPointUpInside( Vector2& pos )
283 Dali::Integration::Point point;
284 point.SetState( PointState::UP );
285 point.SetScreenPosition( pos );
289 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
291 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
293 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
295 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
297 Property::Value* valueSet = NULL;
298 if ( valueGet.first.type == Property::Key::INDEX )
300 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
304 // Get Key is a string so searching Set Map for a string key
305 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
308 if( NULL != valueSet )
310 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
312 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
318 if ( valueGet.first.type == Property::Key::INDEX )
320 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
324 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
334 class ScrollStateChangeCallback : public Dali::ConnectionTracker
337 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
338 : mStartedCalled( startedCalled ),
339 mFinishedCalled( finishedCalled )
343 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
345 if( type == TextEditor::Scroll::STARTED )
347 mStartedCalled = true;
349 else if( type == TextEditor::Scroll::FINISHED )
351 mFinishedCalled = true;
355 bool& mStartedCalled;
356 bool& mFinishedCalled;
361 int UtcDaliToolkitTextEditorConstructorP(void)
363 ToolkitTestApplication application;
364 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
365 TextEditor textEditor;
366 DALI_TEST_CHECK( !textEditor );
370 int UtcDaliToolkitTextEditorNewP(void)
372 ToolkitTestApplication application;
373 tet_infoline(" UtcDaliToolkitTextEditorNewP");
374 TextEditor textEditor = TextEditor::New();
375 DALI_TEST_CHECK( textEditor );
379 int UtcDaliToolkitTextEditorDownCastP(void)
381 ToolkitTestApplication application;
382 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
383 TextEditor textEditor1 = TextEditor::New();
384 BaseHandle object( textEditor1 );
386 TextEditor textEditor2 = TextEditor::DownCast( object );
387 DALI_TEST_CHECK( textEditor2 );
389 TextEditor textEditor3 = DownCast< TextEditor >( object );
390 DALI_TEST_CHECK( textEditor3 );
394 int UtcDaliToolkitTextEditorDownCastN(void)
396 ToolkitTestApplication application;
397 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
398 BaseHandle uninitializedObject;
399 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
400 DALI_TEST_CHECK( !textEditor1 );
402 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
403 DALI_TEST_CHECK( !textEditor2 );
407 int UtcDaliToolkitTextEditorCopyConstructorP(void)
409 ToolkitTestApplication application;
410 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
411 TextEditor textEditor = TextEditor::New();
412 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
414 TextEditor copy( textEditor );
415 DALI_TEST_CHECK( copy );
416 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
420 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
422 ToolkitTestApplication application;
423 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
424 TextEditor textEditor = TextEditor::New();
425 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
427 TextEditor copy = textEditor;
428 DALI_TEST_CHECK( copy );
429 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
433 int UtcDaliTextEditorNewP(void)
435 ToolkitTestApplication application;
436 tet_infoline(" UtcDaliToolkitTextEditorNewP");
437 TextEditor textEditor = TextEditor::New();
438 DALI_TEST_CHECK( textEditor );
442 // Positive test case for a method
443 int UtcDaliTextEditorGetPropertyP(void)
445 ToolkitTestApplication application;
446 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
447 TextEditor editor = TextEditor::New();
448 DALI_TEST_CHECK( editor );
450 // Check Property Indices are correct
451 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextEditor::Property::RENDERING_BACKEND );
452 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
453 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
454 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
455 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
456 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
457 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
458 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
459 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
460 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
461 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
462 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
463 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
464 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
465 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
466 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
467 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
468 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
469 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
470 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
471 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
472 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
473 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
474 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
475 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
476 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
477 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
478 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
479 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
480 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
482 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
483 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
484 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
485 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
486 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
487 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
488 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
489 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
490 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
491 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
492 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
493 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
494 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
495 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
496 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
497 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
498 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
499 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
500 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
501 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
502 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
507 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
510 Property::Map imageMap;
511 imageMap[mapKey] =mapValue;
513 editor.SetProperty( property , imageMap );
514 Property::Value propValue = editor.GetProperty( property );
515 Property::Map* resultMap = propValue.GetMap();
517 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
525 // Positive test case for a method
526 int UtcDaliTextEditorSetPropertyP(void)
528 ToolkitTestApplication application;
529 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
530 TextEditor editor = TextEditor::New();
531 DALI_TEST_CHECK( editor );
532 Stage::GetCurrent().Add( editor );
534 // Note - we can't check the defaults since the stylesheets are platform-specific
536 // Check the render backend property.
537 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
538 DALI_TEST_EQUALS( (Text::RenderingType)editor.GetProperty<int>( TextEditor::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
540 // Check text property.
541 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
542 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
544 // Check text's color property
545 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
546 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
548 // Check font properties.
549 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
550 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
552 Property::Map fontStyleMapSet;
553 Property::Map fontStyleMapGet;
554 Property::Value* slantValue = NULL;
556 fontStyleMapSet.Insert( "weight", "bold" );
557 fontStyleMapSet.Insert( "width", "condensed" );
558 fontStyleMapSet.Insert( "slant", "italic" );
560 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
561 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
562 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
563 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
565 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
566 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
569 fontStyleMapSet.Clear();
570 fontStyleMapSet.Insert( "weight", "normal" );
571 fontStyleMapSet.Insert( "slant", "oblique" );
572 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
573 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
574 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
575 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
577 fontStyleMapSet.Clear();
578 fontStyleMapSet.Insert( "slant", "roman" );
579 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
580 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
582 // Replace 'roman' for 'normal'.
583 slantValue = fontStyleMapGet.Find( "slant" );
584 if( NULL != slantValue )
586 if( "normal" == slantValue->Get<std::string>() )
588 fontStyleMapGet["slant"] = "roman";
591 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
592 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
594 fontStyleMapSet.Clear();
596 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
597 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
598 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
599 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
601 // Check that the Alignment properties can be correctly set
602 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
603 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
605 // Check scroll properties.
606 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
607 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
608 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
609 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
611 // Check cursor properties
612 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
613 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
614 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
615 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
617 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
618 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
619 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
620 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
621 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
622 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
623 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
624 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
626 // Check handle images
627 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
628 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
629 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
630 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
631 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
633 // Check handle images
634 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
635 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
636 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
637 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
638 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
639 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
641 // Check the highlight color
642 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
643 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
645 // Decoration bounding box
646 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
647 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
649 // Check the enable markup property.
650 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
651 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
652 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
654 // Check input color property.
655 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
656 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
658 // Check input font properties.
659 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
660 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
662 fontStyleMapSet.Clear();
663 fontStyleMapSet.Insert( "weight", "bold" );
664 fontStyleMapSet.Insert( "width", "condensed" );
665 fontStyleMapSet.Insert( "slant", "italic" );
667 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
668 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
669 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
670 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
672 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
673 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
675 // Reset input font style.
676 fontStyleMapSet.Clear();
677 fontStyleMapSet.Insert( "weight", "normal" );
678 fontStyleMapSet.Insert( "slant", "oblique" );
680 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
681 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
682 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
683 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
685 fontStyleMapSet.Clear();
686 fontStyleMapSet.Insert( "slant", "roman" );
688 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
689 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
691 // Replace 'roman' for 'normal'.
692 slantValue = fontStyleMapGet.Find( "slant" );
693 if( NULL != slantValue )
695 if( "normal" == slantValue->Get<std::string>() )
697 fontStyleMapGet["slant"] = "roman";
700 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
701 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
703 fontStyleMapSet.Clear();
705 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
706 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
707 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
708 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
710 // Check the line spacing property
711 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
712 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
713 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
715 // Check the input line spacing property
716 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
717 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
718 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
720 // Check the underline property
722 Property::Map underlineMapSet;
723 Property::Map underlineMapGet;
725 underlineMapSet.Insert( "enable", "true" );
726 underlineMapSet.Insert( "color", "red" );
727 underlineMapSet.Insert( "height", "1" );
729 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
731 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
732 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
733 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
735 // Check the input underline property
736 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
737 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
739 // Check the shadow property
740 Property::Map shadowMapSet;
741 Property::Map shadowMapGet;
743 shadowMapSet.Insert( "color", Color::GREEN );
744 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
745 shadowMapSet.Insert( "blurRadius", 3.0f );
747 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
749 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
750 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
751 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
753 // Check the input shadow property
754 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
755 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
757 // Check the emboss property
758 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
759 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
761 // Check the input emboss property
762 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
763 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
765 // Check the outline property
767 // Test string type first
768 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
769 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
770 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
772 // Then test the property map type
773 Property::Map outlineMapSet;
774 Property::Map outlineMapGet;
776 outlineMapSet["color"] = Color::RED;
777 outlineMapSet["width"] = 2.0f;
779 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
781 outlineMapSet["color"] = "red";
782 outlineMapSet["width"] = "2";
783 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
784 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
785 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
787 // Check the input outline property
788 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
789 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
791 // Check the smooth scroll property
792 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
793 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
794 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
796 // Check the smooth scroll duration property
797 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
798 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
800 // Check the scroll bar property
801 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
802 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
803 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
805 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
806 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
807 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
808 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
810 // Check the pixel size of font
811 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
812 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
814 // Check placeholder text properties.
815 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
816 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
818 // Check placeholder text's color property.
819 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
820 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
822 // Check the enable selection property
823 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
824 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
826 // Check the placeholder property with pixel size
827 Property::Map placeholderPixelSizeMapSet;
828 Property::Map placeholderPixelSizeMapGet;
829 Property::Map placeholderFontstyleMap;
830 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
831 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
832 placeholderPixelSizeMapSet["color"] = Color::BLUE;
833 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
834 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
836 placeholderFontstyleMap.Insert( "weight", "bold" );
837 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
838 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
840 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
841 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
843 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
844 Property::Map placeholderConversionMap;
845 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
846 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
847 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
848 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
849 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
850 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
852 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
854 // Check the placeholder property with point size
855 Property::Map placeholderMapSet;
856 Property::Map placeholderMapGet;
857 placeholderMapSet["text"] = "Setting Placeholder Text";
858 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
859 placeholderMapSet["color"] = Color::RED;
860 placeholderMapSet["fontFamily"] = "Arial";
861 placeholderMapSet["pointSize"] = 12.0f;
862 // Check the placeholder font style property
863 placeholderFontstyleMap.Clear();
865 placeholderFontstyleMap.Insert( "weight", "bold" );
866 placeholderFontstyleMap.Insert( "width", "condensed" );
867 placeholderFontstyleMap.Insert( "slant", "italic" );
868 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
869 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
871 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
872 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
874 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
875 placeholderConversionMap.Clear();
876 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
877 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
878 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
879 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
880 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
881 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
882 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
885 placeholderFontstyleMap.Clear();
886 placeholderFontstyleMap.Insert( "weight", "normal" );
887 placeholderFontstyleMap.Insert( "slant", "oblique" );
888 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
889 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
891 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
892 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
893 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
894 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
896 placeholderFontstyleMap.Clear();
897 placeholderFontstyleMap.Insert( "slant", "roman" );
898 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
899 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
901 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
903 placeholderFontstyleMap.Clear();
904 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
906 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
907 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
908 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
909 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
910 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
912 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
913 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
915 application.SendNotification();
916 application.Render();
921 // Positive Atlas Text Renderer test
922 int utcDaliTextEditorAtlasRenderP(void)
924 ToolkitTestApplication application;
925 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
926 StyleManager styleManager = StyleManager::Get();
927 styleManager.ApplyDefaultTheme();
928 TextEditor editor = TextEditor::New();
929 DALI_TEST_CHECK( editor );
931 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
933 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
935 Stage::GetCurrent().Add( editor );
939 // Render some text with the shared atlas backend
940 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
941 application.SendNotification();
942 application.Render();
946 tet_result(TET_FAIL);
951 // Positive test for the textChanged signal.
952 int utcDaliTextEditorTextChangedP(void)
954 ToolkitTestApplication application;
955 tet_infoline(" utcDaliTextEditorTextChangedP");
956 TextEditor editor = TextEditor::New();
957 DALI_TEST_CHECK( editor );
959 Stage::GetCurrent().Add( editor );
961 // connect to the text changed signal.
962 ConnectionTracker* testTracker = new ConnectionTracker();
963 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
964 bool textChangedSignal = false;
965 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
967 gTextChangedCallBackCalled = false;
968 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
969 DALI_TEST_CHECK( gTextChangedCallBackCalled );
970 DALI_TEST_CHECK( textChangedSignal );
972 application.SendNotification();
974 editor.SetKeyInputFocus();
976 gTextChangedCallBackCalled = false;
977 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
978 DALI_TEST_CHECK( gTextChangedCallBackCalled );
983 int utcDaliTextEditorInputStyleChanged01(void)
985 ToolkitTestApplication application;
986 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
988 // The text-editor emits signals when the input style changes. These changes of style are
989 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
990 // can't be emitted during the size negotiation as the callbacks may update the UI.
991 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
992 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
993 application.CreateAdaptor();
997 char* pathNamePtr = get_current_dir_name();
998 const std::string pathName( pathNamePtr );
1001 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1002 fontClient.SetDpi( 93u, 93u );
1004 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1005 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1007 TextEditor editor = TextEditor::New();
1008 DALI_TEST_CHECK( editor );
1011 editor.SetSize( 300.f, 50.f );
1012 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1013 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1015 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1016 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1018 // connect to the text changed signal.
1019 ConnectionTracker* testTracker = new ConnectionTracker();
1020 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1021 bool inputStyleChangedSignal = false;
1022 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1024 Stage::GetCurrent().Add( editor );
1026 // Render and notify
1027 application.SendNotification();
1028 application.Render();
1030 // Executes the idle callbacks added by the text control on the change of input style.
1031 application.RunIdles();
1033 gInputStyleChangedCallbackCalled = false;
1034 gInputStyleMask = TextEditor::InputStyle::NONE;
1035 inputStyleChangedSignal = false;
1037 // Create a tap event to touch the text editor.
1038 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1039 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1041 // Render and notify
1042 application.SendNotification();
1043 application.Render();
1045 // Executes the idle callbacks added by the text control on the change of input style.
1046 application.RunIdles();
1048 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1049 if( gInputStyleChangedCallbackCalled )
1051 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1053 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1054 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1056 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1057 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1059 DALI_TEST_CHECK( inputStyleChangedSignal );
1061 gInputStyleChangedCallbackCalled = false;
1062 gInputStyleMask = TextEditor::InputStyle::NONE;
1063 inputStyleChangedSignal = false;
1065 // Create a tap event to touch the text editor.
1066 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1067 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1069 // Render and notify
1070 application.SendNotification();
1071 application.Render();
1073 // Executes the idle callbacks added by the text control on the change of input style.
1074 application.RunIdles();
1076 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1077 DALI_TEST_CHECK( !inputStyleChangedSignal );
1079 gInputStyleChangedCallbackCalled = false;
1080 gInputStyleMask = TextEditor::InputStyle::NONE;
1081 inputStyleChangedSignal = false;
1083 // Create a tap event to touch the text editor.
1084 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1085 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1087 // Render and notify
1088 application.SendNotification();
1089 application.Render();
1091 // Executes the idle callbacks added by the text control on the change of input style.
1092 application.RunIdles();
1094 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1095 if( gInputStyleChangedCallbackCalled )
1097 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1099 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1100 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1102 DALI_TEST_CHECK( inputStyleChangedSignal );
1104 gInputStyleChangedCallbackCalled = false;
1105 gInputStyleMask = TextEditor::InputStyle::NONE;
1106 inputStyleChangedSignal = false;
1108 // Create a tap event to touch the text editor.
1109 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1110 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1112 // Render and notify
1113 application.SendNotification();
1114 application.Render();
1116 // Executes the idle callbacks added by the text control on the change of input style.
1117 application.RunIdles();
1119 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1120 if( gInputStyleChangedCallbackCalled )
1122 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1124 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1125 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1127 Property::Map fontStyleMapSet;
1128 Property::Map fontStyleMapGet;
1130 fontStyleMapSet.Insert( "weight", "bold" );
1132 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1133 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1134 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1136 DALI_TEST_CHECK( inputStyleChangedSignal );
1138 gInputStyleChangedCallbackCalled = false;
1139 gInputStyleMask = TextEditor::InputStyle::NONE;
1140 inputStyleChangedSignal = false;
1142 // Create a tap event to touch the text editor.
1143 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1144 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1146 // Render and notify
1147 application.SendNotification();
1148 application.Render();
1150 // Executes the idle callbacks added by the text control on the change of input style.
1151 application.RunIdles();
1153 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1154 DALI_TEST_CHECK( !inputStyleChangedSignal );
1156 gInputStyleChangedCallbackCalled = false;
1157 gInputStyleMask = TextEditor::InputStyle::NONE;
1158 inputStyleChangedSignal = false;
1160 // Create a tap event to touch the text editor.
1161 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1162 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1164 // Render and notify
1165 application.SendNotification();
1166 application.Render();
1168 // Executes the idle callbacks added by the text control on the change of input style.
1169 application.RunIdles();
1171 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1172 if( gInputStyleChangedCallbackCalled )
1174 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1176 Property::Map fontStyleMapSet;
1177 Property::Map fontStyleMapGet;
1179 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1180 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1181 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1183 DALI_TEST_CHECK( inputStyleChangedSignal );
1185 gInputStyleChangedCallbackCalled = false;
1186 gInputStyleMask = TextEditor::InputStyle::NONE;
1187 inputStyleChangedSignal = false;
1189 // Create a tap event to touch the text editor.
1190 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1191 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1193 // Render and notify
1194 application.SendNotification();
1195 application.Render();
1197 // Executes the idle callbacks added by the text control on the change of input style.
1198 application.RunIdles();
1200 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1201 DALI_TEST_CHECK( !inputStyleChangedSignal );
1206 int utcDaliTextEditorInputStyleChanged02(void)
1208 ToolkitTestApplication application;
1209 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1211 // The text-editor emits signals when the input style changes. These changes of style are
1212 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1213 // can't be emitted during the size negotiation as the callbacks may update the UI.
1214 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1215 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1216 application.CreateAdaptor();
1220 char* pathNamePtr = get_current_dir_name();
1221 const std::string pathName( pathNamePtr );
1222 free( pathNamePtr );
1224 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1225 fontClient.SetDpi( 93u, 93u );
1227 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1228 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1230 TextEditor editor = TextEditor::New();
1231 DALI_TEST_CHECK( editor );
1234 editor.SetSize( 300.f, 50.f );
1235 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1236 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1238 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1239 editor.SetProperty( TextEditor::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>" );
1241 // connect to the text changed signal.
1242 ConnectionTracker* testTracker = new ConnectionTracker();
1243 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1244 bool inputStyleChangedSignal = false;
1245 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1247 Stage::GetCurrent().Add( editor );
1249 // Render and notify
1250 application.SendNotification();
1251 application.Render();
1253 // Executes the idle callbacks added by the text control on the change of input style.
1254 application.RunIdles();
1256 gInputStyleChangedCallbackCalled = false;
1257 gInputStyleMask = TextEditor::InputStyle::NONE;
1258 inputStyleChangedSignal = false;
1260 // Create a tap event to touch the text editor.
1261 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1262 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1263 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1264 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1266 // Render and notify
1267 application.SendNotification();
1268 application.Render();
1270 // Executes the idle callbacks added by the text control on the change of input style.
1271 application.RunIdles();
1273 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1274 if( gInputStyleChangedCallbackCalled )
1276 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1277 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1278 TextEditor::InputStyle::POINT_SIZE |
1279 TextEditor::InputStyle::COLOR ),
1282 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1283 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1285 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1286 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1288 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1289 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1291 DALI_TEST_CHECK( inputStyleChangedSignal );
1293 gInputStyleChangedCallbackCalled = false;
1294 gInputStyleMask = TextEditor::InputStyle::NONE;
1295 inputStyleChangedSignal = false;
1297 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1299 // Render and notify
1300 application.SendNotification();
1301 application.Render();
1303 // Executes the idle callbacks added by the text control on the change of input style.
1304 application.RunIdles();
1306 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1307 if( gInputStyleChangedCallbackCalled )
1309 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1310 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1313 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1314 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1316 DALI_TEST_CHECK( inputStyleChangedSignal );
1318 gInputStyleChangedCallbackCalled = false;
1319 gInputStyleMask = TextEditor::InputStyle::NONE;
1320 inputStyleChangedSignal = false;
1322 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1324 // Render and notify
1325 application.SendNotification();
1326 application.Render();
1328 // Executes the idle callbacks added by the text control on the change of input style.
1329 application.RunIdles();
1331 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1332 DALI_TEST_CHECK( !inputStyleChangedSignal );
1334 gInputStyleChangedCallbackCalled = false;
1335 gInputStyleMask = TextEditor::InputStyle::NONE;
1336 inputStyleChangedSignal = false;
1338 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1340 // Render and notify
1341 application.SendNotification();
1342 application.Render();
1344 // Executes the idle callbacks added by the text control on the change of input style.
1345 application.RunIdles();
1347 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1348 if( gInputStyleChangedCallbackCalled )
1350 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1351 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1354 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1355 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1357 DALI_TEST_CHECK( inputStyleChangedSignal );
1359 gInputStyleChangedCallbackCalled = false;
1360 gInputStyleMask = TextEditor::InputStyle::NONE;
1361 inputStyleChangedSignal = false;
1363 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1365 Property::Map fontStyleMapSet;
1366 fontStyleMapSet.Insert( "weight", "thin" );
1367 fontStyleMapSet.Insert( "width", "condensed" );
1368 fontStyleMapSet.Insert( "slant", "italic" );
1370 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1371 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1372 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1374 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1375 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1376 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1377 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1379 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1381 // Render and notify
1382 application.SendNotification();
1383 application.Render();
1385 // Executes the idle callbacks added by the text control on the change of input style.
1386 application.RunIdles();
1388 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1389 DALI_TEST_CHECK( !inputStyleChangedSignal );
1391 // Create a tap event to touch the text editor.
1392 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1393 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1395 // Render and notify
1396 application.SendNotification();
1397 application.Render();
1399 // Executes the idle callbacks added by the text control on the change of input style.
1400 application.RunIdles();
1402 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1403 if( gInputStyleChangedCallbackCalled )
1405 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1406 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1407 TextEditor::InputStyle::POINT_SIZE |
1408 TextEditor::InputStyle::FONT_STYLE |
1409 TextEditor::InputStyle::LINE_SPACING |
1410 TextEditor::InputStyle::UNDERLINE |
1411 TextEditor::InputStyle::SHADOW |
1412 TextEditor::InputStyle::EMBOSS |
1413 TextEditor::InputStyle::OUTLINE ),
1416 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1417 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1419 DALI_TEST_CHECK( inputStyleChangedSignal );
1421 gInputStyleChangedCallbackCalled = false;
1422 gInputStyleMask = TextEditor::InputStyle::NONE;
1423 inputStyleChangedSignal = false;
1425 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1427 fontStyleMapSet.Clear();
1428 fontStyleMapSet.Insert( "weight", "black" );
1429 fontStyleMapSet.Insert( "width", "expanded" );
1430 fontStyleMapSet.Insert( "slant", "oblique" );
1432 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1434 // Create a tap event to touch the text editor.
1435 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1436 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1438 // Render and notify
1439 application.SendNotification();
1440 application.Render();
1442 // Executes the idle callbacks added by the text control on the change of input style.
1443 application.RunIdles();
1445 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1446 if( gInputStyleChangedCallbackCalled )
1448 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1449 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1450 TextEditor::InputStyle::POINT_SIZE |
1451 TextEditor::InputStyle::FONT_STYLE ),
1454 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1455 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1457 DALI_TEST_CHECK( inputStyleChangedSignal );
1462 int utcDaliTextEditorEvent01(void)
1464 ToolkitTestApplication application;
1465 tet_infoline(" utcDaliTextEditorEvent01");
1467 // Creates a tap event. After creating a tap event the text editor should
1468 // have the focus and add text with key events should be possible.
1470 TextEditor editor = TextEditor::New();
1471 DALI_TEST_CHECK( editor );
1473 Stage::GetCurrent().Add( editor );
1475 editor.SetSize( 300.f, 50.f );
1476 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1477 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1479 // Avoid a crash when core load gl resources.
1480 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1482 // Render and notify
1483 application.SendNotification();
1484 application.Render();
1486 // Add a key event but as the text editor has not the focus it should do nothing.
1487 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1489 // Render and notify
1490 application.SendNotification();
1491 application.Render();
1493 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1495 // Create a tap event to touch the text editor.
1496 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1497 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1499 // Render and notify
1500 application.SendNotification();
1501 application.Render();
1503 // Now the text editor has the focus, so it can handle the key events.
1504 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1505 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1507 // Render and notify
1508 application.SendNotification();
1509 application.Render();
1511 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1513 // Create a second text editor and send key events to it.
1514 TextEditor editor2 = TextEditor::New();
1516 editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1517 editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1518 editor2.SetSize( 100.f, 100.f );
1519 editor2.SetPosition( 100.f, 100.f );
1521 Stage::GetCurrent().Add( editor2 );
1523 // Render and notify
1524 application.SendNotification();
1525 application.Render();
1527 // Create a tap event on the second text editor.
1528 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1529 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1531 // Render and notify
1532 application.SendNotification();
1533 application.Render();
1535 // The second text editor has the focus. It should handle the key events.
1536 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1537 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1539 // Render and notify
1540 application.SendNotification();
1541 application.Render();
1543 // Check the text has been added to the second text editor.
1544 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1549 int utcDaliTextEditorEvent02(void)
1551 ToolkitTestApplication application;
1552 tet_infoline(" utcDaliTextEditorEvent02");
1554 // Checks if the right number of actors are created.
1556 TextEditor editor = TextEditor::New();
1557 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1558 DALI_TEST_CHECK( editor );
1560 Stage::GetCurrent().Add( editor );
1562 editor.SetSize( 300.f, 50.f );
1563 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1564 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1566 // Avoid a crash when core load gl resources.
1567 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1569 // Render and notify
1570 application.SendNotification();
1571 application.Render();
1573 // Check there are the expected number of children (the stencil).
1574 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1576 Actor stencil = editor.GetChildAt( 0u );
1578 // Create a tap event to touch the text editor.
1579 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1580 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1582 // Render and notify
1583 application.SendNotification();
1584 application.Render();
1586 Actor layer = editor.GetChildAt( 1u );
1587 DALI_TEST_CHECK( layer.IsLayer() );
1589 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1590 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1592 // Now the text editor has the focus, so it can handle the key events.
1593 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1594 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1596 // Render and notify
1597 application.SendNotification();
1598 application.Render();
1600 // Checks the cursor and the renderer have been created.
1601 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1602 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1604 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1605 DALI_TEST_CHECK( cursor );
1607 // The stencil actor has a container with all the actors which contain the text renderers.
1608 Actor container = stencil.GetChildAt( 0u );
1609 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1611 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1612 DALI_TEST_CHECK( renderer );
1615 // Move the cursor and check the position changes.
1616 Vector3 position1 = cursor.GetCurrentPosition();
1618 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1619 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1621 // Render and notify
1622 application.SendNotification();
1623 application.Render();
1625 Vector3 position2 = cursor.GetCurrentPosition();
1627 DALI_TEST_CHECK( position2.x < position1.x );
1629 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1630 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1632 // Render and notify
1633 application.SendNotification();
1634 application.Render();
1636 Vector3 position3 = cursor.GetCurrentPosition();
1638 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1640 // Send some taps and check the cursor positions.
1642 // Try to tap at the beginning.
1643 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1644 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1646 // Render and notify
1647 application.SendNotification();
1648 application.Render();
1650 // Cursor position should be the same than position1.
1651 Vector3 position4 = cursor.GetCurrentPosition();
1653 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1655 // Tap away from the start position.
1656 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1657 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1659 // Render and notify
1660 application.SendNotification();
1661 application.Render();
1663 Vector3 position5 = cursor.GetCurrentPosition();
1665 DALI_TEST_CHECK( position5.x > position4.x );
1667 // Remove all the text.
1668 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1669 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1670 editor.SetProperty( TextEditor::Property::TEXT, "" );
1672 // Render and notify
1673 application.SendNotification();
1674 application.Render();
1676 // Cursor position should be the same than position2.
1677 Vector3 position6 = cursor.GetCurrentPosition();
1679 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1681 // Should not be a renderer.
1682 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1687 int utcDaliTextEditorEvent03(void)
1689 ToolkitTestApplication application;
1690 tet_infoline(" utcDaliTextEditorEvent03");
1692 // Checks if the highlight actor is created.
1694 TextEditor editor = TextEditor::New();
1695 DALI_TEST_CHECK( editor );
1697 Stage::GetCurrent().Add( editor );
1699 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1700 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1701 editor.SetSize( 30.f, 50.f );
1702 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1703 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1705 // Avoid a crash when core load gl resources.
1706 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1708 // Render and notify
1709 application.SendNotification();
1710 application.Render();
1712 // Send some taps and check text controller with clipboard window
1713 Dali::Clipboard clipboard = Clipboard::Get();
1714 clipboard.ShowClipboard();
1715 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1716 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1717 clipboard.HideClipboard();
1719 // Render and notify
1720 application.SendNotification();
1721 application.Render();
1723 // Tap first to get the focus.
1724 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1725 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1727 // Render and notify
1728 application.SendNotification();
1729 application.Render();
1731 // Double tap to select a word.
1732 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1733 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1735 // Render and notify
1736 application.SendNotification();
1737 application.Render();
1739 // The stencil actor should have two actors: the renderer and the highlight actor.
1740 Actor stencil = editor.GetChildAt( 0u );
1742 // Highlight needs to be drawn before text, so should come first in child order
1743 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1744 DALI_TEST_CHECK( highlight );
1746 // The stencil actor has a container with all the actors which contain the text renderers.
1747 Actor container = stencil.GetChildAt( 1u );
1748 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1750 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1751 DALI_TEST_CHECK( renderer );
1754 // Double tap out of bounds
1755 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1756 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1758 // Render and notify
1759 application.SendNotification();
1760 application.Render();
1762 // The stencil actor should have one actors: the renderer actor.
1763 stencil = editor.GetChildAt( 0u );
1765 // The stencil actor has a container with all the actors which contain the text renderers.
1766 container = stencil.GetChildAt( 0u );
1767 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1769 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1770 DALI_TEST_CHECK( renderer );
1774 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1775 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1777 // Render and notify
1778 application.SendNotification();
1779 application.Render();
1784 int utcDaliTextEditorEvent04(void)
1786 ToolkitTestApplication application;
1787 tet_infoline(" utcDaliTextEditorEvent04");
1789 // Checks if the highlight actor is created.
1791 TextEditor editor = TextEditor::New();
1792 DALI_TEST_CHECK( editor );
1794 Stage::GetCurrent().Add( editor );
1796 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1797 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1798 editor.SetSize( 100.f, 50.f );
1799 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1800 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1802 // Avoid a crash when core load gl resources.
1803 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1805 // Render and notify
1806 application.SendNotification();
1807 application.Render();
1809 // Tap on the text editor
1810 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1811 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1813 // Render and notify
1814 application.SendNotification();
1815 application.Render();
1817 // Move at the end of the text.
1818 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1819 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1821 // Render and notify
1822 application.SendNotification();
1823 application.Render();
1825 for( unsigned int index = 0u; index < 10u; ++index )
1827 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1828 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1830 // Render and notify
1831 application.SendNotification();
1832 application.Render();
1836 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1838 // Render and notify
1839 application.SendNotification();
1840 application.Render();
1842 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1844 // Add some key events
1845 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1846 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1848 // Render and notify
1849 application.SendNotification();
1850 application.Render();
1852 for( unsigned int index = 0u; index < 10u; ++index )
1854 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1855 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1857 // Render and notify
1858 application.SendNotification();
1859 application.Render();
1863 application.ProcessEvent( GenerateKey( " ", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1865 // Render and notify
1866 application.SendNotification();
1867 application.Render();
1869 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1874 int utcDaliTextEditorEvent05(void)
1876 ToolkitTestApplication application;
1877 tet_infoline(" utcDaliTextEditorEvent05");
1879 // Checks if the highlight actor is created.
1881 TextEditor editor = TextEditor::New();
1882 DALI_TEST_CHECK( editor );
1884 Stage::GetCurrent().Add( editor );
1886 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1887 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1888 editor.SetSize( 50.f, 50.f );
1889 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1890 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1891 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1892 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1893 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1894 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1895 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1897 // Avoid a crash when core load gl resources.
1898 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1900 // Render and notify
1901 application.SendNotification();
1902 application.Render();
1904 // Tap on the text editor
1905 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1906 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1908 // Render and notify
1909 application.SendNotification();
1910 application.Render();
1912 // Move at the end of the text.
1913 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1914 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1916 // Render and notify
1917 application.SendNotification();
1918 application.Render();
1920 for( unsigned int index = 0u; index < 10u; ++index )
1923 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1925 // Render and notify
1926 application.SendNotification();
1927 application.Render();
1929 // Modify duration after scroll is enabled
1930 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1932 // Continuous scroll left to increase coverage
1933 for( unsigned int index = 0u; index < 10u; ++index )
1935 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1937 // Render and notify
1938 application.SendNotification();
1939 application.Render();
1941 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1942 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1943 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1944 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1945 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1947 // Press Escape to increase coverage
1948 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1949 application.SendNotification();
1950 application.Render();
1952 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1957 int utcDaliTextEditorEvent06(void)
1959 ToolkitTestApplication application;
1960 tet_infoline(" utcDaliTextEditorEvent06");
1962 // Checks if the highlight actor is created.
1964 TextEditor editor = TextEditor::New();
1965 DALI_TEST_CHECK( editor );
1967 Stage::GetCurrent().Add( editor );
1969 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
1970 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1971 editor.SetSize( 100.f, 50.f );
1972 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1973 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1975 // Avoid a crash when core load gl resources.
1976 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1978 // Render and notify
1979 application.SendNotification();
1980 application.Render();
1982 // Tap on the text editor
1983 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1984 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1986 // Render and notify
1987 application.SendNotification();
1988 application.Render();
1990 // Move to seconds line of the text.
1991 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1993 // Render and notify
1994 application.SendNotification();
1995 application.Render();
1997 float layoutHeight = editor.GetHeightForWidth( 100.f );
2000 // Add another script characters ( glyph height is defferent )
2001 application.ProcessEvent( GenerateKey( "d", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2002 application.ProcessEvent( GenerateKey( "d", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2004 // Delete characters
2005 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2006 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2008 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2010 // Render and notify
2011 application.SendNotification();
2012 application.Render();
2014 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2017 application.ProcessEvent( GenerateKey( "", "", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2018 application.SendNotification();
2019 application.Render();
2021 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2022 application.SendNotification();
2023 application.Render();
2025 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2026 application.SendNotification();
2027 application.Render();
2029 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2030 application.SendNotification();
2031 application.Render();
2036 int utcDaliTextEditorHandles(void)
2038 ToolkitTestApplication application;
2039 tet_infoline(" utcDaliTextEditorHandles");
2041 TextEditor editor = TextEditor::New();
2042 DALI_TEST_CHECK( editor );
2044 Stage::GetCurrent().Add( editor );
2046 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2047 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2048 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2049 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2051 editor.SetSize( 30.f, 500.f );
2052 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2053 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2055 // Avoid a crash when core load gl resources.
2056 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2058 // Render and notify
2059 application.SendNotification();
2060 application.Render();
2062 // Tap first to get the focus.
2063 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2064 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2066 // Render and notify
2067 application.SendNotification();
2068 application.Render();
2070 // Tap to create the grab handle.
2071 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2072 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2074 // Render and notify
2075 application.SendNotification();
2076 application.Render();
2078 // Get the active layer where the text's decoration is added.
2079 Actor activeLayer = editor.GetChildAt( 1u );
2081 // Get the handle's actor.
2082 Actor handle = activeLayer.GetChildAt( 1u );
2083 handle.SetSize( 100.f, 100.f );
2085 // Render and notify
2086 application.SendNotification();
2087 application.Render();
2089 // Touch the grab handle to set it as pressed.
2090 Vector2 touchPos( 10.0f, 50.0f );
2091 Dali::Integration::TouchEvent event;
2092 event = Dali::Integration::TouchEvent();
2093 event.AddPoint( GetPointDownInside( touchPos ) );
2094 application.ProcessEvent( event );
2096 // Render and notify
2097 application.SendNotification();
2098 application.Render();
2100 // drag grab handle right
2101 SendPan(application, Gesture::Possible, touchPos);
2102 SendPan(application, Gesture::Started, touchPos);
2104 Wait(application, 100);
2106 for(int i = 0;i<20;i++)
2108 SendPan(application, Gesture::Continuing, touchPos);
2113 SendPan(application, Gesture::Finished, touchPos);
2116 // Release the grab handle.
2117 event = Dali::Integration::TouchEvent();
2118 event.AddPoint( GetPointUpInside( touchPos ) );
2119 application.ProcessEvent( event );
2121 // Render and notify
2122 application.SendNotification();
2123 application.Render();
2129 int utcDaliTextEditorUnderPropertyStringP(void)
2131 ToolkitTestApplication application;
2132 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2133 TextEditor editor = TextEditor::New();
2134 DALI_TEST_CHECK( editor );
2136 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2138 Stage::GetCurrent().Add( editor );
2140 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2141 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2143 tet_infoline("Set underline settings with a map");
2144 // Check the input underline property
2145 Property::Map underlineMapSet;
2146 Property::Map underlineMapGet;
2147 underlineMapSet.Insert( "enable", "true" );
2148 underlineMapSet.Insert( "color", "blue" );
2149 underlineMapSet.Insert( "height", "2" );
2151 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2152 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2153 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2154 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2156 tet_infoline("Set underline settings with a string");
2157 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2158 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2161 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2163 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2164 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2165 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2166 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2168 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2173 int utcDaliTextEditorShadowPropertyStringP(void)
2175 ToolkitTestApplication application;
2176 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2178 TextEditor editor = TextEditor::New();
2180 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2182 Stage::GetCurrent().Add( editor );
2184 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2186 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2190 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2195 int utcDaliTextEditorFontStylePropertyStringP(void)
2197 ToolkitTestApplication application;
2198 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2200 TextEditor editor = TextEditor::New();
2202 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2204 Stage::GetCurrent().Add( editor );
2206 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2208 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2212 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2217 int utcDaliTextEditorGetPropertyLinecountP(void)
2219 ToolkitTestApplication application;
2221 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2225 TextEditor editor = TextEditor::New();
2226 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2227 editor.SetProperty( TextEditor::Property::TEXT,
2228 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2230 Stage::GetCurrent().Add( editor );
2232 editor.SetSize( 100.0f, 100.0f );
2233 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2234 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2236 editor.SetSize( 50.0f, 100.0f );
2237 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2238 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2243 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2246 ToolkitTestApplication application;
2247 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2249 TextEditor editor = TextEditor::New();
2250 DALI_TEST_CHECK( editor );
2252 Stage::GetCurrent().Add( editor );
2254 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2255 editor.SetSize( 50.f, 50.f );
2256 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2257 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2258 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2259 editor.SetKeyboardFocusable(true);
2261 bool startedCalled = false;
2262 bool finishedCalled = false;
2264 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2265 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2267 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2269 // Render and notify
2270 application.SendNotification();
2271 application.Render();
2273 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2274 application.SendNotification();
2275 application.Render(6000);
2277 application.SendNotification();
2278 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2279 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2284 int UtcDaliToolkitTextEditorTextWrapMode(void)
2286 ToolkitTestApplication application;
2287 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2291 TextEditor editor = TextEditor::New();
2292 editor.SetSize( 150.0f, 300.f );
2293 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2295 Stage::GetCurrent().Add( editor );
2297 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2298 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2300 application.SendNotification();
2301 application.Render();
2303 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2304 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2306 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2307 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2309 application.SendNotification();
2310 application.Render();
2312 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2313 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2315 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2316 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2318 application.SendNotification();
2319 application.Render();
2321 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2322 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2324 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2325 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2327 application.SendNotification();
2328 application.Render();
2330 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2331 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2336 int UtcDaliTextEditorSetPaddingProperty(void)
2338 ToolkitTestApplication application;
2339 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2341 TextEditor editor = TextEditor::New();
2342 DALI_TEST_CHECK( editor );
2343 editor.SetSize( 300.f, 50.f );
2344 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2345 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2346 Stage::GetCurrent().Add( editor );
2348 application.SendNotification();
2349 application.Render();
2351 Vector3 originalSize = editor.GetNaturalSize();
2353 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2355 application.SendNotification();
2356 application.Render();
2358 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2360 Vector3 paddingAddedSize = editor.GetNaturalSize();
2362 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2364 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );