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";
100 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
102 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
103 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
105 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
106 const float TO_MILLISECONDS = 1000.f;
107 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
108 const float RENDER_FRAME_INTERVAL = 16.66f;
110 const float SCROLL_THRESHOLD = 10.f;
111 const float SCROLL_SPEED = 300.f;
113 const unsigned int DEFAULT_FONT_SIZE = 1152u;
114 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
116 const int KEY_A_CODE = 38;
117 const int KEY_D_CODE = 40;
118 const int KEY_WHITE_SPACE_CODE = 65;
120 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
122 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
124 static bool gTextChangedCallBackCalled;
125 static bool gInputStyleChangedCallbackCalled;
126 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
128 struct CallbackFunctor
130 CallbackFunctor(bool* callbackFlag)
131 : mCallbackFlag( callbackFlag )
137 *mCallbackFlag = true;
142 static void TestTextChangedCallback( TextEditor control )
144 tet_infoline(" TestTextChangedCallback");
146 gTextChangedCallBackCalled = true;
149 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
151 tet_infoline(" TestInputStyleChangedCallback");
153 gInputStyleChangedCallbackCalled = true;
154 gInputStyleMask = mask;
157 // Generate a TapGestureEvent to send to Core.
158 Integration::TapGestureEvent GenerateTap(
159 Gesture::State state,
160 unsigned int numberOfTaps,
161 unsigned int numberOfTouches,
164 Integration::TapGestureEvent tap( state );
166 tap.numberOfTaps = numberOfTaps;
167 tap.numberOfTouches = numberOfTouches;
173 // Generate a PanGestureEvent to send to Core
174 Integration::PanGestureEvent GeneratePan( Gesture::State state,
175 const Vector2& previousPosition,
176 const Vector2& currentPosition,
177 unsigned long timeDelta,
178 unsigned int numberOfTouches = 1u )
180 Integration::PanGestureEvent pan(state);
182 pan.previousPosition = previousPosition;
183 pan.currentPosition = currentPosition;
184 pan.timeDelta = timeDelta;
185 pan.numberOfTouches = numberOfTouches;
190 // Generate a KeyEvent to send to Core.
191 Integration::KeyEvent GenerateKey( const std::string& keyName,
192 const std::string& keyString,
195 unsigned long timeStamp,
196 const Integration::KeyEvent::State& keyState,
197 const std::string& deviceName,
198 const DevelKeyEvent::DeviceClass::Type& deviceClass )
200 return Integration::KeyEvent( keyName,
211 * Helper to generate PanGestureEvent
213 * @param[in] application Application instance
214 * @param[in] state The Gesture State
215 * @param[in] pos The current position of touch.
217 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
221 if( (state == Gesture::Started) ||
222 (state == Gesture::Possible) )
228 application.ProcessEvent( GeneratePan( state, last, pos, 16 ) );
235 * Simulate time passed by.
237 * @note this will always process at least 1 frame (1/60 sec)
239 * @param application Test application instance
240 * @param duration Time to pass in milliseconds.
241 * @return The actual time passed in milliseconds
243 static int Wait(ToolkitTestApplication& application, int duration = 0)
247 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
249 application.SendNotification();
250 application.Render(RENDER_FRAME_INTERVAL);
251 time += RENDER_FRAME_INTERVAL;
257 Dali::Integration::Point GetPointDownInside( Vector2& pos )
259 Dali::Integration::Point point;
260 point.SetState( PointState::DOWN );
261 point.SetScreenPosition( pos );
265 Dali::Integration::Point GetPointUpInside( Vector2& pos )
267 Dali::Integration::Point point;
268 point.SetState( PointState::UP );
269 point.SetScreenPosition( pos );
273 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
275 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
277 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
279 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
281 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
282 if( NULL != valueSet )
284 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
286 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
292 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
301 class ScrollStateChangeCallback : public Dali::ConnectionTracker
304 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
305 : mStartedCalled( startedCalled ),
306 mFinishedCalled( finishedCalled )
310 void Callback( TextEditor editor, DevelTextEditor::Scroll::Type type )
312 if( type == DevelTextEditor::Scroll::STARTED )
314 mStartedCalled = true;
316 else if( type == DevelTextEditor::Scroll::FINISHED )
318 mFinishedCalled = true;
322 bool& mStartedCalled;
323 bool& mFinishedCalled;
328 int UtcDaliToolkitTextEditorConstructorP(void)
330 ToolkitTestApplication application;
331 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
332 TextEditor textEditor;
333 DALI_TEST_CHECK( !textEditor );
337 int UtcDaliToolkitTextEditorNewP(void)
339 ToolkitTestApplication application;
340 tet_infoline(" UtcDaliToolkitTextEditorNewP");
341 TextEditor textEditor = TextEditor::New();
342 DALI_TEST_CHECK( textEditor );
346 int UtcDaliToolkitTextEditorDownCastP(void)
348 ToolkitTestApplication application;
349 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
350 TextEditor textEditor1 = TextEditor::New();
351 BaseHandle object( textEditor1 );
353 TextEditor textEditor2 = TextEditor::DownCast( object );
354 DALI_TEST_CHECK( textEditor2 );
356 TextEditor textEditor3 = DownCast< TextEditor >( object );
357 DALI_TEST_CHECK( textEditor3 );
361 int UtcDaliToolkitTextEditorDownCastN(void)
363 ToolkitTestApplication application;
364 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
365 BaseHandle uninitializedObject;
366 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
367 DALI_TEST_CHECK( !textEditor1 );
369 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
370 DALI_TEST_CHECK( !textEditor2 );
374 int UtcDaliToolkitTextEditorCopyConstructorP(void)
376 ToolkitTestApplication application;
377 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
378 TextEditor textEditor = TextEditor::New();
379 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
381 TextEditor copy( textEditor );
382 DALI_TEST_CHECK( copy );
383 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
387 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
389 ToolkitTestApplication application;
390 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
391 TextEditor textEditor = TextEditor::New();
392 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
394 TextEditor copy = textEditor;
395 DALI_TEST_CHECK( copy );
396 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
400 int UtcDaliTextEditorNewP(void)
402 ToolkitTestApplication application;
403 tet_infoline(" UtcDaliToolkitTextEditorNewP");
404 TextEditor textEditor = TextEditor::New();
405 DALI_TEST_CHECK( textEditor );
409 // Positive test case for a method
410 int UtcDaliTextEditorGetPropertyP(void)
412 ToolkitTestApplication application;
413 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
414 TextEditor editor = TextEditor::New();
415 DALI_TEST_CHECK( editor );
417 // Check Property Indices are correct
418 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextEditor::Property::RENDERING_BACKEND );
419 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
420 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
421 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
422 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
423 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
424 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
425 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
426 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
427 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
428 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
429 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
430 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
431 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
432 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
433 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
434 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
435 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
436 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
437 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
438 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
439 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
440 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
441 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
442 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
443 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
444 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
445 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
446 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
447 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
449 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
450 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
451 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
452 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
453 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
454 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
455 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
456 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
457 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
458 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
459 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == DevelTextEditor::Property::SMOOTH_SCROLL );
460 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == DevelTextEditor::Property::SMOOTH_SCROLL_DURATION );
461 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == DevelTextEditor::Property::ENABLE_SCROLL_BAR );
462 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION );
463 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION );
464 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == DevelTextEditor::Property::PIXEL_SIZE );
465 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == DevelTextEditor::Property::LINE_COUNT );
466 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
467 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
472 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
475 Property::Map imageMap;
476 imageMap[mapKey] =mapValue;
478 editor.SetProperty( property , imageMap );
479 Property::Value propValue = editor.GetProperty( property );
480 Property::Map* resultMap = propValue.GetMap();
482 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
490 // Positive test case for a method
491 int UtcDaliTextEditorSetPropertyP(void)
493 ToolkitTestApplication application;
494 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
495 TextEditor editor = TextEditor::New();
496 DALI_TEST_CHECK( editor );
497 Stage::GetCurrent().Add( editor );
499 // Note - we can't check the defaults since the stylesheets are platform-specific
501 // Check the render backend property.
502 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
503 DALI_TEST_EQUALS( (Text::RenderingType)editor.GetProperty<int>( TextEditor::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
505 // Check text property.
506 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
507 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
509 // Check text's color property
510 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
511 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
513 // Check font properties.
514 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
515 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
517 Property::Map fontStyleMapSet;
518 Property::Map fontStyleMapGet;
519 Property::Value* slantValue = NULL;
521 fontStyleMapSet.Insert( "weight", "bold" );
522 fontStyleMapSet.Insert( "width", "condensed" );
523 fontStyleMapSet.Insert( "slant", "italic" );
525 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
526 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
527 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
528 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
530 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
531 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
534 fontStyleMapSet.Clear();
535 fontStyleMapSet.Insert( "weight", "normal" );
536 fontStyleMapSet.Insert( "slant", "oblique" );
537 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
538 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
539 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
540 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
542 fontStyleMapSet.Clear();
543 fontStyleMapSet.Insert( "slant", "roman" );
544 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
545 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
547 // Replace 'roman' for 'normal'.
548 slantValue = fontStyleMapGet.Find( "slant" );
549 if( NULL != slantValue )
551 if( "normal" == slantValue->Get<std::string>() )
553 fontStyleMapGet["slant"] = "roman";
556 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
557 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
559 fontStyleMapSet.Clear();
561 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
562 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
563 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
564 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
566 // Check that the Alignment properties can be correctly set
567 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
568 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
570 // Check scroll properties.
571 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
572 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
573 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
574 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
576 // Check cursor properties
577 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
578 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
579 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
580 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
582 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
583 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
584 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
585 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
586 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
587 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
588 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
589 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
591 // Check handle images
592 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
593 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
594 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
595 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
596 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
598 // Check handle images
599 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
600 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
601 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
602 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
603 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
604 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
606 // Check the highlight color
607 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
608 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
610 // Decoration bounding box
611 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
612 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
614 // Check the enable markup property.
615 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
616 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
617 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
619 // Check input color property.
620 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
621 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
623 // Check input font properties.
624 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
625 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
627 fontStyleMapSet.Clear();
628 fontStyleMapSet.Insert( "weight", "bold" );
629 fontStyleMapSet.Insert( "width", "condensed" );
630 fontStyleMapSet.Insert( "slant", "italic" );
632 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
633 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
634 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
635 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
637 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
638 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
640 // Reset input font style.
641 fontStyleMapSet.Clear();
642 fontStyleMapSet.Insert( "weight", "normal" );
643 fontStyleMapSet.Insert( "slant", "oblique" );
645 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
646 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
647 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
648 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
650 fontStyleMapSet.Clear();
651 fontStyleMapSet.Insert( "slant", "roman" );
653 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
654 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
656 // Replace 'roman' for 'normal'.
657 slantValue = fontStyleMapGet.Find( "slant" );
658 if( NULL != slantValue )
660 if( "normal" == slantValue->Get<std::string>() )
662 fontStyleMapGet["slant"] = "roman";
665 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
666 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
668 fontStyleMapSet.Clear();
670 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
671 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
672 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
673 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
675 // Check the line spacing property
676 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
677 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
678 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
680 // Check the input line spacing property
681 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
682 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
683 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
685 // Check the underline property
687 Property::Map underlineMapSet;
688 Property::Map underlineMapGet;
690 underlineMapSet.Insert( "enable", "true" );
691 underlineMapSet.Insert( "color", "red" );
692 underlineMapSet.Insert( "height", "1" );
694 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
696 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
697 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
698 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
700 // Check the input underline property
701 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
702 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
704 // Check the shadow property
705 Property::Map shadowMapSet;
706 Property::Map shadowMapGet;
708 shadowMapSet.Insert( "color", "green" );
709 shadowMapSet.Insert( "offset", "2 2" );
711 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
713 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
714 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
715 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
717 // Check the input shadow property
718 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
719 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
721 // Check the emboss property
722 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
723 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
725 // Check the input emboss property
726 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
727 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
729 // Check the outline property
730 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
731 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
733 // Check the input outline property
734 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
735 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
737 // Check the smooth scroll property
738 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
739 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
740 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
742 // Check the smooth scroll duration property
743 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
744 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
746 // Check the scroll bar property
747 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
748 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, true );
749 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
751 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
752 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
753 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
754 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
756 // Check the pixel size of font
757 editor.SetProperty( DevelTextEditor::Property::PIXEL_SIZE, 20.f );
758 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
760 // Check placeholder text properties.
761 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
762 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
764 // Check placeholder text properties when focused.
765 editor.SetProperty( DevelControl::Property::STATE, "FOCUSED" );
766 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Focused Placeholder Text" );
767 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelControl::Property::STATE ), (int)DevelControl::FOCUSED, TEST_LOCATION );
768 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Focused Placeholder Text"), TEST_LOCATION );
770 // Check placeholder text's color property.
771 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
772 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
777 // Positive Atlas Text Renderer test
778 int utcDaliTextEditorAtlasRenderP(void)
780 ToolkitTestApplication application;
781 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
782 StyleManager styleManager = StyleManager::Get();
783 styleManager.ApplyDefaultTheme();
784 TextEditor editor = TextEditor::New();
785 DALI_TEST_CHECK( editor );
787 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
789 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
791 Stage::GetCurrent().Add( editor );
795 // Render some text with the shared atlas backend
796 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
797 application.SendNotification();
798 application.Render();
802 tet_result(TET_FAIL);
807 // Positive test for the textChanged signal.
808 int utcDaliTextEditorTextChangedP(void)
810 ToolkitTestApplication application;
811 tet_infoline(" utcDaliTextEditorTextChangedP");
812 TextEditor editor = TextEditor::New();
813 DALI_TEST_CHECK( editor );
815 Stage::GetCurrent().Add( editor );
817 // connect to the text changed signal.
818 ConnectionTracker* testTracker = new ConnectionTracker();
819 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
820 bool textChangedSignal = false;
821 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
823 gTextChangedCallBackCalled = false;
824 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
825 DALI_TEST_CHECK( gTextChangedCallBackCalled );
826 DALI_TEST_CHECK( textChangedSignal );
828 application.SendNotification();
830 editor.SetKeyInputFocus();
832 gTextChangedCallBackCalled = false;
833 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
834 DALI_TEST_CHECK( gTextChangedCallBackCalled );
839 int utcDaliTextEditorInputStyleChanged01(void)
841 ToolkitTestApplication application;
842 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
844 // The text-editor emits signals when the input style changes. These changes of style are
845 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
846 // can't be emitted during the size negotiation as the callbacks may update the UI.
847 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
848 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
849 application.CreateAdaptor();
853 char* pathNamePtr = get_current_dir_name();
854 const std::string pathName( pathNamePtr );
857 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
858 fontClient.SetDpi( 93u, 93u );
860 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
861 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
863 TextEditor editor = TextEditor::New();
864 DALI_TEST_CHECK( editor );
867 editor.SetSize( 300.f, 50.f );
868 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
869 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
871 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
872 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
874 // connect to the text changed signal.
875 ConnectionTracker* testTracker = new ConnectionTracker();
876 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
877 bool inputStyleChangedSignal = false;
878 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
880 Stage::GetCurrent().Add( editor );
883 application.SendNotification();
884 application.Render();
886 // Executes the idle callbacks added by the text control on the change of input style.
887 application.RunIdles();
889 gInputStyleChangedCallbackCalled = false;
890 gInputStyleMask = TextEditor::InputStyle::NONE;
891 inputStyleChangedSignal = false;
893 // Create a tap event to touch the text editor.
894 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
895 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
898 application.SendNotification();
899 application.Render();
901 // Executes the idle callbacks added by the text control on the change of input style.
902 application.RunIdles();
904 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
905 if( gInputStyleChangedCallbackCalled )
907 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
909 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
910 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
912 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
913 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
915 DALI_TEST_CHECK( inputStyleChangedSignal );
917 gInputStyleChangedCallbackCalled = false;
918 gInputStyleMask = TextEditor::InputStyle::NONE;
919 inputStyleChangedSignal = false;
921 // Create a tap event to touch the text editor.
922 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
923 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
926 application.SendNotification();
927 application.Render();
929 // Executes the idle callbacks added by the text control on the change of input style.
930 application.RunIdles();
932 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
933 DALI_TEST_CHECK( !inputStyleChangedSignal );
935 gInputStyleChangedCallbackCalled = false;
936 gInputStyleMask = TextEditor::InputStyle::NONE;
937 inputStyleChangedSignal = false;
939 // Create a tap event to touch the text editor.
940 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
941 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
944 application.SendNotification();
945 application.Render();
947 // Executes the idle callbacks added by the text control on the change of input style.
948 application.RunIdles();
950 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
951 if( gInputStyleChangedCallbackCalled )
953 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
955 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
956 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
958 DALI_TEST_CHECK( inputStyleChangedSignal );
960 gInputStyleChangedCallbackCalled = false;
961 gInputStyleMask = TextEditor::InputStyle::NONE;
962 inputStyleChangedSignal = false;
964 // Create a tap event to touch the text editor.
965 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
966 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
969 application.SendNotification();
970 application.Render();
972 // Executes the idle callbacks added by the text control on the change of input style.
973 application.RunIdles();
975 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
976 if( gInputStyleChangedCallbackCalled )
978 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
980 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
981 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
983 Property::Map fontStyleMapSet;
984 Property::Map fontStyleMapGet;
986 fontStyleMapSet.Insert( "weight", "bold" );
988 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
989 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
990 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
992 DALI_TEST_CHECK( inputStyleChangedSignal );
994 gInputStyleChangedCallbackCalled = false;
995 gInputStyleMask = TextEditor::InputStyle::NONE;
996 inputStyleChangedSignal = false;
998 // Create a tap event to touch the text editor.
999 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1000 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1002 // Render and notify
1003 application.SendNotification();
1004 application.Render();
1006 // Executes the idle callbacks added by the text control on the change of input style.
1007 application.RunIdles();
1009 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1010 DALI_TEST_CHECK( !inputStyleChangedSignal );
1012 gInputStyleChangedCallbackCalled = false;
1013 gInputStyleMask = TextEditor::InputStyle::NONE;
1014 inputStyleChangedSignal = false;
1016 // Create a tap event to touch the text editor.
1017 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1018 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1020 // Render and notify
1021 application.SendNotification();
1022 application.Render();
1024 // Executes the idle callbacks added by the text control on the change of input style.
1025 application.RunIdles();
1027 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1028 if( gInputStyleChangedCallbackCalled )
1030 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1032 Property::Map fontStyleMapSet;
1033 Property::Map fontStyleMapGet;
1035 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1036 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1037 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1039 DALI_TEST_CHECK( inputStyleChangedSignal );
1041 gInputStyleChangedCallbackCalled = false;
1042 gInputStyleMask = TextEditor::InputStyle::NONE;
1043 inputStyleChangedSignal = false;
1045 // Create a tap event to touch the text editor.
1046 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1047 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1049 // Render and notify
1050 application.SendNotification();
1051 application.Render();
1053 // Executes the idle callbacks added by the text control on the change of input style.
1054 application.RunIdles();
1056 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1057 DALI_TEST_CHECK( !inputStyleChangedSignal );
1062 int utcDaliTextEditorInputStyleChanged02(void)
1064 ToolkitTestApplication application;
1065 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1067 // The text-editor emits signals when the input style changes. These changes of style are
1068 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1069 // can't be emitted during the size negotiation as the callbacks may update the UI.
1070 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1071 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1072 application.CreateAdaptor();
1076 char* pathNamePtr = get_current_dir_name();
1077 const std::string pathName( pathNamePtr );
1078 free( pathNamePtr );
1080 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1081 fontClient.SetDpi( 93u, 93u );
1083 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1084 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1086 TextEditor editor = TextEditor::New();
1087 DALI_TEST_CHECK( editor );
1090 editor.SetSize( 300.f, 50.f );
1091 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1092 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1094 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1095 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>" );
1097 // connect to the text changed signal.
1098 ConnectionTracker* testTracker = new ConnectionTracker();
1099 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1100 bool inputStyleChangedSignal = false;
1101 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1103 Stage::GetCurrent().Add( editor );
1105 // Render and notify
1106 application.SendNotification();
1107 application.Render();
1109 // Executes the idle callbacks added by the text control on the change of input style.
1110 application.RunIdles();
1112 gInputStyleChangedCallbackCalled = false;
1113 gInputStyleMask = TextEditor::InputStyle::NONE;
1114 inputStyleChangedSignal = false;
1116 // Create a tap event to touch the text editor.
1117 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1118 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1119 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1120 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1122 // Render and notify
1123 application.SendNotification();
1124 application.Render();
1126 // Executes the idle callbacks added by the text control on the change of input style.
1127 application.RunIdles();
1129 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1130 if( gInputStyleChangedCallbackCalled )
1132 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1133 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1134 TextEditor::InputStyle::POINT_SIZE |
1135 TextEditor::InputStyle::COLOR ),
1138 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1139 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1141 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1142 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1144 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1145 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1147 DALI_TEST_CHECK( inputStyleChangedSignal );
1149 gInputStyleChangedCallbackCalled = false;
1150 gInputStyleMask = TextEditor::InputStyle::NONE;
1151 inputStyleChangedSignal = false;
1153 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1155 // Render and notify
1156 application.SendNotification();
1157 application.Render();
1159 // Executes the idle callbacks added by the text control on the change of input style.
1160 application.RunIdles();
1162 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1163 if( gInputStyleChangedCallbackCalled )
1165 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1166 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1169 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1170 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1172 DALI_TEST_CHECK( inputStyleChangedSignal );
1174 gInputStyleChangedCallbackCalled = false;
1175 gInputStyleMask = TextEditor::InputStyle::NONE;
1176 inputStyleChangedSignal = false;
1178 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1180 // Render and notify
1181 application.SendNotification();
1182 application.Render();
1184 // Executes the idle callbacks added by the text control on the change of input style.
1185 application.RunIdles();
1187 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1188 DALI_TEST_CHECK( !inputStyleChangedSignal );
1190 gInputStyleChangedCallbackCalled = false;
1191 gInputStyleMask = TextEditor::InputStyle::NONE;
1192 inputStyleChangedSignal = false;
1194 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
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::COLOR ),
1210 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1211 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1213 DALI_TEST_CHECK( inputStyleChangedSignal );
1215 gInputStyleChangedCallbackCalled = false;
1216 gInputStyleMask = TextEditor::InputStyle::NONE;
1217 inputStyleChangedSignal = false;
1219 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1221 Property::Map fontStyleMapSet;
1222 fontStyleMapSet.Insert( "weight", "thin" );
1223 fontStyleMapSet.Insert( "width", "condensed" );
1224 fontStyleMapSet.Insert( "slant", "italic" );
1226 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1227 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1228 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1230 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1231 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1232 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1233 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1235 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1237 // Render and notify
1238 application.SendNotification();
1239 application.Render();
1241 // Executes the idle callbacks added by the text control on the change of input style.
1242 application.RunIdles();
1244 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1245 DALI_TEST_CHECK( !inputStyleChangedSignal );
1247 // Create a tap event to touch the text editor.
1248 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1249 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1251 // Render and notify
1252 application.SendNotification();
1253 application.Render();
1255 // Executes the idle callbacks added by the text control on the change of input style.
1256 application.RunIdles();
1258 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1259 if( gInputStyleChangedCallbackCalled )
1261 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1262 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1263 TextEditor::InputStyle::POINT_SIZE |
1264 TextEditor::InputStyle::FONT_STYLE |
1265 TextEditor::InputStyle::LINE_SPACING |
1266 TextEditor::InputStyle::UNDERLINE |
1267 TextEditor::InputStyle::SHADOW |
1268 TextEditor::InputStyle::EMBOSS |
1269 TextEditor::InputStyle::OUTLINE ),
1272 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1273 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1275 DALI_TEST_CHECK( inputStyleChangedSignal );
1277 gInputStyleChangedCallbackCalled = false;
1278 gInputStyleMask = TextEditor::InputStyle::NONE;
1279 inputStyleChangedSignal = false;
1281 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1283 fontStyleMapSet.Clear();
1284 fontStyleMapSet.Insert( "weight", "black" );
1285 fontStyleMapSet.Insert( "width", "expanded" );
1286 fontStyleMapSet.Insert( "slant", "oblique" );
1288 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1290 // Create a tap event to touch the text editor.
1291 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1292 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1294 // Render and notify
1295 application.SendNotification();
1296 application.Render();
1298 // Executes the idle callbacks added by the text control on the change of input style.
1299 application.RunIdles();
1301 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1302 if( gInputStyleChangedCallbackCalled )
1304 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1305 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1306 TextEditor::InputStyle::POINT_SIZE |
1307 TextEditor::InputStyle::FONT_STYLE ),
1310 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1311 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1313 DALI_TEST_CHECK( inputStyleChangedSignal );
1318 int utcDaliTextEditorEvent01(void)
1320 ToolkitTestApplication application;
1321 tet_infoline(" utcDaliTextEditorEvent01");
1323 // Creates a tap event. After creating a tap event the text editor should
1324 // have the focus and add text with key events should be possible.
1326 TextEditor editor = TextEditor::New();
1327 DALI_TEST_CHECK( editor );
1329 Stage::GetCurrent().Add( editor );
1331 editor.SetSize( 300.f, 50.f );
1332 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1333 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1335 // Avoid a crash when core load gl resources.
1336 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1338 // Render and notify
1339 application.SendNotification();
1340 application.Render();
1342 // Add a key event but as the text editor has not the focus it should do nothing.
1343 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1345 // Render and notify
1346 application.SendNotification();
1347 application.Render();
1349 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1351 // Create a tap event to touch the text editor.
1352 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1353 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1355 // Render and notify
1356 application.SendNotification();
1357 application.Render();
1359 // Now the text editor has the focus, so it can handle the key events.
1360 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1361 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1363 // Render and notify
1364 application.SendNotification();
1365 application.Render();
1367 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1369 // Create a second text editor and send key events to it.
1370 TextEditor editor2 = TextEditor::New();
1372 editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1373 editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1374 editor2.SetSize( 100.f, 100.f );
1375 editor2.SetPosition( 100.f, 100.f );
1377 Stage::GetCurrent().Add( editor2 );
1379 // Render and notify
1380 application.SendNotification();
1381 application.Render();
1383 // Create a tap event on the second text editor.
1384 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1385 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1387 // Render and notify
1388 application.SendNotification();
1389 application.Render();
1391 // The second text editor has the focus. It should handle the key events.
1392 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1393 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1395 // Render and notify
1396 application.SendNotification();
1397 application.Render();
1399 // Check the text has been added to the second text editor.
1400 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1405 int utcDaliTextEditorEvent02(void)
1407 ToolkitTestApplication application;
1408 tet_infoline(" utcDaliTextEditorEvent02");
1410 // Checks if the right number of actors are created.
1412 TextEditor editor = TextEditor::New();
1413 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1414 DALI_TEST_CHECK( editor );
1416 Stage::GetCurrent().Add( editor );
1418 editor.SetSize( 300.f, 50.f );
1419 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1420 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1422 // Avoid a crash when core load gl resources.
1423 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1425 // Render and notify
1426 application.SendNotification();
1427 application.Render();
1429 // Check there are the expected number of children (the stencil).
1430 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1432 Actor stencil = editor.GetChildAt( 0u );
1434 // Create a tap event to touch the text editor.
1435 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1436 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1438 // Render and notify
1439 application.SendNotification();
1440 application.Render();
1442 Actor layer = editor.GetChildAt( 1u );
1443 DALI_TEST_CHECK( layer.IsLayer() );
1445 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1446 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1448 // Now the text editor has the focus, so it can handle the key events.
1449 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1450 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1452 // Render and notify
1453 application.SendNotification();
1454 application.Render();
1456 // Checks the cursor and the renderer have been created.
1457 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1458 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1460 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1461 DALI_TEST_CHECK( cursor );
1463 // The stencil actor has a container with all the actors which contain the text renderers.
1464 Actor container = stencil.GetChildAt( 0u );
1465 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1467 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1468 DALI_TEST_CHECK( renderer );
1471 // Move the cursor and check the position changes.
1472 Vector3 position1 = cursor.GetCurrentPosition();
1474 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1475 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1477 // Render and notify
1478 application.SendNotification();
1479 application.Render();
1481 Vector3 position2 = cursor.GetCurrentPosition();
1483 DALI_TEST_CHECK( position2.x < position1.x );
1485 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1486 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1488 // Render and notify
1489 application.SendNotification();
1490 application.Render();
1492 Vector3 position3 = cursor.GetCurrentPosition();
1494 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1496 // Send some taps and check the cursor positions.
1498 // Try to tap at the beginning.
1499 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1500 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1502 // Render and notify
1503 application.SendNotification();
1504 application.Render();
1506 // Cursor position should be the same than position1.
1507 Vector3 position4 = cursor.GetCurrentPosition();
1509 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1511 // Tap away from the start position.
1512 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1513 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1515 // Render and notify
1516 application.SendNotification();
1517 application.Render();
1519 Vector3 position5 = cursor.GetCurrentPosition();
1521 DALI_TEST_CHECK( position5.x > position4.x );
1523 // Remove all the text.
1524 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1525 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1526 editor.SetProperty( TextEditor::Property::TEXT, "" );
1528 // Render and notify
1529 application.SendNotification();
1530 application.Render();
1532 // Cursor position should be the same than position2.
1533 Vector3 position6 = cursor.GetCurrentPosition();
1535 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1537 // Should not be a renderer.
1538 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1543 int utcDaliTextEditorEvent03(void)
1545 ToolkitTestApplication application;
1546 tet_infoline(" utcDaliTextEditorEvent03");
1548 // Checks if the highlight actor is created.
1550 TextEditor editor = TextEditor::New();
1551 DALI_TEST_CHECK( editor );
1553 Stage::GetCurrent().Add( editor );
1555 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1556 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1557 editor.SetSize( 30.f, 50.f );
1558 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1559 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1561 // Avoid a crash when core load gl resources.
1562 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1564 // Render and notify
1565 application.SendNotification();
1566 application.Render();
1568 // Send some taps and check text controller with clipboard window
1569 Dali::Clipboard clipboard = Clipboard::Get();
1570 clipboard.ShowClipboard();
1571 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1572 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1573 clipboard.HideClipboard();
1575 // Render and notify
1576 application.SendNotification();
1577 application.Render();
1579 // Tap first to get the focus.
1580 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1581 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1583 // Render and notify
1584 application.SendNotification();
1585 application.Render();
1587 // Double tap to select a word.
1588 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1589 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1591 // Render and notify
1592 application.SendNotification();
1593 application.Render();
1595 // The stencil actor should have two actors: the renderer and the highlight actor.
1596 Actor stencil = editor.GetChildAt( 0u );
1598 // Highlight needs to be drawn before text, so should come first in child order
1599 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1600 DALI_TEST_CHECK( highlight );
1602 // The stencil actor has a container with all the actors which contain the text renderers.
1603 Actor container = stencil.GetChildAt( 1u );
1604 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1606 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1607 DALI_TEST_CHECK( renderer );
1610 // Double tap out of bounds
1611 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1612 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1614 // Render and notify
1615 application.SendNotification();
1616 application.Render();
1618 // The stencil actor should have one actors: the renderer actor.
1619 stencil = editor.GetChildAt( 0u );
1621 // The stencil actor has a container with all the actors which contain the text renderers.
1622 container = stencil.GetChildAt( 0u );
1623 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1625 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1626 DALI_TEST_CHECK( renderer );
1632 int utcDaliTextEditorEvent04(void)
1634 ToolkitTestApplication application;
1635 tet_infoline(" utcDaliTextEditorEvent04");
1637 // Checks if the highlight actor is created.
1639 TextEditor editor = TextEditor::New();
1640 DALI_TEST_CHECK( editor );
1642 Stage::GetCurrent().Add( editor );
1644 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1645 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1646 editor.SetSize( 100.f, 50.f );
1647 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1648 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1650 // Avoid a crash when core load gl resources.
1651 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1653 // Render and notify
1654 application.SendNotification();
1655 application.Render();
1657 // Tap on the text editor
1658 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1659 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1661 // Render and notify
1662 application.SendNotification();
1663 application.Render();
1665 // Move at the end of the text.
1666 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1667 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1669 // Render and notify
1670 application.SendNotification();
1671 application.Render();
1673 for( unsigned int index = 0u; index < 10u; ++index )
1675 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1676 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1678 // Render and notify
1679 application.SendNotification();
1680 application.Render();
1684 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1686 // Render and notify
1687 application.SendNotification();
1688 application.Render();
1690 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1692 // Add some key events
1693 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1694 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1696 // Render and notify
1697 application.SendNotification();
1698 application.Render();
1700 for( unsigned int index = 0u; index < 10u; ++index )
1702 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1703 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1705 // Render and notify
1706 application.SendNotification();
1707 application.Render();
1711 application.ProcessEvent( GenerateKey( " ", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1713 // Render and notify
1714 application.SendNotification();
1715 application.Render();
1717 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1722 int utcDaliTextEditorEvent05(void)
1724 ToolkitTestApplication application;
1725 tet_infoline(" utcDaliTextEditorEvent05");
1727 // Checks if the highlight actor is created.
1729 TextEditor editor = TextEditor::New();
1730 DALI_TEST_CHECK( editor );
1732 Stage::GetCurrent().Add( editor );
1734 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1735 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1736 editor.SetSize( 50.f, 50.f );
1737 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1738 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1739 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
1740 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1741 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, true );
1742 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1743 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1745 // Avoid a crash when core load gl resources.
1746 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1748 // Render and notify
1749 application.SendNotification();
1750 application.Render();
1752 // Tap on the text editor
1753 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1754 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1756 // Render and notify
1757 application.SendNotification();
1758 application.Render();
1760 // Move at the end of the text.
1761 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1762 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1764 // Render and notify
1765 application.SendNotification();
1766 application.Render();
1768 for( unsigned int index = 0u; index < 10u; ++index )
1771 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1773 // Render and notify
1774 application.SendNotification();
1775 application.Render();
1777 // Modify duration after scroll is enabled
1778 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1780 // Continuous scroll left to increase coverage
1781 for( unsigned int index = 0u; index < 10u; ++index )
1783 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1785 // Render and notify
1786 application.SendNotification();
1787 application.Render();
1789 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1790 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1791 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1792 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1793 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1795 // Press Escape to increase coverage
1796 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1797 application.SendNotification();
1798 application.Render();
1800 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1805 int utcDaliTextEditorEvent06(void)
1807 ToolkitTestApplication application;
1808 tet_infoline(" utcDaliTextEditorEvent06");
1810 // Checks if the highlight actor is created.
1812 TextEditor editor = TextEditor::New();
1813 DALI_TEST_CHECK( editor );
1815 Stage::GetCurrent().Add( editor );
1817 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
1818 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1819 editor.SetSize( 100.f, 50.f );
1820 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1821 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1823 // Avoid a crash when core load gl resources.
1824 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1826 // Render and notify
1827 application.SendNotification();
1828 application.Render();
1830 // Tap on the text editor
1831 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1832 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1834 // Render and notify
1835 application.SendNotification();
1836 application.Render();
1838 // Move to seconds line of the text.
1839 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1841 // Render and notify
1842 application.SendNotification();
1843 application.Render();
1845 float layoutHeight = editor.GetHeightForWidth( 100.f );
1848 // Add another script characters ( glyph height is defferent )
1849 application.ProcessEvent( GenerateKey( "d", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1850 application.ProcessEvent( GenerateKey( "d", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1852 // Delete characters
1853 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1854 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1856 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
1858 // Render and notify
1859 application.SendNotification();
1860 application.Render();
1862 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1869 int utcDaliTextEditorHandles(void)
1871 ToolkitTestApplication application;
1872 tet_infoline(" utcDaliTextEditorHandles");
1874 TextEditor editor = TextEditor::New();
1875 DALI_TEST_CHECK( editor );
1877 Stage::GetCurrent().Add( editor );
1879 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1880 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1881 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
1882 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
1884 editor.SetSize( 30.f, 500.f );
1885 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1886 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1888 // Avoid a crash when core load gl resources.
1889 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1891 // Render and notify
1892 application.SendNotification();
1893 application.Render();
1895 // Tap first to get the focus.
1896 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1897 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1899 // Render and notify
1900 application.SendNotification();
1901 application.Render();
1903 // Tap to create the grab handle.
1904 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1905 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1907 // Render and notify
1908 application.SendNotification();
1909 application.Render();
1911 // Get the active layer where the text's decoration is added.
1912 Actor activeLayer = editor.GetChildAt( 1u );
1914 // Get the handle's actor.
1915 Actor handle = activeLayer.GetChildAt( 1u );
1916 handle.SetSize( 100.f, 100.f );
1918 // Render and notify
1919 application.SendNotification();
1920 application.Render();
1922 // Touch the grab handle to set it as pressed.
1923 Vector2 touchPos( 10.0f, 50.0f );
1924 Dali::Integration::TouchEvent event;
1925 event = Dali::Integration::TouchEvent();
1926 event.AddPoint( GetPointDownInside( touchPos ) );
1927 application.ProcessEvent( event );
1929 // Render and notify
1930 application.SendNotification();
1931 application.Render();
1933 // drag grab handle right
1934 SendPan(application, Gesture::Possible, touchPos);
1935 SendPan(application, Gesture::Started, touchPos);
1937 Wait(application, 100);
1939 for(int i = 0;i<20;i++)
1941 SendPan(application, Gesture::Continuing, touchPos);
1946 SendPan(application, Gesture::Finished, touchPos);
1949 // Release the grab handle.
1950 event = Dali::Integration::TouchEvent();
1951 event.AddPoint( GetPointUpInside( touchPos ) );
1952 application.ProcessEvent( event );
1954 // Render and notify
1955 application.SendNotification();
1956 application.Render();
1962 int utcDaliTextEditorUnderPropertyStringP(void)
1964 ToolkitTestApplication application;
1965 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
1966 TextEditor editor = TextEditor::New();
1967 DALI_TEST_CHECK( editor );
1969 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
1971 Stage::GetCurrent().Add( editor );
1973 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
1974 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
1976 tet_infoline("Set underline settings with a map");
1977 // Check the input underline property
1978 Property::Map underlineMapSet;
1979 Property::Map underlineMapGet;
1980 underlineMapSet.Insert( "enable", "true" );
1981 underlineMapSet.Insert( "color", "blue" );
1982 underlineMapSet.Insert( "height", "2" );
1984 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
1985 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
1986 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
1987 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
1989 tet_infoline("Set underline settings with a string");
1990 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
1991 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
1994 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
1996 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
1997 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
1998 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
1999 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2001 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2006 int utcDaliTextEditorShadowPropertyStringP(void)
2008 ToolkitTestApplication application;
2009 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2011 TextEditor editor = TextEditor::New();
2013 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\"}" );
2015 Stage::GetCurrent().Add( editor );
2017 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\"}" );
2019 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2023 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2028 int utcDaliTextEditorFontStylePropertyStringP(void)
2030 ToolkitTestApplication application;
2031 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2033 TextEditor editor = TextEditor::New();
2035 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2037 Stage::GetCurrent().Add( editor );
2039 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2041 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2045 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2050 int utcDaliTextEditorGetPropertyLinecountP(void)
2052 ToolkitTestApplication application;
2054 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2058 TextEditor editor = TextEditor::New();
2059 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2060 editor.SetProperty( TextEditor::Property::TEXT,
2061 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2063 Stage::GetCurrent().Add( editor );
2065 editor.SetSize( 100.0f, 100.0f );
2066 lineCount = editor.GetProperty<int>( DevelTextEditor::Property::LINE_COUNT );
2067 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2069 editor.SetSize( 50.0f, 100.0f );
2070 lineCount = editor.GetProperty<int>( DevelTextEditor::Property::LINE_COUNT );
2071 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2076 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2079 ToolkitTestApplication application;
2080 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2082 TextEditor editor = TextEditor::New();
2083 DALI_TEST_CHECK( editor );
2085 Stage::GetCurrent().Add( editor );
2087 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2088 editor.SetSize( 50.f, 50.f );
2089 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2090 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2091 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, true );
2092 editor.SetKeyboardFocusable(true);
2094 bool startedCalled = false;
2095 bool finishedCalled = false;
2097 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2098 DevelTextEditor::ScrollStateChangedSignal( editor ).Connect( &callback, &ScrollStateChangeCallback::Callback );
2100 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2102 // Render and notify
2103 application.SendNotification();
2104 application.Render();
2106 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2107 application.SendNotification();
2108 application.Render(6000);
2110 application.SendNotification();
2111 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2112 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );