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/devel-api/adaptor-framework/key-devel.h>
24 #include <dali/integration-api/events/key-event-integ.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/integration-api/events/tap-gesture-event.h>
27 #include <dali/integration-api/events/pan-gesture-event.h>
28 #include <dali/integration-api/events/long-press-gesture-event.h>
29 #include <dali-toolkit-test-suite-utils.h>
30 #include <dali-toolkit/dali-toolkit.h>
31 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
34 using namespace Toolkit;
36 void dali_texteditor_startup(void)
38 test_return_value = TET_UNDEF;
41 void dali_texteditor_cleanup(void)
43 test_return_value = TET_PASS;
49 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
50 const char* const PROPERTY_NAME_TEXT = "text";
51 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
52 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
53 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
54 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
55 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
56 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
57 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
58 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
59 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
60 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
61 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
62 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
63 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
64 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
65 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
66 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
71 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
72 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
73 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
74 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
75 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
76 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
77 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
78 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
80 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
81 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
82 const char* const PROPERTY_NAME_UNDERLINE = "underline";
83 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
84 const char* const PROPERTY_NAME_SHADOW = "shadow";
85 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
86 const char* const PROPERTY_NAME_EMBOSS = "emboss";
87 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
88 const char* const PROPERTY_NAME_OUTLINE = "outline";
89 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
91 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
92 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
93 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
94 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
95 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
96 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
97 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
98 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
99 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
100 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
101 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
103 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
105 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
106 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
108 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
109 const float TO_MILLISECONDS = 1000.f;
110 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
111 const float RENDER_FRAME_INTERVAL = 16.66f;
113 const float SCROLL_THRESHOLD = 10.f;
114 const float SCROLL_SPEED = 300.f;
116 const unsigned int DEFAULT_FONT_SIZE = 1152u;
117 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
119 const int KEY_A_CODE = 38;
120 const int KEY_D_CODE = 40;
121 const int KEY_WHITE_SPACE_CODE = 65;
123 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
125 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
127 static bool gTextChangedCallBackCalled;
128 static bool gInputStyleChangedCallbackCalled;
129 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
131 struct CallbackFunctor
133 CallbackFunctor(bool* callbackFlag)
134 : mCallbackFlag( callbackFlag )
140 *mCallbackFlag = true;
145 static void TestTextChangedCallback( TextEditor control )
147 tet_infoline(" TestTextChangedCallback");
149 gTextChangedCallBackCalled = true;
152 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
154 tet_infoline(" TestInputStyleChangedCallback");
156 gInputStyleChangedCallbackCalled = true;
157 gInputStyleMask = mask;
160 // Generate a TapGestureEvent to send to Core.
161 Integration::TapGestureEvent GenerateTap(
162 Gesture::State state,
163 unsigned int numberOfTaps,
164 unsigned int numberOfTouches,
167 Integration::TapGestureEvent tap( state );
169 tap.numberOfTaps = numberOfTaps;
170 tap.numberOfTouches = numberOfTouches;
176 Integration::LongPressGestureEvent GenerateLongPress(
177 Gesture::State state,
178 unsigned int numberOfTouches,
181 Integration::LongPressGestureEvent longPress( state );
183 longPress.numberOfTouches = numberOfTouches;
184 longPress.point = point;
188 // Generate a PanGestureEvent to send to Core
189 Integration::PanGestureEvent GeneratePan( Gesture::State state,
190 const Vector2& previousPosition,
191 const Vector2& currentPosition,
192 unsigned long timeDelta,
193 unsigned int numberOfTouches = 1u )
195 Integration::PanGestureEvent pan(state);
197 pan.previousPosition = previousPosition;
198 pan.currentPosition = currentPosition;
199 pan.timeDelta = timeDelta;
200 pan.numberOfTouches = numberOfTouches;
205 // Generate a KeyEvent to send to Core.
206 Integration::KeyEvent GenerateKey( const std::string& keyName,
207 const std::string& keyString,
210 unsigned long timeStamp,
211 const Integration::KeyEvent::State& keyState,
212 const std::string& deviceName = DEFAULT_DEVICE_NAME,
213 const Device::Class::Type& deviceClass = Device::Class::NONE,
214 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
216 return Integration::KeyEvent( keyName,
228 * Helper to generate PanGestureEvent
230 * @param[in] application Application instance
231 * @param[in] state The Gesture State
232 * @param[in] pos The current position of touch.
234 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
238 if( (state == Gesture::Started) ||
239 (state == Gesture::Possible) )
245 application.ProcessEvent( GeneratePan( state, last, pos, 16 ) );
252 * Simulate time passed by.
254 * @note this will always process at least 1 frame (1/60 sec)
256 * @param application Test application instance
257 * @param duration Time to pass in milliseconds.
258 * @return The actual time passed in milliseconds
260 static int Wait(ToolkitTestApplication& application, int duration = 0)
264 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
266 application.SendNotification();
267 application.Render(RENDER_FRAME_INTERVAL);
268 time += RENDER_FRAME_INTERVAL;
274 Dali::Integration::Point GetPointDownInside( Vector2& pos )
276 Dali::Integration::Point point;
277 point.SetState( PointState::DOWN );
278 point.SetScreenPosition( pos );
282 Dali::Integration::Point GetPointUpInside( Vector2& pos )
284 Dali::Integration::Point point;
285 point.SetState( PointState::UP );
286 point.SetScreenPosition( pos );
290 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
292 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
294 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
296 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
298 Property::Value* valueSet = NULL;
299 if ( valueGet.first.type == Property::Key::INDEX )
301 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
305 // Get Key is a string so searching Set Map for a string key
306 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
309 if( NULL != valueSet )
311 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
313 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
319 if ( valueGet.first.type == Property::Key::INDEX )
321 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
325 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
335 class ScrollStateChangeCallback : public Dali::ConnectionTracker
338 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
339 : mStartedCalled( startedCalled ),
340 mFinishedCalled( finishedCalled )
344 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
346 if( type == TextEditor::Scroll::STARTED )
348 mStartedCalled = true;
350 else if( type == TextEditor::Scroll::FINISHED )
352 mFinishedCalled = true;
356 bool& mStartedCalled;
357 bool& mFinishedCalled;
362 int UtcDaliToolkitTextEditorConstructorP(void)
364 ToolkitTestApplication application;
365 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
366 TextEditor textEditor;
367 DALI_TEST_CHECK( !textEditor );
371 int UtcDaliToolkitTextEditorNewP(void)
373 ToolkitTestApplication application;
374 tet_infoline(" UtcDaliToolkitTextEditorNewP");
375 TextEditor textEditor = TextEditor::New();
376 DALI_TEST_CHECK( textEditor );
380 int UtcDaliToolkitTextEditorDownCastP(void)
382 ToolkitTestApplication application;
383 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
384 TextEditor textEditor1 = TextEditor::New();
385 BaseHandle object( textEditor1 );
387 TextEditor textEditor2 = TextEditor::DownCast( object );
388 DALI_TEST_CHECK( textEditor2 );
390 TextEditor textEditor3 = DownCast< TextEditor >( object );
391 DALI_TEST_CHECK( textEditor3 );
395 int UtcDaliToolkitTextEditorDownCastN(void)
397 ToolkitTestApplication application;
398 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
399 BaseHandle uninitializedObject;
400 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
401 DALI_TEST_CHECK( !textEditor1 );
403 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
404 DALI_TEST_CHECK( !textEditor2 );
408 int UtcDaliToolkitTextEditorCopyConstructorP(void)
410 ToolkitTestApplication application;
411 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
412 TextEditor textEditor = TextEditor::New();
413 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
415 TextEditor copy( textEditor );
416 DALI_TEST_CHECK( copy );
417 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
421 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
423 ToolkitTestApplication application;
424 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
425 TextEditor textEditor = TextEditor::New();
426 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
428 TextEditor copy = textEditor;
429 DALI_TEST_CHECK( copy );
430 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
434 int UtcDaliTextEditorNewP(void)
436 ToolkitTestApplication application;
437 tet_infoline(" UtcDaliToolkitTextEditorNewP");
438 TextEditor textEditor = TextEditor::New();
439 DALI_TEST_CHECK( textEditor );
443 // Positive test case for a method
444 int UtcDaliTextEditorGetPropertyP(void)
446 ToolkitTestApplication application;
447 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
448 TextEditor editor = TextEditor::New();
449 DALI_TEST_CHECK( editor );
451 // Check Property Indices are correct
452 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextEditor::Property::RENDERING_BACKEND );
453 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
454 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
455 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
456 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
457 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
458 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
459 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
460 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
461 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
462 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
463 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
464 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
465 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
466 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
467 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
468 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
469 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
470 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
471 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
472 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
473 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
474 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
475 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
476 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
477 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
478 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
479 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
480 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
481 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
483 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
484 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
485 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
486 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
487 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
488 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
489 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
490 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
491 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
492 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
493 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
494 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
495 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
496 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
497 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
498 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
499 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
500 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
501 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
502 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
503 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
508 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
511 Property::Map imageMap;
512 imageMap[mapKey] =mapValue;
514 editor.SetProperty( property , imageMap );
515 Property::Value propValue = editor.GetProperty( property );
516 Property::Map* resultMap = propValue.GetMap();
518 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
526 // Positive test case for a method
527 int UtcDaliTextEditorSetPropertyP(void)
529 ToolkitTestApplication application;
530 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
531 TextEditor editor = TextEditor::New();
532 DALI_TEST_CHECK( editor );
533 Stage::GetCurrent().Add( editor );
535 // Note - we can't check the defaults since the stylesheets are platform-specific
537 // Check the render backend property.
538 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
539 DALI_TEST_EQUALS( (Text::RenderingType)editor.GetProperty<int>( TextEditor::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
541 // Check text property.
542 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
543 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
545 // Check text's color property
546 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
547 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
549 // Check font properties.
550 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
551 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
553 Property::Map fontStyleMapSet;
554 Property::Map fontStyleMapGet;
555 Property::Value* slantValue = NULL;
557 fontStyleMapSet.Insert( "weight", "bold" );
558 fontStyleMapSet.Insert( "width", "condensed" );
559 fontStyleMapSet.Insert( "slant", "italic" );
561 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
562 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
563 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
564 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
566 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
567 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
570 fontStyleMapSet.Clear();
571 fontStyleMapSet.Insert( "weight", "normal" );
572 fontStyleMapSet.Insert( "slant", "oblique" );
573 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
574 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
575 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
576 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
578 fontStyleMapSet.Clear();
579 fontStyleMapSet.Insert( "slant", "roman" );
580 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
581 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
583 // Replace 'roman' for 'normal'.
584 slantValue = fontStyleMapGet.Find( "slant" );
585 if( NULL != slantValue )
587 if( "normal" == slantValue->Get<std::string>() )
589 fontStyleMapGet["slant"] = "roman";
592 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
593 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
595 fontStyleMapSet.Clear();
597 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
598 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
599 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
600 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
602 // Check that the Alignment properties can be correctly set
603 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
604 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
606 // Check scroll properties.
607 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
608 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
609 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
610 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
612 // Check cursor properties
613 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
614 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
615 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
616 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
618 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
619 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
620 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
621 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
622 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
623 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
624 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
625 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
627 // Check handle images
628 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
629 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
630 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
631 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
632 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
634 // Check handle images
635 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
636 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
637 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
638 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
639 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
640 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
642 // Check the highlight color
643 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
644 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
646 // Decoration bounding box
647 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
648 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
650 // Check the enable markup property.
651 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
652 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
653 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
655 // Check input color property.
656 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
657 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
659 // Check input font properties.
660 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
661 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
663 fontStyleMapSet.Clear();
664 fontStyleMapSet.Insert( "weight", "bold" );
665 fontStyleMapSet.Insert( "width", "condensed" );
666 fontStyleMapSet.Insert( "slant", "italic" );
668 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
669 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
670 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
671 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
673 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
674 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
676 // Reset input font style.
677 fontStyleMapSet.Clear();
678 fontStyleMapSet.Insert( "weight", "normal" );
679 fontStyleMapSet.Insert( "slant", "oblique" );
681 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
682 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
683 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
684 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
686 fontStyleMapSet.Clear();
687 fontStyleMapSet.Insert( "slant", "roman" );
689 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
690 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
692 // Replace 'roman' for 'normal'.
693 slantValue = fontStyleMapGet.Find( "slant" );
694 if( NULL != slantValue )
696 if( "normal" == slantValue->Get<std::string>() )
698 fontStyleMapGet["slant"] = "roman";
701 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
702 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
704 fontStyleMapSet.Clear();
706 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
707 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
708 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
709 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
711 // Check the line spacing property
712 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
713 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
714 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
716 // Check the input line spacing property
717 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
718 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
719 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
721 // Check the underline property
723 Property::Map underlineMapSet;
724 Property::Map underlineMapGet;
726 underlineMapSet.Insert( "enable", "true" );
727 underlineMapSet.Insert( "color", "red" );
728 underlineMapSet.Insert( "height", "1" );
730 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
732 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
733 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
734 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
736 // Check the input underline property
737 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
738 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
740 // Check the shadow property
741 Property::Map shadowMapSet;
742 Property::Map shadowMapGet;
744 shadowMapSet.Insert( "color", Color::GREEN );
745 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
746 shadowMapSet.Insert( "blurRadius", 3.0f );
748 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
750 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
751 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
752 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
754 // Check the input shadow property
755 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
756 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
758 // Check the emboss property
759 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
760 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
762 // Check the input emboss property
763 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
764 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
766 // Check the outline property
768 // Test string type first
769 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
770 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
771 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
773 // Then test the property map type
774 Property::Map outlineMapSet;
775 Property::Map outlineMapGet;
777 outlineMapSet["color"] = Color::RED;
778 outlineMapSet["width"] = 2.0f;
780 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
782 outlineMapSet["color"] = "red";
783 outlineMapSet["width"] = "2";
784 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
785 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
786 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
788 // Check the input outline property
789 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
790 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
792 // Check the smooth scroll property
793 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
794 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
795 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
797 // Check the smooth scroll duration property
798 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
799 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
801 // Check the scroll bar property
802 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
803 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
804 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
806 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
807 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
808 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
809 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
811 // Check the pixel size of font
812 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
813 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
815 // Check placeholder text properties.
816 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
817 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
819 // Check placeholder text's color property.
820 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
821 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
823 // Check the enable selection property
824 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
825 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
827 // Check the placeholder property with pixel size
828 Property::Map placeholderPixelSizeMapSet;
829 Property::Map placeholderPixelSizeMapGet;
830 Property::Map placeholderFontstyleMap;
831 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
832 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
833 placeholderPixelSizeMapSet["color"] = Color::BLUE;
834 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
835 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
837 placeholderFontstyleMap.Insert( "weight", "bold" );
838 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
839 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
841 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
842 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
844 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
845 Property::Map placeholderConversionMap;
846 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
847 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
848 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
849 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
850 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
851 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
853 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
855 // Check the placeholder property with point size
856 Property::Map placeholderMapSet;
857 Property::Map placeholderMapGet;
858 placeholderMapSet["text"] = "Setting Placeholder Text";
859 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
860 placeholderMapSet["color"] = Color::RED;
861 placeholderMapSet["fontFamily"] = "Arial";
862 placeholderMapSet["pointSize"] = 12.0f;
863 // Check the placeholder font style property
864 placeholderFontstyleMap.Clear();
866 placeholderFontstyleMap.Insert( "weight", "bold" );
867 placeholderFontstyleMap.Insert( "width", "condensed" );
868 placeholderFontstyleMap.Insert( "slant", "italic" );
869 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
870 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
872 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
873 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
875 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
876 placeholderConversionMap.Clear();
877 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
878 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
879 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
880 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
881 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
882 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
883 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
886 placeholderFontstyleMap.Clear();
887 placeholderFontstyleMap.Insert( "weight", "normal" );
888 placeholderFontstyleMap.Insert( "slant", "oblique" );
889 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
890 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
892 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
893 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
894 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
895 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
897 placeholderFontstyleMap.Clear();
898 placeholderFontstyleMap.Insert( "slant", "roman" );
899 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
900 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
902 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
904 placeholderFontstyleMap.Clear();
905 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
907 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
908 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
909 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
910 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
911 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
913 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
914 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
916 application.SendNotification();
917 application.Render();
922 // Positive Atlas Text Renderer test
923 int utcDaliTextEditorAtlasRenderP(void)
925 ToolkitTestApplication application;
926 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
927 StyleManager styleManager = StyleManager::Get();
928 styleManager.ApplyDefaultTheme();
929 TextEditor editor = TextEditor::New();
930 DALI_TEST_CHECK( editor );
932 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
934 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
936 Stage::GetCurrent().Add( editor );
940 // Render some text with the shared atlas backend
941 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
942 application.SendNotification();
943 application.Render();
947 tet_result(TET_FAIL);
952 // Positive test for the textChanged signal.
953 int utcDaliTextEditorTextChangedP(void)
955 ToolkitTestApplication application;
956 tet_infoline(" utcDaliTextEditorTextChangedP");
957 TextEditor editor = TextEditor::New();
958 DALI_TEST_CHECK( editor );
960 Stage::GetCurrent().Add( editor );
962 // connect to the text changed signal.
963 ConnectionTracker* testTracker = new ConnectionTracker();
964 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
965 bool textChangedSignal = false;
966 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
968 gTextChangedCallBackCalled = false;
969 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
970 DALI_TEST_CHECK( gTextChangedCallBackCalled );
971 DALI_TEST_CHECK( textChangedSignal );
973 application.SendNotification();
975 editor.SetKeyInputFocus();
977 gTextChangedCallBackCalled = false;
978 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
979 DALI_TEST_CHECK( gTextChangedCallBackCalled );
984 int utcDaliTextEditorInputStyleChanged01(void)
986 ToolkitTestApplication application;
987 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
989 // The text-editor emits signals when the input style changes. These changes of style are
990 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
991 // can't be emitted during the size negotiation as the callbacks may update the UI.
992 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
993 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
994 application.CreateAdaptor();
998 char* pathNamePtr = get_current_dir_name();
999 const std::string pathName( pathNamePtr );
1000 free( pathNamePtr );
1002 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1003 fontClient.SetDpi( 93u, 93u );
1005 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1006 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1008 TextEditor editor = TextEditor::New();
1009 DALI_TEST_CHECK( editor );
1012 editor.SetSize( 300.f, 50.f );
1013 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1014 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1016 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1017 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1019 // connect to the text changed signal.
1020 ConnectionTracker* testTracker = new ConnectionTracker();
1021 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1022 bool inputStyleChangedSignal = false;
1023 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1025 Stage::GetCurrent().Add( editor );
1027 // Render and notify
1028 application.SendNotification();
1029 application.Render();
1031 // Executes the idle callbacks added by the text control on the change of input style.
1032 application.RunIdles();
1034 gInputStyleChangedCallbackCalled = false;
1035 gInputStyleMask = TextEditor::InputStyle::NONE;
1036 inputStyleChangedSignal = false;
1038 // Create a tap event to touch the text editor.
1039 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1040 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1042 // Render and notify
1043 application.SendNotification();
1044 application.Render();
1046 // Executes the idle callbacks added by the text control on the change of input style.
1047 application.RunIdles();
1049 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1050 if( gInputStyleChangedCallbackCalled )
1052 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1054 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1055 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1057 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1058 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1060 DALI_TEST_CHECK( inputStyleChangedSignal );
1062 gInputStyleChangedCallbackCalled = false;
1063 gInputStyleMask = TextEditor::InputStyle::NONE;
1064 inputStyleChangedSignal = false;
1066 // Create a tap event to touch the text editor.
1067 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1068 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1070 // Render and notify
1071 application.SendNotification();
1072 application.Render();
1074 // Executes the idle callbacks added by the text control on the change of input style.
1075 application.RunIdles();
1077 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1078 DALI_TEST_CHECK( !inputStyleChangedSignal );
1080 gInputStyleChangedCallbackCalled = false;
1081 gInputStyleMask = TextEditor::InputStyle::NONE;
1082 inputStyleChangedSignal = false;
1084 // Create a tap event to touch the text editor.
1085 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1086 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1088 // Render and notify
1089 application.SendNotification();
1090 application.Render();
1092 // Executes the idle callbacks added by the text control on the change of input style.
1093 application.RunIdles();
1095 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1096 if( gInputStyleChangedCallbackCalled )
1098 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1100 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1101 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1103 DALI_TEST_CHECK( inputStyleChangedSignal );
1105 gInputStyleChangedCallbackCalled = false;
1106 gInputStyleMask = TextEditor::InputStyle::NONE;
1107 inputStyleChangedSignal = false;
1109 // Create a tap event to touch the text editor.
1110 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1111 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1113 // Render and notify
1114 application.SendNotification();
1115 application.Render();
1117 // Executes the idle callbacks added by the text control on the change of input style.
1118 application.RunIdles();
1120 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1121 if( gInputStyleChangedCallbackCalled )
1123 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1125 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1126 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1128 Property::Map fontStyleMapSet;
1129 Property::Map fontStyleMapGet;
1131 fontStyleMapSet.Insert( "weight", "bold" );
1133 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1134 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1135 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1137 DALI_TEST_CHECK( inputStyleChangedSignal );
1139 gInputStyleChangedCallbackCalled = false;
1140 gInputStyleMask = TextEditor::InputStyle::NONE;
1141 inputStyleChangedSignal = false;
1143 // Create a tap event to touch the text editor.
1144 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1145 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1147 // Render and notify
1148 application.SendNotification();
1149 application.Render();
1151 // Executes the idle callbacks added by the text control on the change of input style.
1152 application.RunIdles();
1154 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1155 DALI_TEST_CHECK( !inputStyleChangedSignal );
1157 gInputStyleChangedCallbackCalled = false;
1158 gInputStyleMask = TextEditor::InputStyle::NONE;
1159 inputStyleChangedSignal = false;
1161 // Create a tap event to touch the text editor.
1162 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1163 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1165 // Render and notify
1166 application.SendNotification();
1167 application.Render();
1169 // Executes the idle callbacks added by the text control on the change of input style.
1170 application.RunIdles();
1172 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1173 if( gInputStyleChangedCallbackCalled )
1175 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1177 Property::Map fontStyleMapSet;
1178 Property::Map fontStyleMapGet;
1180 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1181 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1182 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1184 DALI_TEST_CHECK( inputStyleChangedSignal );
1186 gInputStyleChangedCallbackCalled = false;
1187 gInputStyleMask = TextEditor::InputStyle::NONE;
1188 inputStyleChangedSignal = false;
1190 // Create a tap event to touch the text editor.
1191 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1192 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1194 // Render and notify
1195 application.SendNotification();
1196 application.Render();
1198 // Executes the idle callbacks added by the text control on the change of input style.
1199 application.RunIdles();
1201 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1202 DALI_TEST_CHECK( !inputStyleChangedSignal );
1207 int utcDaliTextEditorInputStyleChanged02(void)
1209 ToolkitTestApplication application;
1210 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1212 // The text-editor emits signals when the input style changes. These changes of style are
1213 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1214 // can't be emitted during the size negotiation as the callbacks may update the UI.
1215 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1216 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1217 application.CreateAdaptor();
1221 char* pathNamePtr = get_current_dir_name();
1222 const std::string pathName( pathNamePtr );
1223 free( pathNamePtr );
1225 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1226 fontClient.SetDpi( 93u, 93u );
1228 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1229 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1231 TextEditor editor = TextEditor::New();
1232 DALI_TEST_CHECK( editor );
1235 editor.SetSize( 300.f, 50.f );
1236 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1237 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1239 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1240 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>" );
1242 // connect to the text changed signal.
1243 ConnectionTracker* testTracker = new ConnectionTracker();
1244 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1245 bool inputStyleChangedSignal = false;
1246 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1248 Stage::GetCurrent().Add( editor );
1250 // Render and notify
1251 application.SendNotification();
1252 application.Render();
1254 // Executes the idle callbacks added by the text control on the change of input style.
1255 application.RunIdles();
1257 gInputStyleChangedCallbackCalled = false;
1258 gInputStyleMask = TextEditor::InputStyle::NONE;
1259 inputStyleChangedSignal = false;
1261 // Create a tap event to touch the text editor.
1262 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1263 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1264 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1265 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1267 // Render and notify
1268 application.SendNotification();
1269 application.Render();
1271 // Executes the idle callbacks added by the text control on the change of input style.
1272 application.RunIdles();
1274 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1275 if( gInputStyleChangedCallbackCalled )
1277 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1278 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1279 TextEditor::InputStyle::POINT_SIZE |
1280 TextEditor::InputStyle::COLOR ),
1283 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1284 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1286 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1287 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1289 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1290 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1292 DALI_TEST_CHECK( inputStyleChangedSignal );
1294 gInputStyleChangedCallbackCalled = false;
1295 gInputStyleMask = TextEditor::InputStyle::NONE;
1296 inputStyleChangedSignal = false;
1298 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1300 // Render and notify
1301 application.SendNotification();
1302 application.Render();
1304 // Executes the idle callbacks added by the text control on the change of input style.
1305 application.RunIdles();
1307 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1308 if( gInputStyleChangedCallbackCalled )
1310 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1311 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1314 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1315 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1317 DALI_TEST_CHECK( inputStyleChangedSignal );
1319 gInputStyleChangedCallbackCalled = false;
1320 gInputStyleMask = TextEditor::InputStyle::NONE;
1321 inputStyleChangedSignal = false;
1323 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1325 // Render and notify
1326 application.SendNotification();
1327 application.Render();
1329 // Executes the idle callbacks added by the text control on the change of input style.
1330 application.RunIdles();
1332 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1333 DALI_TEST_CHECK( !inputStyleChangedSignal );
1335 gInputStyleChangedCallbackCalled = false;
1336 gInputStyleMask = TextEditor::InputStyle::NONE;
1337 inputStyleChangedSignal = false;
1339 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1341 // Render and notify
1342 application.SendNotification();
1343 application.Render();
1345 // Executes the idle callbacks added by the text control on the change of input style.
1346 application.RunIdles();
1348 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1349 if( gInputStyleChangedCallbackCalled )
1351 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1352 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1355 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1356 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1358 DALI_TEST_CHECK( inputStyleChangedSignal );
1360 gInputStyleChangedCallbackCalled = false;
1361 gInputStyleMask = TextEditor::InputStyle::NONE;
1362 inputStyleChangedSignal = false;
1364 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1366 Property::Map fontStyleMapSet;
1367 fontStyleMapSet.Insert( "weight", "thin" );
1368 fontStyleMapSet.Insert( "width", "condensed" );
1369 fontStyleMapSet.Insert( "slant", "italic" );
1371 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1372 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1373 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1375 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1376 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1377 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1378 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1380 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1382 // Render and notify
1383 application.SendNotification();
1384 application.Render();
1386 // Executes the idle callbacks added by the text control on the change of input style.
1387 application.RunIdles();
1389 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1390 DALI_TEST_CHECK( !inputStyleChangedSignal );
1392 // Create a tap event to touch the text editor.
1393 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1394 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1396 // Render and notify
1397 application.SendNotification();
1398 application.Render();
1400 // Executes the idle callbacks added by the text control on the change of input style.
1401 application.RunIdles();
1403 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1404 if( gInputStyleChangedCallbackCalled )
1406 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1407 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1408 TextEditor::InputStyle::POINT_SIZE |
1409 TextEditor::InputStyle::FONT_STYLE |
1410 TextEditor::InputStyle::LINE_SPACING |
1411 TextEditor::InputStyle::UNDERLINE |
1412 TextEditor::InputStyle::SHADOW |
1413 TextEditor::InputStyle::EMBOSS |
1414 TextEditor::InputStyle::OUTLINE ),
1417 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1418 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1420 DALI_TEST_CHECK( inputStyleChangedSignal );
1422 gInputStyleChangedCallbackCalled = false;
1423 gInputStyleMask = TextEditor::InputStyle::NONE;
1424 inputStyleChangedSignal = false;
1426 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1428 fontStyleMapSet.Clear();
1429 fontStyleMapSet.Insert( "weight", "black" );
1430 fontStyleMapSet.Insert( "width", "expanded" );
1431 fontStyleMapSet.Insert( "slant", "oblique" );
1433 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1435 // Create a tap event to touch the text editor.
1436 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1437 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1439 // Render and notify
1440 application.SendNotification();
1441 application.Render();
1443 // Executes the idle callbacks added by the text control on the change of input style.
1444 application.RunIdles();
1446 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1447 if( gInputStyleChangedCallbackCalled )
1449 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1450 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1451 TextEditor::InputStyle::POINT_SIZE |
1452 TextEditor::InputStyle::FONT_STYLE ),
1455 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1456 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1458 DALI_TEST_CHECK( inputStyleChangedSignal );
1463 int utcDaliTextEditorEvent01(void)
1465 ToolkitTestApplication application;
1466 tet_infoline(" utcDaliTextEditorEvent01");
1468 // Creates a tap event. After creating a tap event the text editor should
1469 // have the focus and add text with key events should be possible.
1471 TextEditor editor = TextEditor::New();
1472 DALI_TEST_CHECK( editor );
1474 Stage::GetCurrent().Add( editor );
1476 editor.SetSize( 300.f, 50.f );
1477 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1478 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1480 // Avoid a crash when core load gl resources.
1481 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1483 // Render and notify
1484 application.SendNotification();
1485 application.Render();
1487 // Add a key event but as the text editor has not the focus it should do nothing.
1488 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1490 // Render and notify
1491 application.SendNotification();
1492 application.Render();
1494 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1496 // Create a tap event to touch the text editor.
1497 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1498 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1500 // Render and notify
1501 application.SendNotification();
1502 application.Render();
1504 // Now the text editor has the focus, so it can handle the key events.
1505 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1506 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1508 // Render and notify
1509 application.SendNotification();
1510 application.Render();
1512 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1514 // Create a second text editor and send key events to it.
1515 TextEditor editor2 = TextEditor::New();
1517 editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1518 editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1519 editor2.SetSize( 100.f, 100.f );
1520 editor2.SetPosition( 100.f, 100.f );
1522 Stage::GetCurrent().Add( editor2 );
1524 // Render and notify
1525 application.SendNotification();
1526 application.Render();
1528 // Create a tap event on the second text editor.
1529 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1530 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1532 // Render and notify
1533 application.SendNotification();
1534 application.Render();
1536 // The second text editor has the focus. It should handle the key events.
1537 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1538 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1540 // Render and notify
1541 application.SendNotification();
1542 application.Render();
1544 // Check the text has been added to the second text editor.
1545 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1550 int utcDaliTextEditorEvent02(void)
1552 ToolkitTestApplication application;
1553 tet_infoline(" utcDaliTextEditorEvent02");
1555 // Checks if the right number of actors are created.
1557 TextEditor editor = TextEditor::New();
1558 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1559 DALI_TEST_CHECK( editor );
1561 Stage::GetCurrent().Add( editor );
1563 editor.SetSize( 300.f, 50.f );
1564 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1565 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1567 // Avoid a crash when core load gl resources.
1568 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1570 // Render and notify
1571 application.SendNotification();
1572 application.Render();
1574 // Check there are the expected number of children (the stencil).
1575 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1577 Actor stencil = editor.GetChildAt( 0u );
1579 // Create a tap event to touch the text editor.
1580 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1581 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1583 // Render and notify
1584 application.SendNotification();
1585 application.Render();
1587 Actor layer = editor.GetChildAt( 1u );
1588 DALI_TEST_CHECK( layer.IsLayer() );
1590 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1591 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1593 // Now the text editor has the focus, so it can handle the key events.
1594 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1595 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1597 // Render and notify
1598 application.SendNotification();
1599 application.Render();
1601 // Checks the cursor and the renderer have been created.
1602 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1603 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1605 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1606 DALI_TEST_CHECK( cursor );
1608 // The stencil actor has a container with all the actors which contain the text renderers.
1609 Actor container = stencil.GetChildAt( 0u );
1610 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1612 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1613 DALI_TEST_CHECK( renderer );
1616 // Move the cursor and check the position changes.
1617 Vector3 position1 = cursor.GetCurrentPosition();
1619 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1620 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1622 // Render and notify
1623 application.SendNotification();
1624 application.Render();
1626 Vector3 position2 = cursor.GetCurrentPosition();
1628 DALI_TEST_CHECK( position2.x < position1.x );
1630 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1631 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1633 // Render and notify
1634 application.SendNotification();
1635 application.Render();
1637 Vector3 position3 = cursor.GetCurrentPosition();
1639 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1641 // Send some taps and check the cursor positions.
1643 // Try to tap at the beginning.
1644 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1645 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1647 // Render and notify
1648 application.SendNotification();
1649 application.Render();
1651 // Cursor position should be the same than position1.
1652 Vector3 position4 = cursor.GetCurrentPosition();
1654 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1656 // Tap away from the start position.
1657 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1658 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1660 // Render and notify
1661 application.SendNotification();
1662 application.Render();
1664 Vector3 position5 = cursor.GetCurrentPosition();
1666 DALI_TEST_CHECK( position5.x > position4.x );
1668 // Remove all the text.
1669 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1670 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1671 editor.SetProperty( TextEditor::Property::TEXT, "" );
1673 // Render and notify
1674 application.SendNotification();
1675 application.Render();
1677 // Cursor position should be the same than position2.
1678 Vector3 position6 = cursor.GetCurrentPosition();
1680 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1682 // Should not be a renderer.
1683 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1688 int utcDaliTextEditorEvent03(void)
1690 ToolkitTestApplication application;
1691 tet_infoline(" utcDaliTextEditorEvent03");
1693 // Checks if the highlight actor is created.
1695 TextEditor editor = TextEditor::New();
1696 DALI_TEST_CHECK( editor );
1698 Stage::GetCurrent().Add( editor );
1700 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1701 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1702 editor.SetSize( 30.f, 50.f );
1703 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1704 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1706 // Avoid a crash when core load gl resources.
1707 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1709 // Render and notify
1710 application.SendNotification();
1711 application.Render();
1713 // Send some taps and check text controller with clipboard window
1714 Dali::Clipboard clipboard = Clipboard::Get();
1715 clipboard.ShowClipboard();
1716 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1717 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1718 clipboard.HideClipboard();
1720 // Render and notify
1721 application.SendNotification();
1722 application.Render();
1724 // Tap first to get the focus.
1725 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1726 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1728 // Render and notify
1729 application.SendNotification();
1730 application.Render();
1732 // Double tap to select a word.
1733 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1734 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1736 // Render and notify
1737 application.SendNotification();
1738 application.Render();
1740 // The stencil actor should have two actors: the renderer and the highlight actor.
1741 Actor stencil = editor.GetChildAt( 0u );
1743 // Highlight needs to be drawn before text, so should come first in child order
1744 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1745 DALI_TEST_CHECK( highlight );
1747 // The stencil actor has a container with all the actors which contain the text renderers.
1748 Actor container = stencil.GetChildAt( 1u );
1749 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1751 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1752 DALI_TEST_CHECK( renderer );
1755 // Double tap out of bounds
1756 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1757 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1759 // Render and notify
1760 application.SendNotification();
1761 application.Render();
1763 // The stencil actor should have one actors: the renderer actor.
1764 stencil = editor.GetChildAt( 0u );
1766 // The stencil actor has a container with all the actors which contain the text renderers.
1767 container = stencil.GetChildAt( 0u );
1768 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1770 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1771 DALI_TEST_CHECK( renderer );
1775 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1776 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1778 // Render and notify
1779 application.SendNotification();
1780 application.Render();
1785 int utcDaliTextEditorEvent04(void)
1787 ToolkitTestApplication application;
1788 tet_infoline(" utcDaliTextEditorEvent04");
1790 // Checks if the highlight actor is created.
1792 TextEditor editor = TextEditor::New();
1793 DALI_TEST_CHECK( editor );
1795 Stage::GetCurrent().Add( editor );
1797 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1798 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1799 editor.SetSize( 100.f, 50.f );
1800 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1801 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1803 // Avoid a crash when core load gl resources.
1804 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1806 // Render and notify
1807 application.SendNotification();
1808 application.Render();
1810 // Tap on the text editor
1811 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1812 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1814 // Render and notify
1815 application.SendNotification();
1816 application.Render();
1818 // Move at the end of the text.
1819 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1820 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1822 // Render and notify
1823 application.SendNotification();
1824 application.Render();
1826 for( unsigned int index = 0u; index < 10u; ++index )
1828 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1829 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1831 // Render and notify
1832 application.SendNotification();
1833 application.Render();
1837 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1839 // Render and notify
1840 application.SendNotification();
1841 application.Render();
1843 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1845 // Add some key events
1846 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1847 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1849 // Render and notify
1850 application.SendNotification();
1851 application.Render();
1853 for( unsigned int index = 0u; index < 10u; ++index )
1855 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1856 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1858 // Render and notify
1859 application.SendNotification();
1860 application.Render();
1864 application.ProcessEvent( GenerateKey( " ", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1866 // Render and notify
1867 application.SendNotification();
1868 application.Render();
1870 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1875 int utcDaliTextEditorEvent05(void)
1877 ToolkitTestApplication application;
1878 tet_infoline(" utcDaliTextEditorEvent05");
1880 // Checks if the highlight actor is created.
1882 TextEditor editor = TextEditor::New();
1883 DALI_TEST_CHECK( editor );
1885 Stage::GetCurrent().Add( editor );
1887 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1888 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1889 editor.SetSize( 50.f, 50.f );
1890 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1891 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1892 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1893 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1894 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1895 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1896 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1898 // Avoid a crash when core load gl resources.
1899 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1901 // Render and notify
1902 application.SendNotification();
1903 application.Render();
1905 // Tap on the text editor
1906 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1907 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1909 // Render and notify
1910 application.SendNotification();
1911 application.Render();
1913 // Move at the end of the text.
1914 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1915 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1917 // Render and notify
1918 application.SendNotification();
1919 application.Render();
1921 for( unsigned int index = 0u; index < 10u; ++index )
1924 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1926 // Render and notify
1927 application.SendNotification();
1928 application.Render();
1930 // Modify duration after scroll is enabled
1931 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1933 // Continuous scroll left to increase coverage
1934 for( unsigned int index = 0u; index < 10u; ++index )
1936 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1938 // Render and notify
1939 application.SendNotification();
1940 application.Render();
1942 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1943 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1944 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1945 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1946 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1948 // Press Escape to increase coverage
1949 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1950 application.SendNotification();
1951 application.Render();
1953 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1958 int utcDaliTextEditorEvent06(void)
1960 ToolkitTestApplication application;
1961 tet_infoline(" utcDaliTextEditorEvent06");
1963 // Checks if the highlight actor is created.
1965 TextEditor editor = TextEditor::New();
1966 DALI_TEST_CHECK( editor );
1968 Stage::GetCurrent().Add( editor );
1970 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
1971 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1972 editor.SetSize( 100.f, 50.f );
1973 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1974 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1976 // Avoid a crash when core load gl resources.
1977 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1979 // Render and notify
1980 application.SendNotification();
1981 application.Render();
1983 // Tap on the text editor
1984 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1985 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1987 // Render and notify
1988 application.SendNotification();
1989 application.Render();
1991 // Move to seconds line of the text.
1992 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1994 // Render and notify
1995 application.SendNotification();
1996 application.Render();
1998 float layoutHeight = editor.GetHeightForWidth( 100.f );
2001 // Add another script characters ( glyph height is defferent )
2002 application.ProcessEvent( GenerateKey( "d", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2003 application.ProcessEvent( GenerateKey( "d", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2005 // Delete characters
2006 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2007 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2009 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2011 // Render and notify
2012 application.SendNotification();
2013 application.Render();
2015 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2018 application.ProcessEvent( GenerateKey( "", "", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2019 application.SendNotification();
2020 application.Render();
2022 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2023 application.SendNotification();
2024 application.Render();
2026 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2027 application.SendNotification();
2028 application.Render();
2030 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2031 application.SendNotification();
2032 application.Render();
2034 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2035 application.SendNotification();
2036 application.Render();
2041 int utcDaliTextEditorHandles(void)
2043 ToolkitTestApplication application;
2044 tet_infoline(" utcDaliTextEditorHandles");
2046 TextEditor editor = TextEditor::New();
2047 DALI_TEST_CHECK( editor );
2049 Stage::GetCurrent().Add( editor );
2051 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2052 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2053 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2054 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2056 editor.SetSize( 30.f, 500.f );
2057 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2058 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2060 // Avoid a crash when core load gl resources.
2061 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2063 // Render and notify
2064 application.SendNotification();
2065 application.Render();
2067 // Tap first to get the focus.
2068 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2069 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2071 // Render and notify
2072 application.SendNotification();
2073 application.Render();
2075 // Tap to create the grab handle.
2076 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2077 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2079 // Render and notify
2080 application.SendNotification();
2081 application.Render();
2083 // Get the active layer where the text's decoration is added.
2084 Actor activeLayer = editor.GetChildAt( 1u );
2086 // Get the handle's actor.
2087 Actor handle = activeLayer.GetChildAt( 1u );
2088 handle.SetSize( 100.f, 100.f );
2090 // Render and notify
2091 application.SendNotification();
2092 application.Render();
2094 // Touch the grab handle to set it as pressed.
2095 Vector2 touchPos( 10.0f, 50.0f );
2096 Dali::Integration::TouchEvent event;
2097 event = Dali::Integration::TouchEvent();
2098 event.AddPoint( GetPointDownInside( touchPos ) );
2099 application.ProcessEvent( event );
2101 // Render and notify
2102 application.SendNotification();
2103 application.Render();
2105 // drag grab handle right
2106 SendPan(application, Gesture::Possible, touchPos);
2107 SendPan(application, Gesture::Started, touchPos);
2109 Wait(application, 100);
2111 for(int i = 0;i<20;i++)
2113 SendPan(application, Gesture::Continuing, touchPos);
2118 SendPan(application, Gesture::Finished, touchPos);
2121 // Release the grab handle.
2122 event = Dali::Integration::TouchEvent();
2123 event.AddPoint( GetPointUpInside( touchPos ) );
2124 application.ProcessEvent( event );
2126 // Render and notify
2127 application.SendNotification();
2128 application.Render();
2134 int utcDaliTextEditorUnderPropertyStringP(void)
2136 ToolkitTestApplication application;
2137 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2138 TextEditor editor = TextEditor::New();
2139 DALI_TEST_CHECK( editor );
2141 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2143 Stage::GetCurrent().Add( editor );
2145 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2146 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2148 tet_infoline("Set underline settings with a map");
2149 // Check the input underline property
2150 Property::Map underlineMapSet;
2151 Property::Map underlineMapGet;
2152 underlineMapSet.Insert( "enable", "true" );
2153 underlineMapSet.Insert( "color", "blue" );
2154 underlineMapSet.Insert( "height", "2" );
2156 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2157 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2158 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2159 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2161 tet_infoline("Set underline settings with a string");
2162 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2163 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2166 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2168 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2169 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2170 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2171 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2173 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2178 int utcDaliTextEditorShadowPropertyStringP(void)
2180 ToolkitTestApplication application;
2181 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2183 TextEditor editor = TextEditor::New();
2185 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2187 Stage::GetCurrent().Add( editor );
2189 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2191 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2195 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2200 int utcDaliTextEditorFontStylePropertyStringP(void)
2202 ToolkitTestApplication application;
2203 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2205 TextEditor editor = TextEditor::New();
2207 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2209 Stage::GetCurrent().Add( editor );
2211 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2213 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2217 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2222 int utcDaliTextEditorGetPropertyLinecountP(void)
2224 ToolkitTestApplication application;
2226 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2230 TextEditor editor = TextEditor::New();
2231 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2232 editor.SetProperty( TextEditor::Property::TEXT,
2233 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2235 Stage::GetCurrent().Add( editor );
2237 editor.SetSize( 100.0f, 100.0f );
2238 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2239 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2241 editor.SetSize( 50.0f, 100.0f );
2242 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2243 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2248 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2251 ToolkitTestApplication application;
2252 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2254 TextEditor editor = TextEditor::New();
2255 DALI_TEST_CHECK( editor );
2257 Stage::GetCurrent().Add( editor );
2259 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2260 editor.SetSize( 50.f, 50.f );
2261 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2262 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2263 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2264 editor.SetKeyboardFocusable(true);
2266 bool startedCalled = false;
2267 bool finishedCalled = false;
2269 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2270 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2272 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2274 // Render and notify
2275 application.SendNotification();
2276 application.Render();
2278 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2279 application.SendNotification();
2280 application.Render(6000);
2282 application.SendNotification();
2283 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2284 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2289 int UtcDaliToolkitTextEditorTextWrapMode(void)
2291 ToolkitTestApplication application;
2292 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2296 TextEditor editor = TextEditor::New();
2297 editor.SetSize( 150.0f, 300.f );
2298 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2300 Stage::GetCurrent().Add( editor );
2302 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2303 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2305 application.SendNotification();
2306 application.Render();
2308 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2309 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2311 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2312 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2314 application.SendNotification();
2315 application.Render();
2317 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2318 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2320 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2321 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2323 application.SendNotification();
2324 application.Render();
2326 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2327 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2329 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2330 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2332 application.SendNotification();
2333 application.Render();
2335 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2336 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2341 int UtcDaliTextEditorSetPaddingProperty(void)
2343 ToolkitTestApplication application;
2344 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2346 TextEditor editor = TextEditor::New();
2347 DALI_TEST_CHECK( editor );
2348 editor.SetSize( 300.f, 50.f );
2349 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2350 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2351 Stage::GetCurrent().Add( editor );
2353 application.SendNotification();
2354 application.Render();
2356 Vector3 originalSize = editor.GetNaturalSize();
2358 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2360 application.SendNotification();
2361 application.Render();
2363 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2365 Vector3 paddingAddedSize = editor.GetNaturalSize();
2367 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2369 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );