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 Device::Class::Type& deviceClass = Device::Class::NONE,
200 const Device::Subclass::Type& deviceSubclass = Device::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, TextEditor::Scroll::Type type )
315 if( type == TextEditor::Scroll::STARTED )
317 mStartedCalled = true;
319 else if( type == TextEditor::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 ) == TextEditor::Property::SMOOTH_SCROLL );
463 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
464 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
465 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
466 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
467 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
468 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
469 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
470 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
471 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
472 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
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
736 // Test string type first
737 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
738 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
739 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
741 // Then test the property map type
742 Property::Map outlineMapSet;
743 Property::Map outlineMapGet;
745 outlineMapSet["color"] = Color::RED;
746 outlineMapSet["width"] = 2.0f;
748 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
750 outlineMapSet["color"] = "red";
751 outlineMapSet["width"] = "2";
752 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
753 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
754 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
756 // Check the input outline property
757 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
758 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
760 // Check the smooth scroll property
761 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
762 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
763 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
765 // Check the smooth scroll duration property
766 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
767 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
769 // Check the scroll bar property
770 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
771 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
772 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
774 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
775 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
776 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
777 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
779 // Check the pixel size of font
780 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
781 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
783 // Check placeholder text properties.
784 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
785 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
787 // Check placeholder text's color property.
788 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
789 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
791 // Check the enable selection property
792 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
793 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
795 // Check the placeholder property with pixel size
796 Property::Map placeholderPixelSizeMapSet;
797 Property::Map placeholderPixelSizeMapGet;
798 Property::Map placeholderFontstyleMap;
799 placeholderPixelSizeMapSet["placeholderText"] = "Setting Placeholder Text";
800 placeholderPixelSizeMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused";
801 placeholderPixelSizeMapSet["placeholderColor"] = Color::BLUE;
802 placeholderPixelSizeMapSet["placeholderFontFamily"] = "Arial";
803 placeholderPixelSizeMapSet["placeholderPixelSize"] = 15.0f;
805 placeholderFontstyleMap.Insert( "weight", "bold" );
806 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
807 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
809 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
810 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
811 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
813 // Check the placeholder property with point size
814 Property::Map placeholderMapSet;
815 Property::Map placeholderMapGet;
816 placeholderMapSet["placeholderText"] = "Setting Placeholder Text";
817 placeholderMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused";
818 placeholderMapSet["placeholderColor"] = Color::RED;
819 placeholderMapSet["placeholderFontFamily"] = "Arial";
820 placeholderMapSet["placeholderPointSize"] = 12.0f;
822 // Check the placeholder font style property
823 placeholderFontstyleMap.Clear();
825 placeholderFontstyleMap.Insert( "weight", "bold" );
826 placeholderFontstyleMap.Insert( "width", "condensed" );
827 placeholderFontstyleMap.Insert( "slant", "italic" );
828 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
829 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
831 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
832 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
833 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
836 placeholderFontstyleMap.Clear();
837 placeholderFontstyleMap.Insert( "weight", "normal" );
838 placeholderFontstyleMap.Insert( "slant", "oblique" );
839 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
840 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
842 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
843 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
844 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
846 placeholderFontstyleMap.Clear();
847 placeholderFontstyleMap.Insert( "slant", "roman" );
848 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
849 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
851 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
853 placeholderFontstyleMap.Clear();
854 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
856 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
857 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
858 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
859 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
864 // Positive Atlas Text Renderer test
865 int utcDaliTextEditorAtlasRenderP(void)
867 ToolkitTestApplication application;
868 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
869 StyleManager styleManager = StyleManager::Get();
870 styleManager.ApplyDefaultTheme();
871 TextEditor editor = TextEditor::New();
872 DALI_TEST_CHECK( editor );
874 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
876 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
878 Stage::GetCurrent().Add( editor );
882 // Render some text with the shared atlas backend
883 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
884 application.SendNotification();
885 application.Render();
889 tet_result(TET_FAIL);
894 // Positive test for the textChanged signal.
895 int utcDaliTextEditorTextChangedP(void)
897 ToolkitTestApplication application;
898 tet_infoline(" utcDaliTextEditorTextChangedP");
899 TextEditor editor = TextEditor::New();
900 DALI_TEST_CHECK( editor );
902 Stage::GetCurrent().Add( editor );
904 // connect to the text changed signal.
905 ConnectionTracker* testTracker = new ConnectionTracker();
906 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
907 bool textChangedSignal = false;
908 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
910 gTextChangedCallBackCalled = false;
911 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
912 DALI_TEST_CHECK( gTextChangedCallBackCalled );
913 DALI_TEST_CHECK( textChangedSignal );
915 application.SendNotification();
917 editor.SetKeyInputFocus();
919 gTextChangedCallBackCalled = false;
920 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
921 DALI_TEST_CHECK( gTextChangedCallBackCalled );
926 int utcDaliTextEditorInputStyleChanged01(void)
928 ToolkitTestApplication application;
929 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
931 // The text-editor emits signals when the input style changes. These changes of style are
932 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
933 // can't be emitted during the size negotiation as the callbacks may update the UI.
934 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
935 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
936 application.CreateAdaptor();
940 char* pathNamePtr = get_current_dir_name();
941 const std::string pathName( pathNamePtr );
944 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
945 fontClient.SetDpi( 93u, 93u );
947 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
948 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
950 TextEditor editor = TextEditor::New();
951 DALI_TEST_CHECK( editor );
954 editor.SetSize( 300.f, 50.f );
955 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
956 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
958 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
959 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
961 // connect to the text changed signal.
962 ConnectionTracker* testTracker = new ConnectionTracker();
963 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
964 bool inputStyleChangedSignal = false;
965 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
967 Stage::GetCurrent().Add( editor );
970 application.SendNotification();
971 application.Render();
973 // Executes the idle callbacks added by the text control on the change of input style.
974 application.RunIdles();
976 gInputStyleChangedCallbackCalled = false;
977 gInputStyleMask = TextEditor::InputStyle::NONE;
978 inputStyleChangedSignal = false;
980 // Create a tap event to touch the text editor.
981 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
982 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
985 application.SendNotification();
986 application.Render();
988 // Executes the idle callbacks added by the text control on the change of input style.
989 application.RunIdles();
991 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
992 if( gInputStyleChangedCallbackCalled )
994 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
996 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
997 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
999 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1000 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1002 DALI_TEST_CHECK( inputStyleChangedSignal );
1004 gInputStyleChangedCallbackCalled = false;
1005 gInputStyleMask = TextEditor::InputStyle::NONE;
1006 inputStyleChangedSignal = false;
1008 // Create a tap event to touch the text editor.
1009 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1010 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1012 // Render and notify
1013 application.SendNotification();
1014 application.Render();
1016 // Executes the idle callbacks added by the text control on the change of input style.
1017 application.RunIdles();
1019 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1020 DALI_TEST_CHECK( !inputStyleChangedSignal );
1022 gInputStyleChangedCallbackCalled = false;
1023 gInputStyleMask = TextEditor::InputStyle::NONE;
1024 inputStyleChangedSignal = false;
1026 // Create a tap event to touch the text editor.
1027 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1028 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1030 // Render and notify
1031 application.SendNotification();
1032 application.Render();
1034 // Executes the idle callbacks added by the text control on the change of input style.
1035 application.RunIdles();
1037 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1038 if( gInputStyleChangedCallbackCalled )
1040 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1042 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1043 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1045 DALI_TEST_CHECK( inputStyleChangedSignal );
1047 gInputStyleChangedCallbackCalled = false;
1048 gInputStyleMask = TextEditor::InputStyle::NONE;
1049 inputStyleChangedSignal = false;
1051 // Create a tap event to touch the text editor.
1052 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1053 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1055 // Render and notify
1056 application.SendNotification();
1057 application.Render();
1059 // Executes the idle callbacks added by the text control on the change of input style.
1060 application.RunIdles();
1062 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1063 if( gInputStyleChangedCallbackCalled )
1065 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1067 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1068 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1070 Property::Map fontStyleMapSet;
1071 Property::Map fontStyleMapGet;
1073 fontStyleMapSet.Insert( "weight", "bold" );
1075 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1076 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1077 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1079 DALI_TEST_CHECK( inputStyleChangedSignal );
1081 gInputStyleChangedCallbackCalled = false;
1082 gInputStyleMask = TextEditor::InputStyle::NONE;
1083 inputStyleChangedSignal = false;
1085 // Create a tap event to touch the text editor.
1086 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1087 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1089 // Render and notify
1090 application.SendNotification();
1091 application.Render();
1093 // Executes the idle callbacks added by the text control on the change of input style.
1094 application.RunIdles();
1096 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1097 DALI_TEST_CHECK( !inputStyleChangedSignal );
1099 gInputStyleChangedCallbackCalled = false;
1100 gInputStyleMask = TextEditor::InputStyle::NONE;
1101 inputStyleChangedSignal = false;
1103 // Create a tap event to touch the text editor.
1104 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1105 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1107 // Render and notify
1108 application.SendNotification();
1109 application.Render();
1111 // Executes the idle callbacks added by the text control on the change of input style.
1112 application.RunIdles();
1114 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1115 if( gInputStyleChangedCallbackCalled )
1117 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1119 Property::Map fontStyleMapSet;
1120 Property::Map fontStyleMapGet;
1122 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1123 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1124 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1126 DALI_TEST_CHECK( inputStyleChangedSignal );
1128 gInputStyleChangedCallbackCalled = false;
1129 gInputStyleMask = TextEditor::InputStyle::NONE;
1130 inputStyleChangedSignal = false;
1132 // Create a tap event to touch the text editor.
1133 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1134 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1136 // Render and notify
1137 application.SendNotification();
1138 application.Render();
1140 // Executes the idle callbacks added by the text control on the change of input style.
1141 application.RunIdles();
1143 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1144 DALI_TEST_CHECK( !inputStyleChangedSignal );
1149 int utcDaliTextEditorInputStyleChanged02(void)
1151 ToolkitTestApplication application;
1152 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1154 // The text-editor emits signals when the input style changes. These changes of style are
1155 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1156 // can't be emitted during the size negotiation as the callbacks may update the UI.
1157 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1158 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1159 application.CreateAdaptor();
1163 char* pathNamePtr = get_current_dir_name();
1164 const std::string pathName( pathNamePtr );
1165 free( pathNamePtr );
1167 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1168 fontClient.SetDpi( 93u, 93u );
1170 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1171 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1173 TextEditor editor = TextEditor::New();
1174 DALI_TEST_CHECK( editor );
1177 editor.SetSize( 300.f, 50.f );
1178 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1179 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1181 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1182 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>" );
1184 // connect to the text changed signal.
1185 ConnectionTracker* testTracker = new ConnectionTracker();
1186 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1187 bool inputStyleChangedSignal = false;
1188 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1190 Stage::GetCurrent().Add( editor );
1192 // Render and notify
1193 application.SendNotification();
1194 application.Render();
1196 // Executes the idle callbacks added by the text control on the change of input style.
1197 application.RunIdles();
1199 gInputStyleChangedCallbackCalled = false;
1200 gInputStyleMask = TextEditor::InputStyle::NONE;
1201 inputStyleChangedSignal = false;
1203 // Create a tap event to touch the text editor.
1204 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1205 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1206 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1207 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1209 // Render and notify
1210 application.SendNotification();
1211 application.Render();
1213 // Executes the idle callbacks added by the text control on the change of input style.
1214 application.RunIdles();
1216 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1217 if( gInputStyleChangedCallbackCalled )
1219 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1220 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1221 TextEditor::InputStyle::POINT_SIZE |
1222 TextEditor::InputStyle::COLOR ),
1225 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1226 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1228 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1229 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1231 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1232 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1234 DALI_TEST_CHECK( inputStyleChangedSignal );
1236 gInputStyleChangedCallbackCalled = false;
1237 gInputStyleMask = TextEditor::InputStyle::NONE;
1238 inputStyleChangedSignal = false;
1240 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1242 // Render and notify
1243 application.SendNotification();
1244 application.Render();
1246 // Executes the idle callbacks added by the text control on the change of input style.
1247 application.RunIdles();
1249 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1250 if( gInputStyleChangedCallbackCalled )
1252 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1253 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1256 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1257 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1259 DALI_TEST_CHECK( inputStyleChangedSignal );
1261 gInputStyleChangedCallbackCalled = false;
1262 gInputStyleMask = TextEditor::InputStyle::NONE;
1263 inputStyleChangedSignal = false;
1265 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1267 // Render and notify
1268 application.SendNotification();
1269 application.Render();
1271 // Executes the idle callbacks added by the text control on the change of input style.
1272 application.RunIdles();
1274 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1275 DALI_TEST_CHECK( !inputStyleChangedSignal );
1277 gInputStyleChangedCallbackCalled = false;
1278 gInputStyleMask = TextEditor::InputStyle::NONE;
1279 inputStyleChangedSignal = false;
1281 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1283 // Render and notify
1284 application.SendNotification();
1285 application.Render();
1287 // Executes the idle callbacks added by the text control on the change of input style.
1288 application.RunIdles();
1290 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1291 if( gInputStyleChangedCallbackCalled )
1293 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1294 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1297 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1298 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1300 DALI_TEST_CHECK( inputStyleChangedSignal );
1302 gInputStyleChangedCallbackCalled = false;
1303 gInputStyleMask = TextEditor::InputStyle::NONE;
1304 inputStyleChangedSignal = false;
1306 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1308 Property::Map fontStyleMapSet;
1309 fontStyleMapSet.Insert( "weight", "thin" );
1310 fontStyleMapSet.Insert( "width", "condensed" );
1311 fontStyleMapSet.Insert( "slant", "italic" );
1313 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1314 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1315 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1317 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1318 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1319 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1320 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1322 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1324 // Render and notify
1325 application.SendNotification();
1326 application.Render();
1328 // Executes the idle callbacks added by the text control on the change of input style.
1329 application.RunIdles();
1331 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1332 DALI_TEST_CHECK( !inputStyleChangedSignal );
1334 // Create a tap event to touch the text editor.
1335 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1336 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1338 // Render and notify
1339 application.SendNotification();
1340 application.Render();
1342 // Executes the idle callbacks added by the text control on the change of input style.
1343 application.RunIdles();
1345 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1346 if( gInputStyleChangedCallbackCalled )
1348 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1349 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1350 TextEditor::InputStyle::POINT_SIZE |
1351 TextEditor::InputStyle::FONT_STYLE |
1352 TextEditor::InputStyle::LINE_SPACING |
1353 TextEditor::InputStyle::UNDERLINE |
1354 TextEditor::InputStyle::SHADOW |
1355 TextEditor::InputStyle::EMBOSS |
1356 TextEditor::InputStyle::OUTLINE ),
1359 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1360 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1362 DALI_TEST_CHECK( inputStyleChangedSignal );
1364 gInputStyleChangedCallbackCalled = false;
1365 gInputStyleMask = TextEditor::InputStyle::NONE;
1366 inputStyleChangedSignal = false;
1368 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1370 fontStyleMapSet.Clear();
1371 fontStyleMapSet.Insert( "weight", "black" );
1372 fontStyleMapSet.Insert( "width", "expanded" );
1373 fontStyleMapSet.Insert( "slant", "oblique" );
1375 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1377 // Create a tap event to touch the text editor.
1378 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1379 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1381 // Render and notify
1382 application.SendNotification();
1383 application.Render();
1385 // Executes the idle callbacks added by the text control on the change of input style.
1386 application.RunIdles();
1388 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1389 if( gInputStyleChangedCallbackCalled )
1391 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1392 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1393 TextEditor::InputStyle::POINT_SIZE |
1394 TextEditor::InputStyle::FONT_STYLE ),
1397 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1398 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1400 DALI_TEST_CHECK( inputStyleChangedSignal );
1405 int utcDaliTextEditorEvent01(void)
1407 ToolkitTestApplication application;
1408 tet_infoline(" utcDaliTextEditorEvent01");
1410 // Creates a tap event. After creating a tap event the text editor should
1411 // have the focus and add text with key events should be possible.
1413 TextEditor editor = TextEditor::New();
1414 DALI_TEST_CHECK( editor );
1416 Stage::GetCurrent().Add( editor );
1418 editor.SetSize( 300.f, 50.f );
1419 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1420 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1422 // Avoid a crash when core load gl resources.
1423 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1425 // Render and notify
1426 application.SendNotification();
1427 application.Render();
1429 // Add a key event but as the text editor has not the focus it should do nothing.
1430 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1432 // Render and notify
1433 application.SendNotification();
1434 application.Render();
1436 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1438 // Create a tap event to touch the text editor.
1439 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1440 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1442 // Render and notify
1443 application.SendNotification();
1444 application.Render();
1446 // Now the text editor has the focus, so it can handle the key events.
1447 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1448 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1450 // Render and notify
1451 application.SendNotification();
1452 application.Render();
1454 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1456 // Create a second text editor and send key events to it.
1457 TextEditor editor2 = TextEditor::New();
1459 editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1460 editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1461 editor2.SetSize( 100.f, 100.f );
1462 editor2.SetPosition( 100.f, 100.f );
1464 Stage::GetCurrent().Add( editor2 );
1466 // Render and notify
1467 application.SendNotification();
1468 application.Render();
1470 // Create a tap event on the second text editor.
1471 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1472 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1474 // Render and notify
1475 application.SendNotification();
1476 application.Render();
1478 // The second text editor has the focus. It should handle the key events.
1479 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1480 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1482 // Render and notify
1483 application.SendNotification();
1484 application.Render();
1486 // Check the text has been added to the second text editor.
1487 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1492 int utcDaliTextEditorEvent02(void)
1494 ToolkitTestApplication application;
1495 tet_infoline(" utcDaliTextEditorEvent02");
1497 // Checks if the right number of actors are created.
1499 TextEditor editor = TextEditor::New();
1500 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1501 DALI_TEST_CHECK( editor );
1503 Stage::GetCurrent().Add( editor );
1505 editor.SetSize( 300.f, 50.f );
1506 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1507 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1509 // Avoid a crash when core load gl resources.
1510 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1512 // Render and notify
1513 application.SendNotification();
1514 application.Render();
1516 // Check there are the expected number of children (the stencil).
1517 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1519 Actor stencil = editor.GetChildAt( 0u );
1521 // Create a tap event to touch the text editor.
1522 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1523 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1525 // Render and notify
1526 application.SendNotification();
1527 application.Render();
1529 Actor layer = editor.GetChildAt( 1u );
1530 DALI_TEST_CHECK( layer.IsLayer() );
1532 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1533 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1535 // Now the text editor has the focus, so it can handle the key events.
1536 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1537 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1539 // Render and notify
1540 application.SendNotification();
1541 application.Render();
1543 // Checks the cursor and the renderer have been created.
1544 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1545 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1547 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1548 DALI_TEST_CHECK( cursor );
1550 // The stencil actor has a container with all the actors which contain the text renderers.
1551 Actor container = stencil.GetChildAt( 0u );
1552 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1554 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1555 DALI_TEST_CHECK( renderer );
1558 // Move the cursor and check the position changes.
1559 Vector3 position1 = cursor.GetCurrentPosition();
1561 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1562 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1564 // Render and notify
1565 application.SendNotification();
1566 application.Render();
1568 Vector3 position2 = cursor.GetCurrentPosition();
1570 DALI_TEST_CHECK( position2.x < position1.x );
1572 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1573 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1575 // Render and notify
1576 application.SendNotification();
1577 application.Render();
1579 Vector3 position3 = cursor.GetCurrentPosition();
1581 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1583 // Send some taps and check the cursor positions.
1585 // Try to tap at the beginning.
1586 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1587 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1589 // Render and notify
1590 application.SendNotification();
1591 application.Render();
1593 // Cursor position should be the same than position1.
1594 Vector3 position4 = cursor.GetCurrentPosition();
1596 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1598 // Tap away from the start position.
1599 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1600 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1602 // Render and notify
1603 application.SendNotification();
1604 application.Render();
1606 Vector3 position5 = cursor.GetCurrentPosition();
1608 DALI_TEST_CHECK( position5.x > position4.x );
1610 // Remove all the text.
1611 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1612 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1613 editor.SetProperty( TextEditor::Property::TEXT, "" );
1615 // Render and notify
1616 application.SendNotification();
1617 application.Render();
1619 // Cursor position should be the same than position2.
1620 Vector3 position6 = cursor.GetCurrentPosition();
1622 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1624 // Should not be a renderer.
1625 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1630 int utcDaliTextEditorEvent03(void)
1632 ToolkitTestApplication application;
1633 tet_infoline(" utcDaliTextEditorEvent03");
1635 // Checks if the highlight actor is created.
1637 TextEditor editor = TextEditor::New();
1638 DALI_TEST_CHECK( editor );
1640 Stage::GetCurrent().Add( editor );
1642 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1643 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1644 editor.SetSize( 30.f, 50.f );
1645 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1646 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1648 // Avoid a crash when core load gl resources.
1649 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1651 // Render and notify
1652 application.SendNotification();
1653 application.Render();
1655 // Send some taps and check text controller with clipboard window
1656 Dali::Clipboard clipboard = Clipboard::Get();
1657 clipboard.ShowClipboard();
1658 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1659 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1660 clipboard.HideClipboard();
1662 // Render and notify
1663 application.SendNotification();
1664 application.Render();
1666 // Tap first to get the focus.
1667 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1668 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1670 // Render and notify
1671 application.SendNotification();
1672 application.Render();
1674 // Double tap to select a word.
1675 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1676 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1678 // Render and notify
1679 application.SendNotification();
1680 application.Render();
1682 // The stencil actor should have two actors: the renderer and the highlight actor.
1683 Actor stencil = editor.GetChildAt( 0u );
1685 // Highlight needs to be drawn before text, so should come first in child order
1686 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1687 DALI_TEST_CHECK( highlight );
1689 // The stencil actor has a container with all the actors which contain the text renderers.
1690 Actor container = stencil.GetChildAt( 1u );
1691 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1693 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1694 DALI_TEST_CHECK( renderer );
1697 // Double tap out of bounds
1698 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1699 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1701 // Render and notify
1702 application.SendNotification();
1703 application.Render();
1705 // The stencil actor should have one actors: the renderer actor.
1706 stencil = editor.GetChildAt( 0u );
1708 // The stencil actor has a container with all the actors which contain the text renderers.
1709 container = stencil.GetChildAt( 0u );
1710 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1712 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1713 DALI_TEST_CHECK( renderer );
1719 int utcDaliTextEditorEvent04(void)
1721 ToolkitTestApplication application;
1722 tet_infoline(" utcDaliTextEditorEvent04");
1724 // Checks if the highlight actor is created.
1726 TextEditor editor = TextEditor::New();
1727 DALI_TEST_CHECK( editor );
1729 Stage::GetCurrent().Add( editor );
1731 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1732 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1733 editor.SetSize( 100.f, 50.f );
1734 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1735 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1737 // Avoid a crash when core load gl resources.
1738 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1740 // Render and notify
1741 application.SendNotification();
1742 application.Render();
1744 // Tap on the text editor
1745 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1746 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1748 // Render and notify
1749 application.SendNotification();
1750 application.Render();
1752 // Move at the end of the text.
1753 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1754 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1756 // Render and notify
1757 application.SendNotification();
1758 application.Render();
1760 for( unsigned int index = 0u; index < 10u; ++index )
1762 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1763 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1765 // Render and notify
1766 application.SendNotification();
1767 application.Render();
1771 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1773 // Render and notify
1774 application.SendNotification();
1775 application.Render();
1777 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1779 // Add some key events
1780 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1781 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1783 // Render and notify
1784 application.SendNotification();
1785 application.Render();
1787 for( unsigned int index = 0u; index < 10u; ++index )
1789 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1790 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1792 // Render and notify
1793 application.SendNotification();
1794 application.Render();
1798 application.ProcessEvent( GenerateKey( " ", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1800 // Render and notify
1801 application.SendNotification();
1802 application.Render();
1804 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1809 int utcDaliTextEditorEvent05(void)
1811 ToolkitTestApplication application;
1812 tet_infoline(" utcDaliTextEditorEvent05");
1814 // Checks if the highlight actor is created.
1816 TextEditor editor = TextEditor::New();
1817 DALI_TEST_CHECK( editor );
1819 Stage::GetCurrent().Add( editor );
1821 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1822 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1823 editor.SetSize( 50.f, 50.f );
1824 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1825 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1826 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1827 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1828 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1829 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1830 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1832 // Avoid a crash when core load gl resources.
1833 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1835 // Render and notify
1836 application.SendNotification();
1837 application.Render();
1839 // Tap on the text editor
1840 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1841 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1843 // Render and notify
1844 application.SendNotification();
1845 application.Render();
1847 // Move at the end of the text.
1848 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1849 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1851 // Render and notify
1852 application.SendNotification();
1853 application.Render();
1855 for( unsigned int index = 0u; index < 10u; ++index )
1858 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1860 // Render and notify
1861 application.SendNotification();
1862 application.Render();
1864 // Modify duration after scroll is enabled
1865 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1867 // Continuous scroll left to increase coverage
1868 for( unsigned int index = 0u; index < 10u; ++index )
1870 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1872 // Render and notify
1873 application.SendNotification();
1874 application.Render();
1876 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1877 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1878 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1879 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1880 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1882 // Press Escape to increase coverage
1883 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1884 application.SendNotification();
1885 application.Render();
1887 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1892 int utcDaliTextEditorEvent06(void)
1894 ToolkitTestApplication application;
1895 tet_infoline(" utcDaliTextEditorEvent06");
1897 // Checks if the highlight actor is created.
1899 TextEditor editor = TextEditor::New();
1900 DALI_TEST_CHECK( editor );
1902 Stage::GetCurrent().Add( editor );
1904 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
1905 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1906 editor.SetSize( 100.f, 50.f );
1907 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1908 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1910 // Avoid a crash when core load gl resources.
1911 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1913 // Render and notify
1914 application.SendNotification();
1915 application.Render();
1917 // Tap on the text editor
1918 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1919 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1921 // Render and notify
1922 application.SendNotification();
1923 application.Render();
1925 // Move to seconds line of the text.
1926 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1928 // Render and notify
1929 application.SendNotification();
1930 application.Render();
1932 float layoutHeight = editor.GetHeightForWidth( 100.f );
1935 // Add another script characters ( glyph height is defferent )
1936 application.ProcessEvent( GenerateKey( "d", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1937 application.ProcessEvent( GenerateKey( "d", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1939 // Delete characters
1940 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1941 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1943 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
1945 // Render and notify
1946 application.SendNotification();
1947 application.Render();
1949 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1952 application.ProcessEvent( GenerateKey( "", "", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1953 application.SendNotification();
1954 application.Render();
1956 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1957 application.SendNotification();
1958 application.Render();
1960 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1961 application.SendNotification();
1962 application.Render();
1964 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1965 application.SendNotification();
1966 application.Render();
1971 int utcDaliTextEditorHandles(void)
1973 ToolkitTestApplication application;
1974 tet_infoline(" utcDaliTextEditorHandles");
1976 TextEditor editor = TextEditor::New();
1977 DALI_TEST_CHECK( editor );
1979 Stage::GetCurrent().Add( editor );
1981 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1982 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1983 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
1984 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1986 editor.SetSize( 30.f, 500.f );
1987 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1988 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1990 // Avoid a crash when core load gl resources.
1991 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1993 // Render and notify
1994 application.SendNotification();
1995 application.Render();
1997 // Tap first to get the focus.
1998 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1999 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2001 // Render and notify
2002 application.SendNotification();
2003 application.Render();
2005 // Tap to create the grab handle.
2006 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2007 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2009 // Render and notify
2010 application.SendNotification();
2011 application.Render();
2013 // Get the active layer where the text's decoration is added.
2014 Actor activeLayer = editor.GetChildAt( 1u );
2016 // Get the handle's actor.
2017 Actor handle = activeLayer.GetChildAt( 1u );
2018 handle.SetSize( 100.f, 100.f );
2020 // Render and notify
2021 application.SendNotification();
2022 application.Render();
2024 // Touch the grab handle to set it as pressed.
2025 Vector2 touchPos( 10.0f, 50.0f );
2026 Dali::Integration::TouchEvent event;
2027 event = Dali::Integration::TouchEvent();
2028 event.AddPoint( GetPointDownInside( touchPos ) );
2029 application.ProcessEvent( event );
2031 // Render and notify
2032 application.SendNotification();
2033 application.Render();
2035 // drag grab handle right
2036 SendPan(application, Gesture::Possible, touchPos);
2037 SendPan(application, Gesture::Started, touchPos);
2039 Wait(application, 100);
2041 for(int i = 0;i<20;i++)
2043 SendPan(application, Gesture::Continuing, touchPos);
2048 SendPan(application, Gesture::Finished, touchPos);
2051 // Release the grab handle.
2052 event = Dali::Integration::TouchEvent();
2053 event.AddPoint( GetPointUpInside( touchPos ) );
2054 application.ProcessEvent( event );
2056 // Render and notify
2057 application.SendNotification();
2058 application.Render();
2064 int utcDaliTextEditorUnderPropertyStringP(void)
2066 ToolkitTestApplication application;
2067 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2068 TextEditor editor = TextEditor::New();
2069 DALI_TEST_CHECK( editor );
2071 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2073 Stage::GetCurrent().Add( editor );
2075 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2076 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2078 tet_infoline("Set underline settings with a map");
2079 // Check the input underline property
2080 Property::Map underlineMapSet;
2081 Property::Map underlineMapGet;
2082 underlineMapSet.Insert( "enable", "true" );
2083 underlineMapSet.Insert( "color", "blue" );
2084 underlineMapSet.Insert( "height", "2" );
2086 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2087 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2088 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2089 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2091 tet_infoline("Set underline settings with a string");
2092 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2093 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2096 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2098 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2099 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2100 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2101 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2103 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2108 int utcDaliTextEditorShadowPropertyStringP(void)
2110 ToolkitTestApplication application;
2111 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2113 TextEditor editor = TextEditor::New();
2115 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\"}" );
2117 Stage::GetCurrent().Add( editor );
2119 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\"}" );
2121 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2125 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2130 int utcDaliTextEditorFontStylePropertyStringP(void)
2132 ToolkitTestApplication application;
2133 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2135 TextEditor editor = TextEditor::New();
2137 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2139 Stage::GetCurrent().Add( editor );
2141 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2143 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2147 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2152 int utcDaliTextEditorGetPropertyLinecountP(void)
2154 ToolkitTestApplication application;
2156 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2160 TextEditor editor = TextEditor::New();
2161 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2162 editor.SetProperty( TextEditor::Property::TEXT,
2163 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2165 Stage::GetCurrent().Add( editor );
2167 editor.SetSize( 100.0f, 100.0f );
2168 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2169 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2171 editor.SetSize( 50.0f, 100.0f );
2172 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2173 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2178 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2181 ToolkitTestApplication application;
2182 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2184 TextEditor editor = TextEditor::New();
2185 DALI_TEST_CHECK( editor );
2187 Stage::GetCurrent().Add( editor );
2189 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2190 editor.SetSize( 50.f, 50.f );
2191 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2192 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2193 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2194 editor.SetKeyboardFocusable(true);
2196 bool startedCalled = false;
2197 bool finishedCalled = false;
2199 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2200 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2202 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2204 // Render and notify
2205 application.SendNotification();
2206 application.Render();
2208 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2209 application.SendNotification();
2210 application.Render(6000);
2212 application.SendNotification();
2213 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2214 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2219 int UtcDaliToolkitTextEditorTextWrapMode(void)
2221 ToolkitTestApplication application;
2222 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2226 TextEditor editor = TextEditor::New();
2227 editor.SetSize( 150.0f, 300.f );
2228 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2230 Stage::GetCurrent().Add( editor );
2232 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2233 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2235 application.SendNotification();
2236 application.Render();
2238 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2239 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2241 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2242 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2244 application.SendNotification();
2245 application.Render();
2247 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2248 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2250 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2251 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2253 application.SendNotification();
2254 application.Render();
2256 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2257 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2259 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2260 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2262 application.SendNotification();
2263 application.Render();
2265 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2266 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );