2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali/public-api/rendering/renderer.h>
22 #include <dali/devel-api/adaptor-framework/clipboard.h>
23 #include <dali/integration-api/events/key-event-integ.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
25 #include <dali/integration-api/events/tap-gesture-event.h>
26 #include <dali/integration-api/events/pan-gesture-event.h>
27 #include <dali-toolkit-test-suite-utils.h>
28 #include <dali-toolkit/dali-toolkit.h>
29 #include <dali-toolkit/devel-api/controls/control-devel.h>
30 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
33 using namespace Toolkit;
35 void dali_texteditor_startup(void)
37 test_return_value = TET_UNDEF;
40 void dali_texteditor_cleanup(void)
42 test_return_value = TET_PASS;
48 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
49 const char* const PROPERTY_NAME_TEXT = "text";
50 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
51 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
52 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
53 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
54 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
55 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
56 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
57 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
58 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
59 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
60 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
61 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
62 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
63 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
64 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
65 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
66 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
71 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
72 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
73 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
74 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
75 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
76 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
77 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
79 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
80 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
81 const char* const PROPERTY_NAME_UNDERLINE = "underline";
82 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
83 const char* const PROPERTY_NAME_SHADOW = "shadow";
84 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
85 const char* const PROPERTY_NAME_EMBOSS = "emboss";
86 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
87 const char* const PROPERTY_NAME_OUTLINE = "outline";
88 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
90 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
91 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
92 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
93 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
94 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
95 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
96 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
97 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
98 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
99 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
100 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
102 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
104 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
105 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
107 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
108 const float TO_MILLISECONDS = 1000.f;
109 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
110 const float RENDER_FRAME_INTERVAL = 16.66f;
112 const float SCROLL_THRESHOLD = 10.f;
113 const float SCROLL_SPEED = 300.f;
115 const unsigned int DEFAULT_FONT_SIZE = 1152u;
116 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
118 const int KEY_A_CODE = 38;
119 const int KEY_D_CODE = 40;
120 const int KEY_WHITE_SPACE_CODE = 65;
122 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
124 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
126 static bool gTextChangedCallBackCalled;
127 static bool gInputStyleChangedCallbackCalled;
128 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
130 struct CallbackFunctor
132 CallbackFunctor(bool* callbackFlag)
133 : mCallbackFlag( callbackFlag )
139 *mCallbackFlag = true;
144 static void TestTextChangedCallback( TextEditor control )
146 tet_infoline(" TestTextChangedCallback");
148 gTextChangedCallBackCalled = true;
151 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
153 tet_infoline(" TestInputStyleChangedCallback");
155 gInputStyleChangedCallbackCalled = true;
156 gInputStyleMask = mask;
159 // Generate a TapGestureEvent to send to Core.
160 Integration::TapGestureEvent GenerateTap(
161 Gesture::State state,
162 unsigned int numberOfTaps,
163 unsigned int numberOfTouches,
166 Integration::TapGestureEvent tap( state );
168 tap.numberOfTaps = numberOfTaps;
169 tap.numberOfTouches = numberOfTouches;
175 // Generate a PanGestureEvent to send to Core
176 Integration::PanGestureEvent GeneratePan( Gesture::State state,
177 const Vector2& previousPosition,
178 const Vector2& currentPosition,
179 unsigned long timeDelta,
180 unsigned int numberOfTouches = 1u )
182 Integration::PanGestureEvent pan(state);
184 pan.previousPosition = previousPosition;
185 pan.currentPosition = currentPosition;
186 pan.timeDelta = timeDelta;
187 pan.numberOfTouches = numberOfTouches;
192 // Generate a KeyEvent to send to Core.
193 Integration::KeyEvent GenerateKey( const std::string& keyName,
194 const std::string& keyString,
197 unsigned long timeStamp,
198 const Integration::KeyEvent::State& keyState,
199 const std::string& deviceName = DEFAULT_DEVICE_NAME,
200 const DevelDevice::Class::Type& deviceClass = DevelDevice::Class::NONE,
201 const DevelDevice::Subclass::Type& deviceSubclass = DevelDevice::Subclass::NONE )
203 return Integration::KeyEvent( keyName,
215 * Helper to generate PanGestureEvent
217 * @param[in] application Application instance
218 * @param[in] state The Gesture State
219 * @param[in] pos The current position of touch.
221 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
225 if( (state == Gesture::Started) ||
226 (state == Gesture::Possible) )
232 application.ProcessEvent( GeneratePan( state, last, pos, 16 ) );
239 * Simulate time passed by.
241 * @note this will always process at least 1 frame (1/60 sec)
243 * @param application Test application instance
244 * @param duration Time to pass in milliseconds.
245 * @return The actual time passed in milliseconds
247 static int Wait(ToolkitTestApplication& application, int duration = 0)
251 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
253 application.SendNotification();
254 application.Render(RENDER_FRAME_INTERVAL);
255 time += RENDER_FRAME_INTERVAL;
261 Dali::Integration::Point GetPointDownInside( Vector2& pos )
263 Dali::Integration::Point point;
264 point.SetState( PointState::DOWN );
265 point.SetScreenPosition( pos );
269 Dali::Integration::Point GetPointUpInside( Vector2& pos )
271 Dali::Integration::Point point;
272 point.SetState( PointState::UP );
273 point.SetScreenPosition( pos );
277 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
279 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
281 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
283 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
285 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
286 if( NULL != valueSet )
288 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
290 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
296 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
305 class ScrollStateChangeCallback : public Dali::ConnectionTracker
308 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
309 : mStartedCalled( startedCalled ),
310 mFinishedCalled( finishedCalled )
314 void Callback( TextEditor editor, DevelTextEditor::Scroll::Type type )
316 if( type == DevelTextEditor::Scroll::STARTED )
318 mStartedCalled = true;
320 else if( type == DevelTextEditor::Scroll::FINISHED )
322 mFinishedCalled = true;
326 bool& mStartedCalled;
327 bool& mFinishedCalled;
332 int UtcDaliToolkitTextEditorConstructorP(void)
334 ToolkitTestApplication application;
335 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
336 TextEditor textEditor;
337 DALI_TEST_CHECK( !textEditor );
341 int UtcDaliToolkitTextEditorNewP(void)
343 ToolkitTestApplication application;
344 tet_infoline(" UtcDaliToolkitTextEditorNewP");
345 TextEditor textEditor = TextEditor::New();
346 DALI_TEST_CHECK( textEditor );
350 int UtcDaliToolkitTextEditorDownCastP(void)
352 ToolkitTestApplication application;
353 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
354 TextEditor textEditor1 = TextEditor::New();
355 BaseHandle object( textEditor1 );
357 TextEditor textEditor2 = TextEditor::DownCast( object );
358 DALI_TEST_CHECK( textEditor2 );
360 TextEditor textEditor3 = DownCast< TextEditor >( object );
361 DALI_TEST_CHECK( textEditor3 );
365 int UtcDaliToolkitTextEditorDownCastN(void)
367 ToolkitTestApplication application;
368 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
369 BaseHandle uninitializedObject;
370 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
371 DALI_TEST_CHECK( !textEditor1 );
373 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
374 DALI_TEST_CHECK( !textEditor2 );
378 int UtcDaliToolkitTextEditorCopyConstructorP(void)
380 ToolkitTestApplication application;
381 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
382 TextEditor textEditor = TextEditor::New();
383 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
385 TextEditor copy( textEditor );
386 DALI_TEST_CHECK( copy );
387 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
391 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
393 ToolkitTestApplication application;
394 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
395 TextEditor textEditor = TextEditor::New();
396 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
398 TextEditor copy = textEditor;
399 DALI_TEST_CHECK( copy );
400 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
404 int UtcDaliTextEditorNewP(void)
406 ToolkitTestApplication application;
407 tet_infoline(" UtcDaliToolkitTextEditorNewP");
408 TextEditor textEditor = TextEditor::New();
409 DALI_TEST_CHECK( textEditor );
413 // Positive test case for a method
414 int UtcDaliTextEditorGetPropertyP(void)
416 ToolkitTestApplication application;
417 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
418 TextEditor editor = TextEditor::New();
419 DALI_TEST_CHECK( editor );
421 // Check Property Indices are correct
422 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextEditor::Property::RENDERING_BACKEND );
423 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
424 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
425 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
426 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
427 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
428 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
429 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
430 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
431 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
432 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
433 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
434 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
435 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
436 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
437 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
438 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
439 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
440 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
441 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
442 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
443 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
444 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
445 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
446 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
447 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
448 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
449 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
450 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
451 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
453 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
454 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
455 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
456 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
457 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
458 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
459 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
460 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
461 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
462 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
463 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == DevelTextEditor::Property::SMOOTH_SCROLL );
464 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == DevelTextEditor::Property::SMOOTH_SCROLL_DURATION );
465 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == DevelTextEditor::Property::ENABLE_SCROLL_BAR );
466 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION );
467 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION );
468 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == DevelTextEditor::Property::PIXEL_SIZE );
469 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == DevelTextEditor::Property::LINE_COUNT );
470 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
471 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
472 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == DevelTextEditor::Property::ENABLE_SELECTION );
473 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == DevelTextEditor::Property::PLACEHOLDER );
478 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
481 Property::Map imageMap;
482 imageMap[mapKey] =mapValue;
484 editor.SetProperty( property , imageMap );
485 Property::Value propValue = editor.GetProperty( property );
486 Property::Map* resultMap = propValue.GetMap();
488 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
496 // Positive test case for a method
497 int UtcDaliTextEditorSetPropertyP(void)
499 ToolkitTestApplication application;
500 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
501 TextEditor editor = TextEditor::New();
502 DALI_TEST_CHECK( editor );
503 Stage::GetCurrent().Add( editor );
505 // Note - we can't check the defaults since the stylesheets are platform-specific
507 // Check the render backend property.
508 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
509 DALI_TEST_EQUALS( (Text::RenderingType)editor.GetProperty<int>( TextEditor::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
511 // Check text property.
512 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
513 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
515 // Check text's color property
516 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
517 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
519 // Check font properties.
520 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
521 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
523 Property::Map fontStyleMapSet;
524 Property::Map fontStyleMapGet;
525 Property::Value* slantValue = NULL;
527 fontStyleMapSet.Insert( "weight", "bold" );
528 fontStyleMapSet.Insert( "width", "condensed" );
529 fontStyleMapSet.Insert( "slant", "italic" );
531 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
532 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
533 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
534 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
536 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
537 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
540 fontStyleMapSet.Clear();
541 fontStyleMapSet.Insert( "weight", "normal" );
542 fontStyleMapSet.Insert( "slant", "oblique" );
543 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
544 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
545 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
546 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
548 fontStyleMapSet.Clear();
549 fontStyleMapSet.Insert( "slant", "roman" );
550 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
551 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
553 // Replace 'roman' for 'normal'.
554 slantValue = fontStyleMapGet.Find( "slant" );
555 if( NULL != slantValue )
557 if( "normal" == slantValue->Get<std::string>() )
559 fontStyleMapGet["slant"] = "roman";
562 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
563 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
565 fontStyleMapSet.Clear();
567 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
568 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
569 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
570 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
572 // Check that the Alignment properties can be correctly set
573 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
574 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
576 // Check scroll properties.
577 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
578 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
579 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
580 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
582 // Check cursor properties
583 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
584 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
585 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
586 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
588 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
589 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
590 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
591 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
592 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
593 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
594 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
595 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
597 // Check handle images
598 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
599 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
600 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
601 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
602 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
604 // Check handle images
605 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
606 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
607 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
608 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
609 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
610 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
612 // Check the highlight color
613 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
614 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
616 // Decoration bounding box
617 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
618 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
620 // Check the enable markup property.
621 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
622 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
623 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
625 // Check input color property.
626 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
627 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
629 // Check input font properties.
630 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
631 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
633 fontStyleMapSet.Clear();
634 fontStyleMapSet.Insert( "weight", "bold" );
635 fontStyleMapSet.Insert( "width", "condensed" );
636 fontStyleMapSet.Insert( "slant", "italic" );
638 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
639 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
640 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
641 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
643 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
644 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
646 // Reset input font style.
647 fontStyleMapSet.Clear();
648 fontStyleMapSet.Insert( "weight", "normal" );
649 fontStyleMapSet.Insert( "slant", "oblique" );
651 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
652 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
653 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
654 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
656 fontStyleMapSet.Clear();
657 fontStyleMapSet.Insert( "slant", "roman" );
659 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
660 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
662 // Replace 'roman' for 'normal'.
663 slantValue = fontStyleMapGet.Find( "slant" );
664 if( NULL != slantValue )
666 if( "normal" == slantValue->Get<std::string>() )
668 fontStyleMapGet["slant"] = "roman";
671 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
672 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
674 fontStyleMapSet.Clear();
676 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
677 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
678 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
679 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
681 // Check the line spacing property
682 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
683 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
684 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
686 // Check the input line spacing property
687 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
688 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
689 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
691 // Check the underline property
693 Property::Map underlineMapSet;
694 Property::Map underlineMapGet;
696 underlineMapSet.Insert( "enable", "true" );
697 underlineMapSet.Insert( "color", "red" );
698 underlineMapSet.Insert( "height", "1" );
700 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
702 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
703 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
704 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
706 // Check the input underline property
707 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
708 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
710 // Check the shadow property
711 Property::Map shadowMapSet;
712 Property::Map shadowMapGet;
714 shadowMapSet.Insert( "color", "green" );
715 shadowMapSet.Insert( "offset", "2 2" );
717 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
719 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
720 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
721 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
723 // Check the input shadow property
724 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
725 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
727 // Check the emboss property
728 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
729 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
731 // Check the input emboss property
732 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
733 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
735 // Check the outline property
736 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
737 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
739 // Check the input outline property
740 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
741 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
743 // Check the smooth scroll property
744 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
745 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
746 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
748 // Check the smooth scroll duration property
749 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
750 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
752 // Check the scroll bar property
753 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
754 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, true );
755 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
757 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
758 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
759 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
760 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
762 // Check the pixel size of font
763 editor.SetProperty( DevelTextEditor::Property::PIXEL_SIZE, 20.f );
764 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
766 // Check placeholder text properties.
767 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
768 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
770 // Check placeholder text properties when focused.
771 editor.SetProperty( DevelControl::Property::STATE, "FOCUSED" );
772 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Focused Placeholder Text" );
773 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelControl::Property::STATE ), (int)DevelControl::FOCUSED, TEST_LOCATION );
774 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Focused Placeholder Text"), TEST_LOCATION );
776 // Check placeholder text's color property.
777 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
778 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
780 // Check the enable selection property
781 editor.SetProperty( DevelTextEditor::Property::ENABLE_SELECTION, false );
782 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
784 // Check the placeholder property with pixel size
785 Property::Map placeholderPixelSizeMapSet;
786 Property::Map placeholderPixelSizeMapGet;
787 Property::Map placeholderFontstyleMap;
788 placeholderPixelSizeMapSet["placeholderText"] = "Setting Placeholder Text";
789 placeholderPixelSizeMapSet["placeholderColor"] = Color::BLUE;
790 placeholderPixelSizeMapSet["placeholderFontFamily"] = "Arial";
791 placeholderPixelSizeMapSet["placeholderPixelSize"] = 15.0f;
793 placeholderFontstyleMap.Insert( "weight", "bold" );
794 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
795 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
797 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
798 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
799 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
801 // Check the placeholder property with point size
802 Property::Map placeholderMapSet;
803 Property::Map placeholderMapGet;
804 placeholderMapSet["placeholderText"] = "Setting Placeholder Text";
805 placeholderMapSet["placeholderColor"] = Color::RED;
806 placeholderMapSet["placeholderFontFamily"] = "Arial";
807 placeholderMapSet["placeholderPointSize"] = 12.0f;
809 // Check the placeholder font style property
810 placeholderFontstyleMap.Clear();
812 placeholderFontstyleMap.Insert( "weight", "bold" );
813 placeholderFontstyleMap.Insert( "width", "condensed" );
814 placeholderFontstyleMap.Insert( "slant", "italic" );
815 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
816 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderMapSet );
818 placeholderMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
819 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
820 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
823 placeholderFontstyleMap.Clear();
824 placeholderFontstyleMap.Insert( "weight", "normal" );
825 placeholderFontstyleMap.Insert( "slant", "oblique" );
826 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
827 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderMapSet );
829 placeholderMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
830 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
831 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
833 placeholderFontstyleMap.Clear();
834 placeholderFontstyleMap.Insert( "slant", "roman" );
835 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
836 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderMapSet );
838 placeholderMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
840 placeholderFontstyleMap.Clear();
841 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
843 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderMapSet );
844 placeholderMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
845 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
846 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
851 // Positive Atlas Text Renderer test
852 int utcDaliTextEditorAtlasRenderP(void)
854 ToolkitTestApplication application;
855 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
856 StyleManager styleManager = StyleManager::Get();
857 styleManager.ApplyDefaultTheme();
858 TextEditor editor = TextEditor::New();
859 DALI_TEST_CHECK( editor );
861 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
863 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
865 Stage::GetCurrent().Add( editor );
869 // Render some text with the shared atlas backend
870 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
871 application.SendNotification();
872 application.Render();
876 tet_result(TET_FAIL);
881 // Positive test for the textChanged signal.
882 int utcDaliTextEditorTextChangedP(void)
884 ToolkitTestApplication application;
885 tet_infoline(" utcDaliTextEditorTextChangedP");
886 TextEditor editor = TextEditor::New();
887 DALI_TEST_CHECK( editor );
889 Stage::GetCurrent().Add( editor );
891 // connect to the text changed signal.
892 ConnectionTracker* testTracker = new ConnectionTracker();
893 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
894 bool textChangedSignal = false;
895 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
897 gTextChangedCallBackCalled = false;
898 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
899 DALI_TEST_CHECK( gTextChangedCallBackCalled );
900 DALI_TEST_CHECK( textChangedSignal );
902 application.SendNotification();
904 editor.SetKeyInputFocus();
906 gTextChangedCallBackCalled = false;
907 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
908 DALI_TEST_CHECK( gTextChangedCallBackCalled );
913 int utcDaliTextEditorInputStyleChanged01(void)
915 ToolkitTestApplication application;
916 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
918 // The text-editor emits signals when the input style changes. These changes of style are
919 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
920 // can't be emitted during the size negotiation as the callbacks may update the UI.
921 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
922 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
923 application.CreateAdaptor();
927 char* pathNamePtr = get_current_dir_name();
928 const std::string pathName( pathNamePtr );
931 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
932 fontClient.SetDpi( 93u, 93u );
934 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
935 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
937 TextEditor editor = TextEditor::New();
938 DALI_TEST_CHECK( editor );
941 editor.SetSize( 300.f, 50.f );
942 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
943 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
945 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
946 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
948 // connect to the text changed signal.
949 ConnectionTracker* testTracker = new ConnectionTracker();
950 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
951 bool inputStyleChangedSignal = false;
952 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
954 Stage::GetCurrent().Add( editor );
957 application.SendNotification();
958 application.Render();
960 // Executes the idle callbacks added by the text control on the change of input style.
961 application.RunIdles();
963 gInputStyleChangedCallbackCalled = false;
964 gInputStyleMask = TextEditor::InputStyle::NONE;
965 inputStyleChangedSignal = false;
967 // Create a tap event to touch the text editor.
968 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
969 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
972 application.SendNotification();
973 application.Render();
975 // Executes the idle callbacks added by the text control on the change of input style.
976 application.RunIdles();
978 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
979 if( gInputStyleChangedCallbackCalled )
981 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
983 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
984 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
986 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
987 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
989 DALI_TEST_CHECK( inputStyleChangedSignal );
991 gInputStyleChangedCallbackCalled = false;
992 gInputStyleMask = TextEditor::InputStyle::NONE;
993 inputStyleChangedSignal = false;
995 // Create a tap event to touch the text editor.
996 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
997 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1000 application.SendNotification();
1001 application.Render();
1003 // Executes the idle callbacks added by the text control on the change of input style.
1004 application.RunIdles();
1006 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1007 DALI_TEST_CHECK( !inputStyleChangedSignal );
1009 gInputStyleChangedCallbackCalled = false;
1010 gInputStyleMask = TextEditor::InputStyle::NONE;
1011 inputStyleChangedSignal = false;
1013 // Create a tap event to touch the text editor.
1014 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1015 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1017 // Render and notify
1018 application.SendNotification();
1019 application.Render();
1021 // Executes the idle callbacks added by the text control on the change of input style.
1022 application.RunIdles();
1024 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1025 if( gInputStyleChangedCallbackCalled )
1027 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1029 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1030 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1032 DALI_TEST_CHECK( inputStyleChangedSignal );
1034 gInputStyleChangedCallbackCalled = false;
1035 gInputStyleMask = TextEditor::InputStyle::NONE;
1036 inputStyleChangedSignal = false;
1038 // Create a tap event to touch the text editor.
1039 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1040 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1042 // Render and notify
1043 application.SendNotification();
1044 application.Render();
1046 // Executes the idle callbacks added by the text control on the change of input style.
1047 application.RunIdles();
1049 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1050 if( gInputStyleChangedCallbackCalled )
1052 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1054 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1055 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1057 Property::Map fontStyleMapSet;
1058 Property::Map fontStyleMapGet;
1060 fontStyleMapSet.Insert( "weight", "bold" );
1062 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1063 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1064 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1066 DALI_TEST_CHECK( inputStyleChangedSignal );
1068 gInputStyleChangedCallbackCalled = false;
1069 gInputStyleMask = TextEditor::InputStyle::NONE;
1070 inputStyleChangedSignal = false;
1072 // Create a tap event to touch the text editor.
1073 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1074 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1076 // Render and notify
1077 application.SendNotification();
1078 application.Render();
1080 // Executes the idle callbacks added by the text control on the change of input style.
1081 application.RunIdles();
1083 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1084 DALI_TEST_CHECK( !inputStyleChangedSignal );
1086 gInputStyleChangedCallbackCalled = false;
1087 gInputStyleMask = TextEditor::InputStyle::NONE;
1088 inputStyleChangedSignal = false;
1090 // Create a tap event to touch the text editor.
1091 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1092 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1094 // Render and notify
1095 application.SendNotification();
1096 application.Render();
1098 // Executes the idle callbacks added by the text control on the change of input style.
1099 application.RunIdles();
1101 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1102 if( gInputStyleChangedCallbackCalled )
1104 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1106 Property::Map fontStyleMapSet;
1107 Property::Map fontStyleMapGet;
1109 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1110 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1111 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1113 DALI_TEST_CHECK( inputStyleChangedSignal );
1115 gInputStyleChangedCallbackCalled = false;
1116 gInputStyleMask = TextEditor::InputStyle::NONE;
1117 inputStyleChangedSignal = false;
1119 // Create a tap event to touch the text editor.
1120 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1121 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1123 // Render and notify
1124 application.SendNotification();
1125 application.Render();
1127 // Executes the idle callbacks added by the text control on the change of input style.
1128 application.RunIdles();
1130 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1131 DALI_TEST_CHECK( !inputStyleChangedSignal );
1136 int utcDaliTextEditorInputStyleChanged02(void)
1138 ToolkitTestApplication application;
1139 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1141 // The text-editor emits signals when the input style changes. These changes of style are
1142 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1143 // can't be emitted during the size negotiation as the callbacks may update the UI.
1144 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1145 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1146 application.CreateAdaptor();
1150 char* pathNamePtr = get_current_dir_name();
1151 const std::string pathName( pathNamePtr );
1152 free( pathNamePtr );
1154 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1155 fontClient.SetDpi( 93u, 93u );
1157 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1158 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1160 TextEditor editor = TextEditor::New();
1161 DALI_TEST_CHECK( editor );
1164 editor.SetSize( 300.f, 50.f );
1165 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1166 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1168 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1169 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>" );
1171 // connect to the text changed signal.
1172 ConnectionTracker* testTracker = new ConnectionTracker();
1173 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1174 bool inputStyleChangedSignal = false;
1175 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1177 Stage::GetCurrent().Add( editor );
1179 // Render and notify
1180 application.SendNotification();
1181 application.Render();
1183 // Executes the idle callbacks added by the text control on the change of input style.
1184 application.RunIdles();
1186 gInputStyleChangedCallbackCalled = false;
1187 gInputStyleMask = TextEditor::InputStyle::NONE;
1188 inputStyleChangedSignal = false;
1190 // Create a tap event to touch the text editor.
1191 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1192 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1193 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1194 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1196 // Render and notify
1197 application.SendNotification();
1198 application.Render();
1200 // Executes the idle callbacks added by the text control on the change of input style.
1201 application.RunIdles();
1203 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1204 if( gInputStyleChangedCallbackCalled )
1206 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1207 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1208 TextEditor::InputStyle::POINT_SIZE |
1209 TextEditor::InputStyle::COLOR ),
1212 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1213 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1215 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1216 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1218 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1219 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1221 DALI_TEST_CHECK( inputStyleChangedSignal );
1223 gInputStyleChangedCallbackCalled = false;
1224 gInputStyleMask = TextEditor::InputStyle::NONE;
1225 inputStyleChangedSignal = false;
1227 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1229 // Render and notify
1230 application.SendNotification();
1231 application.Render();
1233 // Executes the idle callbacks added by the text control on the change of input style.
1234 application.RunIdles();
1236 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1237 if( gInputStyleChangedCallbackCalled )
1239 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1240 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1243 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1244 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1246 DALI_TEST_CHECK( inputStyleChangedSignal );
1248 gInputStyleChangedCallbackCalled = false;
1249 gInputStyleMask = TextEditor::InputStyle::NONE;
1250 inputStyleChangedSignal = false;
1252 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1254 // Render and notify
1255 application.SendNotification();
1256 application.Render();
1258 // Executes the idle callbacks added by the text control on the change of input style.
1259 application.RunIdles();
1261 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1262 DALI_TEST_CHECK( !inputStyleChangedSignal );
1264 gInputStyleChangedCallbackCalled = false;
1265 gInputStyleMask = TextEditor::InputStyle::NONE;
1266 inputStyleChangedSignal = false;
1268 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1270 // Render and notify
1271 application.SendNotification();
1272 application.Render();
1274 // Executes the idle callbacks added by the text control on the change of input style.
1275 application.RunIdles();
1277 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1278 if( gInputStyleChangedCallbackCalled )
1280 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1281 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1284 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1285 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1287 DALI_TEST_CHECK( inputStyleChangedSignal );
1289 gInputStyleChangedCallbackCalled = false;
1290 gInputStyleMask = TextEditor::InputStyle::NONE;
1291 inputStyleChangedSignal = false;
1293 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1295 Property::Map fontStyleMapSet;
1296 fontStyleMapSet.Insert( "weight", "thin" );
1297 fontStyleMapSet.Insert( "width", "condensed" );
1298 fontStyleMapSet.Insert( "slant", "italic" );
1300 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1301 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1302 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1304 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1305 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1306 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1307 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1309 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1311 // Render and notify
1312 application.SendNotification();
1313 application.Render();
1315 // Executes the idle callbacks added by the text control on the change of input style.
1316 application.RunIdles();
1318 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1319 DALI_TEST_CHECK( !inputStyleChangedSignal );
1321 // Create a tap event to touch the text editor.
1322 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1323 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1325 // Render and notify
1326 application.SendNotification();
1327 application.Render();
1329 // Executes the idle callbacks added by the text control on the change of input style.
1330 application.RunIdles();
1332 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1333 if( gInputStyleChangedCallbackCalled )
1335 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1336 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1337 TextEditor::InputStyle::POINT_SIZE |
1338 TextEditor::InputStyle::FONT_STYLE |
1339 TextEditor::InputStyle::LINE_SPACING |
1340 TextEditor::InputStyle::UNDERLINE |
1341 TextEditor::InputStyle::SHADOW |
1342 TextEditor::InputStyle::EMBOSS |
1343 TextEditor::InputStyle::OUTLINE ),
1346 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1347 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1349 DALI_TEST_CHECK( inputStyleChangedSignal );
1351 gInputStyleChangedCallbackCalled = false;
1352 gInputStyleMask = TextEditor::InputStyle::NONE;
1353 inputStyleChangedSignal = false;
1355 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1357 fontStyleMapSet.Clear();
1358 fontStyleMapSet.Insert( "weight", "black" );
1359 fontStyleMapSet.Insert( "width", "expanded" );
1360 fontStyleMapSet.Insert( "slant", "oblique" );
1362 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1364 // Create a tap event to touch the text editor.
1365 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1366 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1368 // Render and notify
1369 application.SendNotification();
1370 application.Render();
1372 // Executes the idle callbacks added by the text control on the change of input style.
1373 application.RunIdles();
1375 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1376 if( gInputStyleChangedCallbackCalled )
1378 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1379 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1380 TextEditor::InputStyle::POINT_SIZE |
1381 TextEditor::InputStyle::FONT_STYLE ),
1384 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1385 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1387 DALI_TEST_CHECK( inputStyleChangedSignal );
1392 int utcDaliTextEditorEvent01(void)
1394 ToolkitTestApplication application;
1395 tet_infoline(" utcDaliTextEditorEvent01");
1397 // Creates a tap event. After creating a tap event the text editor should
1398 // have the focus and add text with key events should be possible.
1400 TextEditor editor = TextEditor::New();
1401 DALI_TEST_CHECK( editor );
1403 Stage::GetCurrent().Add( editor );
1405 editor.SetSize( 300.f, 50.f );
1406 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1407 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1409 // Avoid a crash when core load gl resources.
1410 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1412 // Render and notify
1413 application.SendNotification();
1414 application.Render();
1416 // Add a key event but as the text editor has not the focus it should do nothing.
1417 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1419 // Render and notify
1420 application.SendNotification();
1421 application.Render();
1423 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1425 // Create a tap event to touch the text editor.
1426 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1427 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1429 // Render and notify
1430 application.SendNotification();
1431 application.Render();
1433 // Now the text editor has the focus, so it can handle the key events.
1434 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1435 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1437 // Render and notify
1438 application.SendNotification();
1439 application.Render();
1441 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1443 // Create a second text editor and send key events to it.
1444 TextEditor editor2 = TextEditor::New();
1446 editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1447 editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1448 editor2.SetSize( 100.f, 100.f );
1449 editor2.SetPosition( 100.f, 100.f );
1451 Stage::GetCurrent().Add( editor2 );
1453 // Render and notify
1454 application.SendNotification();
1455 application.Render();
1457 // Create a tap event on the second text editor.
1458 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1459 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1461 // Render and notify
1462 application.SendNotification();
1463 application.Render();
1465 // The second text editor has the focus. It should handle the key events.
1466 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1467 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1469 // Render and notify
1470 application.SendNotification();
1471 application.Render();
1473 // Check the text has been added to the second text editor.
1474 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1479 int utcDaliTextEditorEvent02(void)
1481 ToolkitTestApplication application;
1482 tet_infoline(" utcDaliTextEditorEvent02");
1484 // Checks if the right number of actors are created.
1486 TextEditor editor = TextEditor::New();
1487 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1488 DALI_TEST_CHECK( editor );
1490 Stage::GetCurrent().Add( editor );
1492 editor.SetSize( 300.f, 50.f );
1493 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1494 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1496 // Avoid a crash when core load gl resources.
1497 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1499 // Render and notify
1500 application.SendNotification();
1501 application.Render();
1503 // Check there are the expected number of children (the stencil).
1504 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1506 Actor stencil = editor.GetChildAt( 0u );
1508 // Create a tap event to touch the text editor.
1509 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1510 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1512 // Render and notify
1513 application.SendNotification();
1514 application.Render();
1516 Actor layer = editor.GetChildAt( 1u );
1517 DALI_TEST_CHECK( layer.IsLayer() );
1519 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1520 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1522 // Now the text editor has the focus, so it can handle the key events.
1523 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1524 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1526 // Render and notify
1527 application.SendNotification();
1528 application.Render();
1530 // Checks the cursor and the renderer have been created.
1531 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1532 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1534 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1535 DALI_TEST_CHECK( cursor );
1537 // The stencil actor has a container with all the actors which contain the text renderers.
1538 Actor container = stencil.GetChildAt( 0u );
1539 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1541 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1542 DALI_TEST_CHECK( renderer );
1545 // Move the cursor and check the position changes.
1546 Vector3 position1 = cursor.GetCurrentPosition();
1548 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1549 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1551 // Render and notify
1552 application.SendNotification();
1553 application.Render();
1555 Vector3 position2 = cursor.GetCurrentPosition();
1557 DALI_TEST_CHECK( position2.x < position1.x );
1559 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1560 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1562 // Render and notify
1563 application.SendNotification();
1564 application.Render();
1566 Vector3 position3 = cursor.GetCurrentPosition();
1568 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1570 // Send some taps and check the cursor positions.
1572 // Try to tap at the beginning.
1573 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1574 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1576 // Render and notify
1577 application.SendNotification();
1578 application.Render();
1580 // Cursor position should be the same than position1.
1581 Vector3 position4 = cursor.GetCurrentPosition();
1583 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1585 // Tap away from the start position.
1586 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1587 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1589 // Render and notify
1590 application.SendNotification();
1591 application.Render();
1593 Vector3 position5 = cursor.GetCurrentPosition();
1595 DALI_TEST_CHECK( position5.x > position4.x );
1597 // Remove all the text.
1598 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1599 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1600 editor.SetProperty( TextEditor::Property::TEXT, "" );
1602 // Render and notify
1603 application.SendNotification();
1604 application.Render();
1606 // Cursor position should be the same than position2.
1607 Vector3 position6 = cursor.GetCurrentPosition();
1609 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1611 // Should not be a renderer.
1612 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1617 int utcDaliTextEditorEvent03(void)
1619 ToolkitTestApplication application;
1620 tet_infoline(" utcDaliTextEditorEvent03");
1622 // Checks if the highlight actor is created.
1624 TextEditor editor = TextEditor::New();
1625 DALI_TEST_CHECK( editor );
1627 Stage::GetCurrent().Add( editor );
1629 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1630 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1631 editor.SetSize( 30.f, 50.f );
1632 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1633 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1635 // Avoid a crash when core load gl resources.
1636 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1638 // Render and notify
1639 application.SendNotification();
1640 application.Render();
1642 // Send some taps and check text controller with clipboard window
1643 Dali::Clipboard clipboard = Clipboard::Get();
1644 clipboard.ShowClipboard();
1645 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1646 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1647 clipboard.HideClipboard();
1649 // Render and notify
1650 application.SendNotification();
1651 application.Render();
1653 // Tap first to get the focus.
1654 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1655 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1657 // Render and notify
1658 application.SendNotification();
1659 application.Render();
1661 // Double tap to select a word.
1662 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1663 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1665 // Render and notify
1666 application.SendNotification();
1667 application.Render();
1669 // The stencil actor should have two actors: the renderer and the highlight actor.
1670 Actor stencil = editor.GetChildAt( 0u );
1672 // Highlight needs to be drawn before text, so should come first in child order
1673 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1674 DALI_TEST_CHECK( highlight );
1676 // The stencil actor has a container with all the actors which contain the text renderers.
1677 Actor container = stencil.GetChildAt( 1u );
1678 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1680 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1681 DALI_TEST_CHECK( renderer );
1684 // Double tap out of bounds
1685 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1686 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1688 // Render and notify
1689 application.SendNotification();
1690 application.Render();
1692 // The stencil actor should have one actors: the renderer actor.
1693 stencil = editor.GetChildAt( 0u );
1695 // The stencil actor has a container with all the actors which contain the text renderers.
1696 container = stencil.GetChildAt( 0u );
1697 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1699 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1700 DALI_TEST_CHECK( renderer );
1706 int utcDaliTextEditorEvent04(void)
1708 ToolkitTestApplication application;
1709 tet_infoline(" utcDaliTextEditorEvent04");
1711 // Checks if the highlight actor is created.
1713 TextEditor editor = TextEditor::New();
1714 DALI_TEST_CHECK( editor );
1716 Stage::GetCurrent().Add( editor );
1718 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1719 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1720 editor.SetSize( 100.f, 50.f );
1721 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1722 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1724 // Avoid a crash when core load gl resources.
1725 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1727 // Render and notify
1728 application.SendNotification();
1729 application.Render();
1731 // Tap on the text editor
1732 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1733 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1735 // Render and notify
1736 application.SendNotification();
1737 application.Render();
1739 // Move at the end of the text.
1740 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1741 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1743 // Render and notify
1744 application.SendNotification();
1745 application.Render();
1747 for( unsigned int index = 0u; index < 10u; ++index )
1749 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1750 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1752 // Render and notify
1753 application.SendNotification();
1754 application.Render();
1758 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1760 // Render and notify
1761 application.SendNotification();
1762 application.Render();
1764 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1766 // Add some key events
1767 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1768 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1770 // Render and notify
1771 application.SendNotification();
1772 application.Render();
1774 for( unsigned int index = 0u; index < 10u; ++index )
1776 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1777 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1779 // Render and notify
1780 application.SendNotification();
1781 application.Render();
1785 application.ProcessEvent( GenerateKey( " ", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1787 // Render and notify
1788 application.SendNotification();
1789 application.Render();
1791 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1796 int utcDaliTextEditorEvent05(void)
1798 ToolkitTestApplication application;
1799 tet_infoline(" utcDaliTextEditorEvent05");
1801 // Checks if the highlight actor is created.
1803 TextEditor editor = TextEditor::New();
1804 DALI_TEST_CHECK( editor );
1806 Stage::GetCurrent().Add( editor );
1808 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1809 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1810 editor.SetSize( 50.f, 50.f );
1811 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1812 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1813 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
1814 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1815 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, true );
1816 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1817 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1819 // Avoid a crash when core load gl resources.
1820 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1822 // Render and notify
1823 application.SendNotification();
1824 application.Render();
1826 // Tap on the text editor
1827 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1828 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1830 // Render and notify
1831 application.SendNotification();
1832 application.Render();
1834 // Move at the end of the text.
1835 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1836 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1838 // Render and notify
1839 application.SendNotification();
1840 application.Render();
1842 for( unsigned int index = 0u; index < 10u; ++index )
1845 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1847 // Render and notify
1848 application.SendNotification();
1849 application.Render();
1851 // Modify duration after scroll is enabled
1852 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1854 // Continuous scroll left to increase coverage
1855 for( unsigned int index = 0u; index < 10u; ++index )
1857 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1859 // Render and notify
1860 application.SendNotification();
1861 application.Render();
1863 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1864 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1865 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1866 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1867 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1869 // Press Escape to increase coverage
1870 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1871 application.SendNotification();
1872 application.Render();
1874 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1879 int utcDaliTextEditorEvent06(void)
1881 ToolkitTestApplication application;
1882 tet_infoline(" utcDaliTextEditorEvent06");
1884 // Checks if the highlight actor is created.
1886 TextEditor editor = TextEditor::New();
1887 DALI_TEST_CHECK( editor );
1889 Stage::GetCurrent().Add( editor );
1891 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
1892 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1893 editor.SetSize( 100.f, 50.f );
1894 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1895 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1897 // Avoid a crash when core load gl resources.
1898 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1900 // Render and notify
1901 application.SendNotification();
1902 application.Render();
1904 // Tap on the text editor
1905 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1906 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1908 // Render and notify
1909 application.SendNotification();
1910 application.Render();
1912 // Move to seconds line of the text.
1913 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1915 // Render and notify
1916 application.SendNotification();
1917 application.Render();
1919 float layoutHeight = editor.GetHeightForWidth( 100.f );
1922 // Add another script characters ( glyph height is defferent )
1923 application.ProcessEvent( GenerateKey( "d", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1924 application.ProcessEvent( GenerateKey( "d", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1926 // Delete characters
1927 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1928 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
1930 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
1932 // Render and notify
1933 application.SendNotification();
1934 application.Render();
1936 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1943 int utcDaliTextEditorHandles(void)
1945 ToolkitTestApplication application;
1946 tet_infoline(" utcDaliTextEditorHandles");
1948 TextEditor editor = TextEditor::New();
1949 DALI_TEST_CHECK( editor );
1951 Stage::GetCurrent().Add( editor );
1953 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1954 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1955 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
1956 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
1958 editor.SetSize( 30.f, 500.f );
1959 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1960 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1962 // Avoid a crash when core load gl resources.
1963 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1965 // Render and notify
1966 application.SendNotification();
1967 application.Render();
1969 // Tap first to get the focus.
1970 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1971 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1973 // Render and notify
1974 application.SendNotification();
1975 application.Render();
1977 // Tap to create the grab handle.
1978 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1979 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1981 // Render and notify
1982 application.SendNotification();
1983 application.Render();
1985 // Get the active layer where the text's decoration is added.
1986 Actor activeLayer = editor.GetChildAt( 1u );
1988 // Get the handle's actor.
1989 Actor handle = activeLayer.GetChildAt( 1u );
1990 handle.SetSize( 100.f, 100.f );
1992 // Render and notify
1993 application.SendNotification();
1994 application.Render();
1996 // Touch the grab handle to set it as pressed.
1997 Vector2 touchPos( 10.0f, 50.0f );
1998 Dali::Integration::TouchEvent event;
1999 event = Dali::Integration::TouchEvent();
2000 event.AddPoint( GetPointDownInside( touchPos ) );
2001 application.ProcessEvent( event );
2003 // Render and notify
2004 application.SendNotification();
2005 application.Render();
2007 // drag grab handle right
2008 SendPan(application, Gesture::Possible, touchPos);
2009 SendPan(application, Gesture::Started, touchPos);
2011 Wait(application, 100);
2013 for(int i = 0;i<20;i++)
2015 SendPan(application, Gesture::Continuing, touchPos);
2020 SendPan(application, Gesture::Finished, touchPos);
2023 // Release the grab handle.
2024 event = Dali::Integration::TouchEvent();
2025 event.AddPoint( GetPointUpInside( touchPos ) );
2026 application.ProcessEvent( event );
2028 // Render and notify
2029 application.SendNotification();
2030 application.Render();
2036 int utcDaliTextEditorUnderPropertyStringP(void)
2038 ToolkitTestApplication application;
2039 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2040 TextEditor editor = TextEditor::New();
2041 DALI_TEST_CHECK( editor );
2043 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2045 Stage::GetCurrent().Add( editor );
2047 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2048 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2050 tet_infoline("Set underline settings with a map");
2051 // Check the input underline property
2052 Property::Map underlineMapSet;
2053 Property::Map underlineMapGet;
2054 underlineMapSet.Insert( "enable", "true" );
2055 underlineMapSet.Insert( "color", "blue" );
2056 underlineMapSet.Insert( "height", "2" );
2058 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2059 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2060 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2061 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2063 tet_infoline("Set underline settings with a string");
2064 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2065 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2068 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2070 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2071 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2072 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2073 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2075 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2080 int utcDaliTextEditorShadowPropertyStringP(void)
2082 ToolkitTestApplication application;
2083 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2085 TextEditor editor = TextEditor::New();
2087 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\"}" );
2089 Stage::GetCurrent().Add( editor );
2091 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\"}" );
2093 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2097 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2102 int utcDaliTextEditorFontStylePropertyStringP(void)
2104 ToolkitTestApplication application;
2105 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2107 TextEditor editor = TextEditor::New();
2109 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2111 Stage::GetCurrent().Add( editor );
2113 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2115 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2119 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2124 int utcDaliTextEditorGetPropertyLinecountP(void)
2126 ToolkitTestApplication application;
2128 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2132 TextEditor editor = TextEditor::New();
2133 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2134 editor.SetProperty( TextEditor::Property::TEXT,
2135 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2137 Stage::GetCurrent().Add( editor );
2139 editor.SetSize( 100.0f, 100.0f );
2140 lineCount = editor.GetProperty<int>( DevelTextEditor::Property::LINE_COUNT );
2141 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2143 editor.SetSize( 50.0f, 100.0f );
2144 lineCount = editor.GetProperty<int>( DevelTextEditor::Property::LINE_COUNT );
2145 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2150 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2153 ToolkitTestApplication application;
2154 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2156 TextEditor editor = TextEditor::New();
2157 DALI_TEST_CHECK( editor );
2159 Stage::GetCurrent().Add( editor );
2161 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2162 editor.SetSize( 50.f, 50.f );
2163 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2164 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2165 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, true );
2166 editor.SetKeyboardFocusable(true);
2168 bool startedCalled = false;
2169 bool finishedCalled = false;
2171 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2172 DevelTextEditor::ScrollStateChangedSignal( editor ).Connect( &callback, &ScrollStateChangeCallback::Callback );
2174 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2176 // Render and notify
2177 application.SendNotification();
2178 application.Render();
2180 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2181 application.SendNotification();
2182 application.Render(6000);
2184 application.SendNotification();
2185 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2186 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );