2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali/public-api/rendering/renderer.h>
22 #include <dali/devel-api/adaptor-framework/clipboard.h>
23 #include <dali/integration-api/events/key-event-integ.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
25 #include <dali/integration-api/events/tap-gesture-event.h>
26 #include <dali/integration-api/events/pan-gesture-event.h>
27 #include <dali-toolkit-test-suite-utils.h>
28 #include <dali-toolkit/dali-toolkit.h>
29 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
32 using namespace Toolkit;
34 void dali_texteditor_startup(void)
36 test_return_value = TET_UNDEF;
39 void dali_texteditor_cleanup(void)
41 test_return_value = TET_PASS;
47 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
48 const char* const PROPERTY_NAME_TEXT = "text";
49 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
50 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
51 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
52 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
53 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
54 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
55 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
56 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
57 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
58 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
59 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
60 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
61 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
62 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
63 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
64 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
65 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
66 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
70 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
71 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
72 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
73 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
74 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
75 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
76 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
78 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
79 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
80 const char* const PROPERTY_NAME_UNDERLINE = "underline";
81 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
82 const char* const PROPERTY_NAME_SHADOW = "shadow";
83 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
84 const char* const PROPERTY_NAME_EMBOSS = "emboss";
85 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
86 const char* const PROPERTY_NAME_OUTLINE = "outline";
87 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
89 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
90 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
91 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
92 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
93 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
94 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
95 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
96 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
97 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
98 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
99 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
101 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
103 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
104 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
106 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
107 const float TO_MILLISECONDS = 1000.f;
108 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
109 const float RENDER_FRAME_INTERVAL = 16.66f;
111 const float SCROLL_THRESHOLD = 10.f;
112 const float SCROLL_SPEED = 300.f;
114 const unsigned int DEFAULT_FONT_SIZE = 1152u;
115 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
117 const int KEY_A_CODE = 38;
118 const int KEY_D_CODE = 40;
119 const int KEY_WHITE_SPACE_CODE = 65;
121 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
123 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
125 static bool gTextChangedCallBackCalled;
126 static bool gInputStyleChangedCallbackCalled;
127 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
129 struct CallbackFunctor
131 CallbackFunctor(bool* callbackFlag)
132 : mCallbackFlag( callbackFlag )
138 *mCallbackFlag = true;
143 static void TestTextChangedCallback( TextEditor control )
145 tet_infoline(" TestTextChangedCallback");
147 gTextChangedCallBackCalled = true;
150 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
152 tet_infoline(" TestInputStyleChangedCallback");
154 gInputStyleChangedCallbackCalled = true;
155 gInputStyleMask = mask;
158 // Generate a TapGestureEvent to send to Core.
159 Integration::TapGestureEvent GenerateTap(
160 Gesture::State state,
161 unsigned int numberOfTaps,
162 unsigned int numberOfTouches,
165 Integration::TapGestureEvent tap( state );
167 tap.numberOfTaps = numberOfTaps;
168 tap.numberOfTouches = numberOfTouches;
174 // Generate a PanGestureEvent to send to Core
175 Integration::PanGestureEvent GeneratePan( Gesture::State state,
176 const Vector2& previousPosition,
177 const Vector2& currentPosition,
178 unsigned long timeDelta,
179 unsigned int numberOfTouches = 1u )
181 Integration::PanGestureEvent pan(state);
183 pan.previousPosition = previousPosition;
184 pan.currentPosition = currentPosition;
185 pan.timeDelta = timeDelta;
186 pan.numberOfTouches = numberOfTouches;
191 // Generate a KeyEvent to send to Core.
192 Integration::KeyEvent GenerateKey( const std::string& keyName,
193 const std::string& keyString,
196 unsigned long timeStamp,
197 const Integration::KeyEvent::State& keyState,
198 const std::string& deviceName = DEFAULT_DEVICE_NAME,
199 const DevelDevice::Class::Type& deviceClass = DevelDevice::Class::NONE,
200 const DevelDevice::Subclass::Type& deviceSubclass = DevelDevice::Subclass::NONE )
202 return Integration::KeyEvent( keyName,
214 * Helper to generate PanGestureEvent
216 * @param[in] application Application instance
217 * @param[in] state The Gesture State
218 * @param[in] pos The current position of touch.
220 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
224 if( (state == Gesture::Started) ||
225 (state == Gesture::Possible) )
231 application.ProcessEvent( GeneratePan( state, last, pos, 16 ) );
238 * Simulate time passed by.
240 * @note this will always process at least 1 frame (1/60 sec)
242 * @param application Test application instance
243 * @param duration Time to pass in milliseconds.
244 * @return The actual time passed in milliseconds
246 static int Wait(ToolkitTestApplication& application, int duration = 0)
250 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
252 application.SendNotification();
253 application.Render(RENDER_FRAME_INTERVAL);
254 time += RENDER_FRAME_INTERVAL;
260 Dali::Integration::Point GetPointDownInside( Vector2& pos )
262 Dali::Integration::Point point;
263 point.SetState( PointState::DOWN );
264 point.SetScreenPosition( pos );
268 Dali::Integration::Point GetPointUpInside( Vector2& pos )
270 Dali::Integration::Point point;
271 point.SetState( PointState::UP );
272 point.SetScreenPosition( pos );
276 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
278 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
280 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
282 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
284 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
285 if( NULL != valueSet )
287 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
289 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
295 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
304 class ScrollStateChangeCallback : public Dali::ConnectionTracker
307 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
308 : mStartedCalled( startedCalled ),
309 mFinishedCalled( finishedCalled )
313 void Callback( TextEditor editor, DevelTextEditor::Scroll::Type type )
315 if( type == DevelTextEditor::Scroll::STARTED )
317 mStartedCalled = true;
319 else if( type == DevelTextEditor::Scroll::FINISHED )
321 mFinishedCalled = true;
325 bool& mStartedCalled;
326 bool& mFinishedCalled;
331 int UtcDaliToolkitTextEditorConstructorP(void)
333 ToolkitTestApplication application;
334 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
335 TextEditor textEditor;
336 DALI_TEST_CHECK( !textEditor );
340 int UtcDaliToolkitTextEditorNewP(void)
342 ToolkitTestApplication application;
343 tet_infoline(" UtcDaliToolkitTextEditorNewP");
344 TextEditor textEditor = TextEditor::New();
345 DALI_TEST_CHECK( textEditor );
349 int UtcDaliToolkitTextEditorDownCastP(void)
351 ToolkitTestApplication application;
352 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
353 TextEditor textEditor1 = TextEditor::New();
354 BaseHandle object( textEditor1 );
356 TextEditor textEditor2 = TextEditor::DownCast( object );
357 DALI_TEST_CHECK( textEditor2 );
359 TextEditor textEditor3 = DownCast< TextEditor >( object );
360 DALI_TEST_CHECK( textEditor3 );
364 int UtcDaliToolkitTextEditorDownCastN(void)
366 ToolkitTestApplication application;
367 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
368 BaseHandle uninitializedObject;
369 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
370 DALI_TEST_CHECK( !textEditor1 );
372 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
373 DALI_TEST_CHECK( !textEditor2 );
377 int UtcDaliToolkitTextEditorCopyConstructorP(void)
379 ToolkitTestApplication application;
380 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
381 TextEditor textEditor = TextEditor::New();
382 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
384 TextEditor copy( textEditor );
385 DALI_TEST_CHECK( copy );
386 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
390 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
392 ToolkitTestApplication application;
393 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
394 TextEditor textEditor = TextEditor::New();
395 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
397 TextEditor copy = textEditor;
398 DALI_TEST_CHECK( copy );
399 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
403 int UtcDaliTextEditorNewP(void)
405 ToolkitTestApplication application;
406 tet_infoline(" UtcDaliToolkitTextEditorNewP");
407 TextEditor textEditor = TextEditor::New();
408 DALI_TEST_CHECK( textEditor );
412 // Positive test case for a method
413 int UtcDaliTextEditorGetPropertyP(void)
415 ToolkitTestApplication application;
416 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
417 TextEditor editor = TextEditor::New();
418 DALI_TEST_CHECK( editor );
420 // Check Property Indices are correct
421 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextEditor::Property::RENDERING_BACKEND );
422 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
423 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
424 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
425 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
426 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
427 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
428 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
429 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
430 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
431 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
432 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
433 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
434 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
435 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
436 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
437 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
438 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
439 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
440 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
441 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
442 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
443 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
444 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
445 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
446 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
447 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
448 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
449 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
450 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
452 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
453 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
454 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
455 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
456 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
457 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
458 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
459 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
460 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
461 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
462 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == DevelTextEditor::Property::SMOOTH_SCROLL );
463 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == DevelTextEditor::Property::SMOOTH_SCROLL_DURATION );
464 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == DevelTextEditor::Property::ENABLE_SCROLL_BAR );
465 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION );
466 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION );
467 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == DevelTextEditor::Property::PIXEL_SIZE );
468 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == DevelTextEditor::Property::LINE_COUNT );
469 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
470 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
471 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == DevelTextEditor::Property::ENABLE_SELECTION );
472 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == DevelTextEditor::Property::PLACEHOLDER );
477 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
480 Property::Map imageMap;
481 imageMap[mapKey] =mapValue;
483 editor.SetProperty( property , imageMap );
484 Property::Value propValue = editor.GetProperty( property );
485 Property::Map* resultMap = propValue.GetMap();
487 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
495 // Positive test case for a method
496 int UtcDaliTextEditorSetPropertyP(void)
498 ToolkitTestApplication application;
499 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
500 TextEditor editor = TextEditor::New();
501 DALI_TEST_CHECK( editor );
502 Stage::GetCurrent().Add( editor );
504 // Note - we can't check the defaults since the stylesheets are platform-specific
506 // Check the render backend property.
507 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
508 DALI_TEST_EQUALS( (Text::RenderingType)editor.GetProperty<int>( TextEditor::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
510 // Check text property.
511 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
512 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
514 // Check text's color property
515 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
516 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
518 // Check font properties.
519 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
520 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
522 Property::Map fontStyleMapSet;
523 Property::Map fontStyleMapGet;
524 Property::Value* slantValue = NULL;
526 fontStyleMapSet.Insert( "weight", "bold" );
527 fontStyleMapSet.Insert( "width", "condensed" );
528 fontStyleMapSet.Insert( "slant", "italic" );
530 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
531 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
532 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
533 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
535 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
536 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
539 fontStyleMapSet.Clear();
540 fontStyleMapSet.Insert( "weight", "normal" );
541 fontStyleMapSet.Insert( "slant", "oblique" );
542 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
543 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
544 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
545 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
547 fontStyleMapSet.Clear();
548 fontStyleMapSet.Insert( "slant", "roman" );
549 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
550 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
552 // Replace 'roman' for 'normal'.
553 slantValue = fontStyleMapGet.Find( "slant" );
554 if( NULL != slantValue )
556 if( "normal" == slantValue->Get<std::string>() )
558 fontStyleMapGet["slant"] = "roman";
561 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
562 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
564 fontStyleMapSet.Clear();
566 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
567 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
568 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
569 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
571 // Check that the Alignment properties can be correctly set
572 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
573 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
575 // Check scroll properties.
576 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
577 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
578 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
579 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
581 // Check cursor properties
582 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
583 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
584 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
585 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
587 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
588 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
589 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
590 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
591 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
592 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
593 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
594 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
596 // Check handle images
597 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
598 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
599 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
600 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
601 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
603 // Check handle images
604 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
605 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
606 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
607 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
608 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
609 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
611 // Check the highlight color
612 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
613 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
615 // Decoration bounding box
616 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
617 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
619 // Check the enable markup property.
620 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
621 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
622 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
624 // Check input color property.
625 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
626 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
628 // Check input font properties.
629 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
630 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
632 fontStyleMapSet.Clear();
633 fontStyleMapSet.Insert( "weight", "bold" );
634 fontStyleMapSet.Insert( "width", "condensed" );
635 fontStyleMapSet.Insert( "slant", "italic" );
637 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
638 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
639 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
640 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
642 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
643 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
645 // Reset input font style.
646 fontStyleMapSet.Clear();
647 fontStyleMapSet.Insert( "weight", "normal" );
648 fontStyleMapSet.Insert( "slant", "oblique" );
650 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
651 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
652 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
653 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
655 fontStyleMapSet.Clear();
656 fontStyleMapSet.Insert( "slant", "roman" );
658 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
659 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
661 // Replace 'roman' for 'normal'.
662 slantValue = fontStyleMapGet.Find( "slant" );
663 if( NULL != slantValue )
665 if( "normal" == slantValue->Get<std::string>() )
667 fontStyleMapGet["slant"] = "roman";
670 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
671 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
673 fontStyleMapSet.Clear();
675 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
676 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
677 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
678 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
680 // Check the line spacing property
681 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
682 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
683 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
685 // Check the input line spacing property
686 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
687 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
688 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
690 // Check the underline property
692 Property::Map underlineMapSet;
693 Property::Map underlineMapGet;
695 underlineMapSet.Insert( "enable", "true" );
696 underlineMapSet.Insert( "color", "red" );
697 underlineMapSet.Insert( "height", "1" );
699 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
701 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
702 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
703 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
705 // Check the input underline property
706 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
707 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
709 // Check the shadow property
710 Property::Map shadowMapSet;
711 Property::Map shadowMapGet;
713 shadowMapSet.Insert( "color", "green" );
714 shadowMapSet.Insert( "offset", "2 2" );
716 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
718 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
719 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
720 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
722 // Check the input shadow property
723 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
724 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
726 // Check the emboss property
727 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
728 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
730 // Check the input emboss property
731 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
732 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
734 // Check the outline property
735 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
736 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
738 // Check the input outline property
739 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
740 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
742 // Check the smooth scroll property
743 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
744 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
745 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
747 // Check the smooth scroll duration property
748 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
749 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
751 // Check the scroll bar property
752 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
753 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, true );
754 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
756 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
757 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
758 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
759 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
761 // Check the pixel size of font
762 editor.SetProperty( DevelTextEditor::Property::PIXEL_SIZE, 20.f );
763 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
765 // Check placeholder text properties.
766 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
767 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
769 // Check placeholder text's color property.
770 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
771 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
773 // Check the enable selection property
774 editor.SetProperty( DevelTextEditor::Property::ENABLE_SELECTION, false );
775 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
777 // Check the placeholder property with pixel size
778 Property::Map placeholderPixelSizeMapSet;
779 Property::Map placeholderPixelSizeMapGet;
780 Property::Map placeholderFontstyleMap;
781 placeholderPixelSizeMapSet["placeholderText"] = "Setting Placeholder Text";
782 placeholderPixelSizeMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused";
783 placeholderPixelSizeMapSet["placeholderColor"] = Color::BLUE;
784 placeholderPixelSizeMapSet["placeholderFontFamily"] = "Arial";
785 placeholderPixelSizeMapSet["placeholderPixelSize"] = 15.0f;
787 placeholderFontstyleMap.Insert( "weight", "bold" );
788 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
789 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
791 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
792 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
793 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
795 // Check the placeholder property with point size
796 Property::Map placeholderMapSet;
797 Property::Map placeholderMapGet;
798 placeholderMapSet["placeholderText"] = "Setting Placeholder Text";
799 placeholderMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused";
800 placeholderMapSet["placeholderColor"] = Color::RED;
801 placeholderMapSet["placeholderFontFamily"] = "Arial";
802 placeholderMapSet["placeholderPointSize"] = 12.0f;
804 // Check the placeholder font style property
805 placeholderFontstyleMap.Clear();
807 placeholderFontstyleMap.Insert( "weight", "bold" );
808 placeholderFontstyleMap.Insert( "width", "condensed" );
809 placeholderFontstyleMap.Insert( "slant", "italic" );
810 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
811 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderMapSet );
813 placeholderMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
814 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
815 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
818 placeholderFontstyleMap.Clear();
819 placeholderFontstyleMap.Insert( "weight", "normal" );
820 placeholderFontstyleMap.Insert( "slant", "oblique" );
821 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
822 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderMapSet );
824 placeholderMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
825 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
826 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
828 placeholderFontstyleMap.Clear();
829 placeholderFontstyleMap.Insert( "slant", "roman" );
830 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
831 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderMapSet );
833 placeholderMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
835 placeholderFontstyleMap.Clear();
836 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
838 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderMapSet );
839 placeholderMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
840 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
841 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
846 // Positive Atlas Text Renderer test
847 int utcDaliTextEditorAtlasRenderP(void)
849 ToolkitTestApplication application;
850 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
851 StyleManager styleManager = StyleManager::Get();
852 styleManager.ApplyDefaultTheme();
853 TextEditor editor = TextEditor::New();
854 DALI_TEST_CHECK( editor );
856 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
858 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
860 Stage::GetCurrent().Add( editor );
864 // Render some text with the shared atlas backend
865 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
866 application.SendNotification();
867 application.Render();
871 tet_result(TET_FAIL);
876 // Positive test for the textChanged signal.
877 int utcDaliTextEditorTextChangedP(void)
879 ToolkitTestApplication application;
880 tet_infoline(" utcDaliTextEditorTextChangedP");
881 TextEditor editor = TextEditor::New();
882 DALI_TEST_CHECK( editor );
884 Stage::GetCurrent().Add( editor );
886 // connect to the text changed signal.
887 ConnectionTracker* testTracker = new ConnectionTracker();
888 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
889 bool textChangedSignal = false;
890 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
892 gTextChangedCallBackCalled = false;
893 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
894 DALI_TEST_CHECK( gTextChangedCallBackCalled );
895 DALI_TEST_CHECK( textChangedSignal );
897 application.SendNotification();
899 editor.SetKeyInputFocus();
901 gTextChangedCallBackCalled = false;
902 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
903 DALI_TEST_CHECK( gTextChangedCallBackCalled );
908 int utcDaliTextEditorInputStyleChanged01(void)
910 ToolkitTestApplication application;
911 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
913 // The text-editor emits signals when the input style changes. These changes of style are
914 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
915 // can't be emitted during the size negotiation as the callbacks may update the UI.
916 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
917 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
918 application.CreateAdaptor();
922 char* pathNamePtr = get_current_dir_name();
923 const std::string pathName( pathNamePtr );
926 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
927 fontClient.SetDpi( 93u, 93u );
929 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
930 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
932 TextEditor editor = TextEditor::New();
933 DALI_TEST_CHECK( editor );
936 editor.SetSize( 300.f, 50.f );
937 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
938 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
940 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
941 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
943 // connect to the text changed signal.
944 ConnectionTracker* testTracker = new ConnectionTracker();
945 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
946 bool inputStyleChangedSignal = false;
947 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
949 Stage::GetCurrent().Add( editor );
952 application.SendNotification();
953 application.Render();
955 // Executes the idle callbacks added by the text control on the change of input style.
956 application.RunIdles();
958 gInputStyleChangedCallbackCalled = false;
959 gInputStyleMask = TextEditor::InputStyle::NONE;
960 inputStyleChangedSignal = false;
962 // Create a tap event to touch the text editor.
963 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
964 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
967 application.SendNotification();
968 application.Render();
970 // Executes the idle callbacks added by the text control on the change of input style.
971 application.RunIdles();
973 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
974 if( gInputStyleChangedCallbackCalled )
976 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
978 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
979 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
981 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
982 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
984 DALI_TEST_CHECK( inputStyleChangedSignal );
986 gInputStyleChangedCallbackCalled = false;
987 gInputStyleMask = TextEditor::InputStyle::NONE;
988 inputStyleChangedSignal = false;
990 // Create a tap event to touch the text editor.
991 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
992 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
995 application.SendNotification();
996 application.Render();
998 // Executes the idle callbacks added by the text control on the change of input style.
999 application.RunIdles();
1001 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1002 DALI_TEST_CHECK( !inputStyleChangedSignal );
1004 gInputStyleChangedCallbackCalled = false;
1005 gInputStyleMask = TextEditor::InputStyle::NONE;
1006 inputStyleChangedSignal = false;
1008 // Create a tap event to touch the text editor.
1009 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1010 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1012 // Render and notify
1013 application.SendNotification();
1014 application.Render();
1016 // Executes the idle callbacks added by the text control on the change of input style.
1017 application.RunIdles();
1019 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1020 if( gInputStyleChangedCallbackCalled )
1022 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1024 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1025 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1027 DALI_TEST_CHECK( inputStyleChangedSignal );
1029 gInputStyleChangedCallbackCalled = false;
1030 gInputStyleMask = TextEditor::InputStyle::NONE;
1031 inputStyleChangedSignal = false;
1033 // Create a tap event to touch the text editor.
1034 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1035 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1037 // Render and notify
1038 application.SendNotification();
1039 application.Render();
1041 // Executes the idle callbacks added by the text control on the change of input style.
1042 application.RunIdles();
1044 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1045 if( gInputStyleChangedCallbackCalled )
1047 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1049 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1050 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1052 Property::Map fontStyleMapSet;
1053 Property::Map fontStyleMapGet;
1055 fontStyleMapSet.Insert( "weight", "bold" );
1057 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1058 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1059 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1061 DALI_TEST_CHECK( inputStyleChangedSignal );
1063 gInputStyleChangedCallbackCalled = false;
1064 gInputStyleMask = TextEditor::InputStyle::NONE;
1065 inputStyleChangedSignal = false;
1067 // Create a tap event to touch the text editor.
1068 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1069 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1071 // Render and notify
1072 application.SendNotification();
1073 application.Render();
1075 // Executes the idle callbacks added by the text control on the change of input style.
1076 application.RunIdles();
1078 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1079 DALI_TEST_CHECK( !inputStyleChangedSignal );
1081 gInputStyleChangedCallbackCalled = false;
1082 gInputStyleMask = TextEditor::InputStyle::NONE;
1083 inputStyleChangedSignal = false;
1085 // Create a tap event to touch the text editor.
1086 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1087 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1089 // Render and notify
1090 application.SendNotification();
1091 application.Render();
1093 // Executes the idle callbacks added by the text control on the change of input style.
1094 application.RunIdles();
1096 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1097 if( gInputStyleChangedCallbackCalled )
1099 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1101 Property::Map fontStyleMapSet;
1102 Property::Map fontStyleMapGet;
1104 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1105 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1106 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1108 DALI_TEST_CHECK( inputStyleChangedSignal );
1110 gInputStyleChangedCallbackCalled = false;
1111 gInputStyleMask = TextEditor::InputStyle::NONE;
1112 inputStyleChangedSignal = false;
1114 // Create a tap event to touch the text editor.
1115 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1116 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1118 // Render and notify
1119 application.SendNotification();
1120 application.Render();
1122 // Executes the idle callbacks added by the text control on the change of input style.
1123 application.RunIdles();
1125 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1126 DALI_TEST_CHECK( !inputStyleChangedSignal );
1131 int utcDaliTextEditorInputStyleChanged02(void)
1133 ToolkitTestApplication application;
1134 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1136 // The text-editor emits signals when the input style changes. These changes of style are
1137 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1138 // can't be emitted during the size negotiation as the callbacks may update the UI.
1139 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1140 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1141 application.CreateAdaptor();
1145 char* pathNamePtr = get_current_dir_name();
1146 const std::string pathName( pathNamePtr );
1147 free( pathNamePtr );
1149 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1150 fontClient.SetDpi( 93u, 93u );
1152 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1153 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1155 TextEditor editor = TextEditor::New();
1156 DALI_TEST_CHECK( editor );
1159 editor.SetSize( 300.f, 50.f );
1160 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1161 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1163 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1164 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>" );
1166 // connect to the text changed signal.
1167 ConnectionTracker* testTracker = new ConnectionTracker();
1168 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1169 bool inputStyleChangedSignal = false;
1170 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1172 Stage::GetCurrent().Add( editor );
1174 // Render and notify
1175 application.SendNotification();
1176 application.Render();
1178 // Executes the idle callbacks added by the text control on the change of input style.
1179 application.RunIdles();
1181 gInputStyleChangedCallbackCalled = false;
1182 gInputStyleMask = TextEditor::InputStyle::NONE;
1183 inputStyleChangedSignal = false;
1185 // Create a tap event to touch the text editor.
1186 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1187 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1188 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1189 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1191 // Render and notify
1192 application.SendNotification();
1193 application.Render();
1195 // Executes the idle callbacks added by the text control on the change of input style.
1196 application.RunIdles();
1198 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1199 if( gInputStyleChangedCallbackCalled )
1201 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1202 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1203 TextEditor::InputStyle::POINT_SIZE |
1204 TextEditor::InputStyle::COLOR ),
1207 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1208 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1210 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1211 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1213 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1214 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1216 DALI_TEST_CHECK( inputStyleChangedSignal );
1218 gInputStyleChangedCallbackCalled = false;
1219 gInputStyleMask = TextEditor::InputStyle::NONE;
1220 inputStyleChangedSignal = false;
1222 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1224 // Render and notify
1225 application.SendNotification();
1226 application.Render();
1228 // Executes the idle callbacks added by the text control on the change of input style.
1229 application.RunIdles();
1231 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1232 if( gInputStyleChangedCallbackCalled )
1234 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1235 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1238 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1239 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1241 DALI_TEST_CHECK( inputStyleChangedSignal );
1243 gInputStyleChangedCallbackCalled = false;
1244 gInputStyleMask = TextEditor::InputStyle::NONE;
1245 inputStyleChangedSignal = false;
1247 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1249 // Render and notify
1250 application.SendNotification();
1251 application.Render();
1253 // Executes the idle callbacks added by the text control on the change of input style.
1254 application.RunIdles();
1256 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1257 DALI_TEST_CHECK( !inputStyleChangedSignal );
1259 gInputStyleChangedCallbackCalled = false;
1260 gInputStyleMask = TextEditor::InputStyle::NONE;
1261 inputStyleChangedSignal = false;
1263 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1265 // Render and notify
1266 application.SendNotification();
1267 application.Render();
1269 // Executes the idle callbacks added by the text control on the change of input style.
1270 application.RunIdles();
1272 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1273 if( gInputStyleChangedCallbackCalled )
1275 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1276 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1279 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1280 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1282 DALI_TEST_CHECK( inputStyleChangedSignal );
1284 gInputStyleChangedCallbackCalled = false;
1285 gInputStyleMask = TextEditor::InputStyle::NONE;
1286 inputStyleChangedSignal = false;
1288 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1290 Property::Map fontStyleMapSet;
1291 fontStyleMapSet.Insert( "weight", "thin" );
1292 fontStyleMapSet.Insert( "width", "condensed" );
1293 fontStyleMapSet.Insert( "slant", "italic" );
1295 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1296 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1297 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1299 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1300 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1301 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1302 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1304 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1306 // Render and notify
1307 application.SendNotification();
1308 application.Render();
1310 // Executes the idle callbacks added by the text control on the change of input style.
1311 application.RunIdles();
1313 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1314 DALI_TEST_CHECK( !inputStyleChangedSignal );
1316 // Create a tap event to touch the text editor.
1317 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1318 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1320 // Render and notify
1321 application.SendNotification();
1322 application.Render();
1324 // Executes the idle callbacks added by the text control on the change of input style.
1325 application.RunIdles();
1327 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1328 if( gInputStyleChangedCallbackCalled )
1330 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1331 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1332 TextEditor::InputStyle::POINT_SIZE |
1333 TextEditor::InputStyle::FONT_STYLE |
1334 TextEditor::InputStyle::LINE_SPACING |
1335 TextEditor::InputStyle::UNDERLINE |
1336 TextEditor::InputStyle::SHADOW |
1337 TextEditor::InputStyle::EMBOSS |
1338 TextEditor::InputStyle::OUTLINE ),
1341 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1342 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1344 DALI_TEST_CHECK( inputStyleChangedSignal );
1346 gInputStyleChangedCallbackCalled = false;
1347 gInputStyleMask = TextEditor::InputStyle::NONE;
1348 inputStyleChangedSignal = false;
1350 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1352 fontStyleMapSet.Clear();
1353 fontStyleMapSet.Insert( "weight", "black" );
1354 fontStyleMapSet.Insert( "width", "expanded" );
1355 fontStyleMapSet.Insert( "slant", "oblique" );
1357 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1359 // Create a tap event to touch the text editor.
1360 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1361 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1363 // Render and notify
1364 application.SendNotification();
1365 application.Render();
1367 // Executes the idle callbacks added by the text control on the change of input style.
1368 application.RunIdles();
1370 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1371 if( gInputStyleChangedCallbackCalled )
1373 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1374 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1375 TextEditor::InputStyle::POINT_SIZE |
1376 TextEditor::InputStyle::FONT_STYLE ),
1379 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1380 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1382 DALI_TEST_CHECK( inputStyleChangedSignal );
1387 int utcDaliTextEditorEvent01(void)
1389 ToolkitTestApplication application;
1390 tet_infoline(" utcDaliTextEditorEvent01");
1392 // Creates a tap event. After creating a tap event the text editor should
1393 // have the focus and add text with key events should be possible.
1395 TextEditor editor = TextEditor::New();
1396 DALI_TEST_CHECK( editor );
1398 Stage::GetCurrent().Add( editor );
1400 editor.SetSize( 300.f, 50.f );
1401 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1402 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1404 // Avoid a crash when core load gl resources.
1405 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1407 // Render and notify
1408 application.SendNotification();
1409 application.Render();
1411 // Add a key event but as the text editor has not the focus it should do nothing.
1412 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1414 // Render and notify
1415 application.SendNotification();
1416 application.Render();
1418 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1420 // Create a tap event to touch the text editor.
1421 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1422 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1424 // Render and notify
1425 application.SendNotification();
1426 application.Render();
1428 // Now the text editor has the focus, so it can handle the key events.
1429 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1430 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1432 // Render and notify
1433 application.SendNotification();
1434 application.Render();
1436 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1438 // Create a second text editor and send key events to it.
1439 TextEditor editor2 = TextEditor::New();
1441 editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1442 editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1443 editor2.SetSize( 100.f, 100.f );
1444 editor2.SetPosition( 100.f, 100.f );
1446 Stage::GetCurrent().Add( editor2 );
1448 // Render and notify
1449 application.SendNotification();
1450 application.Render();
1452 // Create a tap event on the second text editor.
1453 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1454 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1456 // Render and notify
1457 application.SendNotification();
1458 application.Render();
1460 // The second text editor has the focus. It should handle the key events.
1461 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1462 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1464 // Render and notify
1465 application.SendNotification();
1466 application.Render();
1468 // Check the text has been added to the second text editor.
1469 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1474 int utcDaliTextEditorEvent02(void)
1476 ToolkitTestApplication application;
1477 tet_infoline(" utcDaliTextEditorEvent02");
1479 // Checks if the right number of actors are created.
1481 TextEditor editor = TextEditor::New();
1482 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1483 DALI_TEST_CHECK( editor );
1485 Stage::GetCurrent().Add( editor );
1487 editor.SetSize( 300.f, 50.f );
1488 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1489 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1491 // Avoid a crash when core load gl resources.
1492 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1494 // Render and notify
1495 application.SendNotification();
1496 application.Render();
1498 // Check there are the expected number of children (the stencil).
1499 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1501 Actor stencil = editor.GetChildAt( 0u );
1503 // Create a tap event to touch the text editor.
1504 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1505 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1507 // Render and notify
1508 application.SendNotification();
1509 application.Render();
1511 Actor layer = editor.GetChildAt( 1u );
1512 DALI_TEST_CHECK( layer.IsLayer() );
1514 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1515 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1517 // Now the text editor has the focus, so it can handle the key events.
1518 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1519 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1521 // Render and notify
1522 application.SendNotification();
1523 application.Render();
1525 // Checks the cursor and the renderer have been created.
1526 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1527 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1529 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1530 DALI_TEST_CHECK( cursor );
1532 // The stencil actor has a container with all the actors which contain the text renderers.
1533 Actor container = stencil.GetChildAt( 0u );
1534 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1536 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1537 DALI_TEST_CHECK( renderer );
1540 // Move the cursor and check the position changes.
1541 Vector3 position1 = cursor.GetCurrentPosition();
1543 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1544 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1546 // Render and notify
1547 application.SendNotification();
1548 application.Render();
1550 Vector3 position2 = cursor.GetCurrentPosition();
1552 DALI_TEST_CHECK( position2.x < position1.x );
1554 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1555 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1557 // Render and notify
1558 application.SendNotification();
1559 application.Render();
1561 Vector3 position3 = cursor.GetCurrentPosition();
1563 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1565 // Send some taps and check the cursor positions.
1567 // Try to tap at the beginning.
1568 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1569 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1571 // Render and notify
1572 application.SendNotification();
1573 application.Render();
1575 // Cursor position should be the same than position1.
1576 Vector3 position4 = cursor.GetCurrentPosition();
1578 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1580 // Tap away from the start position.
1581 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1582 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1584 // Render and notify
1585 application.SendNotification();
1586 application.Render();
1588 Vector3 position5 = cursor.GetCurrentPosition();
1590 DALI_TEST_CHECK( position5.x > position4.x );
1592 // Remove all the text.
1593 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1594 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1595 editor.SetProperty( TextEditor::Property::TEXT, "" );
1597 // Render and notify
1598 application.SendNotification();
1599 application.Render();
1601 // Cursor position should be the same than position2.
1602 Vector3 position6 = cursor.GetCurrentPosition();
1604 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1606 // Should not be a renderer.
1607 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1612 int utcDaliTextEditorEvent03(void)
1614 ToolkitTestApplication application;
1615 tet_infoline(" utcDaliTextEditorEvent03");
1617 // Checks if the highlight actor is created.
1619 TextEditor editor = TextEditor::New();
1620 DALI_TEST_CHECK( editor );
1622 Stage::GetCurrent().Add( editor );
1624 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1625 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1626 editor.SetSize( 30.f, 50.f );
1627 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1628 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1630 // Avoid a crash when core load gl resources.
1631 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1633 // Render and notify
1634 application.SendNotification();
1635 application.Render();
1637 // Send some taps and check text controller with clipboard window
1638 Dali::Clipboard clipboard = Clipboard::Get();
1639 clipboard.ShowClipboard();
1640 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1641 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1642 clipboard.HideClipboard();
1644 // Render and notify
1645 application.SendNotification();
1646 application.Render();
1648 // Tap first to get the focus.
1649 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1650 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1652 // Render and notify
1653 application.SendNotification();
1654 application.Render();
1656 // Double tap to select a word.
1657 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1658 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1660 // Render and notify
1661 application.SendNotification();
1662 application.Render();
1664 // The stencil actor should have two actors: the renderer and the highlight actor.
1665 Actor stencil = editor.GetChildAt( 0u );
1667 // Highlight needs to be drawn before text, so should come first in child order
1668 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1669 DALI_TEST_CHECK( highlight );
1671 // The stencil actor has a container with all the actors which contain the text renderers.
1672 Actor container = stencil.GetChildAt( 1u );
1673 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1675 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1676 DALI_TEST_CHECK( renderer );
1679 // Double tap out of bounds
1680 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1681 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1683 // Render and notify
1684 application.SendNotification();
1685 application.Render();
1687 // The stencil actor should have one actors: the renderer actor.
1688 stencil = editor.GetChildAt( 0u );
1690 // The stencil actor has a container with all the actors which contain the text renderers.
1691 container = stencil.GetChildAt( 0u );
1692 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1694 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1695 DALI_TEST_CHECK( renderer );
1701 int utcDaliTextEditorEvent04(void)
1703 ToolkitTestApplication application;
1704 tet_infoline(" utcDaliTextEditorEvent04");
1706 // Checks if the highlight actor is created.
1708 TextEditor editor = TextEditor::New();
1709 DALI_TEST_CHECK( editor );
1711 Stage::GetCurrent().Add( editor );
1713 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1714 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1715 editor.SetSize( 100.f, 50.f );
1716 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1717 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1719 // Avoid a crash when core load gl resources.
1720 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1722 // Render and notify
1723 application.SendNotification();
1724 application.Render();
1726 // Tap on the text editor
1727 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1728 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1730 // Render and notify
1731 application.SendNotification();
1732 application.Render();
1734 // Move at the end of the text.
1735 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1736 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1738 // Render and notify
1739 application.SendNotification();
1740 application.Render();
1742 for( unsigned int index = 0u; index < 10u; ++index )
1744 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1745 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1747 // Render and notify
1748 application.SendNotification();
1749 application.Render();
1753 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1755 // Render and notify
1756 application.SendNotification();
1757 application.Render();
1759 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1761 // Add some key events
1762 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1763 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1765 // Render and notify
1766 application.SendNotification();
1767 application.Render();
1769 for( unsigned int index = 0u; index < 10u; ++index )
1771 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1772 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1774 // Render and notify
1775 application.SendNotification();
1776 application.Render();
1780 application.ProcessEvent( GenerateKey( " ", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1782 // Render and notify
1783 application.SendNotification();
1784 application.Render();
1786 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1791 int utcDaliTextEditorEvent05(void)
1793 ToolkitTestApplication application;
1794 tet_infoline(" utcDaliTextEditorEvent05");
1796 // Checks if the highlight actor is created.
1798 TextEditor editor = TextEditor::New();
1799 DALI_TEST_CHECK( editor );
1801 Stage::GetCurrent().Add( editor );
1803 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1804 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1805 editor.SetSize( 50.f, 50.f );
1806 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1807 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1808 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
1809 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1810 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, true );
1811 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1812 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1814 // Avoid a crash when core load gl resources.
1815 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1817 // Render and notify
1818 application.SendNotification();
1819 application.Render();
1821 // Tap on the text editor
1822 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1823 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1825 // Render and notify
1826 application.SendNotification();
1827 application.Render();
1829 // Move at the end of the text.
1830 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1831 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1833 // Render and notify
1834 application.SendNotification();
1835 application.Render();
1837 for( unsigned int index = 0u; index < 10u; ++index )
1840 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1842 // Render and notify
1843 application.SendNotification();
1844 application.Render();
1846 // Modify duration after scroll is enabled
1847 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1849 // Continuous scroll left to increase coverage
1850 for( unsigned int index = 0u; index < 10u; ++index )
1852 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1854 // Render and notify
1855 application.SendNotification();
1856 application.Render();
1858 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1859 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1860 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1861 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1862 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1864 // Press Escape to increase coverage
1865 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1866 application.SendNotification();
1867 application.Render();
1869 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1874 int utcDaliTextEditorEvent06(void)
1876 ToolkitTestApplication application;
1877 tet_infoline(" utcDaliTextEditorEvent06");
1879 // Checks if the highlight actor is created.
1881 TextEditor editor = TextEditor::New();
1882 DALI_TEST_CHECK( editor );
1884 Stage::GetCurrent().Add( editor );
1886 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
1887 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1888 editor.SetSize( 100.f, 50.f );
1889 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1890 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1892 // Avoid a crash when core load gl resources.
1893 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1895 // Render and notify
1896 application.SendNotification();
1897 application.Render();
1899 // Tap on the text editor
1900 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1901 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1903 // Render and notify
1904 application.SendNotification();
1905 application.Render();
1907 // Move to seconds line of the text.
1908 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1910 // Render and notify
1911 application.SendNotification();
1912 application.Render();
1914 float layoutHeight = editor.GetHeightForWidth( 100.f );
1917 // Add another script characters ( glyph height is defferent )
1918 application.ProcessEvent( GenerateKey( "d", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1919 application.ProcessEvent( GenerateKey( "d", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1921 // Delete characters
1922 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1923 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1925 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
1927 // Render and notify
1928 application.SendNotification();
1929 application.Render();
1931 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1934 application.ProcessEvent( GenerateKey( "", "", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1935 application.SendNotification();
1936 application.Render();
1938 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1939 application.SendNotification();
1940 application.Render();
1942 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1943 application.SendNotification();
1944 application.Render();
1946 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1947 application.SendNotification();
1948 application.Render();
1953 int utcDaliTextEditorHandles(void)
1955 ToolkitTestApplication application;
1956 tet_infoline(" utcDaliTextEditorHandles");
1958 TextEditor editor = TextEditor::New();
1959 DALI_TEST_CHECK( editor );
1961 Stage::GetCurrent().Add( editor );
1963 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1964 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1965 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
1966 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
1968 editor.SetSize( 30.f, 500.f );
1969 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1970 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1972 // Avoid a crash when core load gl resources.
1973 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1975 // Render and notify
1976 application.SendNotification();
1977 application.Render();
1979 // Tap first to get the focus.
1980 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1981 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1983 // Render and notify
1984 application.SendNotification();
1985 application.Render();
1987 // Tap to create the grab handle.
1988 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1989 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1991 // Render and notify
1992 application.SendNotification();
1993 application.Render();
1995 // Get the active layer where the text's decoration is added.
1996 Actor activeLayer = editor.GetChildAt( 1u );
1998 // Get the handle's actor.
1999 Actor handle = activeLayer.GetChildAt( 1u );
2000 handle.SetSize( 100.f, 100.f );
2002 // Render and notify
2003 application.SendNotification();
2004 application.Render();
2006 // Touch the grab handle to set it as pressed.
2007 Vector2 touchPos( 10.0f, 50.0f );
2008 Dali::Integration::TouchEvent event;
2009 event = Dali::Integration::TouchEvent();
2010 event.AddPoint( GetPointDownInside( touchPos ) );
2011 application.ProcessEvent( event );
2013 // Render and notify
2014 application.SendNotification();
2015 application.Render();
2017 // drag grab handle right
2018 SendPan(application, Gesture::Possible, touchPos);
2019 SendPan(application, Gesture::Started, touchPos);
2021 Wait(application, 100);
2023 for(int i = 0;i<20;i++)
2025 SendPan(application, Gesture::Continuing, touchPos);
2030 SendPan(application, Gesture::Finished, touchPos);
2033 // Release the grab handle.
2034 event = Dali::Integration::TouchEvent();
2035 event.AddPoint( GetPointUpInside( touchPos ) );
2036 application.ProcessEvent( event );
2038 // Render and notify
2039 application.SendNotification();
2040 application.Render();
2046 int utcDaliTextEditorUnderPropertyStringP(void)
2048 ToolkitTestApplication application;
2049 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2050 TextEditor editor = TextEditor::New();
2051 DALI_TEST_CHECK( editor );
2053 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2055 Stage::GetCurrent().Add( editor );
2057 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2058 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2060 tet_infoline("Set underline settings with a map");
2061 // Check the input underline property
2062 Property::Map underlineMapSet;
2063 Property::Map underlineMapGet;
2064 underlineMapSet.Insert( "enable", "true" );
2065 underlineMapSet.Insert( "color", "blue" );
2066 underlineMapSet.Insert( "height", "2" );
2068 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2069 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2070 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2071 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2073 tet_infoline("Set underline settings with a string");
2074 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2075 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2078 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2080 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2081 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2082 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2083 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2085 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2090 int utcDaliTextEditorShadowPropertyStringP(void)
2092 ToolkitTestApplication application;
2093 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2095 TextEditor editor = TextEditor::New();
2097 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\"}" );
2099 Stage::GetCurrent().Add( editor );
2101 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\"}" );
2103 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2107 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2112 int utcDaliTextEditorFontStylePropertyStringP(void)
2114 ToolkitTestApplication application;
2115 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2117 TextEditor editor = TextEditor::New();
2119 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2121 Stage::GetCurrent().Add( editor );
2123 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2125 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2129 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2134 int utcDaliTextEditorGetPropertyLinecountP(void)
2136 ToolkitTestApplication application;
2138 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2142 TextEditor editor = TextEditor::New();
2143 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2144 editor.SetProperty( TextEditor::Property::TEXT,
2145 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2147 Stage::GetCurrent().Add( editor );
2149 editor.SetSize( 100.0f, 100.0f );
2150 lineCount = editor.GetProperty<int>( DevelTextEditor::Property::LINE_COUNT );
2151 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2153 editor.SetSize( 50.0f, 100.0f );
2154 lineCount = editor.GetProperty<int>( DevelTextEditor::Property::LINE_COUNT );
2155 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2160 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2163 ToolkitTestApplication application;
2164 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2166 TextEditor editor = TextEditor::New();
2167 DALI_TEST_CHECK( editor );
2169 Stage::GetCurrent().Add( editor );
2171 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2172 editor.SetSize( 50.f, 50.f );
2173 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2174 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2175 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, true );
2176 editor.SetKeyboardFocusable(true);
2178 bool startedCalled = false;
2179 bool finishedCalled = false;
2181 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2182 DevelTextEditor::ScrollStateChangedSignal( editor ).Connect( &callback, &ScrollStateChangeCallback::Callback );
2184 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2186 // Render and notify
2187 application.SendNotification();
2188 application.Render();
2190 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2191 application.SendNotification();
2192 application.Render(6000);
2194 application.SendNotification();
2195 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2196 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2200 int UtcDaliToolkitTextEditorTextWarpMode(void)
2202 ToolkitTestApplication application;
2203 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2207 TextEditor editor = TextEditor::New();
2208 editor.SetSize( 150.0f, 300.f );
2209 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2211 Stage::GetCurrent().Add( editor );
2213 editor.SetProperty( DevelTextEditor::Property::LINE_WRAP_MODE, "WORD" );
2215 application.SendNotification();
2216 application.Render();
2218 lineCount = editor.GetProperty<int>( DevelTextEditor::Property::LINE_COUNT );
2219 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2223 editor.SetProperty( DevelTextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2225 application.SendNotification();
2226 application.Render();
2229 lineCount = editor.GetProperty<int>( DevelTextEditor::Property::LINE_COUNT );
2230 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );