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/devel-api/adaptor-framework/key-devel.h>
24 #include <dali/integration-api/events/key-event-integ.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/integration-api/events/tap-gesture-event.h>
27 #include <dali/integration-api/events/pan-gesture-event.h>
28 #include <dali/integration-api/events/long-press-gesture-event.h>
29 #include <dali-toolkit-test-suite-utils.h>
30 #include <dali-toolkit/dali-toolkit.h>
31 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
34 using namespace Toolkit;
36 void dali_texteditor_startup(void)
38 test_return_value = TET_UNDEF;
41 void dali_texteditor_cleanup(void)
43 test_return_value = TET_PASS;
49 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
50 const char* const PROPERTY_NAME_TEXT = "text";
51 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
52 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
53 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
54 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
55 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
56 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
57 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
58 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
59 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
60 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
61 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
62 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
63 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
64 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
65 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
66 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
71 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
72 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
73 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
74 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
75 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
76 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
77 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
78 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
80 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
81 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
82 const char* const PROPERTY_NAME_UNDERLINE = "underline";
83 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
84 const char* const PROPERTY_NAME_SHADOW = "shadow";
85 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
86 const char* const PROPERTY_NAME_EMBOSS = "emboss";
87 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
88 const char* const PROPERTY_NAME_OUTLINE = "outline";
89 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
91 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
92 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
93 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
94 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
95 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
96 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
97 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
98 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
99 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
100 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
101 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
102 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
104 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
106 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
107 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
109 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
110 const float TO_MILLISECONDS = 1000.f;
111 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
112 const float RENDER_FRAME_INTERVAL = 16.66f;
114 const float SCROLL_THRESHOLD = 10.f;
115 const float SCROLL_SPEED = 300.f;
117 const unsigned int DEFAULT_FONT_SIZE = 1152u;
118 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
120 const int KEY_A_CODE = 38;
121 const int KEY_D_CODE = 40;
122 const int KEY_C_CODE = 54;
123 const int KEY_V_CODE = 55;
124 const int KEY_X_CODE = 53;
125 const int KEY_WHITE_SPACE_CODE = 65;
127 const int KEY_SHIFT_MODIFIER = 257;
128 const int KEY_CONTROL_MODIFIER = 258;
130 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
132 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
134 static bool gTextChangedCallBackCalled;
135 static bool gInputStyleChangedCallbackCalled;
136 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
138 struct CallbackFunctor
140 CallbackFunctor(bool* callbackFlag)
141 : mCallbackFlag( callbackFlag )
147 *mCallbackFlag = true;
152 static void TestTextChangedCallback( TextEditor control )
154 tet_infoline(" TestTextChangedCallback");
156 gTextChangedCallBackCalled = true;
159 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
161 tet_infoline(" TestInputStyleChangedCallback");
163 gInputStyleChangedCallbackCalled = true;
164 gInputStyleMask = mask;
167 // Generate a TapGestureEvent to send to Core.
168 Integration::TapGestureEvent GenerateTap(
169 Gesture::State state,
170 unsigned int numberOfTaps,
171 unsigned int numberOfTouches,
174 Integration::TapGestureEvent tap( state );
176 tap.numberOfTaps = numberOfTaps;
177 tap.numberOfTouches = numberOfTouches;
183 Integration::LongPressGestureEvent GenerateLongPress(
184 Gesture::State state,
185 unsigned int numberOfTouches,
188 Integration::LongPressGestureEvent longPress( state );
190 longPress.numberOfTouches = numberOfTouches;
191 longPress.point = point;
195 // Generate a PanGestureEvent to send to Core
196 Integration::PanGestureEvent GeneratePan( Gesture::State state,
197 const Vector2& previousPosition,
198 const Vector2& currentPosition,
199 unsigned long timeDelta,
200 unsigned int numberOfTouches = 1u )
202 Integration::PanGestureEvent pan(state);
204 pan.previousPosition = previousPosition;
205 pan.currentPosition = currentPosition;
206 pan.timeDelta = timeDelta;
207 pan.numberOfTouches = numberOfTouches;
212 // Generate a KeyEvent to send to Core.
213 Integration::KeyEvent GenerateKey( const std::string& keyName,
214 const std::string& keyString,
217 unsigned long timeStamp,
218 const Integration::KeyEvent::State& keyState,
219 const std::string& deviceName = DEFAULT_DEVICE_NAME,
220 const Device::Class::Type& deviceClass = Device::Class::NONE,
221 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
223 return Integration::KeyEvent( keyName,
235 * Helper to generate PanGestureEvent
237 * @param[in] application Application instance
238 * @param[in] state The Gesture State
239 * @param[in] pos The current position of touch.
241 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
245 if( (state == Gesture::Started) ||
246 (state == Gesture::Possible) )
252 application.ProcessEvent( GeneratePan( state, last, pos, 16 ) );
259 * Simulate time passed by.
261 * @note this will always process at least 1 frame (1/60 sec)
263 * @param application Test application instance
264 * @param duration Time to pass in milliseconds.
265 * @return The actual time passed in milliseconds
267 static int Wait(ToolkitTestApplication& application, int duration = 0)
271 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
273 application.SendNotification();
274 application.Render(RENDER_FRAME_INTERVAL);
275 time += RENDER_FRAME_INTERVAL;
281 Dali::Integration::Point GetPointDownInside( Vector2& pos )
283 Dali::Integration::Point point;
284 point.SetState( PointState::DOWN );
285 point.SetScreenPosition( pos );
289 Dali::Integration::Point GetPointUpInside( Vector2& pos )
291 Dali::Integration::Point point;
292 point.SetState( PointState::UP );
293 point.SetScreenPosition( pos );
297 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
299 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
301 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
303 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
305 Property::Value* valueSet = NULL;
306 if ( valueGet.first.type == Property::Key::INDEX )
308 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
312 // Get Key is a string so searching Set Map for a string key
313 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
316 if( NULL != valueSet )
318 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
320 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
326 if ( valueGet.first.type == Property::Key::INDEX )
328 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
332 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
342 class ScrollStateChangeCallback : public Dali::ConnectionTracker
345 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
346 : mStartedCalled( startedCalled ),
347 mFinishedCalled( finishedCalled )
351 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
353 if( type == TextEditor::Scroll::STARTED )
355 mStartedCalled = true;
357 else if( type == TextEditor::Scroll::FINISHED )
359 mFinishedCalled = true;
363 bool& mStartedCalled;
364 bool& mFinishedCalled;
369 int UtcDaliToolkitTextEditorConstructorP(void)
371 ToolkitTestApplication application;
372 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
373 TextEditor textEditor;
374 DALI_TEST_CHECK( !textEditor );
378 int UtcDaliToolkitTextEditorNewP(void)
380 ToolkitTestApplication application;
381 tet_infoline(" UtcDaliToolkitTextEditorNewP");
382 TextEditor textEditor = TextEditor::New();
383 DALI_TEST_CHECK( textEditor );
387 int UtcDaliToolkitTextEditorDownCastP(void)
389 ToolkitTestApplication application;
390 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
391 TextEditor textEditor1 = TextEditor::New();
392 BaseHandle object( textEditor1 );
394 TextEditor textEditor2 = TextEditor::DownCast( object );
395 DALI_TEST_CHECK( textEditor2 );
397 TextEditor textEditor3 = DownCast< TextEditor >( object );
398 DALI_TEST_CHECK( textEditor3 );
402 int UtcDaliToolkitTextEditorDownCastN(void)
404 ToolkitTestApplication application;
405 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
406 BaseHandle uninitializedObject;
407 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
408 DALI_TEST_CHECK( !textEditor1 );
410 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
411 DALI_TEST_CHECK( !textEditor2 );
415 int UtcDaliToolkitTextEditorCopyConstructorP(void)
417 ToolkitTestApplication application;
418 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
419 TextEditor textEditor = TextEditor::New();
420 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
422 TextEditor copy( textEditor );
423 DALI_TEST_CHECK( copy );
424 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
428 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
430 ToolkitTestApplication application;
431 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
432 TextEditor textEditor = TextEditor::New();
433 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
435 TextEditor copy = textEditor;
436 DALI_TEST_CHECK( copy );
437 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
441 int UtcDaliTextEditorNewP(void)
443 ToolkitTestApplication application;
444 tet_infoline(" UtcDaliToolkitTextEditorNewP");
445 TextEditor textEditor = TextEditor::New();
446 DALI_TEST_CHECK( textEditor );
450 // Positive test case for a method
451 int UtcDaliTextEditorGetPropertyP(void)
453 ToolkitTestApplication application;
454 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
455 TextEditor editor = TextEditor::New();
456 DALI_TEST_CHECK( editor );
458 // Check Property Indices are correct
459 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextEditor::Property::RENDERING_BACKEND );
460 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
461 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
462 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
463 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
464 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
465 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
466 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
467 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
468 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
469 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
470 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
471 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
472 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
473 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
474 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
475 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
476 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
477 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
478 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
479 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
480 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
481 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
482 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
483 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
484 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
485 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
486 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
487 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
488 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
490 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
491 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
492 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
493 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
494 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
495 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
496 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
497 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
498 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
499 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
500 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
501 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
502 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
503 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
504 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
505 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
506 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
507 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
508 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
509 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
510 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
511 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
516 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
519 Property::Map imageMap;
520 imageMap[mapKey] =mapValue;
522 editor.SetProperty( property , imageMap );
523 Property::Value propValue = editor.GetProperty( property );
524 Property::Map* resultMap = propValue.GetMap();
526 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
534 // Positive test case for a method
535 int UtcDaliTextEditorSetPropertyP(void)
537 ToolkitTestApplication application;
538 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
539 TextEditor editor = TextEditor::New();
540 DALI_TEST_CHECK( editor );
541 Stage::GetCurrent().Add( editor );
543 // Note - we can't check the defaults since the stylesheets are platform-specific
545 // Check the render backend property.
546 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
547 DALI_TEST_EQUALS( (Text::RenderingType)editor.GetProperty<int>( TextEditor::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
549 // Check text property.
550 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
551 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
553 // Check text's color property
554 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
555 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
557 // Check font properties.
558 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
559 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
561 Property::Map fontStyleMapSet;
562 Property::Map fontStyleMapGet;
563 Property::Value* slantValue = NULL;
565 fontStyleMapSet.Insert( "weight", "bold" );
566 fontStyleMapSet.Insert( "width", "condensed" );
567 fontStyleMapSet.Insert( "slant", "italic" );
569 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
570 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
571 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
572 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
574 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
575 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
578 fontStyleMapSet.Clear();
579 fontStyleMapSet.Insert( "weight", "normal" );
580 fontStyleMapSet.Insert( "slant", "oblique" );
581 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
582 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
583 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
584 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
586 fontStyleMapSet.Clear();
587 fontStyleMapSet.Insert( "slant", "roman" );
588 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
589 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
591 // Replace 'roman' for 'normal'.
592 slantValue = fontStyleMapGet.Find( "slant" );
593 if( NULL != slantValue )
595 if( "normal" == slantValue->Get<std::string>() )
597 fontStyleMapGet["slant"] = "roman";
600 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
601 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
603 fontStyleMapSet.Clear();
605 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
606 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
607 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
608 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
610 // Check that the Alignment properties can be correctly set
611 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
612 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
614 // Check scroll properties.
615 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
616 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
617 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
618 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
620 // Check cursor properties
621 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
622 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
623 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
624 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
626 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
627 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
628 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
629 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
630 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
631 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
632 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
633 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
635 // Check handle images
636 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
637 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
638 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
639 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
640 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
642 // Check handle images
643 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
644 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
645 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
646 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
647 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
648 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
650 // Check the highlight color
651 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
652 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
654 // Decoration bounding box
655 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
656 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
658 // Check the enable markup property.
659 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
660 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
661 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
663 // Check input color property.
664 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
665 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
667 // Check input font properties.
668 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
669 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
671 fontStyleMapSet.Clear();
672 fontStyleMapSet.Insert( "weight", "bold" );
673 fontStyleMapSet.Insert( "width", "condensed" );
674 fontStyleMapSet.Insert( "slant", "italic" );
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 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
682 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
684 // Reset input font style.
685 fontStyleMapSet.Clear();
686 fontStyleMapSet.Insert( "weight", "normal" );
687 fontStyleMapSet.Insert( "slant", "oblique" );
689 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
690 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
691 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
692 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
694 fontStyleMapSet.Clear();
695 fontStyleMapSet.Insert( "slant", "roman" );
697 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
698 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
700 // Replace 'roman' for 'normal'.
701 slantValue = fontStyleMapGet.Find( "slant" );
702 if( NULL != slantValue )
704 if( "normal" == slantValue->Get<std::string>() )
706 fontStyleMapGet["slant"] = "roman";
709 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
710 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
712 fontStyleMapSet.Clear();
714 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
715 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
716 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
717 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
719 // Check the line spacing property
720 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
721 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
722 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
724 // Check the input line spacing property
725 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
726 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
727 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
729 // Check the underline property
731 Property::Map underlineMapSet;
732 Property::Map underlineMapGet;
734 underlineMapSet.Insert( "enable", "true" );
735 underlineMapSet.Insert( "color", "red" );
736 underlineMapSet.Insert( "height", "1" );
738 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
740 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
741 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
742 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
744 // Check the input underline property
745 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
746 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
748 // Check the shadow property
749 Property::Map shadowMapSet;
750 Property::Map shadowMapGet;
752 shadowMapSet.Insert( "color", Color::GREEN );
753 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
754 shadowMapSet.Insert( "blurRadius", 3.0f );
756 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
758 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
759 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
760 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
762 // Check the input shadow property
763 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
764 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
766 // Check the emboss property
767 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
768 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
770 // Check the input emboss property
771 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
772 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
774 // Check the outline property
776 // Test string type first
777 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
778 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
779 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
781 // Then test the property map type
782 Property::Map outlineMapSet;
783 Property::Map outlineMapGet;
785 outlineMapSet["color"] = Color::RED;
786 outlineMapSet["width"] = 2.0f;
788 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
790 outlineMapSet["color"] = "red";
791 outlineMapSet["width"] = "2";
792 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
793 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
794 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
796 // Check the input outline property
797 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
798 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
800 // Check the smooth scroll property
801 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
802 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
803 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
805 // Check the smooth scroll duration property
806 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
807 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
809 // Check the scroll bar property
810 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
811 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
812 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
814 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
815 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
816 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
817 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
819 // Check the pixel size of font
820 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
821 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
823 // Check placeholder text properties.
824 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
825 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
827 // Check placeholder text's color property.
828 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
829 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
831 // Check the enable selection property
832 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
833 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
835 // Check the placeholder property with pixel size
836 Property::Map placeholderPixelSizeMapSet;
837 Property::Map placeholderPixelSizeMapGet;
838 Property::Map placeholderFontstyleMap;
839 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
840 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
841 placeholderPixelSizeMapSet["color"] = Color::BLUE;
842 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
843 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
845 placeholderFontstyleMap.Insert( "weight", "bold" );
846 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
847 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
849 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
850 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
852 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
853 Property::Map placeholderConversionMap;
854 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
855 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
856 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
857 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
858 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
859 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
861 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
863 // Check the placeholder property with point size
864 Property::Map placeholderMapSet;
865 Property::Map placeholderMapGet;
866 placeholderMapSet["text"] = "Setting Placeholder Text";
867 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
868 placeholderMapSet["color"] = Color::RED;
869 placeholderMapSet["fontFamily"] = "Arial";
870 placeholderMapSet["pointSize"] = 12.0f;
871 // Check the placeholder font style property
872 placeholderFontstyleMap.Clear();
874 placeholderFontstyleMap.Insert( "weight", "bold" );
875 placeholderFontstyleMap.Insert( "width", "condensed" );
876 placeholderFontstyleMap.Insert( "slant", "italic" );
877 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
878 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
880 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
881 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
883 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
884 placeholderConversionMap.Clear();
885 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
886 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
887 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
888 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
889 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
890 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
891 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
894 placeholderFontstyleMap.Clear();
895 placeholderFontstyleMap.Insert( "weight", "normal" );
896 placeholderFontstyleMap.Insert( "slant", "oblique" );
897 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
898 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
900 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
901 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
902 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
903 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
905 placeholderFontstyleMap.Clear();
906 placeholderFontstyleMap.Insert( "slant", "roman" );
907 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
908 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
910 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
912 placeholderFontstyleMap.Clear();
913 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
915 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
916 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
917 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
918 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
919 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
921 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
922 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
924 application.SendNotification();
925 application.Render();
930 // Positive Atlas Text Renderer test
931 int utcDaliTextEditorAtlasRenderP(void)
933 ToolkitTestApplication application;
934 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
935 StyleManager styleManager = StyleManager::Get();
936 styleManager.ApplyDefaultTheme();
937 TextEditor editor = TextEditor::New();
938 DALI_TEST_CHECK( editor );
940 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
942 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
944 Stage::GetCurrent().Add( editor );
948 // Render some text with the shared atlas backend
949 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
950 application.SendNotification();
951 application.Render();
955 tet_result(TET_FAIL);
960 // Positive test for the textChanged signal.
961 int utcDaliTextEditorTextChangedP(void)
963 ToolkitTestApplication application;
964 tet_infoline(" utcDaliTextEditorTextChangedP");
965 TextEditor editor = TextEditor::New();
966 DALI_TEST_CHECK( editor );
968 Stage::GetCurrent().Add( editor );
970 // connect to the text changed signal.
971 ConnectionTracker* testTracker = new ConnectionTracker();
972 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
973 bool textChangedSignal = false;
974 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
976 gTextChangedCallBackCalled = false;
977 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
978 DALI_TEST_CHECK( gTextChangedCallBackCalled );
979 DALI_TEST_CHECK( textChangedSignal );
981 application.SendNotification();
983 editor.SetKeyInputFocus();
985 gTextChangedCallBackCalled = false;
986 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
987 DALI_TEST_CHECK( gTextChangedCallBackCalled );
992 int utcDaliTextEditorInputStyleChanged01(void)
994 ToolkitTestApplication application;
995 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
997 // The text-editor emits signals when the input style changes. These changes of style are
998 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
999 // can't be emitted during the size negotiation as the callbacks may update the UI.
1000 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1001 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1002 application.CreateAdaptor();
1006 char* pathNamePtr = get_current_dir_name();
1007 const std::string pathName( pathNamePtr );
1008 free( pathNamePtr );
1010 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1011 fontClient.SetDpi( 93u, 93u );
1013 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1014 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1016 TextEditor editor = TextEditor::New();
1017 DALI_TEST_CHECK( editor );
1020 editor.SetSize( 300.f, 50.f );
1021 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1022 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1024 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1025 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1027 // connect to the text changed signal.
1028 ConnectionTracker* testTracker = new ConnectionTracker();
1029 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1030 bool inputStyleChangedSignal = false;
1031 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1033 Stage::GetCurrent().Add( editor );
1035 // Render and notify
1036 application.SendNotification();
1037 application.Render();
1039 // Executes the idle callbacks added by the text control on the change of input style.
1040 application.RunIdles();
1042 gInputStyleChangedCallbackCalled = false;
1043 gInputStyleMask = TextEditor::InputStyle::NONE;
1044 inputStyleChangedSignal = false;
1046 // Create a tap event to touch the text editor.
1047 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1048 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1050 // Render and notify
1051 application.SendNotification();
1052 application.Render();
1054 // Executes the idle callbacks added by the text control on the change of input style.
1055 application.RunIdles();
1057 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1058 if( gInputStyleChangedCallbackCalled )
1060 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1062 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1063 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1065 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1066 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1068 DALI_TEST_CHECK( inputStyleChangedSignal );
1070 gInputStyleChangedCallbackCalled = false;
1071 gInputStyleMask = TextEditor::InputStyle::NONE;
1072 inputStyleChangedSignal = false;
1074 // Create a tap event to touch the text editor.
1075 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1076 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1078 // Render and notify
1079 application.SendNotification();
1080 application.Render();
1082 // Executes the idle callbacks added by the text control on the change of input style.
1083 application.RunIdles();
1085 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1086 DALI_TEST_CHECK( !inputStyleChangedSignal );
1088 gInputStyleChangedCallbackCalled = false;
1089 gInputStyleMask = TextEditor::InputStyle::NONE;
1090 inputStyleChangedSignal = false;
1092 // Create a tap event to touch the text editor.
1093 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1094 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1096 // Render and notify
1097 application.SendNotification();
1098 application.Render();
1100 // Executes the idle callbacks added by the text control on the change of input style.
1101 application.RunIdles();
1103 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1104 if( gInputStyleChangedCallbackCalled )
1106 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1108 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1109 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1111 DALI_TEST_CHECK( inputStyleChangedSignal );
1113 gInputStyleChangedCallbackCalled = false;
1114 gInputStyleMask = TextEditor::InputStyle::NONE;
1115 inputStyleChangedSignal = false;
1117 // Create a tap event to touch the text editor.
1118 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1119 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1121 // Render and notify
1122 application.SendNotification();
1123 application.Render();
1125 // Executes the idle callbacks added by the text control on the change of input style.
1126 application.RunIdles();
1128 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1129 if( gInputStyleChangedCallbackCalled )
1131 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1133 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1134 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1136 Property::Map fontStyleMapSet;
1137 Property::Map fontStyleMapGet;
1139 fontStyleMapSet.Insert( "weight", "bold" );
1141 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1142 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1143 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1145 DALI_TEST_CHECK( inputStyleChangedSignal );
1147 gInputStyleChangedCallbackCalled = false;
1148 gInputStyleMask = TextEditor::InputStyle::NONE;
1149 inputStyleChangedSignal = false;
1151 // Create a tap event to touch the text editor.
1152 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1153 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
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 DALI_TEST_CHECK( !inputStyleChangedSignal );
1165 gInputStyleChangedCallbackCalled = false;
1166 gInputStyleMask = TextEditor::InputStyle::NONE;
1167 inputStyleChangedSignal = false;
1169 // Create a tap event to touch the text editor.
1170 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1171 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1173 // Render and notify
1174 application.SendNotification();
1175 application.Render();
1177 // Executes the idle callbacks added by the text control on the change of input style.
1178 application.RunIdles();
1180 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1181 if( gInputStyleChangedCallbackCalled )
1183 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1185 Property::Map fontStyleMapSet;
1186 Property::Map fontStyleMapGet;
1188 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1189 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1190 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1192 DALI_TEST_CHECK( inputStyleChangedSignal );
1194 gInputStyleChangedCallbackCalled = false;
1195 gInputStyleMask = TextEditor::InputStyle::NONE;
1196 inputStyleChangedSignal = false;
1198 // Create a tap event to touch the text editor.
1199 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1200 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1202 // Render and notify
1203 application.SendNotification();
1204 application.Render();
1206 // Executes the idle callbacks added by the text control on the change of input style.
1207 application.RunIdles();
1209 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1210 DALI_TEST_CHECK( !inputStyleChangedSignal );
1215 int utcDaliTextEditorInputStyleChanged02(void)
1217 ToolkitTestApplication application;
1218 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1220 // The text-editor emits signals when the input style changes. These changes of style are
1221 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1222 // can't be emitted during the size negotiation as the callbacks may update the UI.
1223 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1224 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1225 application.CreateAdaptor();
1229 char* pathNamePtr = get_current_dir_name();
1230 const std::string pathName( pathNamePtr );
1231 free( pathNamePtr );
1233 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1234 fontClient.SetDpi( 93u, 93u );
1236 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1237 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1239 TextEditor editor = TextEditor::New();
1240 DALI_TEST_CHECK( editor );
1243 editor.SetSize( 300.f, 50.f );
1244 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1245 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1247 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1248 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>" );
1250 // connect to the text changed signal.
1251 ConnectionTracker* testTracker = new ConnectionTracker();
1252 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1253 bool inputStyleChangedSignal = false;
1254 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1256 Stage::GetCurrent().Add( editor );
1258 // Render and notify
1259 application.SendNotification();
1260 application.Render();
1262 // Executes the idle callbacks added by the text control on the change of input style.
1263 application.RunIdles();
1265 gInputStyleChangedCallbackCalled = false;
1266 gInputStyleMask = TextEditor::InputStyle::NONE;
1267 inputStyleChangedSignal = false;
1269 // Create a tap event to touch the text editor.
1270 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1271 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1272 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1273 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1275 // Render and notify
1276 application.SendNotification();
1277 application.Render();
1279 // Executes the idle callbacks added by the text control on the change of input style.
1280 application.RunIdles();
1282 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1283 if( gInputStyleChangedCallbackCalled )
1285 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1286 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1287 TextEditor::InputStyle::POINT_SIZE |
1288 TextEditor::InputStyle::COLOR ),
1291 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1292 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1294 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1295 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1297 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1298 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1300 DALI_TEST_CHECK( inputStyleChangedSignal );
1302 gInputStyleChangedCallbackCalled = false;
1303 gInputStyleMask = TextEditor::InputStyle::NONE;
1304 inputStyleChangedSignal = false;
1306 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1308 // Render and notify
1309 application.SendNotification();
1310 application.Render();
1312 // Executes the idle callbacks added by the text control on the change of input style.
1313 application.RunIdles();
1315 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1316 if( gInputStyleChangedCallbackCalled )
1318 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1319 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1322 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1323 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1325 DALI_TEST_CHECK( inputStyleChangedSignal );
1327 gInputStyleChangedCallbackCalled = false;
1328 gInputStyleMask = TextEditor::InputStyle::NONE;
1329 inputStyleChangedSignal = false;
1331 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1333 // Render and notify
1334 application.SendNotification();
1335 application.Render();
1337 // Executes the idle callbacks added by the text control on the change of input style.
1338 application.RunIdles();
1340 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1341 DALI_TEST_CHECK( !inputStyleChangedSignal );
1343 gInputStyleChangedCallbackCalled = false;
1344 gInputStyleMask = TextEditor::InputStyle::NONE;
1345 inputStyleChangedSignal = false;
1347 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1349 // Render and notify
1350 application.SendNotification();
1351 application.Render();
1353 // Executes the idle callbacks added by the text control on the change of input style.
1354 application.RunIdles();
1356 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1357 if( gInputStyleChangedCallbackCalled )
1359 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1360 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1363 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1364 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1366 DALI_TEST_CHECK( inputStyleChangedSignal );
1368 gInputStyleChangedCallbackCalled = false;
1369 gInputStyleMask = TextEditor::InputStyle::NONE;
1370 inputStyleChangedSignal = false;
1372 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1374 Property::Map fontStyleMapSet;
1375 fontStyleMapSet.Insert( "weight", "thin" );
1376 fontStyleMapSet.Insert( "width", "condensed" );
1377 fontStyleMapSet.Insert( "slant", "italic" );
1379 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1380 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1381 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1383 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1384 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1385 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1386 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1388 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1390 // Render and notify
1391 application.SendNotification();
1392 application.Render();
1394 // Executes the idle callbacks added by the text control on the change of input style.
1395 application.RunIdles();
1397 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1398 DALI_TEST_CHECK( !inputStyleChangedSignal );
1400 // Create a tap event to touch the text editor.
1401 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1402 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1404 // Render and notify
1405 application.SendNotification();
1406 application.Render();
1408 // Executes the idle callbacks added by the text control on the change of input style.
1409 application.RunIdles();
1411 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1412 if( gInputStyleChangedCallbackCalled )
1414 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1415 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1416 TextEditor::InputStyle::POINT_SIZE |
1417 TextEditor::InputStyle::FONT_STYLE |
1418 TextEditor::InputStyle::LINE_SPACING |
1419 TextEditor::InputStyle::UNDERLINE |
1420 TextEditor::InputStyle::SHADOW |
1421 TextEditor::InputStyle::EMBOSS |
1422 TextEditor::InputStyle::OUTLINE ),
1425 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1426 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1428 DALI_TEST_CHECK( inputStyleChangedSignal );
1430 gInputStyleChangedCallbackCalled = false;
1431 gInputStyleMask = TextEditor::InputStyle::NONE;
1432 inputStyleChangedSignal = false;
1434 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1436 fontStyleMapSet.Clear();
1437 fontStyleMapSet.Insert( "weight", "black" );
1438 fontStyleMapSet.Insert( "width", "expanded" );
1439 fontStyleMapSet.Insert( "slant", "oblique" );
1441 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1443 // Create a tap event to touch the text editor.
1444 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1445 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1447 // Render and notify
1448 application.SendNotification();
1449 application.Render();
1451 // Executes the idle callbacks added by the text control on the change of input style.
1452 application.RunIdles();
1454 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1455 if( gInputStyleChangedCallbackCalled )
1457 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1458 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1459 TextEditor::InputStyle::POINT_SIZE |
1460 TextEditor::InputStyle::FONT_STYLE ),
1463 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1464 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1466 DALI_TEST_CHECK( inputStyleChangedSignal );
1471 int utcDaliTextEditorEvent01(void)
1473 ToolkitTestApplication application;
1474 tet_infoline(" utcDaliTextEditorEvent01");
1476 // Creates a tap event. After creating a tap event the text editor should
1477 // have the focus and add text with key events should be possible.
1479 TextEditor editor = TextEditor::New();
1480 DALI_TEST_CHECK( editor );
1482 Stage::GetCurrent().Add( editor );
1484 editor.SetSize( 300.f, 50.f );
1485 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1486 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1488 // Avoid a crash when core load gl resources.
1489 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1491 // Render and notify
1492 application.SendNotification();
1493 application.Render();
1495 // Add a key event but as the text editor has not the focus it should do nothing.
1496 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1498 // Render and notify
1499 application.SendNotification();
1500 application.Render();
1502 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1504 // Create a tap event to touch the text editor.
1505 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1506 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1508 // Render and notify
1509 application.SendNotification();
1510 application.Render();
1512 // Now the text editor has the focus, so it can handle the key events.
1513 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1514 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1516 // Render and notify
1517 application.SendNotification();
1518 application.Render();
1520 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1522 // Create a second text editor and send key events to it.
1523 TextEditor editor2 = TextEditor::New();
1525 editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1526 editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1527 editor2.SetSize( 100.f, 100.f );
1528 editor2.SetPosition( 100.f, 100.f );
1530 Stage::GetCurrent().Add( editor2 );
1532 // Render and notify
1533 application.SendNotification();
1534 application.Render();
1536 // Create a tap event on the second text editor.
1537 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1538 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1540 // Render and notify
1541 application.SendNotification();
1542 application.Render();
1544 // The second text editor has the focus. It should handle the key events.
1545 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1546 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1548 // Render and notify
1549 application.SendNotification();
1550 application.Render();
1552 // Check the text has been added to the second text editor.
1553 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1558 int utcDaliTextEditorEvent02(void)
1560 ToolkitTestApplication application;
1561 tet_infoline(" utcDaliTextEditorEvent02");
1563 // Checks if the right number of actors are created.
1565 TextEditor editor = TextEditor::New();
1566 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1567 DALI_TEST_CHECK( editor );
1569 Stage::GetCurrent().Add( editor );
1571 editor.SetSize( 300.f, 50.f );
1572 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1573 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1575 // Avoid a crash when core load gl resources.
1576 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1578 // Render and notify
1579 application.SendNotification();
1580 application.Render();
1582 // Check there are the expected number of children (the stencil).
1583 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1585 Actor stencil = editor.GetChildAt( 0u );
1587 // Create a tap event to touch the text editor.
1588 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1589 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1591 // Render and notify
1592 application.SendNotification();
1593 application.Render();
1595 Actor layer = editor.GetChildAt( 1u );
1596 DALI_TEST_CHECK( layer.IsLayer() );
1598 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1599 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1601 // Now the text editor has the focus, so it can handle the key events.
1602 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1603 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1605 // Render and notify
1606 application.SendNotification();
1607 application.Render();
1609 // Checks the cursor and the renderer have been created.
1610 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1611 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1613 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1614 DALI_TEST_CHECK( cursor );
1616 // The stencil actor has a container with all the actors which contain the text renderers.
1617 Actor container = stencil.GetChildAt( 0u );
1618 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1620 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1621 DALI_TEST_CHECK( renderer );
1624 // Move the cursor and check the position changes.
1625 Vector3 position1 = cursor.GetCurrentPosition();
1627 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1628 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1630 // Render and notify
1631 application.SendNotification();
1632 application.Render();
1634 Vector3 position2 = cursor.GetCurrentPosition();
1636 DALI_TEST_CHECK( position2.x < position1.x );
1638 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1639 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1641 // Render and notify
1642 application.SendNotification();
1643 application.Render();
1645 Vector3 position3 = cursor.GetCurrentPosition();
1647 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1649 // Send some taps and check the cursor positions.
1651 // Try to tap at the beginning.
1652 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1653 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1655 // Render and notify
1656 application.SendNotification();
1657 application.Render();
1659 // Cursor position should be the same than position1.
1660 Vector3 position4 = cursor.GetCurrentPosition();
1662 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1664 // Tap away from the start position.
1665 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1666 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1668 // Render and notify
1669 application.SendNotification();
1670 application.Render();
1672 Vector3 position5 = cursor.GetCurrentPosition();
1674 DALI_TEST_CHECK( position5.x > position4.x );
1676 // Remove all the text.
1677 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1678 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1679 editor.SetProperty( TextEditor::Property::TEXT, "" );
1681 // Render and notify
1682 application.SendNotification();
1683 application.Render();
1685 // Cursor position should be the same than position2.
1686 Vector3 position6 = cursor.GetCurrentPosition();
1688 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1690 // Should not be a renderer.
1691 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1696 int utcDaliTextEditorEvent03(void)
1698 ToolkitTestApplication application;
1699 tet_infoline(" utcDaliTextEditorEvent03");
1701 // Checks if the highlight actor is created.
1703 TextEditor editor = TextEditor::New();
1704 DALI_TEST_CHECK( editor );
1706 Stage::GetCurrent().Add( editor );
1708 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1709 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1710 editor.SetSize( 30.f, 50.f );
1711 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1712 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1714 // Avoid a crash when core load gl resources.
1715 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1717 // Render and notify
1718 application.SendNotification();
1719 application.Render();
1721 // Send some taps and check text controller with clipboard window
1722 Dali::Clipboard clipboard = Clipboard::Get();
1723 clipboard.ShowClipboard();
1724 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1725 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1726 clipboard.HideClipboard();
1728 // Render and notify
1729 application.SendNotification();
1730 application.Render();
1732 // Tap first to get the focus.
1733 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1734 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1736 // Render and notify
1737 application.SendNotification();
1738 application.Render();
1740 // Double tap to select a word.
1741 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1742 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1744 // Render and notify
1745 application.SendNotification();
1746 application.Render();
1748 // The stencil actor should have two actors: the renderer and the highlight actor.
1749 Actor stencil = editor.GetChildAt( 0u );
1751 // Highlight needs to be drawn before text, so should come first in child order
1752 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1753 DALI_TEST_CHECK( highlight );
1755 // The stencil actor has a container with all the actors which contain the text renderers.
1756 Actor container = stencil.GetChildAt( 1u );
1757 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1759 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1760 DALI_TEST_CHECK( renderer );
1763 // Double tap out of bounds
1764 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1765 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1767 // Render and notify
1768 application.SendNotification();
1769 application.Render();
1771 // The stencil actor should have one actors: the renderer actor.
1772 stencil = editor.GetChildAt( 0u );
1774 // The stencil actor has a container with all the actors which contain the text renderers.
1775 container = stencil.GetChildAt( 0u );
1776 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1778 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1779 DALI_TEST_CHECK( renderer );
1783 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1784 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1786 // Render and notify
1787 application.SendNotification();
1788 application.Render();
1793 int utcDaliTextEditorEvent04(void)
1795 ToolkitTestApplication application;
1796 tet_infoline(" utcDaliTextEditorEvent04");
1798 // Checks if the highlight actor is created.
1800 TextEditor editor = TextEditor::New();
1801 DALI_TEST_CHECK( editor );
1803 Stage::GetCurrent().Add( editor );
1805 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1806 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1807 editor.SetSize( 100.f, 50.f );
1808 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1809 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1811 // Avoid a crash when core load gl resources.
1812 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1814 // Render and notify
1815 application.SendNotification();
1816 application.Render();
1818 // Tap on the text editor
1819 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1820 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1822 // Render and notify
1823 application.SendNotification();
1824 application.Render();
1826 // Move at the end of the text.
1827 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1828 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1830 // Render and notify
1831 application.SendNotification();
1832 application.Render();
1834 for( unsigned int index = 0u; index < 10u; ++index )
1836 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1837 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1839 // Render and notify
1840 application.SendNotification();
1841 application.Render();
1845 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1847 // Render and notify
1848 application.SendNotification();
1849 application.Render();
1851 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1853 // Add some key events
1854 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1855 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1857 // Render and notify
1858 application.SendNotification();
1859 application.Render();
1861 for( unsigned int index = 0u; index < 10u; ++index )
1863 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1864 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1866 // Render and notify
1867 application.SendNotification();
1868 application.Render();
1872 application.ProcessEvent( GenerateKey( " ", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1874 // Render and notify
1875 application.SendNotification();
1876 application.Render();
1878 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1883 int utcDaliTextEditorEvent05(void)
1885 ToolkitTestApplication application;
1886 tet_infoline(" utcDaliTextEditorEvent05");
1888 // Checks if the highlight actor is created.
1890 TextEditor editor = TextEditor::New();
1891 DALI_TEST_CHECK( editor );
1893 Stage::GetCurrent().Add( editor );
1895 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1896 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1897 editor.SetSize( 50.f, 50.f );
1898 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1899 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1900 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1901 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1902 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1903 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1904 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1906 // Avoid a crash when core load gl resources.
1907 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1909 // Render and notify
1910 application.SendNotification();
1911 application.Render();
1913 // Tap on the text editor
1914 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1915 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1917 // Render and notify
1918 application.SendNotification();
1919 application.Render();
1921 // Move at the end of the text.
1922 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1923 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1925 // Render and notify
1926 application.SendNotification();
1927 application.Render();
1929 for( unsigned int index = 0u; index < 10u; ++index )
1932 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1934 // Render and notify
1935 application.SendNotification();
1936 application.Render();
1938 // Modify duration after scroll is enabled
1939 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1941 // Continuous scroll left to increase coverage
1942 for( unsigned int index = 0u; index < 10u; ++index )
1944 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1946 // Render and notify
1947 application.SendNotification();
1948 application.Render();
1950 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1951 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1952 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1953 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1954 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1956 // Press Escape to increase coverage
1957 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1958 application.SendNotification();
1959 application.Render();
1961 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1966 int utcDaliTextEditorEvent06(void)
1968 ToolkitTestApplication application;
1969 tet_infoline(" utcDaliTextEditorEvent06");
1971 // Checks if the highlight actor is created.
1973 TextEditor editor = TextEditor::New();
1974 DALI_TEST_CHECK( editor );
1976 Stage::GetCurrent().Add( editor );
1978 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
1979 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1980 editor.SetSize( 100.f, 50.f );
1981 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1982 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1984 // Avoid a crash when core load gl resources.
1985 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1987 // Render and notify
1988 application.SendNotification();
1989 application.Render();
1991 // Tap on the text editor
1992 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1993 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1995 // Render and notify
1996 application.SendNotification();
1997 application.Render();
1999 // Move to seconds line of the text.
2000 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2002 // Render and notify
2003 application.SendNotification();
2004 application.Render();
2006 float layoutHeight = editor.GetHeightForWidth( 100.f );
2009 // Add another script characters ( glyph height is defferent )
2010 application.ProcessEvent( GenerateKey( "d", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2011 application.ProcessEvent( GenerateKey( "d", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2013 // Delete characters
2014 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2015 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2017 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2019 // Render and notify
2020 application.SendNotification();
2021 application.Render();
2023 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2026 application.ProcessEvent( GenerateKey( "", "", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2027 application.SendNotification();
2028 application.Render();
2030 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2031 application.SendNotification();
2032 application.Render();
2034 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2035 application.SendNotification();
2036 application.Render();
2038 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2039 application.SendNotification();
2040 application.Render();
2042 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2043 application.SendNotification();
2044 application.Render();
2046 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2047 application.SendNotification();
2048 application.Render();
2050 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2051 application.SendNotification();
2052 application.Render();
2057 int utcDaliTextEditorEvent07(void)
2059 ToolkitTestApplication application;
2060 tet_infoline(" utcDaliTextEditorEvent07");
2062 // Checks if the highlight actor is created.
2064 TextEditor editor = TextEditor::New();
2065 DALI_TEST_CHECK( editor );
2067 Stage::GetCurrent().Add( editor );
2069 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2070 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2071 editor.SetSize( 100.f, 50.f );
2072 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2073 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2075 // Avoid a crash when core load gl resources.
2076 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2078 // Render and notify
2079 application.SendNotification();
2080 application.Render();
2082 // Tap on the text editor
2083 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2084 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2086 // Render and notify
2087 application.SendNotification();
2088 application.Render();
2090 // Move to second line of the text.
2091 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2093 // Render and notify
2094 application.SendNotification();
2095 application.Render();
2097 // Select some text in the right of the current cursor position
2098 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2099 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2100 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2101 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2103 // Render and notify
2104 application.SendNotification();
2105 application.Render();
2107 // Cut the selected text
2108 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2109 application.ProcessEvent( GenerateKey( "x", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2111 // Render and notify
2112 application.SendNotification();
2113 application.Render();
2115 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2117 // Select some text in the left of the current cursor position
2118 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2119 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2120 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2121 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2123 // Render and notify
2124 application.SendNotification();
2125 application.Render();
2127 // Copy the selected text
2128 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2129 application.ProcessEvent( GenerateKey( "c", "c", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2131 // Render and notify
2132 application.SendNotification();
2133 application.Render();
2135 // Move the cursor to the third line
2136 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2137 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2139 // Render and notify
2140 application.SendNotification();
2141 application.Render();
2143 // Paste the selected text at the current cursor position
2144 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2145 application.ProcessEvent( GenerateKey( "v", "v", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2147 // Render and notify
2148 application.SendNotification();
2149 application.Render();
2151 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2154 // Disable Shift Selection
2155 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2157 // Test to select some text in the right of the current cursor position
2158 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2159 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2160 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2161 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2163 // Render and notify
2164 application.SendNotification();
2165 application.Render();
2167 // Cut the selected text
2168 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2169 application.ProcessEvent( GenerateKey( "x", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2171 // Render and notify
2172 application.SendNotification();
2173 application.Render();
2175 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2176 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2178 // Test to select some text in the left of the current cursor position
2179 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2180 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2181 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2182 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2184 // Render and notify
2185 application.SendNotification();
2186 application.Render();
2188 // Copy the selected text
2189 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2190 application.ProcessEvent( GenerateKey( "c", "c", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2192 // Render and notify
2193 application.SendNotification();
2194 application.Render();
2196 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2197 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2202 int utcDaliTextEditorHandles(void)
2204 ToolkitTestApplication application;
2205 tet_infoline(" utcDaliTextEditorHandles");
2207 TextEditor editor = TextEditor::New();
2208 DALI_TEST_CHECK( editor );
2210 Stage::GetCurrent().Add( editor );
2212 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2213 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2214 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2215 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2217 editor.SetSize( 30.f, 500.f );
2218 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2219 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2221 // Avoid a crash when core load gl resources.
2222 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2224 // Render and notify
2225 application.SendNotification();
2226 application.Render();
2228 // Tap first to get the focus.
2229 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2230 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2232 // Render and notify
2233 application.SendNotification();
2234 application.Render();
2236 // Tap to create the grab handle.
2237 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2238 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2240 // Render and notify
2241 application.SendNotification();
2242 application.Render();
2244 // Get the active layer where the text's decoration is added.
2245 Actor activeLayer = editor.GetChildAt( 1u );
2247 // Get the handle's actor.
2248 Actor handle = activeLayer.GetChildAt( 1u );
2249 handle.SetSize( 100.f, 100.f );
2251 // Render and notify
2252 application.SendNotification();
2253 application.Render();
2255 // Touch the grab handle to set it as pressed.
2256 Vector2 touchPos( 10.0f, 50.0f );
2257 Dali::Integration::TouchEvent event;
2258 event = Dali::Integration::TouchEvent();
2259 event.AddPoint( GetPointDownInside( touchPos ) );
2260 application.ProcessEvent( event );
2262 // Render and notify
2263 application.SendNotification();
2264 application.Render();
2266 // drag grab handle right
2267 SendPan(application, Gesture::Possible, touchPos);
2268 SendPan(application, Gesture::Started, touchPos);
2270 Wait(application, 100);
2272 for(int i = 0;i<20;i++)
2274 SendPan(application, Gesture::Continuing, touchPos);
2279 SendPan(application, Gesture::Finished, touchPos);
2282 // Release the grab handle.
2283 event = Dali::Integration::TouchEvent();
2284 event.AddPoint( GetPointUpInside( touchPos ) );
2285 application.ProcessEvent( event );
2287 // Render and notify
2288 application.SendNotification();
2289 application.Render();
2295 int utcDaliTextEditorUnderPropertyStringP(void)
2297 ToolkitTestApplication application;
2298 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2299 TextEditor editor = TextEditor::New();
2300 DALI_TEST_CHECK( editor );
2302 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2304 Stage::GetCurrent().Add( editor );
2306 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2307 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2309 tet_infoline("Set underline settings with a map");
2310 // Check the input underline property
2311 Property::Map underlineMapSet;
2312 Property::Map underlineMapGet;
2313 underlineMapSet.Insert( "enable", "true" );
2314 underlineMapSet.Insert( "color", "blue" );
2315 underlineMapSet.Insert( "height", "2" );
2317 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2318 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2319 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2320 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2322 tet_infoline("Set underline settings with a string");
2323 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2324 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2327 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2329 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2330 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2331 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2332 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2334 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2339 int utcDaliTextEditorShadowPropertyStringP(void)
2341 ToolkitTestApplication application;
2342 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2344 TextEditor editor = TextEditor::New();
2346 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2348 Stage::GetCurrent().Add( editor );
2350 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2352 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2356 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2361 int utcDaliTextEditorFontStylePropertyStringP(void)
2363 ToolkitTestApplication application;
2364 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2366 TextEditor editor = TextEditor::New();
2368 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2370 Stage::GetCurrent().Add( editor );
2372 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2374 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2378 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2383 int utcDaliTextEditorGetPropertyLinecountP(void)
2385 ToolkitTestApplication application;
2387 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2391 TextEditor editor = TextEditor::New();
2392 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2393 editor.SetProperty( TextEditor::Property::TEXT,
2394 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2396 Stage::GetCurrent().Add( editor );
2398 editor.SetSize( 100.0f, 100.0f );
2399 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2400 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2402 editor.SetSize( 50.0f, 100.0f );
2403 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2404 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2409 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2412 ToolkitTestApplication application;
2413 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2415 TextEditor editor = TextEditor::New();
2416 DALI_TEST_CHECK( editor );
2418 Stage::GetCurrent().Add( editor );
2420 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2421 editor.SetSize( 50.f, 50.f );
2422 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2423 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2424 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2425 editor.SetKeyboardFocusable(true);
2427 bool startedCalled = false;
2428 bool finishedCalled = false;
2430 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2431 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2433 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2435 // Render and notify
2436 application.SendNotification();
2437 application.Render();
2439 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2440 application.SendNotification();
2441 application.Render(6000);
2443 application.SendNotification();
2444 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2445 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2450 int UtcDaliToolkitTextEditorTextWrapMode(void)
2452 ToolkitTestApplication application;
2453 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2457 TextEditor editor = TextEditor::New();
2458 editor.SetSize( 150.0f, 300.f );
2459 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2461 Stage::GetCurrent().Add( editor );
2463 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2464 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2466 application.SendNotification();
2467 application.Render();
2469 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2470 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2472 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2473 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2475 application.SendNotification();
2476 application.Render();
2478 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2479 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2481 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2482 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2484 application.SendNotification();
2485 application.Render();
2487 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2488 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2490 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2491 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2493 application.SendNotification();
2494 application.Render();
2496 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2497 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2502 int UtcDaliTextEditorSetPaddingProperty(void)
2504 ToolkitTestApplication application;
2505 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2507 TextEditor editor = TextEditor::New();
2508 DALI_TEST_CHECK( editor );
2509 editor.SetSize( 300.f, 50.f );
2510 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2511 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2512 Stage::GetCurrent().Add( editor );
2514 application.SendNotification();
2515 application.Render();
2517 Vector3 originalSize = editor.GetNaturalSize();
2519 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2521 application.SendNotification();
2522 application.Render();
2524 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2526 Vector3 paddingAddedSize = editor.GetNaturalSize();
2528 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2530 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2535 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
2537 ToolkitTestApplication application;
2538 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
2540 TextEditor editor = TextEditor::New();
2541 DALI_TEST_CHECK( editor );
2542 editor.SetSize( 300.f, 50.f );
2543 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2544 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2545 Stage::GetCurrent().Add( editor );
2547 application.SendNotification();
2548 application.Render();
2550 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2551 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2553 // Check the enable shift selection property
2554 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2555 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2557 application.SendNotification();
2558 application.Render();