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 Property::Map outlineMapSet;
736 Property::Map outlineMapGet;
738 outlineMapSet["color"] = Color::RED;
739 outlineMapSet["width"] = 2.0f;
741 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
743 outlineMapSet["color"] = "red";
744 outlineMapSet["width"] = "2";
745 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
746 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
747 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
749 // Check the input outline property
750 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
751 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
753 // Check the smooth scroll property
754 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
755 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
756 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
758 // Check the smooth scroll duration property
759 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
760 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
762 // Check the scroll bar property
763 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
764 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, true );
765 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
767 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
768 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
769 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
770 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
772 // Check the pixel size of font
773 editor.SetProperty( DevelTextEditor::Property::PIXEL_SIZE, 20.f );
774 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
776 // Check placeholder text properties.
777 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
778 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
780 // Check placeholder text's color property.
781 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
782 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
784 // Check the enable selection property
785 editor.SetProperty( DevelTextEditor::Property::ENABLE_SELECTION, false );
786 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
788 // Check the placeholder property with pixel size
789 Property::Map placeholderPixelSizeMapSet;
790 Property::Map placeholderPixelSizeMapGet;
791 Property::Map placeholderFontstyleMap;
792 placeholderPixelSizeMapSet["placeholderText"] = "Setting Placeholder Text";
793 placeholderPixelSizeMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused";
794 placeholderPixelSizeMapSet["placeholderColor"] = Color::BLUE;
795 placeholderPixelSizeMapSet["placeholderFontFamily"] = "Arial";
796 placeholderPixelSizeMapSet["placeholderPixelSize"] = 15.0f;
798 placeholderFontstyleMap.Insert( "weight", "bold" );
799 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
800 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
802 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
803 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
804 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
806 // Check the placeholder property with point size
807 Property::Map placeholderMapSet;
808 Property::Map placeholderMapGet;
809 placeholderMapSet["placeholderText"] = "Setting Placeholder Text";
810 placeholderMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused";
811 placeholderMapSet["placeholderColor"] = Color::RED;
812 placeholderMapSet["placeholderFontFamily"] = "Arial";
813 placeholderMapSet["placeholderPointSize"] = 12.0f;
815 // Check the placeholder font style property
816 placeholderFontstyleMap.Clear();
818 placeholderFontstyleMap.Insert( "weight", "bold" );
819 placeholderFontstyleMap.Insert( "width", "condensed" );
820 placeholderFontstyleMap.Insert( "slant", "italic" );
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 );
829 placeholderFontstyleMap.Clear();
830 placeholderFontstyleMap.Insert( "weight", "normal" );
831 placeholderFontstyleMap.Insert( "slant", "oblique" );
832 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
833 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderMapSet );
835 placeholderMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
836 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
837 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
839 placeholderFontstyleMap.Clear();
840 placeholderFontstyleMap.Insert( "slant", "roman" );
841 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
842 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderMapSet );
844 placeholderMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
846 placeholderFontstyleMap.Clear();
847 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
849 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderMapSet );
850 placeholderMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
851 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
852 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
857 // Positive Atlas Text Renderer test
858 int utcDaliTextEditorAtlasRenderP(void)
860 ToolkitTestApplication application;
861 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
862 StyleManager styleManager = StyleManager::Get();
863 styleManager.ApplyDefaultTheme();
864 TextEditor editor = TextEditor::New();
865 DALI_TEST_CHECK( editor );
867 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
869 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
871 Stage::GetCurrent().Add( editor );
875 // Render some text with the shared atlas backend
876 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
877 application.SendNotification();
878 application.Render();
882 tet_result(TET_FAIL);
887 // Positive test for the textChanged signal.
888 int utcDaliTextEditorTextChangedP(void)
890 ToolkitTestApplication application;
891 tet_infoline(" utcDaliTextEditorTextChangedP");
892 TextEditor editor = TextEditor::New();
893 DALI_TEST_CHECK( editor );
895 Stage::GetCurrent().Add( editor );
897 // connect to the text changed signal.
898 ConnectionTracker* testTracker = new ConnectionTracker();
899 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
900 bool textChangedSignal = false;
901 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
903 gTextChangedCallBackCalled = false;
904 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
905 DALI_TEST_CHECK( gTextChangedCallBackCalled );
906 DALI_TEST_CHECK( textChangedSignal );
908 application.SendNotification();
910 editor.SetKeyInputFocus();
912 gTextChangedCallBackCalled = false;
913 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
914 DALI_TEST_CHECK( gTextChangedCallBackCalled );
919 int utcDaliTextEditorInputStyleChanged01(void)
921 ToolkitTestApplication application;
922 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
924 // The text-editor emits signals when the input style changes. These changes of style are
925 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
926 // can't be emitted during the size negotiation as the callbacks may update the UI.
927 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
928 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
929 application.CreateAdaptor();
933 char* pathNamePtr = get_current_dir_name();
934 const std::string pathName( pathNamePtr );
937 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
938 fontClient.SetDpi( 93u, 93u );
940 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
941 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
943 TextEditor editor = TextEditor::New();
944 DALI_TEST_CHECK( editor );
947 editor.SetSize( 300.f, 50.f );
948 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
949 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
951 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
952 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
954 // connect to the text changed signal.
955 ConnectionTracker* testTracker = new ConnectionTracker();
956 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
957 bool inputStyleChangedSignal = false;
958 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
960 Stage::GetCurrent().Add( editor );
963 application.SendNotification();
964 application.Render();
966 // Executes the idle callbacks added by the text control on the change of input style.
967 application.RunIdles();
969 gInputStyleChangedCallbackCalled = false;
970 gInputStyleMask = TextEditor::InputStyle::NONE;
971 inputStyleChangedSignal = false;
973 // Create a tap event to touch the text editor.
974 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
975 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
978 application.SendNotification();
979 application.Render();
981 // Executes the idle callbacks added by the text control on the change of input style.
982 application.RunIdles();
984 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
985 if( gInputStyleChangedCallbackCalled )
987 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
989 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
990 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
992 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
993 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
995 DALI_TEST_CHECK( inputStyleChangedSignal );
997 gInputStyleChangedCallbackCalled = false;
998 gInputStyleMask = TextEditor::InputStyle::NONE;
999 inputStyleChangedSignal = false;
1001 // Create a tap event to touch the text editor.
1002 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1003 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1005 // Render and notify
1006 application.SendNotification();
1007 application.Render();
1009 // Executes the idle callbacks added by the text control on the change of input style.
1010 application.RunIdles();
1012 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1013 DALI_TEST_CHECK( !inputStyleChangedSignal );
1015 gInputStyleChangedCallbackCalled = false;
1016 gInputStyleMask = TextEditor::InputStyle::NONE;
1017 inputStyleChangedSignal = false;
1019 // Create a tap event to touch the text editor.
1020 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1021 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1023 // Render and notify
1024 application.SendNotification();
1025 application.Render();
1027 // Executes the idle callbacks added by the text control on the change of input style.
1028 application.RunIdles();
1030 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1031 if( gInputStyleChangedCallbackCalled )
1033 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1035 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1036 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1038 DALI_TEST_CHECK( inputStyleChangedSignal );
1040 gInputStyleChangedCallbackCalled = false;
1041 gInputStyleMask = TextEditor::InputStyle::NONE;
1042 inputStyleChangedSignal = false;
1044 // Create a tap event to touch the text editor.
1045 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1046 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1048 // Render and notify
1049 application.SendNotification();
1050 application.Render();
1052 // Executes the idle callbacks added by the text control on the change of input style.
1053 application.RunIdles();
1055 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1056 if( gInputStyleChangedCallbackCalled )
1058 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1060 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1061 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1063 Property::Map fontStyleMapSet;
1064 Property::Map fontStyleMapGet;
1066 fontStyleMapSet.Insert( "weight", "bold" );
1068 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1069 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1070 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1072 DALI_TEST_CHECK( inputStyleChangedSignal );
1074 gInputStyleChangedCallbackCalled = false;
1075 gInputStyleMask = TextEditor::InputStyle::NONE;
1076 inputStyleChangedSignal = false;
1078 // Create a tap event to touch the text editor.
1079 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1080 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1082 // Render and notify
1083 application.SendNotification();
1084 application.Render();
1086 // Executes the idle callbacks added by the text control on the change of input style.
1087 application.RunIdles();
1089 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1090 DALI_TEST_CHECK( !inputStyleChangedSignal );
1092 gInputStyleChangedCallbackCalled = false;
1093 gInputStyleMask = TextEditor::InputStyle::NONE;
1094 inputStyleChangedSignal = false;
1096 // Create a tap event to touch the text editor.
1097 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1098 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1100 // Render and notify
1101 application.SendNotification();
1102 application.Render();
1104 // Executes the idle callbacks added by the text control on the change of input style.
1105 application.RunIdles();
1107 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1108 if( gInputStyleChangedCallbackCalled )
1110 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1112 Property::Map fontStyleMapSet;
1113 Property::Map fontStyleMapGet;
1115 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1116 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1117 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1119 DALI_TEST_CHECK( inputStyleChangedSignal );
1121 gInputStyleChangedCallbackCalled = false;
1122 gInputStyleMask = TextEditor::InputStyle::NONE;
1123 inputStyleChangedSignal = false;
1125 // Create a tap event to touch the text editor.
1126 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1127 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1129 // Render and notify
1130 application.SendNotification();
1131 application.Render();
1133 // Executes the idle callbacks added by the text control on the change of input style.
1134 application.RunIdles();
1136 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1137 DALI_TEST_CHECK( !inputStyleChangedSignal );
1142 int utcDaliTextEditorInputStyleChanged02(void)
1144 ToolkitTestApplication application;
1145 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1147 // The text-editor emits signals when the input style changes. These changes of style are
1148 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1149 // can't be emitted during the size negotiation as the callbacks may update the UI.
1150 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1151 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1152 application.CreateAdaptor();
1156 char* pathNamePtr = get_current_dir_name();
1157 const std::string pathName( pathNamePtr );
1158 free( pathNamePtr );
1160 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1161 fontClient.SetDpi( 93u, 93u );
1163 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1164 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1166 TextEditor editor = TextEditor::New();
1167 DALI_TEST_CHECK( editor );
1170 editor.SetSize( 300.f, 50.f );
1171 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1172 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1174 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1175 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>" );
1177 // connect to the text changed signal.
1178 ConnectionTracker* testTracker = new ConnectionTracker();
1179 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1180 bool inputStyleChangedSignal = false;
1181 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1183 Stage::GetCurrent().Add( editor );
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 gInputStyleChangedCallbackCalled = false;
1193 gInputStyleMask = TextEditor::InputStyle::NONE;
1194 inputStyleChangedSignal = false;
1196 // Create a tap event to touch the text editor.
1197 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1198 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1199 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1200 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1202 // Render and notify
1203 application.SendNotification();
1204 application.Render();
1206 // Executes the idle callbacks added by the text control on the change of input style.
1207 application.RunIdles();
1209 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1210 if( gInputStyleChangedCallbackCalled )
1212 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1213 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1214 TextEditor::InputStyle::POINT_SIZE |
1215 TextEditor::InputStyle::COLOR ),
1218 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1219 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1221 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1222 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1224 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1225 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1227 DALI_TEST_CHECK( inputStyleChangedSignal );
1229 gInputStyleChangedCallbackCalled = false;
1230 gInputStyleMask = TextEditor::InputStyle::NONE;
1231 inputStyleChangedSignal = false;
1233 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1235 // Render and notify
1236 application.SendNotification();
1237 application.Render();
1239 // Executes the idle callbacks added by the text control on the change of input style.
1240 application.RunIdles();
1242 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1243 if( gInputStyleChangedCallbackCalled )
1245 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1246 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1249 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1250 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1252 DALI_TEST_CHECK( inputStyleChangedSignal );
1254 gInputStyleChangedCallbackCalled = false;
1255 gInputStyleMask = TextEditor::InputStyle::NONE;
1256 inputStyleChangedSignal = false;
1258 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1260 // Render and notify
1261 application.SendNotification();
1262 application.Render();
1264 // Executes the idle callbacks added by the text control on the change of input style.
1265 application.RunIdles();
1267 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1268 DALI_TEST_CHECK( !inputStyleChangedSignal );
1270 gInputStyleChangedCallbackCalled = false;
1271 gInputStyleMask = TextEditor::InputStyle::NONE;
1272 inputStyleChangedSignal = false;
1274 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1276 // Render and notify
1277 application.SendNotification();
1278 application.Render();
1280 // Executes the idle callbacks added by the text control on the change of input style.
1281 application.RunIdles();
1283 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1284 if( gInputStyleChangedCallbackCalled )
1286 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1287 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1290 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1291 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1293 DALI_TEST_CHECK( inputStyleChangedSignal );
1295 gInputStyleChangedCallbackCalled = false;
1296 gInputStyleMask = TextEditor::InputStyle::NONE;
1297 inputStyleChangedSignal = false;
1299 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1301 Property::Map fontStyleMapSet;
1302 fontStyleMapSet.Insert( "weight", "thin" );
1303 fontStyleMapSet.Insert( "width", "condensed" );
1304 fontStyleMapSet.Insert( "slant", "italic" );
1306 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1307 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1308 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1310 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1311 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1312 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1313 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1315 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1317 // Render and notify
1318 application.SendNotification();
1319 application.Render();
1321 // Executes the idle callbacks added by the text control on the change of input style.
1322 application.RunIdles();
1324 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1325 DALI_TEST_CHECK( !inputStyleChangedSignal );
1327 // Create a tap event to touch the text editor.
1328 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1329 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1331 // Render and notify
1332 application.SendNotification();
1333 application.Render();
1335 // Executes the idle callbacks added by the text control on the change of input style.
1336 application.RunIdles();
1338 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1339 if( gInputStyleChangedCallbackCalled )
1341 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1342 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1343 TextEditor::InputStyle::POINT_SIZE |
1344 TextEditor::InputStyle::FONT_STYLE |
1345 TextEditor::InputStyle::LINE_SPACING |
1346 TextEditor::InputStyle::UNDERLINE |
1347 TextEditor::InputStyle::SHADOW |
1348 TextEditor::InputStyle::EMBOSS |
1349 TextEditor::InputStyle::OUTLINE ),
1352 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1353 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1355 DALI_TEST_CHECK( inputStyleChangedSignal );
1357 gInputStyleChangedCallbackCalled = false;
1358 gInputStyleMask = TextEditor::InputStyle::NONE;
1359 inputStyleChangedSignal = false;
1361 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1363 fontStyleMapSet.Clear();
1364 fontStyleMapSet.Insert( "weight", "black" );
1365 fontStyleMapSet.Insert( "width", "expanded" );
1366 fontStyleMapSet.Insert( "slant", "oblique" );
1368 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1370 // Create a tap event to touch the text editor.
1371 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1372 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1374 // Render and notify
1375 application.SendNotification();
1376 application.Render();
1378 // Executes the idle callbacks added by the text control on the change of input style.
1379 application.RunIdles();
1381 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1382 if( gInputStyleChangedCallbackCalled )
1384 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1385 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1386 TextEditor::InputStyle::POINT_SIZE |
1387 TextEditor::InputStyle::FONT_STYLE ),
1390 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1391 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1393 DALI_TEST_CHECK( inputStyleChangedSignal );
1398 int utcDaliTextEditorEvent01(void)
1400 ToolkitTestApplication application;
1401 tet_infoline(" utcDaliTextEditorEvent01");
1403 // Creates a tap event. After creating a tap event the text editor should
1404 // have the focus and add text with key events should be possible.
1406 TextEditor editor = TextEditor::New();
1407 DALI_TEST_CHECK( editor );
1409 Stage::GetCurrent().Add( editor );
1411 editor.SetSize( 300.f, 50.f );
1412 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1413 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1415 // Avoid a crash when core load gl resources.
1416 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1418 // Render and notify
1419 application.SendNotification();
1420 application.Render();
1422 // Add a key event but as the text editor has not the focus it should do nothing.
1423 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1425 // Render and notify
1426 application.SendNotification();
1427 application.Render();
1429 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1431 // Create a tap event to touch the text editor.
1432 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1433 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1435 // Render and notify
1436 application.SendNotification();
1437 application.Render();
1439 // Now the text editor has the focus, so it can handle the key events.
1440 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1441 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1443 // Render and notify
1444 application.SendNotification();
1445 application.Render();
1447 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1449 // Create a second text editor and send key events to it.
1450 TextEditor editor2 = TextEditor::New();
1452 editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1453 editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1454 editor2.SetSize( 100.f, 100.f );
1455 editor2.SetPosition( 100.f, 100.f );
1457 Stage::GetCurrent().Add( editor2 );
1459 // Render and notify
1460 application.SendNotification();
1461 application.Render();
1463 // Create a tap event on the second text editor.
1464 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1465 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1467 // Render and notify
1468 application.SendNotification();
1469 application.Render();
1471 // The second text editor has the focus. It should handle the key events.
1472 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1473 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1475 // Render and notify
1476 application.SendNotification();
1477 application.Render();
1479 // Check the text has been added to the second text editor.
1480 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1485 int utcDaliTextEditorEvent02(void)
1487 ToolkitTestApplication application;
1488 tet_infoline(" utcDaliTextEditorEvent02");
1490 // Checks if the right number of actors are created.
1492 TextEditor editor = TextEditor::New();
1493 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1494 DALI_TEST_CHECK( editor );
1496 Stage::GetCurrent().Add( editor );
1498 editor.SetSize( 300.f, 50.f );
1499 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1500 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1502 // Avoid a crash when core load gl resources.
1503 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1505 // Render and notify
1506 application.SendNotification();
1507 application.Render();
1509 // Check there are the expected number of children (the stencil).
1510 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1512 Actor stencil = editor.GetChildAt( 0u );
1514 // Create a tap event to touch the text editor.
1515 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1516 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1518 // Render and notify
1519 application.SendNotification();
1520 application.Render();
1522 Actor layer = editor.GetChildAt( 1u );
1523 DALI_TEST_CHECK( layer.IsLayer() );
1525 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1526 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1528 // Now the text editor has the focus, so it can handle the key events.
1529 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1530 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1532 // Render and notify
1533 application.SendNotification();
1534 application.Render();
1536 // Checks the cursor and the renderer have been created.
1537 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1538 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1540 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1541 DALI_TEST_CHECK( cursor );
1543 // The stencil actor has a container with all the actors which contain the text renderers.
1544 Actor container = stencil.GetChildAt( 0u );
1545 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1547 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1548 DALI_TEST_CHECK( renderer );
1551 // Move the cursor and check the position changes.
1552 Vector3 position1 = cursor.GetCurrentPosition();
1554 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1555 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 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 position2 = cursor.GetCurrentPosition();
1563 DALI_TEST_CHECK( position2.x < position1.x );
1565 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1566 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1568 // Render and notify
1569 application.SendNotification();
1570 application.Render();
1572 Vector3 position3 = cursor.GetCurrentPosition();
1574 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1576 // Send some taps and check the cursor positions.
1578 // Try to tap at the beginning.
1579 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1580 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1582 // Render and notify
1583 application.SendNotification();
1584 application.Render();
1586 // Cursor position should be the same than position1.
1587 Vector3 position4 = cursor.GetCurrentPosition();
1589 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1591 // Tap away from the start position.
1592 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1593 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1595 // Render and notify
1596 application.SendNotification();
1597 application.Render();
1599 Vector3 position5 = cursor.GetCurrentPosition();
1601 DALI_TEST_CHECK( position5.x > position4.x );
1603 // Remove all the text.
1604 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1605 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1606 editor.SetProperty( TextEditor::Property::TEXT, "" );
1608 // Render and notify
1609 application.SendNotification();
1610 application.Render();
1612 // Cursor position should be the same than position2.
1613 Vector3 position6 = cursor.GetCurrentPosition();
1615 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1617 // Should not be a renderer.
1618 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1623 int utcDaliTextEditorEvent03(void)
1625 ToolkitTestApplication application;
1626 tet_infoline(" utcDaliTextEditorEvent03");
1628 // Checks if the highlight actor is created.
1630 TextEditor editor = TextEditor::New();
1631 DALI_TEST_CHECK( editor );
1633 Stage::GetCurrent().Add( editor );
1635 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1636 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1637 editor.SetSize( 30.f, 50.f );
1638 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1639 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1641 // Avoid a crash when core load gl resources.
1642 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1644 // Render and notify
1645 application.SendNotification();
1646 application.Render();
1648 // Send some taps and check text controller with clipboard window
1649 Dali::Clipboard clipboard = Clipboard::Get();
1650 clipboard.ShowClipboard();
1651 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1652 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1653 clipboard.HideClipboard();
1655 // Render and notify
1656 application.SendNotification();
1657 application.Render();
1659 // Tap first to get the focus.
1660 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1661 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1663 // Render and notify
1664 application.SendNotification();
1665 application.Render();
1667 // Double tap to select a word.
1668 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1669 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1671 // Render and notify
1672 application.SendNotification();
1673 application.Render();
1675 // The stencil actor should have two actors: the renderer and the highlight actor.
1676 Actor stencil = editor.GetChildAt( 0u );
1678 // Highlight needs to be drawn before text, so should come first in child order
1679 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1680 DALI_TEST_CHECK( highlight );
1682 // The stencil actor has a container with all the actors which contain the text renderers.
1683 Actor container = stencil.GetChildAt( 1u );
1684 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1686 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1687 DALI_TEST_CHECK( renderer );
1690 // Double tap out of bounds
1691 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1692 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1694 // Render and notify
1695 application.SendNotification();
1696 application.Render();
1698 // The stencil actor should have one actors: the renderer actor.
1699 stencil = editor.GetChildAt( 0u );
1701 // The stencil actor has a container with all the actors which contain the text renderers.
1702 container = stencil.GetChildAt( 0u );
1703 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1705 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1706 DALI_TEST_CHECK( renderer );
1712 int utcDaliTextEditorEvent04(void)
1714 ToolkitTestApplication application;
1715 tet_infoline(" utcDaliTextEditorEvent04");
1717 // Checks if the highlight actor is created.
1719 TextEditor editor = TextEditor::New();
1720 DALI_TEST_CHECK( editor );
1722 Stage::GetCurrent().Add( editor );
1724 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1725 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1726 editor.SetSize( 100.f, 50.f );
1727 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1728 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1730 // Avoid a crash when core load gl resources.
1731 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1733 // Render and notify
1734 application.SendNotification();
1735 application.Render();
1737 // Tap on the text editor
1738 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1739 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1741 // Render and notify
1742 application.SendNotification();
1743 application.Render();
1745 // Move at the end of the text.
1746 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1747 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1749 // Render and notify
1750 application.SendNotification();
1751 application.Render();
1753 for( unsigned int index = 0u; index < 10u; ++index )
1755 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1756 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1758 // Render and notify
1759 application.SendNotification();
1760 application.Render();
1764 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1766 // Render and notify
1767 application.SendNotification();
1768 application.Render();
1770 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1772 // Add some key events
1773 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1774 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1776 // Render and notify
1777 application.SendNotification();
1778 application.Render();
1780 for( unsigned int index = 0u; index < 10u; ++index )
1782 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1783 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1785 // Render and notify
1786 application.SendNotification();
1787 application.Render();
1791 application.ProcessEvent( GenerateKey( " ", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1793 // Render and notify
1794 application.SendNotification();
1795 application.Render();
1797 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1802 int utcDaliTextEditorEvent05(void)
1804 ToolkitTestApplication application;
1805 tet_infoline(" utcDaliTextEditorEvent05");
1807 // Checks if the highlight actor is created.
1809 TextEditor editor = TextEditor::New();
1810 DALI_TEST_CHECK( editor );
1812 Stage::GetCurrent().Add( editor );
1814 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1815 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1816 editor.SetSize( 50.f, 50.f );
1817 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1818 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1819 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
1820 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1821 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, true );
1822 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1823 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1825 // Avoid a crash when core load gl resources.
1826 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1828 // Render and notify
1829 application.SendNotification();
1830 application.Render();
1832 // Tap on the text editor
1833 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1834 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1836 // Render and notify
1837 application.SendNotification();
1838 application.Render();
1840 // Move at the end of the text.
1841 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1842 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1844 // Render and notify
1845 application.SendNotification();
1846 application.Render();
1848 for( unsigned int index = 0u; index < 10u; ++index )
1851 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1853 // Render and notify
1854 application.SendNotification();
1855 application.Render();
1857 // Modify duration after scroll is enabled
1858 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1860 // Continuous scroll left to increase coverage
1861 for( unsigned int index = 0u; index < 10u; ++index )
1863 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1865 // Render and notify
1866 application.SendNotification();
1867 application.Render();
1869 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1870 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1871 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1872 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1873 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1875 // Press Escape to increase coverage
1876 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1877 application.SendNotification();
1878 application.Render();
1880 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1885 int utcDaliTextEditorEvent06(void)
1887 ToolkitTestApplication application;
1888 tet_infoline(" utcDaliTextEditorEvent06");
1890 // Checks if the highlight actor is created.
1892 TextEditor editor = TextEditor::New();
1893 DALI_TEST_CHECK( editor );
1895 Stage::GetCurrent().Add( editor );
1897 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
1898 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1899 editor.SetSize( 100.f, 50.f );
1900 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1901 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1903 // Avoid a crash when core load gl resources.
1904 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1906 // Render and notify
1907 application.SendNotification();
1908 application.Render();
1910 // Tap on the text editor
1911 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1912 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1914 // Render and notify
1915 application.SendNotification();
1916 application.Render();
1918 // Move to seconds line of the text.
1919 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1921 // Render and notify
1922 application.SendNotification();
1923 application.Render();
1925 float layoutHeight = editor.GetHeightForWidth( 100.f );
1928 // Add another script characters ( glyph height is defferent )
1929 application.ProcessEvent( GenerateKey( "d", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1930 application.ProcessEvent( GenerateKey( "d", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1932 // Delete characters
1933 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1934 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1936 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
1938 // Render and notify
1939 application.SendNotification();
1940 application.Render();
1942 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1945 application.ProcessEvent( GenerateKey( "", "", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1946 application.SendNotification();
1947 application.Render();
1949 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1950 application.SendNotification();
1951 application.Render();
1953 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1954 application.SendNotification();
1955 application.Render();
1957 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1958 application.SendNotification();
1959 application.Render();
1964 int utcDaliTextEditorHandles(void)
1966 ToolkitTestApplication application;
1967 tet_infoline(" utcDaliTextEditorHandles");
1969 TextEditor editor = TextEditor::New();
1970 DALI_TEST_CHECK( editor );
1972 Stage::GetCurrent().Add( editor );
1974 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1975 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1976 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
1977 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
1979 editor.SetSize( 30.f, 500.f );
1980 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1981 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1983 // Avoid a crash when core load gl resources.
1984 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1986 // Render and notify
1987 application.SendNotification();
1988 application.Render();
1990 // Tap first to get the focus.
1991 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1992 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1994 // Render and notify
1995 application.SendNotification();
1996 application.Render();
1998 // Tap to create the grab handle.
1999 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2000 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2002 // Render and notify
2003 application.SendNotification();
2004 application.Render();
2006 // Get the active layer where the text's decoration is added.
2007 Actor activeLayer = editor.GetChildAt( 1u );
2009 // Get the handle's actor.
2010 Actor handle = activeLayer.GetChildAt( 1u );
2011 handle.SetSize( 100.f, 100.f );
2013 // Render and notify
2014 application.SendNotification();
2015 application.Render();
2017 // Touch the grab handle to set it as pressed.
2018 Vector2 touchPos( 10.0f, 50.0f );
2019 Dali::Integration::TouchEvent event;
2020 event = Dali::Integration::TouchEvent();
2021 event.AddPoint( GetPointDownInside( touchPos ) );
2022 application.ProcessEvent( event );
2024 // Render and notify
2025 application.SendNotification();
2026 application.Render();
2028 // drag grab handle right
2029 SendPan(application, Gesture::Possible, touchPos);
2030 SendPan(application, Gesture::Started, touchPos);
2032 Wait(application, 100);
2034 for(int i = 0;i<20;i++)
2036 SendPan(application, Gesture::Continuing, touchPos);
2041 SendPan(application, Gesture::Finished, touchPos);
2044 // Release the grab handle.
2045 event = Dali::Integration::TouchEvent();
2046 event.AddPoint( GetPointUpInside( touchPos ) );
2047 application.ProcessEvent( event );
2049 // Render and notify
2050 application.SendNotification();
2051 application.Render();
2057 int utcDaliTextEditorUnderPropertyStringP(void)
2059 ToolkitTestApplication application;
2060 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2061 TextEditor editor = TextEditor::New();
2062 DALI_TEST_CHECK( editor );
2064 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2066 Stage::GetCurrent().Add( editor );
2068 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2069 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2071 tet_infoline("Set underline settings with a map");
2072 // Check the input underline property
2073 Property::Map underlineMapSet;
2074 Property::Map underlineMapGet;
2075 underlineMapSet.Insert( "enable", "true" );
2076 underlineMapSet.Insert( "color", "blue" );
2077 underlineMapSet.Insert( "height", "2" );
2079 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2080 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2081 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2082 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2084 tet_infoline("Set underline settings with a string");
2085 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2086 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2089 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2091 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2092 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2093 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2094 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2096 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2101 int utcDaliTextEditorShadowPropertyStringP(void)
2103 ToolkitTestApplication application;
2104 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2106 TextEditor editor = TextEditor::New();
2108 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\"}" );
2110 Stage::GetCurrent().Add( editor );
2112 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\"}" );
2114 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2118 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2123 int utcDaliTextEditorFontStylePropertyStringP(void)
2125 ToolkitTestApplication application;
2126 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2128 TextEditor editor = TextEditor::New();
2130 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2132 Stage::GetCurrent().Add( editor );
2134 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2136 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2140 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2145 int utcDaliTextEditorGetPropertyLinecountP(void)
2147 ToolkitTestApplication application;
2149 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2153 TextEditor editor = TextEditor::New();
2154 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2155 editor.SetProperty( TextEditor::Property::TEXT,
2156 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2158 Stage::GetCurrent().Add( editor );
2160 editor.SetSize( 100.0f, 100.0f );
2161 lineCount = editor.GetProperty<int>( DevelTextEditor::Property::LINE_COUNT );
2162 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2164 editor.SetSize( 50.0f, 100.0f );
2165 lineCount = editor.GetProperty<int>( DevelTextEditor::Property::LINE_COUNT );
2166 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2171 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2174 ToolkitTestApplication application;
2175 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2177 TextEditor editor = TextEditor::New();
2178 DALI_TEST_CHECK( editor );
2180 Stage::GetCurrent().Add( editor );
2182 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2183 editor.SetSize( 50.f, 50.f );
2184 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2185 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2186 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, true );
2187 editor.SetKeyboardFocusable(true);
2189 bool startedCalled = false;
2190 bool finishedCalled = false;
2192 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2193 DevelTextEditor::ScrollStateChangedSignal( editor ).Connect( &callback, &ScrollStateChangeCallback::Callback );
2195 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2197 // Render and notify
2198 application.SendNotification();
2199 application.Render();
2201 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2202 application.SendNotification();
2203 application.Render(6000);
2205 application.SendNotification();
2206 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2207 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2211 int UtcDaliToolkitTextEditorTextWarpMode(void)
2213 ToolkitTestApplication application;
2214 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2218 TextEditor editor = TextEditor::New();
2219 editor.SetSize( 150.0f, 300.f );
2220 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2222 Stage::GetCurrent().Add( editor );
2224 editor.SetProperty( DevelTextEditor::Property::LINE_WRAP_MODE, "WORD" );
2226 application.SendNotification();
2227 application.Render();
2229 lineCount = editor.GetProperty<int>( DevelTextEditor::Property::LINE_COUNT );
2230 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2234 editor.SetProperty( DevelTextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2236 application.SendNotification();
2237 application.Render();
2240 lineCount = editor.GetProperty<int>( DevelTextEditor::Property::LINE_COUNT );
2241 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );