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/control-devel.h>
30 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
33 using namespace Toolkit;
35 void dali_texteditor_startup(void)
37 test_return_value = TET_UNDEF;
40 void dali_texteditor_cleanup(void)
42 test_return_value = TET_PASS;
48 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
49 const char* const PROPERTY_NAME_TEXT = "text";
50 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
51 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
52 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
53 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
54 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
55 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
56 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
57 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
58 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
59 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
60 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
61 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
62 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
63 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
64 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
65 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
66 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
71 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
72 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
73 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
74 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
75 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
76 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
77 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
79 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
80 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
81 const char* const PROPERTY_NAME_UNDERLINE = "underline";
82 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
83 const char* const PROPERTY_NAME_SHADOW = "shadow";
84 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
85 const char* const PROPERTY_NAME_EMBOSS = "emboss";
86 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
87 const char* const PROPERTY_NAME_OUTLINE = "outline";
88 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
90 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
91 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
92 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
93 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
94 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
95 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
96 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
97 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
98 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
99 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
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,
199 const DevelKeyEvent::DeviceClass::Type& deviceClass )
201 return Integration::KeyEvent( keyName,
212 * Helper to generate PanGestureEvent
214 * @param[in] application Application instance
215 * @param[in] state The Gesture State
216 * @param[in] pos The current position of touch.
218 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
222 if( (state == Gesture::Started) ||
223 (state == Gesture::Possible) )
229 application.ProcessEvent( GeneratePan( state, last, pos, 16 ) );
236 * Simulate time passed by.
238 * @note this will always process at least 1 frame (1/60 sec)
240 * @param application Test application instance
241 * @param duration Time to pass in milliseconds.
242 * @return The actual time passed in milliseconds
244 static int Wait(ToolkitTestApplication& application, int duration = 0)
248 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
250 application.SendNotification();
251 application.Render(RENDER_FRAME_INTERVAL);
252 time += RENDER_FRAME_INTERVAL;
258 Dali::Integration::Point GetPointDownInside( Vector2& pos )
260 Dali::Integration::Point point;
261 point.SetState( PointState::DOWN );
262 point.SetScreenPosition( pos );
266 Dali::Integration::Point GetPointUpInside( Vector2& pos )
268 Dali::Integration::Point point;
269 point.SetState( PointState::UP );
270 point.SetScreenPosition( pos );
274 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
276 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
278 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
280 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
282 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
283 if( NULL != valueSet )
285 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
287 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
293 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
302 class ScrollStateChangeCallback : public Dali::ConnectionTracker
305 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
306 : mStartedCalled( startedCalled ),
307 mFinishedCalled( finishedCalled )
311 void Callback( TextEditor editor, DevelTextEditor::Scroll::Type type )
313 if( type == DevelTextEditor::Scroll::STARTED )
315 mStartedCalled = true;
317 else if( type == DevelTextEditor::Scroll::FINISHED )
319 mFinishedCalled = true;
323 bool& mStartedCalled;
324 bool& mFinishedCalled;
329 int UtcDaliToolkitTextEditorConstructorP(void)
331 ToolkitTestApplication application;
332 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
333 TextEditor textEditor;
334 DALI_TEST_CHECK( !textEditor );
338 int UtcDaliToolkitTextEditorNewP(void)
340 ToolkitTestApplication application;
341 tet_infoline(" UtcDaliToolkitTextEditorNewP");
342 TextEditor textEditor = TextEditor::New();
343 DALI_TEST_CHECK( textEditor );
347 int UtcDaliToolkitTextEditorDownCastP(void)
349 ToolkitTestApplication application;
350 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
351 TextEditor textEditor1 = TextEditor::New();
352 BaseHandle object( textEditor1 );
354 TextEditor textEditor2 = TextEditor::DownCast( object );
355 DALI_TEST_CHECK( textEditor2 );
357 TextEditor textEditor3 = DownCast< TextEditor >( object );
358 DALI_TEST_CHECK( textEditor3 );
362 int UtcDaliToolkitTextEditorDownCastN(void)
364 ToolkitTestApplication application;
365 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
366 BaseHandle uninitializedObject;
367 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
368 DALI_TEST_CHECK( !textEditor1 );
370 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
371 DALI_TEST_CHECK( !textEditor2 );
375 int UtcDaliToolkitTextEditorCopyConstructorP(void)
377 ToolkitTestApplication application;
378 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
379 TextEditor textEditor = TextEditor::New();
380 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
382 TextEditor copy( textEditor );
383 DALI_TEST_CHECK( copy );
384 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
388 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
390 ToolkitTestApplication application;
391 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
392 TextEditor textEditor = TextEditor::New();
393 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
395 TextEditor copy = textEditor;
396 DALI_TEST_CHECK( copy );
397 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
401 int UtcDaliTextEditorNewP(void)
403 ToolkitTestApplication application;
404 tet_infoline(" UtcDaliToolkitTextEditorNewP");
405 TextEditor textEditor = TextEditor::New();
406 DALI_TEST_CHECK( textEditor );
410 // Positive test case for a method
411 int UtcDaliTextEditorGetPropertyP(void)
413 ToolkitTestApplication application;
414 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
415 TextEditor editor = TextEditor::New();
416 DALI_TEST_CHECK( editor );
418 // Check Property Indices are correct
419 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextEditor::Property::RENDERING_BACKEND );
420 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
421 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
422 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
423 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
424 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
425 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
426 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
427 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
428 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
429 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
430 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
431 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
432 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
433 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
434 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
435 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
436 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
437 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
438 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
439 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
440 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
441 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
442 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
443 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
444 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
445 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
446 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
447 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
448 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
450 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
451 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
452 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
453 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
454 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
455 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
456 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
457 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
458 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
459 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
460 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == DevelTextEditor::Property::SMOOTH_SCROLL );
461 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == DevelTextEditor::Property::SMOOTH_SCROLL_DURATION );
462 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == DevelTextEditor::Property::ENABLE_SCROLL_BAR );
463 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION );
464 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION );
465 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == DevelTextEditor::Property::PIXEL_SIZE );
466 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == DevelTextEditor::Property::LINE_COUNT );
467 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
468 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
469 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == DevelTextEditor::Property::ENABLE_SELECTION );
474 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
477 Property::Map imageMap;
478 imageMap[mapKey] =mapValue;
480 editor.SetProperty( property , imageMap );
481 Property::Value propValue = editor.GetProperty( property );
482 Property::Map* resultMap = propValue.GetMap();
484 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
492 // Positive test case for a method
493 int UtcDaliTextEditorSetPropertyP(void)
495 ToolkitTestApplication application;
496 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
497 TextEditor editor = TextEditor::New();
498 DALI_TEST_CHECK( editor );
499 Stage::GetCurrent().Add( editor );
501 // Note - we can't check the defaults since the stylesheets are platform-specific
503 // Check the render backend property.
504 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
505 DALI_TEST_EQUALS( (Text::RenderingType)editor.GetProperty<int>( TextEditor::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
507 // Check text property.
508 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
509 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
511 // Check text's color property
512 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
513 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
515 // Check font properties.
516 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
517 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
519 Property::Map fontStyleMapSet;
520 Property::Map fontStyleMapGet;
521 Property::Value* slantValue = NULL;
523 fontStyleMapSet.Insert( "weight", "bold" );
524 fontStyleMapSet.Insert( "width", "condensed" );
525 fontStyleMapSet.Insert( "slant", "italic" );
527 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
528 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
529 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
530 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
532 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
533 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
536 fontStyleMapSet.Clear();
537 fontStyleMapSet.Insert( "weight", "normal" );
538 fontStyleMapSet.Insert( "slant", "oblique" );
539 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
540 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
541 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
542 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
544 fontStyleMapSet.Clear();
545 fontStyleMapSet.Insert( "slant", "roman" );
546 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
547 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
549 // Replace 'roman' for 'normal'.
550 slantValue = fontStyleMapGet.Find( "slant" );
551 if( NULL != slantValue )
553 if( "normal" == slantValue->Get<std::string>() )
555 fontStyleMapGet["slant"] = "roman";
558 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
559 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
561 fontStyleMapSet.Clear();
563 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
564 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
565 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
566 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
568 // Check that the Alignment properties can be correctly set
569 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
570 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
572 // Check scroll properties.
573 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
574 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
575 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
576 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
578 // Check cursor properties
579 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
580 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
581 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
582 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
584 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
585 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
586 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
587 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
588 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
589 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
590 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
591 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
593 // Check handle images
594 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
595 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
596 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
597 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
598 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
600 // Check handle images
601 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
602 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
603 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
604 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
605 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
606 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
608 // Check the highlight color
609 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
610 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
612 // Decoration bounding box
613 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
614 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
616 // Check the enable markup property.
617 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
618 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
619 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
621 // Check input color property.
622 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
623 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
625 // Check input font properties.
626 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
627 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
629 fontStyleMapSet.Clear();
630 fontStyleMapSet.Insert( "weight", "bold" );
631 fontStyleMapSet.Insert( "width", "condensed" );
632 fontStyleMapSet.Insert( "slant", "italic" );
634 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
635 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
636 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
637 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
639 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
640 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
642 // Reset input font style.
643 fontStyleMapSet.Clear();
644 fontStyleMapSet.Insert( "weight", "normal" );
645 fontStyleMapSet.Insert( "slant", "oblique" );
647 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
648 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
649 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
650 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
652 fontStyleMapSet.Clear();
653 fontStyleMapSet.Insert( "slant", "roman" );
655 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
656 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
658 // Replace 'roman' for 'normal'.
659 slantValue = fontStyleMapGet.Find( "slant" );
660 if( NULL != slantValue )
662 if( "normal" == slantValue->Get<std::string>() )
664 fontStyleMapGet["slant"] = "roman";
667 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
668 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
670 fontStyleMapSet.Clear();
672 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
673 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
674 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
675 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
677 // Check the line spacing property
678 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
679 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
680 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
682 // Check the input line spacing property
683 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
684 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
685 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
687 // Check the underline property
689 Property::Map underlineMapSet;
690 Property::Map underlineMapGet;
692 underlineMapSet.Insert( "enable", "true" );
693 underlineMapSet.Insert( "color", "red" );
694 underlineMapSet.Insert( "height", "1" );
696 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
698 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
699 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
700 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
702 // Check the input underline property
703 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
704 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
706 // Check the shadow property
707 Property::Map shadowMapSet;
708 Property::Map shadowMapGet;
710 shadowMapSet.Insert( "color", "green" );
711 shadowMapSet.Insert( "offset", "2 2" );
713 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
715 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
716 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
717 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
719 // Check the input shadow property
720 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
721 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
723 // Check the emboss property
724 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
725 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
727 // Check the input emboss property
728 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
729 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
731 // Check the outline property
732 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
733 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
735 // Check the input outline property
736 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
737 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
739 // Check the smooth scroll property
740 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
741 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
742 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
744 // Check the smooth scroll duration property
745 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
746 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
748 // Check the scroll bar property
749 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
750 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, true );
751 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
753 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
754 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
755 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
756 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
758 // Check the pixel size of font
759 editor.SetProperty( DevelTextEditor::Property::PIXEL_SIZE, 20.f );
760 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
762 // Check placeholder text properties.
763 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
764 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
766 // Check placeholder text properties when focused.
767 editor.SetProperty( DevelControl::Property::STATE, "FOCUSED" );
768 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Focused Placeholder Text" );
769 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelControl::Property::STATE ), (int)DevelControl::FOCUSED, TEST_LOCATION );
770 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Focused Placeholder Text"), TEST_LOCATION );
772 // Check placeholder text's color property.
773 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
774 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
776 editor.SetProperty( DevelTextEditor::Property::ENABLE_SELECTION, false );
777 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
782 // Positive Atlas Text Renderer test
783 int utcDaliTextEditorAtlasRenderP(void)
785 ToolkitTestApplication application;
786 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
787 StyleManager styleManager = StyleManager::Get();
788 styleManager.ApplyDefaultTheme();
789 TextEditor editor = TextEditor::New();
790 DALI_TEST_CHECK( editor );
792 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
794 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
796 Stage::GetCurrent().Add( editor );
800 // Render some text with the shared atlas backend
801 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
802 application.SendNotification();
803 application.Render();
807 tet_result(TET_FAIL);
812 // Positive test for the textChanged signal.
813 int utcDaliTextEditorTextChangedP(void)
815 ToolkitTestApplication application;
816 tet_infoline(" utcDaliTextEditorTextChangedP");
817 TextEditor editor = TextEditor::New();
818 DALI_TEST_CHECK( editor );
820 Stage::GetCurrent().Add( editor );
822 // connect to the text changed signal.
823 ConnectionTracker* testTracker = new ConnectionTracker();
824 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
825 bool textChangedSignal = false;
826 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
828 gTextChangedCallBackCalled = false;
829 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
830 DALI_TEST_CHECK( gTextChangedCallBackCalled );
831 DALI_TEST_CHECK( textChangedSignal );
833 application.SendNotification();
835 editor.SetKeyInputFocus();
837 gTextChangedCallBackCalled = false;
838 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
839 DALI_TEST_CHECK( gTextChangedCallBackCalled );
844 int utcDaliTextEditorInputStyleChanged01(void)
846 ToolkitTestApplication application;
847 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
849 // The text-editor emits signals when the input style changes. These changes of style are
850 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
851 // can't be emitted during the size negotiation as the callbacks may update the UI.
852 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
853 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
854 application.CreateAdaptor();
858 char* pathNamePtr = get_current_dir_name();
859 const std::string pathName( pathNamePtr );
862 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
863 fontClient.SetDpi( 93u, 93u );
865 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
866 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
868 TextEditor editor = TextEditor::New();
869 DALI_TEST_CHECK( editor );
872 editor.SetSize( 300.f, 50.f );
873 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
874 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
876 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
877 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
879 // connect to the text changed signal.
880 ConnectionTracker* testTracker = new ConnectionTracker();
881 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
882 bool inputStyleChangedSignal = false;
883 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
885 Stage::GetCurrent().Add( editor );
888 application.SendNotification();
889 application.Render();
891 // Executes the idle callbacks added by the text control on the change of input style.
892 application.RunIdles();
894 gInputStyleChangedCallbackCalled = false;
895 gInputStyleMask = TextEditor::InputStyle::NONE;
896 inputStyleChangedSignal = false;
898 // Create a tap event to touch the text editor.
899 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
900 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
903 application.SendNotification();
904 application.Render();
906 // Executes the idle callbacks added by the text control on the change of input style.
907 application.RunIdles();
909 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
910 if( gInputStyleChangedCallbackCalled )
912 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
914 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
915 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
917 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
918 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
920 DALI_TEST_CHECK( inputStyleChangedSignal );
922 gInputStyleChangedCallbackCalled = false;
923 gInputStyleMask = TextEditor::InputStyle::NONE;
924 inputStyleChangedSignal = false;
926 // Create a tap event to touch the text editor.
927 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
928 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
931 application.SendNotification();
932 application.Render();
934 // Executes the idle callbacks added by the text control on the change of input style.
935 application.RunIdles();
937 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
938 DALI_TEST_CHECK( !inputStyleChangedSignal );
940 gInputStyleChangedCallbackCalled = false;
941 gInputStyleMask = TextEditor::InputStyle::NONE;
942 inputStyleChangedSignal = false;
944 // Create a tap event to touch the text editor.
945 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
946 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
949 application.SendNotification();
950 application.Render();
952 // Executes the idle callbacks added by the text control on the change of input style.
953 application.RunIdles();
955 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
956 if( gInputStyleChangedCallbackCalled )
958 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
960 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
961 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
963 DALI_TEST_CHECK( inputStyleChangedSignal );
965 gInputStyleChangedCallbackCalled = false;
966 gInputStyleMask = TextEditor::InputStyle::NONE;
967 inputStyleChangedSignal = false;
969 // Create a tap event to touch the text editor.
970 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
971 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
974 application.SendNotification();
975 application.Render();
977 // Executes the idle callbacks added by the text control on the change of input style.
978 application.RunIdles();
980 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
981 if( gInputStyleChangedCallbackCalled )
983 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
985 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
986 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
988 Property::Map fontStyleMapSet;
989 Property::Map fontStyleMapGet;
991 fontStyleMapSet.Insert( "weight", "bold" );
993 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
994 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
995 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
997 DALI_TEST_CHECK( inputStyleChangedSignal );
999 gInputStyleChangedCallbackCalled = false;
1000 gInputStyleMask = TextEditor::InputStyle::NONE;
1001 inputStyleChangedSignal = false;
1003 // Create a tap event to touch the text editor.
1004 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1005 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1007 // Render and notify
1008 application.SendNotification();
1009 application.Render();
1011 // Executes the idle callbacks added by the text control on the change of input style.
1012 application.RunIdles();
1014 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1015 DALI_TEST_CHECK( !inputStyleChangedSignal );
1017 gInputStyleChangedCallbackCalled = false;
1018 gInputStyleMask = TextEditor::InputStyle::NONE;
1019 inputStyleChangedSignal = false;
1021 // Create a tap event to touch the text editor.
1022 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1023 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1025 // Render and notify
1026 application.SendNotification();
1027 application.Render();
1029 // Executes the idle callbacks added by the text control on the change of input style.
1030 application.RunIdles();
1032 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1033 if( gInputStyleChangedCallbackCalled )
1035 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1037 Property::Map fontStyleMapSet;
1038 Property::Map fontStyleMapGet;
1040 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1041 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1042 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1044 DALI_TEST_CHECK( inputStyleChangedSignal );
1046 gInputStyleChangedCallbackCalled = false;
1047 gInputStyleMask = TextEditor::InputStyle::NONE;
1048 inputStyleChangedSignal = false;
1050 // Create a tap event to touch the text editor.
1051 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1052 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1054 // Render and notify
1055 application.SendNotification();
1056 application.Render();
1058 // Executes the idle callbacks added by the text control on the change of input style.
1059 application.RunIdles();
1061 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1062 DALI_TEST_CHECK( !inputStyleChangedSignal );
1067 int utcDaliTextEditorInputStyleChanged02(void)
1069 ToolkitTestApplication application;
1070 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1072 // The text-editor emits signals when the input style changes. These changes of style are
1073 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1074 // can't be emitted during the size negotiation as the callbacks may update the UI.
1075 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1076 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1077 application.CreateAdaptor();
1081 char* pathNamePtr = get_current_dir_name();
1082 const std::string pathName( pathNamePtr );
1083 free( pathNamePtr );
1085 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1086 fontClient.SetDpi( 93u, 93u );
1088 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1089 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1091 TextEditor editor = TextEditor::New();
1092 DALI_TEST_CHECK( editor );
1095 editor.SetSize( 300.f, 50.f );
1096 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1097 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1099 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1100 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>" );
1102 // connect to the text changed signal.
1103 ConnectionTracker* testTracker = new ConnectionTracker();
1104 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1105 bool inputStyleChangedSignal = false;
1106 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1108 Stage::GetCurrent().Add( editor );
1110 // Render and notify
1111 application.SendNotification();
1112 application.Render();
1114 // Executes the idle callbacks added by the text control on the change of input style.
1115 application.RunIdles();
1117 gInputStyleChangedCallbackCalled = false;
1118 gInputStyleMask = TextEditor::InputStyle::NONE;
1119 inputStyleChangedSignal = false;
1121 // Create a tap event to touch the text editor.
1122 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1123 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1124 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1125 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1127 // Render and notify
1128 application.SendNotification();
1129 application.Render();
1131 // Executes the idle callbacks added by the text control on the change of input style.
1132 application.RunIdles();
1134 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1135 if( gInputStyleChangedCallbackCalled )
1137 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1138 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1139 TextEditor::InputStyle::POINT_SIZE |
1140 TextEditor::InputStyle::COLOR ),
1143 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1144 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1146 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1147 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1149 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1150 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1152 DALI_TEST_CHECK( inputStyleChangedSignal );
1154 gInputStyleChangedCallbackCalled = false;
1155 gInputStyleMask = TextEditor::InputStyle::NONE;
1156 inputStyleChangedSignal = false;
1158 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1160 // Render and notify
1161 application.SendNotification();
1162 application.Render();
1164 // Executes the idle callbacks added by the text control on the change of input style.
1165 application.RunIdles();
1167 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1168 if( gInputStyleChangedCallbackCalled )
1170 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1171 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1174 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1175 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1177 DALI_TEST_CHECK( inputStyleChangedSignal );
1179 gInputStyleChangedCallbackCalled = false;
1180 gInputStyleMask = TextEditor::InputStyle::NONE;
1181 inputStyleChangedSignal = false;
1183 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1185 // Render and notify
1186 application.SendNotification();
1187 application.Render();
1189 // Executes the idle callbacks added by the text control on the change of input style.
1190 application.RunIdles();
1192 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1193 DALI_TEST_CHECK( !inputStyleChangedSignal );
1195 gInputStyleChangedCallbackCalled = false;
1196 gInputStyleMask = TextEditor::InputStyle::NONE;
1197 inputStyleChangedSignal = false;
1199 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1201 // Render and notify
1202 application.SendNotification();
1203 application.Render();
1205 // Executes the idle callbacks added by the text control on the change of input style.
1206 application.RunIdles();
1208 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1209 if( gInputStyleChangedCallbackCalled )
1211 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1212 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1215 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1216 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1218 DALI_TEST_CHECK( inputStyleChangedSignal );
1220 gInputStyleChangedCallbackCalled = false;
1221 gInputStyleMask = TextEditor::InputStyle::NONE;
1222 inputStyleChangedSignal = false;
1224 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1226 Property::Map fontStyleMapSet;
1227 fontStyleMapSet.Insert( "weight", "thin" );
1228 fontStyleMapSet.Insert( "width", "condensed" );
1229 fontStyleMapSet.Insert( "slant", "italic" );
1231 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1232 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1233 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1235 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1236 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1237 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1238 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1240 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1242 // Render and notify
1243 application.SendNotification();
1244 application.Render();
1246 // Executes the idle callbacks added by the text control on the change of input style.
1247 application.RunIdles();
1249 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1250 DALI_TEST_CHECK( !inputStyleChangedSignal );
1252 // Create a tap event to touch the text editor.
1253 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1254 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1256 // Render and notify
1257 application.SendNotification();
1258 application.Render();
1260 // Executes the idle callbacks added by the text control on the change of input style.
1261 application.RunIdles();
1263 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1264 if( gInputStyleChangedCallbackCalled )
1266 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1267 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1268 TextEditor::InputStyle::POINT_SIZE |
1269 TextEditor::InputStyle::FONT_STYLE |
1270 TextEditor::InputStyle::LINE_SPACING |
1271 TextEditor::InputStyle::UNDERLINE |
1272 TextEditor::InputStyle::SHADOW |
1273 TextEditor::InputStyle::EMBOSS |
1274 TextEditor::InputStyle::OUTLINE ),
1277 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1278 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1280 DALI_TEST_CHECK( inputStyleChangedSignal );
1282 gInputStyleChangedCallbackCalled = false;
1283 gInputStyleMask = TextEditor::InputStyle::NONE;
1284 inputStyleChangedSignal = false;
1286 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1288 fontStyleMapSet.Clear();
1289 fontStyleMapSet.Insert( "weight", "black" );
1290 fontStyleMapSet.Insert( "width", "expanded" );
1291 fontStyleMapSet.Insert( "slant", "oblique" );
1293 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1295 // Create a tap event to touch the text editor.
1296 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1297 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1299 // Render and notify
1300 application.SendNotification();
1301 application.Render();
1303 // Executes the idle callbacks added by the text control on the change of input style.
1304 application.RunIdles();
1306 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1307 if( gInputStyleChangedCallbackCalled )
1309 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1310 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1311 TextEditor::InputStyle::POINT_SIZE |
1312 TextEditor::InputStyle::FONT_STYLE ),
1315 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1316 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1318 DALI_TEST_CHECK( inputStyleChangedSignal );
1323 int utcDaliTextEditorEvent01(void)
1325 ToolkitTestApplication application;
1326 tet_infoline(" utcDaliTextEditorEvent01");
1328 // Creates a tap event. After creating a tap event the text editor should
1329 // have the focus and add text with key events should be possible.
1331 TextEditor editor = TextEditor::New();
1332 DALI_TEST_CHECK( editor );
1334 Stage::GetCurrent().Add( editor );
1336 editor.SetSize( 300.f, 50.f );
1337 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1338 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1340 // Avoid a crash when core load gl resources.
1341 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1343 // Render and notify
1344 application.SendNotification();
1345 application.Render();
1347 // Add a key event but as the text editor has not the focus it should do nothing.
1348 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1350 // Render and notify
1351 application.SendNotification();
1352 application.Render();
1354 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1356 // Create a tap event to touch the text editor.
1357 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1358 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1360 // Render and notify
1361 application.SendNotification();
1362 application.Render();
1364 // Now the text editor has the focus, so it can handle the key events.
1365 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1366 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1368 // Render and notify
1369 application.SendNotification();
1370 application.Render();
1372 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1374 // Create a second text editor and send key events to it.
1375 TextEditor editor2 = TextEditor::New();
1377 editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1378 editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1379 editor2.SetSize( 100.f, 100.f );
1380 editor2.SetPosition( 100.f, 100.f );
1382 Stage::GetCurrent().Add( editor2 );
1384 // Render and notify
1385 application.SendNotification();
1386 application.Render();
1388 // Create a tap event on the second text editor.
1389 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1390 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1392 // Render and notify
1393 application.SendNotification();
1394 application.Render();
1396 // The second text editor has the focus. It should handle the key events.
1397 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1398 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1400 // Render and notify
1401 application.SendNotification();
1402 application.Render();
1404 // Check the text has been added to the second text editor.
1405 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1410 int utcDaliTextEditorEvent02(void)
1412 ToolkitTestApplication application;
1413 tet_infoline(" utcDaliTextEditorEvent02");
1415 // Checks if the right number of actors are created.
1417 TextEditor editor = TextEditor::New();
1418 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1419 DALI_TEST_CHECK( editor );
1421 Stage::GetCurrent().Add( editor );
1423 editor.SetSize( 300.f, 50.f );
1424 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1425 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1427 // Avoid a crash when core load gl resources.
1428 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1430 // Render and notify
1431 application.SendNotification();
1432 application.Render();
1434 // Check there are the expected number of children (the stencil).
1435 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1437 Actor stencil = editor.GetChildAt( 0u );
1439 // Create a tap event to touch the text editor.
1440 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1441 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1443 // Render and notify
1444 application.SendNotification();
1445 application.Render();
1447 Actor layer = editor.GetChildAt( 1u );
1448 DALI_TEST_CHECK( layer.IsLayer() );
1450 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1451 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1453 // Now the text editor has the focus, so it can handle the key events.
1454 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1455 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1457 // Render and notify
1458 application.SendNotification();
1459 application.Render();
1461 // Checks the cursor and the renderer have been created.
1462 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1463 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1465 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1466 DALI_TEST_CHECK( cursor );
1468 // The stencil actor has a container with all the actors which contain the text renderers.
1469 Actor container = stencil.GetChildAt( 0u );
1470 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1472 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1473 DALI_TEST_CHECK( renderer );
1476 // Move the cursor and check the position changes.
1477 Vector3 position1 = cursor.GetCurrentPosition();
1479 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1480 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1482 // Render and notify
1483 application.SendNotification();
1484 application.Render();
1486 Vector3 position2 = cursor.GetCurrentPosition();
1488 DALI_TEST_CHECK( position2.x < position1.x );
1490 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1491 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1493 // Render and notify
1494 application.SendNotification();
1495 application.Render();
1497 Vector3 position3 = cursor.GetCurrentPosition();
1499 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1501 // Send some taps and check the cursor positions.
1503 // Try to tap at the beginning.
1504 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1505 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1507 // Render and notify
1508 application.SendNotification();
1509 application.Render();
1511 // Cursor position should be the same than position1.
1512 Vector3 position4 = cursor.GetCurrentPosition();
1514 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1516 // Tap away from the start position.
1517 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1518 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1520 // Render and notify
1521 application.SendNotification();
1522 application.Render();
1524 Vector3 position5 = cursor.GetCurrentPosition();
1526 DALI_TEST_CHECK( position5.x > position4.x );
1528 // Remove all the text.
1529 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1530 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1531 editor.SetProperty( TextEditor::Property::TEXT, "" );
1533 // Render and notify
1534 application.SendNotification();
1535 application.Render();
1537 // Cursor position should be the same than position2.
1538 Vector3 position6 = cursor.GetCurrentPosition();
1540 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1542 // Should not be a renderer.
1543 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1548 int utcDaliTextEditorEvent03(void)
1550 ToolkitTestApplication application;
1551 tet_infoline(" utcDaliTextEditorEvent03");
1553 // Checks if the highlight actor is created.
1555 TextEditor editor = TextEditor::New();
1556 DALI_TEST_CHECK( editor );
1558 Stage::GetCurrent().Add( editor );
1560 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1561 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1562 editor.SetSize( 30.f, 50.f );
1563 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1564 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1566 // Avoid a crash when core load gl resources.
1567 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1569 // Render and notify
1570 application.SendNotification();
1571 application.Render();
1573 // Send some taps and check text controller with clipboard window
1574 Dali::Clipboard clipboard = Clipboard::Get();
1575 clipboard.ShowClipboard();
1576 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1577 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1578 clipboard.HideClipboard();
1580 // Render and notify
1581 application.SendNotification();
1582 application.Render();
1584 // Tap first to get the focus.
1585 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1586 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1588 // Render and notify
1589 application.SendNotification();
1590 application.Render();
1592 // Double tap to select a word.
1593 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1594 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1596 // Render and notify
1597 application.SendNotification();
1598 application.Render();
1600 // The stencil actor should have two actors: the renderer and the highlight actor.
1601 Actor stencil = editor.GetChildAt( 0u );
1603 // Highlight needs to be drawn before text, so should come first in child order
1604 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1605 DALI_TEST_CHECK( highlight );
1607 // The stencil actor has a container with all the actors which contain the text renderers.
1608 Actor container = stencil.GetChildAt( 1u );
1609 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1611 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1612 DALI_TEST_CHECK( renderer );
1615 // Double tap out of bounds
1616 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1617 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1619 // Render and notify
1620 application.SendNotification();
1621 application.Render();
1623 // The stencil actor should have one actors: the renderer actor.
1624 stencil = editor.GetChildAt( 0u );
1626 // The stencil actor has a container with all the actors which contain the text renderers.
1627 container = stencil.GetChildAt( 0u );
1628 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1630 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1631 DALI_TEST_CHECK( renderer );
1637 int utcDaliTextEditorEvent04(void)
1639 ToolkitTestApplication application;
1640 tet_infoline(" utcDaliTextEditorEvent04");
1642 // Checks if the highlight actor is created.
1644 TextEditor editor = TextEditor::New();
1645 DALI_TEST_CHECK( editor );
1647 Stage::GetCurrent().Add( editor );
1649 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1650 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1651 editor.SetSize( 100.f, 50.f );
1652 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1653 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1655 // Avoid a crash when core load gl resources.
1656 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1658 // Render and notify
1659 application.SendNotification();
1660 application.Render();
1662 // Tap on the text editor
1663 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1664 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1666 // Render and notify
1667 application.SendNotification();
1668 application.Render();
1670 // Move at the end of the text.
1671 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1672 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1674 // Render and notify
1675 application.SendNotification();
1676 application.Render();
1678 for( unsigned int index = 0u; index < 10u; ++index )
1680 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1681 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1683 // Render and notify
1684 application.SendNotification();
1685 application.Render();
1689 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1691 // Render and notify
1692 application.SendNotification();
1693 application.Render();
1695 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1697 // Add some key events
1698 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1699 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1701 // Render and notify
1702 application.SendNotification();
1703 application.Render();
1705 for( unsigned int index = 0u; index < 10u; ++index )
1707 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1708 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1710 // Render and notify
1711 application.SendNotification();
1712 application.Render();
1716 application.ProcessEvent( GenerateKey( " ", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1718 // Render and notify
1719 application.SendNotification();
1720 application.Render();
1722 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1727 int utcDaliTextEditorEvent05(void)
1729 ToolkitTestApplication application;
1730 tet_infoline(" utcDaliTextEditorEvent05");
1732 // Checks if the highlight actor is created.
1734 TextEditor editor = TextEditor::New();
1735 DALI_TEST_CHECK( editor );
1737 Stage::GetCurrent().Add( editor );
1739 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1740 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1741 editor.SetSize( 50.f, 50.f );
1742 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1743 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1744 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
1745 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1746 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, true );
1747 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1748 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1750 // Avoid a crash when core load gl resources.
1751 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1753 // Render and notify
1754 application.SendNotification();
1755 application.Render();
1757 // Tap on the text editor
1758 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1759 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1761 // Render and notify
1762 application.SendNotification();
1763 application.Render();
1765 // Move at the end of the text.
1766 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1767 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1769 // Render and notify
1770 application.SendNotification();
1771 application.Render();
1773 for( unsigned int index = 0u; index < 10u; ++index )
1776 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1778 // Render and notify
1779 application.SendNotification();
1780 application.Render();
1782 // Modify duration after scroll is enabled
1783 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1785 // Continuous scroll left to increase coverage
1786 for( unsigned int index = 0u; index < 10u; ++index )
1788 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1790 // Render and notify
1791 application.SendNotification();
1792 application.Render();
1794 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1795 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1796 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1797 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1798 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1800 // Press Escape to increase coverage
1801 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1802 application.SendNotification();
1803 application.Render();
1805 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1810 int utcDaliTextEditorEvent06(void)
1812 ToolkitTestApplication application;
1813 tet_infoline(" utcDaliTextEditorEvent06");
1815 // Checks if the highlight actor is created.
1817 TextEditor editor = TextEditor::New();
1818 DALI_TEST_CHECK( editor );
1820 Stage::GetCurrent().Add( editor );
1822 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
1823 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1824 editor.SetSize( 100.f, 50.f );
1825 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1826 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1828 // Avoid a crash when core load gl resources.
1829 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1831 // Render and notify
1832 application.SendNotification();
1833 application.Render();
1835 // Tap on the text editor
1836 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1837 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1839 // Render and notify
1840 application.SendNotification();
1841 application.Render();
1843 // Move to seconds line of the text.
1844 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1846 // Render and notify
1847 application.SendNotification();
1848 application.Render();
1850 float layoutHeight = editor.GetHeightForWidth( 100.f );
1853 // Add another script characters ( glyph height is defferent )
1854 application.ProcessEvent( GenerateKey( "d", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1855 application.ProcessEvent( GenerateKey( "d", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1857 // Delete characters
1858 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1859 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1861 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
1863 // Render and notify
1864 application.SendNotification();
1865 application.Render();
1867 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1874 int utcDaliTextEditorHandles(void)
1876 ToolkitTestApplication application;
1877 tet_infoline(" utcDaliTextEditorHandles");
1879 TextEditor editor = TextEditor::New();
1880 DALI_TEST_CHECK( editor );
1882 Stage::GetCurrent().Add( editor );
1884 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1885 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1886 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
1887 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
1889 editor.SetSize( 30.f, 500.f );
1890 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1891 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1893 // Avoid a crash when core load gl resources.
1894 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1896 // Render and notify
1897 application.SendNotification();
1898 application.Render();
1900 // Tap first to get the focus.
1901 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1902 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1904 // Render and notify
1905 application.SendNotification();
1906 application.Render();
1908 // Tap to create the grab handle.
1909 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1910 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1912 // Render and notify
1913 application.SendNotification();
1914 application.Render();
1916 // Get the active layer where the text's decoration is added.
1917 Actor activeLayer = editor.GetChildAt( 1u );
1919 // Get the handle's actor.
1920 Actor handle = activeLayer.GetChildAt( 1u );
1921 handle.SetSize( 100.f, 100.f );
1923 // Render and notify
1924 application.SendNotification();
1925 application.Render();
1927 // Touch the grab handle to set it as pressed.
1928 Vector2 touchPos( 10.0f, 50.0f );
1929 Dali::Integration::TouchEvent event;
1930 event = Dali::Integration::TouchEvent();
1931 event.AddPoint( GetPointDownInside( touchPos ) );
1932 application.ProcessEvent( event );
1934 // Render and notify
1935 application.SendNotification();
1936 application.Render();
1938 // drag grab handle right
1939 SendPan(application, Gesture::Possible, touchPos);
1940 SendPan(application, Gesture::Started, touchPos);
1942 Wait(application, 100);
1944 for(int i = 0;i<20;i++)
1946 SendPan(application, Gesture::Continuing, touchPos);
1951 SendPan(application, Gesture::Finished, touchPos);
1954 // Release the grab handle.
1955 event = Dali::Integration::TouchEvent();
1956 event.AddPoint( GetPointUpInside( touchPos ) );
1957 application.ProcessEvent( event );
1959 // Render and notify
1960 application.SendNotification();
1961 application.Render();
1967 int utcDaliTextEditorUnderPropertyStringP(void)
1969 ToolkitTestApplication application;
1970 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
1971 TextEditor editor = TextEditor::New();
1972 DALI_TEST_CHECK( editor );
1974 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
1976 Stage::GetCurrent().Add( editor );
1978 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
1979 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
1981 tet_infoline("Set underline settings with a map");
1982 // Check the input underline property
1983 Property::Map underlineMapSet;
1984 Property::Map underlineMapGet;
1985 underlineMapSet.Insert( "enable", "true" );
1986 underlineMapSet.Insert( "color", "blue" );
1987 underlineMapSet.Insert( "height", "2" );
1989 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
1990 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
1991 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
1992 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
1994 tet_infoline("Set underline settings with a string");
1995 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
1996 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
1999 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2001 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2002 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2003 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2004 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2006 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2011 int utcDaliTextEditorShadowPropertyStringP(void)
2013 ToolkitTestApplication application;
2014 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2016 TextEditor editor = TextEditor::New();
2018 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\"}" );
2020 Stage::GetCurrent().Add( editor );
2022 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\"}" );
2024 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2028 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2033 int utcDaliTextEditorFontStylePropertyStringP(void)
2035 ToolkitTestApplication application;
2036 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2038 TextEditor editor = TextEditor::New();
2040 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2042 Stage::GetCurrent().Add( editor );
2044 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2046 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2050 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2055 int utcDaliTextEditorGetPropertyLinecountP(void)
2057 ToolkitTestApplication application;
2059 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2063 TextEditor editor = TextEditor::New();
2064 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2065 editor.SetProperty( TextEditor::Property::TEXT,
2066 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2068 Stage::GetCurrent().Add( editor );
2070 editor.SetSize( 100.0f, 100.0f );
2071 lineCount = editor.GetProperty<int>( DevelTextEditor::Property::LINE_COUNT );
2072 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2074 editor.SetSize( 50.0f, 100.0f );
2075 lineCount = editor.GetProperty<int>( DevelTextEditor::Property::LINE_COUNT );
2076 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2081 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2084 ToolkitTestApplication application;
2085 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2087 TextEditor editor = TextEditor::New();
2088 DALI_TEST_CHECK( editor );
2090 Stage::GetCurrent().Add( editor );
2092 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2093 editor.SetSize( 50.f, 50.f );
2094 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2095 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2096 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, true );
2097 editor.SetKeyboardFocusable(true);
2099 bool startedCalled = false;
2100 bool finishedCalled = false;
2102 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2103 DevelTextEditor::ScrollStateChangedSignal( editor ).Connect( &callback, &ScrollStateChangeCallback::Callback );
2105 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2107 // Render and notify
2108 application.SendNotification();
2109 application.Render();
2111 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2112 application.SendNotification();
2113 application.Render(6000);
2115 application.SendNotification();
2116 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2117 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );