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( valueSet->GetType() == Dali::Property::STRING && ( 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() );
323 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
325 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
328 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
330 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
333 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
335 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
338 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
340 Vector2 vector2Get = valueGet.second.Get<Vector2>();
341 Vector2 vector2Set = valueSet->Get<Vector2>();
342 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
345 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
347 Vector4 vector4Get = valueGet.second.Get<Vector4>();
348 Vector4 vector4Set = valueSet->Get<Vector4>();
349 tet_printf( "Value got : [%f, %f, %f, %f], expected : [%f, %f, %f, %f]", vector4Get.r, vector4Get.g, vector4Get.b, vector4Get.a, vector4Set.r, vector4Set.g, vector4Set.b, vector4Set.a );
355 if ( valueGet.first.type == Property::Key::INDEX )
357 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
361 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
371 class ScrollStateChangeCallback : public Dali::ConnectionTracker
374 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
375 : mStartedCalled( startedCalled ),
376 mFinishedCalled( finishedCalled )
380 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
382 if( type == TextEditor::Scroll::STARTED )
384 mStartedCalled = true;
386 else if( type == TextEditor::Scroll::FINISHED )
388 mFinishedCalled = true;
392 bool& mStartedCalled;
393 bool& mFinishedCalled;
398 int UtcDaliToolkitTextEditorConstructorP(void)
400 ToolkitTestApplication application;
401 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
402 TextEditor textEditor;
403 DALI_TEST_CHECK( !textEditor );
407 int UtcDaliToolkitTextEditorNewP(void)
409 ToolkitTestApplication application;
410 tet_infoline(" UtcDaliToolkitTextEditorNewP");
411 TextEditor textEditor = TextEditor::New();
412 DALI_TEST_CHECK( textEditor );
416 int UtcDaliToolkitTextEditorDownCastP(void)
418 ToolkitTestApplication application;
419 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
420 TextEditor textEditor1 = TextEditor::New();
421 BaseHandle object( textEditor1 );
423 TextEditor textEditor2 = TextEditor::DownCast( object );
424 DALI_TEST_CHECK( textEditor2 );
426 TextEditor textEditor3 = DownCast< TextEditor >( object );
427 DALI_TEST_CHECK( textEditor3 );
431 int UtcDaliToolkitTextEditorDownCastN(void)
433 ToolkitTestApplication application;
434 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
435 BaseHandle uninitializedObject;
436 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
437 DALI_TEST_CHECK( !textEditor1 );
439 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
440 DALI_TEST_CHECK( !textEditor2 );
444 int UtcDaliToolkitTextEditorCopyConstructorP(void)
446 ToolkitTestApplication application;
447 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
448 TextEditor textEditor = TextEditor::New();
449 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
451 TextEditor copy( textEditor );
452 DALI_TEST_CHECK( copy );
453 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
457 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
459 ToolkitTestApplication application;
460 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
461 TextEditor textEditor = TextEditor::New();
462 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
464 TextEditor copy = textEditor;
465 DALI_TEST_CHECK( copy );
466 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
470 int UtcDaliTextEditorNewP(void)
472 ToolkitTestApplication application;
473 tet_infoline(" UtcDaliToolkitTextEditorNewP");
474 TextEditor textEditor = TextEditor::New();
475 DALI_TEST_CHECK( textEditor );
479 // Positive test case for a method
480 int UtcDaliTextEditorGetPropertyP(void)
482 ToolkitTestApplication application;
483 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
484 TextEditor editor = TextEditor::New();
485 DALI_TEST_CHECK( editor );
487 // Check Property Indices are correct
488 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextEditor::Property::RENDERING_BACKEND );
489 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
490 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
491 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
492 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
493 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
494 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
495 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
496 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
497 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
498 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
499 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
500 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
501 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
502 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
503 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
504 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
505 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
506 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
507 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
508 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
509 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
510 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
511 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
512 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
513 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
514 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
515 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
516 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
517 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
519 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
520 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
521 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
522 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
523 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
524 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
525 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
526 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
527 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
528 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
529 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
530 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
531 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
532 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
533 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
534 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
535 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
536 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
537 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
538 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
539 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
540 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
545 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
548 Property::Map imageMap;
549 imageMap[mapKey] =mapValue;
551 editor.SetProperty( property , imageMap );
552 Property::Value propValue = editor.GetProperty( property );
553 Property::Map* resultMap = propValue.GetMap();
555 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
563 // Positive test case for a method
564 int UtcDaliTextEditorSetPropertyP(void)
566 ToolkitTestApplication application;
567 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
568 TextEditor editor = TextEditor::New();
569 DALI_TEST_CHECK( editor );
570 Stage::GetCurrent().Add( editor );
572 // Note - we can't check the defaults since the stylesheets are platform-specific
574 // Check the render backend property.
575 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
576 DALI_TEST_EQUALS( (Text::RenderingType)editor.GetProperty<int>( TextEditor::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
578 // Check text property.
579 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
580 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
582 // Check text's color property
583 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
584 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
586 // Check font properties.
587 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
588 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
590 Property::Map fontStyleMapSet;
591 Property::Map fontStyleMapGet;
592 Property::Value* slantValue = NULL;
594 fontStyleMapSet.Insert( "weight", "bold" );
595 fontStyleMapSet.Insert( "width", "condensed" );
596 fontStyleMapSet.Insert( "slant", "italic" );
598 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
599 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
600 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
601 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
603 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
604 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
607 fontStyleMapSet.Clear();
608 fontStyleMapSet.Insert( "weight", "normal" );
609 fontStyleMapSet.Insert( "slant", "oblique" );
610 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
611 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
612 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
613 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
615 fontStyleMapSet.Clear();
616 fontStyleMapSet.Insert( "slant", "roman" );
617 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
618 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
620 // Replace 'roman' for 'normal'.
621 slantValue = fontStyleMapGet.Find( "slant" );
622 if( NULL != slantValue )
624 if( "normal" == slantValue->Get<std::string>() )
626 fontStyleMapGet["slant"] = "roman";
629 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
630 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
632 fontStyleMapSet.Clear();
634 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
635 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
636 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
637 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
639 // Check that the Alignment properties can be correctly set
640 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
641 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
643 // Check scroll properties.
644 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
645 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
646 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
647 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
649 // Check cursor properties
650 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
651 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
652 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
653 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
655 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
656 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
657 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
658 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
659 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
660 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
661 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
662 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
664 // Check handle images
665 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
666 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
667 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
668 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
669 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
671 // Check handle images
672 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
673 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
674 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
675 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
676 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
677 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
679 // Check the highlight color
680 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
681 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
683 // Decoration bounding box
684 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
685 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
687 // Check the enable markup property.
688 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
689 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
690 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
692 // Check input color property.
693 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
694 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
696 // Check input font properties.
697 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
698 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
700 fontStyleMapSet.Clear();
701 fontStyleMapSet.Insert( "weight", "bold" );
702 fontStyleMapSet.Insert( "width", "condensed" );
703 fontStyleMapSet.Insert( "slant", "italic" );
705 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
706 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
707 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
708 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
710 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
711 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
713 // Reset input font style.
714 fontStyleMapSet.Clear();
715 fontStyleMapSet.Insert( "weight", "normal" );
716 fontStyleMapSet.Insert( "slant", "oblique" );
718 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
719 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
720 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
721 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
723 fontStyleMapSet.Clear();
724 fontStyleMapSet.Insert( "slant", "roman" );
726 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
727 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
729 // Replace 'roman' for 'normal'.
730 slantValue = fontStyleMapGet.Find( "slant" );
731 if( NULL != slantValue )
733 if( "normal" == slantValue->Get<std::string>() )
735 fontStyleMapGet["slant"] = "roman";
738 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
739 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
741 fontStyleMapSet.Clear();
743 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
744 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
745 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
746 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
748 // Check the line spacing property
749 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
750 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
751 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
753 // Check the input line spacing property
754 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
755 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
756 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
758 // Check the underline property
760 Property::Map underlineMapSet;
761 Property::Map underlineMapGet;
763 underlineMapSet.Insert( "enable", "true" );
764 underlineMapSet.Insert( "color", "red" );
765 underlineMapSet.Insert( "height", "1" );
767 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
769 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
770 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
771 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
773 // Check the input underline property
774 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
775 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
777 // Check the shadow property
778 Property::Map shadowMapSet;
779 Property::Map shadowMapGet;
781 shadowMapSet.Insert( "color", Color::GREEN );
782 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
783 shadowMapSet.Insert( "blurRadius", 3.0f );
785 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
787 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
788 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
789 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
791 // Check the input shadow property
792 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
793 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
795 // Check the emboss property
796 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
797 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
799 // Check the input emboss property
800 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
801 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
803 // Check the outline property
805 // Test string type first
806 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
807 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
808 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
810 // Then test the property map type
811 Property::Map outlineMapSet;
812 Property::Map outlineMapGet;
814 outlineMapSet["color"] = Color::RED;
815 outlineMapSet["width"] = 2.0f;
817 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
819 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
820 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
821 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
823 // Check the input outline property
824 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
825 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
827 // Check the smooth scroll property
828 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
829 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
830 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
832 // Check the smooth scroll duration property
833 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
834 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
836 // Check the scroll bar property
837 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
838 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
839 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
841 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
842 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
843 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
844 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
846 // Check the pixel size of font
847 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
848 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
850 // Check placeholder text properties.
851 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
852 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
854 // Check placeholder text's color property.
855 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
856 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
858 // Check the enable selection property
859 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
860 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
862 // Check the placeholder property with pixel size
863 Property::Map placeholderPixelSizeMapSet;
864 Property::Map placeholderPixelSizeMapGet;
865 Property::Map placeholderFontstyleMap;
866 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
867 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
868 placeholderPixelSizeMapSet["color"] = Color::BLUE;
869 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
870 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
872 placeholderFontstyleMap.Insert( "weight", "bold" );
873 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
874 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
876 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
877 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
879 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
880 Property::Map placeholderConversionMap;
881 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
882 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
883 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
884 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
885 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
886 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
888 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
890 // Check the placeholder property with point size
891 Property::Map placeholderMapSet;
892 Property::Map placeholderMapGet;
893 placeholderMapSet["text"] = "Setting Placeholder Text";
894 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
895 placeholderMapSet["color"] = Color::RED;
896 placeholderMapSet["fontFamily"] = "Arial";
897 placeholderMapSet["pointSize"] = 12.0f;
898 // Check the placeholder font style property
899 placeholderFontstyleMap.Clear();
901 placeholderFontstyleMap.Insert( "weight", "bold" );
902 placeholderFontstyleMap.Insert( "width", "condensed" );
903 placeholderFontstyleMap.Insert( "slant", "italic" );
904 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
905 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
907 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
908 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
910 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
911 placeholderConversionMap.Clear();
912 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
913 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
914 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
915 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
916 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
917 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
918 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
921 placeholderFontstyleMap.Clear();
922 placeholderFontstyleMap.Insert( "weight", "normal" );
923 placeholderFontstyleMap.Insert( "slant", "oblique" );
924 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
925 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
927 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
928 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
929 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
930 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
932 placeholderFontstyleMap.Clear();
933 placeholderFontstyleMap.Insert( "slant", "roman" );
934 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
935 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
937 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
939 placeholderFontstyleMap.Clear();
940 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
942 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
943 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
944 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
945 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
946 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
948 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
949 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
951 application.SendNotification();
952 application.Render();
957 // Positive Atlas Text Renderer test
958 int utcDaliTextEditorAtlasRenderP(void)
960 ToolkitTestApplication application;
961 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
962 StyleManager styleManager = StyleManager::Get();
963 styleManager.ApplyDefaultTheme();
964 TextEditor editor = TextEditor::New();
965 DALI_TEST_CHECK( editor );
967 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
969 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
971 Stage::GetCurrent().Add( editor );
975 // Render some text with the shared atlas backend
976 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
977 application.SendNotification();
978 application.Render();
982 tet_result(TET_FAIL);
987 // Positive test for the textChanged signal.
988 int utcDaliTextEditorTextChangedP(void)
990 ToolkitTestApplication application;
991 tet_infoline(" utcDaliTextEditorTextChangedP");
992 TextEditor editor = TextEditor::New();
993 DALI_TEST_CHECK( editor );
995 Stage::GetCurrent().Add( editor );
997 // connect to the text changed signal.
998 ConnectionTracker* testTracker = new ConnectionTracker();
999 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
1000 bool textChangedSignal = false;
1001 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1003 gTextChangedCallBackCalled = false;
1004 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
1005 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1006 DALI_TEST_CHECK( textChangedSignal );
1008 application.SendNotification();
1010 editor.SetKeyInputFocus();
1012 gTextChangedCallBackCalled = false;
1013 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1014 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1019 int utcDaliTextEditorInputStyleChanged01(void)
1021 ToolkitTestApplication application;
1022 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1024 // The text-editor emits signals when the input style changes. These changes of style are
1025 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1026 // can't be emitted during the size negotiation as the callbacks may update the UI.
1027 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1028 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1029 application.CreateAdaptor();
1033 char* pathNamePtr = get_current_dir_name();
1034 const std::string pathName( pathNamePtr );
1035 free( pathNamePtr );
1037 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1038 fontClient.SetDpi( 93u, 93u );
1040 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1041 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1043 TextEditor editor = TextEditor::New();
1044 DALI_TEST_CHECK( editor );
1047 editor.SetSize( 300.f, 50.f );
1048 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1049 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1051 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1052 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1054 // connect to the text changed signal.
1055 ConnectionTracker* testTracker = new ConnectionTracker();
1056 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1057 bool inputStyleChangedSignal = false;
1058 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1060 Stage::GetCurrent().Add( editor );
1062 // Render and notify
1063 application.SendNotification();
1064 application.Render();
1066 // Executes the idle callbacks added by the text control on the change of input style.
1067 application.RunIdles();
1069 gInputStyleChangedCallbackCalled = false;
1070 gInputStyleMask = TextEditor::InputStyle::NONE;
1071 inputStyleChangedSignal = false;
1073 // Create a tap event to touch the text editor.
1074 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1075 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1077 // Render and notify
1078 application.SendNotification();
1079 application.Render();
1081 // Executes the idle callbacks added by the text control on the change of input style.
1082 application.RunIdles();
1084 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1085 if( gInputStyleChangedCallbackCalled )
1087 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1089 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1090 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1092 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1093 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1095 DALI_TEST_CHECK( inputStyleChangedSignal );
1097 gInputStyleChangedCallbackCalled = false;
1098 gInputStyleMask = TextEditor::InputStyle::NONE;
1099 inputStyleChangedSignal = false;
1101 // Create a tap event to touch the text editor.
1102 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1103 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1105 // Render and notify
1106 application.SendNotification();
1107 application.Render();
1109 // Executes the idle callbacks added by the text control on the change of input style.
1110 application.RunIdles();
1112 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1113 DALI_TEST_CHECK( !inputStyleChangedSignal );
1115 gInputStyleChangedCallbackCalled = false;
1116 gInputStyleMask = TextEditor::InputStyle::NONE;
1117 inputStyleChangedSignal = false;
1119 // Create a tap event to touch the text editor.
1120 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1121 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1123 // Render and notify
1124 application.SendNotification();
1125 application.Render();
1127 // Executes the idle callbacks added by the text control on the change of input style.
1128 application.RunIdles();
1130 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1131 if( gInputStyleChangedCallbackCalled )
1133 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1135 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1136 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1138 DALI_TEST_CHECK( inputStyleChangedSignal );
1140 gInputStyleChangedCallbackCalled = false;
1141 gInputStyleMask = TextEditor::InputStyle::NONE;
1142 inputStyleChangedSignal = false;
1144 // Create a tap event to touch the text editor.
1145 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1146 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1148 // Render and notify
1149 application.SendNotification();
1150 application.Render();
1152 // Executes the idle callbacks added by the text control on the change of input style.
1153 application.RunIdles();
1155 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1156 if( gInputStyleChangedCallbackCalled )
1158 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1160 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1161 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1163 Property::Map fontStyleMapSet;
1164 Property::Map fontStyleMapGet;
1166 fontStyleMapSet.Insert( "weight", "bold" );
1168 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1169 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1170 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1172 DALI_TEST_CHECK( inputStyleChangedSignal );
1174 gInputStyleChangedCallbackCalled = false;
1175 gInputStyleMask = TextEditor::InputStyle::NONE;
1176 inputStyleChangedSignal = false;
1178 // Create a tap event to touch the text editor.
1179 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1180 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1182 // Render and notify
1183 application.SendNotification();
1184 application.Render();
1186 // Executes the idle callbacks added by the text control on the change of input style.
1187 application.RunIdles();
1189 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1190 DALI_TEST_CHECK( !inputStyleChangedSignal );
1192 gInputStyleChangedCallbackCalled = false;
1193 gInputStyleMask = TextEditor::InputStyle::NONE;
1194 inputStyleChangedSignal = false;
1196 // Create a tap event to touch the text editor.
1197 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1198 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1200 // Render and notify
1201 application.SendNotification();
1202 application.Render();
1204 // Executes the idle callbacks added by the text control on the change of input style.
1205 application.RunIdles();
1207 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1208 if( gInputStyleChangedCallbackCalled )
1210 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1212 Property::Map fontStyleMapSet;
1213 Property::Map fontStyleMapGet;
1215 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1216 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1217 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1219 DALI_TEST_CHECK( inputStyleChangedSignal );
1221 gInputStyleChangedCallbackCalled = false;
1222 gInputStyleMask = TextEditor::InputStyle::NONE;
1223 inputStyleChangedSignal = false;
1225 // Create a tap event to touch the text editor.
1226 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1227 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1229 // Render and notify
1230 application.SendNotification();
1231 application.Render();
1233 // Executes the idle callbacks added by the text control on the change of input style.
1234 application.RunIdles();
1236 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1237 DALI_TEST_CHECK( !inputStyleChangedSignal );
1242 int utcDaliTextEditorInputStyleChanged02(void)
1244 ToolkitTestApplication application;
1245 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1247 // The text-editor emits signals when the input style changes. These changes of style are
1248 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1249 // can't be emitted during the size negotiation as the callbacks may update the UI.
1250 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1251 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1252 application.CreateAdaptor();
1256 char* pathNamePtr = get_current_dir_name();
1257 const std::string pathName( pathNamePtr );
1258 free( pathNamePtr );
1260 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1261 fontClient.SetDpi( 93u, 93u );
1263 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1264 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1266 TextEditor editor = TextEditor::New();
1267 DALI_TEST_CHECK( editor );
1270 editor.SetSize( 300.f, 50.f );
1271 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1272 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1274 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1275 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>" );
1277 // connect to the text changed signal.
1278 ConnectionTracker* testTracker = new ConnectionTracker();
1279 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1280 bool inputStyleChangedSignal = false;
1281 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1283 Stage::GetCurrent().Add( editor );
1285 // Render and notify
1286 application.SendNotification();
1287 application.Render();
1289 // Executes the idle callbacks added by the text control on the change of input style.
1290 application.RunIdles();
1292 gInputStyleChangedCallbackCalled = false;
1293 gInputStyleMask = TextEditor::InputStyle::NONE;
1294 inputStyleChangedSignal = false;
1296 // Create a tap event to touch the text editor.
1297 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1298 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1299 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1300 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1302 // Render and notify
1303 application.SendNotification();
1304 application.Render();
1306 // Executes the idle callbacks added by the text control on the change of input style.
1307 application.RunIdles();
1309 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1310 if( gInputStyleChangedCallbackCalled )
1312 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1313 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1314 TextEditor::InputStyle::POINT_SIZE |
1315 TextEditor::InputStyle::COLOR ),
1318 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1319 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1321 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1322 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1324 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1325 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1327 DALI_TEST_CHECK( inputStyleChangedSignal );
1329 gInputStyleChangedCallbackCalled = false;
1330 gInputStyleMask = TextEditor::InputStyle::NONE;
1331 inputStyleChangedSignal = false;
1333 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1335 // Render and notify
1336 application.SendNotification();
1337 application.Render();
1339 // Executes the idle callbacks added by the text control on the change of input style.
1340 application.RunIdles();
1342 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1343 if( gInputStyleChangedCallbackCalled )
1345 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1346 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1349 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1350 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1352 DALI_TEST_CHECK( inputStyleChangedSignal );
1354 gInputStyleChangedCallbackCalled = false;
1355 gInputStyleMask = TextEditor::InputStyle::NONE;
1356 inputStyleChangedSignal = false;
1358 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1360 // Render and notify
1361 application.SendNotification();
1362 application.Render();
1364 // Executes the idle callbacks added by the text control on the change of input style.
1365 application.RunIdles();
1367 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1368 DALI_TEST_CHECK( !inputStyleChangedSignal );
1370 gInputStyleChangedCallbackCalled = false;
1371 gInputStyleMask = TextEditor::InputStyle::NONE;
1372 inputStyleChangedSignal = false;
1374 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1376 // Render and notify
1377 application.SendNotification();
1378 application.Render();
1380 // Executes the idle callbacks added by the text control on the change of input style.
1381 application.RunIdles();
1383 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1384 if( gInputStyleChangedCallbackCalled )
1386 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1387 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1390 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1391 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1393 DALI_TEST_CHECK( inputStyleChangedSignal );
1395 gInputStyleChangedCallbackCalled = false;
1396 gInputStyleMask = TextEditor::InputStyle::NONE;
1397 inputStyleChangedSignal = false;
1399 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1401 Property::Map fontStyleMapSet;
1402 fontStyleMapSet.Insert( "weight", "thin" );
1403 fontStyleMapSet.Insert( "width", "condensed" );
1404 fontStyleMapSet.Insert( "slant", "italic" );
1406 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1407 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1408 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1410 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1411 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1412 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1413 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1415 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1417 // Render and notify
1418 application.SendNotification();
1419 application.Render();
1421 // Executes the idle callbacks added by the text control on the change of input style.
1422 application.RunIdles();
1424 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1425 DALI_TEST_CHECK( !inputStyleChangedSignal );
1427 // Create a tap event to touch the text editor.
1428 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1429 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1431 // Render and notify
1432 application.SendNotification();
1433 application.Render();
1435 // Executes the idle callbacks added by the text control on the change of input style.
1436 application.RunIdles();
1438 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1439 if( gInputStyleChangedCallbackCalled )
1441 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1442 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1443 TextEditor::InputStyle::POINT_SIZE |
1444 TextEditor::InputStyle::FONT_STYLE |
1445 TextEditor::InputStyle::LINE_SPACING |
1446 TextEditor::InputStyle::UNDERLINE |
1447 TextEditor::InputStyle::SHADOW |
1448 TextEditor::InputStyle::EMBOSS |
1449 TextEditor::InputStyle::OUTLINE ),
1452 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1453 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1455 DALI_TEST_CHECK( inputStyleChangedSignal );
1457 gInputStyleChangedCallbackCalled = false;
1458 gInputStyleMask = TextEditor::InputStyle::NONE;
1459 inputStyleChangedSignal = false;
1461 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1463 fontStyleMapSet.Clear();
1464 fontStyleMapSet.Insert( "weight", "black" );
1465 fontStyleMapSet.Insert( "width", "expanded" );
1466 fontStyleMapSet.Insert( "slant", "oblique" );
1468 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1470 // Create a tap event to touch the text editor.
1471 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1472 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1474 // Render and notify
1475 application.SendNotification();
1476 application.Render();
1478 // Executes the idle callbacks added by the text control on the change of input style.
1479 application.RunIdles();
1481 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1482 if( gInputStyleChangedCallbackCalled )
1484 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1485 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1486 TextEditor::InputStyle::POINT_SIZE |
1487 TextEditor::InputStyle::FONT_STYLE ),
1490 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1491 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1493 DALI_TEST_CHECK( inputStyleChangedSignal );
1498 int utcDaliTextEditorEvent01(void)
1500 ToolkitTestApplication application;
1501 tet_infoline(" utcDaliTextEditorEvent01");
1503 // Creates a tap event. After creating a tap event the text editor should
1504 // have the focus and add text with key events should be possible.
1506 TextEditor editor = TextEditor::New();
1507 DALI_TEST_CHECK( editor );
1509 Stage::GetCurrent().Add( editor );
1511 editor.SetSize( 300.f, 50.f );
1512 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1513 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1515 // Avoid a crash when core load gl resources.
1516 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1518 // Render and notify
1519 application.SendNotification();
1520 application.Render();
1522 // Add a key event but as the text editor has not the focus it should do nothing.
1523 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1525 // Render and notify
1526 application.SendNotification();
1527 application.Render();
1529 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1531 // Create a tap event to touch the text editor.
1532 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1533 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1535 // Render and notify
1536 application.SendNotification();
1537 application.Render();
1539 // Now the text editor has the focus, so it can handle the key events.
1540 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1541 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1543 // Render and notify
1544 application.SendNotification();
1545 application.Render();
1547 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1549 // Create a second text editor and send key events to it.
1550 TextEditor editor2 = TextEditor::New();
1552 editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1553 editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1554 editor2.SetSize( 100.f, 100.f );
1555 editor2.SetPosition( 100.f, 100.f );
1557 Stage::GetCurrent().Add( editor2 );
1559 // Render and notify
1560 application.SendNotification();
1561 application.Render();
1563 // Create a tap event on the second text editor.
1564 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1565 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1567 // Render and notify
1568 application.SendNotification();
1569 application.Render();
1571 // The second text editor has the focus. It should handle the key events.
1572 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1573 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1575 // Render and notify
1576 application.SendNotification();
1577 application.Render();
1579 // Check the text has been added to the second text editor.
1580 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1585 int utcDaliTextEditorEvent02(void)
1587 ToolkitTestApplication application;
1588 tet_infoline(" utcDaliTextEditorEvent02");
1590 // Checks if the right number of actors are created.
1592 TextEditor editor = TextEditor::New();
1593 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1594 DALI_TEST_CHECK( editor );
1596 Stage::GetCurrent().Add( editor );
1598 editor.SetSize( 300.f, 50.f );
1599 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1600 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1602 // Avoid a crash when core load gl resources.
1603 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1605 // Render and notify
1606 application.SendNotification();
1607 application.Render();
1609 // Check there are the expected number of children (the stencil).
1610 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1612 Actor stencil = editor.GetChildAt( 0u );
1614 // Create a tap event to touch the text editor.
1615 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1616 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1618 // Render and notify
1619 application.SendNotification();
1620 application.Render();
1622 Actor layer = editor.GetChildAt( 1u );
1623 DALI_TEST_CHECK( layer.IsLayer() );
1625 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1626 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1628 // Now the text editor has the focus, so it can handle the key events.
1629 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1630 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1632 // Render and notify
1633 application.SendNotification();
1634 application.Render();
1636 // Checks the cursor and the renderer have been created.
1637 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1638 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1640 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1641 DALI_TEST_CHECK( cursor );
1643 // The stencil actor has a container with all the actors which contain the text renderers.
1644 Actor container = stencil.GetChildAt( 0u );
1645 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1647 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1648 DALI_TEST_CHECK( renderer );
1651 // Move the cursor and check the position changes.
1652 Vector3 position1 = cursor.GetCurrentPosition();
1654 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1655 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1657 // Render and notify
1658 application.SendNotification();
1659 application.Render();
1661 Vector3 position2 = cursor.GetCurrentPosition();
1663 DALI_TEST_CHECK( position2.x < position1.x );
1665 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1666 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1668 // Render and notify
1669 application.SendNotification();
1670 application.Render();
1672 Vector3 position3 = cursor.GetCurrentPosition();
1674 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1676 // Send some taps and check the cursor positions.
1678 // Try to tap at the beginning.
1679 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1680 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1682 // Render and notify
1683 application.SendNotification();
1684 application.Render();
1686 // Cursor position should be the same than position1.
1687 Vector3 position4 = cursor.GetCurrentPosition();
1689 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1691 // Tap away from the start position.
1692 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1693 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1695 // Render and notify
1696 application.SendNotification();
1697 application.Render();
1699 Vector3 position5 = cursor.GetCurrentPosition();
1701 DALI_TEST_CHECK( position5.x > position4.x );
1703 // Remove all the text.
1704 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1705 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1706 editor.SetProperty( TextEditor::Property::TEXT, "" );
1708 // Render and notify
1709 application.SendNotification();
1710 application.Render();
1712 // Cursor position should be the same than position2.
1713 Vector3 position6 = cursor.GetCurrentPosition();
1715 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1717 // Should not be a renderer.
1718 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1723 int utcDaliTextEditorEvent03(void)
1725 ToolkitTestApplication application;
1726 tet_infoline(" utcDaliTextEditorEvent03");
1728 // Checks if the highlight actor is created.
1730 TextEditor editor = TextEditor::New();
1731 DALI_TEST_CHECK( editor );
1733 Stage::GetCurrent().Add( editor );
1735 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1736 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1737 editor.SetSize( 30.f, 50.f );
1738 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1739 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1741 // Avoid a crash when core load gl resources.
1742 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1744 // Render and notify
1745 application.SendNotification();
1746 application.Render();
1748 // Send some taps and check text controller with clipboard window
1749 Dali::Clipboard clipboard = Clipboard::Get();
1750 clipboard.ShowClipboard();
1751 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1752 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1753 clipboard.HideClipboard();
1755 // Render and notify
1756 application.SendNotification();
1757 application.Render();
1759 // Tap first to get the focus.
1760 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1761 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1763 // Render and notify
1764 application.SendNotification();
1765 application.Render();
1767 // Double tap to select a word.
1768 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1769 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1771 // Render and notify
1772 application.SendNotification();
1773 application.Render();
1775 // The stencil actor should have two actors: the renderer and the highlight actor.
1776 Actor stencil = editor.GetChildAt( 0u );
1778 // Highlight needs to be drawn before text, so should come first in child order
1779 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1780 DALI_TEST_CHECK( highlight );
1782 // The stencil actor has a container with all the actors which contain the text renderers.
1783 Actor container = stencil.GetChildAt( 1u );
1784 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1786 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1787 DALI_TEST_CHECK( renderer );
1790 // Double tap out of bounds
1791 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1792 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1794 // Render and notify
1795 application.SendNotification();
1796 application.Render();
1798 // The stencil actor should have one actors: the renderer actor.
1799 stencil = editor.GetChildAt( 0u );
1801 // The stencil actor has a container with all the actors which contain the text renderers.
1802 container = stencil.GetChildAt( 0u );
1803 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1805 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1806 DALI_TEST_CHECK( renderer );
1810 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1811 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1813 // Render and notify
1814 application.SendNotification();
1815 application.Render();
1820 int utcDaliTextEditorEvent04(void)
1822 ToolkitTestApplication application;
1823 tet_infoline(" utcDaliTextEditorEvent04");
1825 // Checks if the highlight actor is created.
1827 TextEditor editor = TextEditor::New();
1828 DALI_TEST_CHECK( editor );
1830 Stage::GetCurrent().Add( editor );
1832 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1833 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1834 editor.SetSize( 100.f, 50.f );
1835 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1836 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1838 // Avoid a crash when core load gl resources.
1839 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1841 // Render and notify
1842 application.SendNotification();
1843 application.Render();
1845 // Tap on the text editor
1846 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1847 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1849 // Render and notify
1850 application.SendNotification();
1851 application.Render();
1853 // Move at the end of the text.
1854 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1855 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 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_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1864 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 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( "d", "d", KEY_D_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 );
1880 // Add some key events
1881 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1882 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1884 // Render and notify
1885 application.SendNotification();
1886 application.Render();
1888 for( unsigned int index = 0u; index < 10u; ++index )
1890 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1891 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1893 // Render and notify
1894 application.SendNotification();
1895 application.Render();
1899 application.ProcessEvent( GenerateKey( " ", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1901 // Render and notify
1902 application.SendNotification();
1903 application.Render();
1905 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1910 int utcDaliTextEditorEvent05(void)
1912 ToolkitTestApplication application;
1913 tet_infoline(" utcDaliTextEditorEvent05");
1915 // Checks if the highlight actor is created.
1917 TextEditor editor = TextEditor::New();
1918 DALI_TEST_CHECK( editor );
1920 Stage::GetCurrent().Add( editor );
1922 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1923 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1924 editor.SetSize( 50.f, 50.f );
1925 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1926 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1927 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1928 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1929 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1930 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1931 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1933 // Avoid a crash when core load gl resources.
1934 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1936 // Render and notify
1937 application.SendNotification();
1938 application.Render();
1940 // Tap on the text editor
1941 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1942 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1944 // Render and notify
1945 application.SendNotification();
1946 application.Render();
1948 // Move at the end of the text.
1949 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1950 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1952 // Render and notify
1953 application.SendNotification();
1954 application.Render();
1956 for( unsigned int index = 0u; index < 10u; ++index )
1959 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1961 // Render and notify
1962 application.SendNotification();
1963 application.Render();
1965 // Modify duration after scroll is enabled
1966 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1968 // Continuous scroll left to increase coverage
1969 for( unsigned int index = 0u; index < 10u; ++index )
1971 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1973 // Render and notify
1974 application.SendNotification();
1975 application.Render();
1977 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1978 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1979 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1980 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1981 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1983 // Press Escape to increase coverage
1984 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1985 application.SendNotification();
1986 application.Render();
1988 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1993 int utcDaliTextEditorEvent06(void)
1995 ToolkitTestApplication application;
1996 tet_infoline(" utcDaliTextEditorEvent06");
1998 // Checks if the highlight actor is created.
2000 TextEditor editor = TextEditor::New();
2001 DALI_TEST_CHECK( editor );
2003 Stage::GetCurrent().Add( editor );
2005 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2006 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2007 editor.SetSize( 100.f, 50.f );
2008 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2009 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2011 // Avoid a crash when core load gl resources.
2012 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2014 // Render and notify
2015 application.SendNotification();
2016 application.Render();
2018 // Tap on the text editor
2019 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2020 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2022 // Render and notify
2023 application.SendNotification();
2024 application.Render();
2026 // Move to seconds line of the text.
2027 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2029 // Render and notify
2030 application.SendNotification();
2031 application.Render();
2033 float layoutHeight = editor.GetHeightForWidth( 100.f );
2036 // Add another script characters ( glyph height is defferent )
2037 application.ProcessEvent( GenerateKey( "d", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2038 application.ProcessEvent( GenerateKey( "d", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2040 // Delete characters
2041 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2042 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2044 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2046 // Render and notify
2047 application.SendNotification();
2048 application.Render();
2050 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2053 application.ProcessEvent( GenerateKey( "", "", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2054 application.SendNotification();
2055 application.Render();
2057 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2058 application.SendNotification();
2059 application.Render();
2061 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2062 application.SendNotification();
2063 application.Render();
2065 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2066 application.SendNotification();
2067 application.Render();
2069 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2070 application.SendNotification();
2071 application.Render();
2073 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2074 application.SendNotification();
2075 application.Render();
2077 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2078 application.SendNotification();
2079 application.Render();
2084 int utcDaliTextEditorEvent07(void)
2086 ToolkitTestApplication application;
2087 tet_infoline(" utcDaliTextEditorEvent07");
2089 // Checks if the highlight actor is created.
2091 TextEditor editor = TextEditor::New();
2092 DALI_TEST_CHECK( editor );
2094 Stage::GetCurrent().Add( editor );
2096 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2097 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2098 editor.SetSize( 100.f, 50.f );
2099 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2100 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2102 // Avoid a crash when core load gl resources.
2103 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2105 // Render and notify
2106 application.SendNotification();
2107 application.Render();
2109 // Tap on the text editor
2110 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2111 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2113 // Render and notify
2114 application.SendNotification();
2115 application.Render();
2117 // Move to second line of the text.
2118 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2120 // Render and notify
2121 application.SendNotification();
2122 application.Render();
2124 // Select some text in the right of the current cursor position
2125 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2126 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2127 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2128 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2130 // Render and notify
2131 application.SendNotification();
2132 application.Render();
2134 // Cut the selected text
2135 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2136 application.ProcessEvent( GenerateKey( "x", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2138 // Render and notify
2139 application.SendNotification();
2140 application.Render();
2142 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2144 // Select some text in the left of the current cursor position
2145 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2146 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2147 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2148 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2150 // Render and notify
2151 application.SendNotification();
2152 application.Render();
2154 // Copy the selected text
2155 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2156 application.ProcessEvent( GenerateKey( "c", "c", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2158 // Render and notify
2159 application.SendNotification();
2160 application.Render();
2162 // Move the cursor to the third line
2163 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2164 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2166 // Render and notify
2167 application.SendNotification();
2168 application.Render();
2170 // Paste the selected text at the current cursor position
2171 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2172 application.ProcessEvent( GenerateKey( "v", "v", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2174 // Render and notify
2175 application.SendNotification();
2176 application.Render();
2178 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2181 // Disable Shift Selection
2182 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2184 // Test to select some text in the right of the current cursor position
2185 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2186 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2187 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2188 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2190 // Render and notify
2191 application.SendNotification();
2192 application.Render();
2194 // Cut the selected text
2195 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2196 application.ProcessEvent( GenerateKey( "x", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2198 // Render and notify
2199 application.SendNotification();
2200 application.Render();
2202 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2203 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2205 // Test to select some text in the left of the current cursor position
2206 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2207 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2208 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2209 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2211 // Render and notify
2212 application.SendNotification();
2213 application.Render();
2215 // Copy the selected text
2216 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2217 application.ProcessEvent( GenerateKey( "c", "c", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2219 // Render and notify
2220 application.SendNotification();
2221 application.Render();
2223 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2224 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2229 int utcDaliTextEditorHandles(void)
2231 ToolkitTestApplication application;
2232 tet_infoline(" utcDaliTextEditorHandles");
2234 TextEditor editor = TextEditor::New();
2235 DALI_TEST_CHECK( editor );
2237 Stage::GetCurrent().Add( editor );
2239 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2240 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2241 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2242 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2244 editor.SetSize( 30.f, 500.f );
2245 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2246 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2248 // Avoid a crash when core load gl resources.
2249 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2251 // Render and notify
2252 application.SendNotification();
2253 application.Render();
2255 // Tap first to get the focus.
2256 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2257 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2259 // Render and notify
2260 application.SendNotification();
2261 application.Render();
2263 // Tap to create the grab handle.
2264 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2265 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2267 // Render and notify
2268 application.SendNotification();
2269 application.Render();
2271 // Get the active layer where the text's decoration is added.
2272 Actor activeLayer = editor.GetChildAt( 1u );
2274 // Get the handle's actor.
2275 Actor handle = activeLayer.GetChildAt( 1u );
2276 handle.SetSize( 100.f, 100.f );
2278 // Render and notify
2279 application.SendNotification();
2280 application.Render();
2282 // Touch the grab handle to set it as pressed.
2283 Vector2 touchPos( 10.0f, 50.0f );
2284 Dali::Integration::TouchEvent event;
2285 event = Dali::Integration::TouchEvent();
2286 event.AddPoint( GetPointDownInside( touchPos ) );
2287 application.ProcessEvent( event );
2289 // Render and notify
2290 application.SendNotification();
2291 application.Render();
2293 // drag grab handle right
2294 SendPan(application, Gesture::Possible, touchPos);
2295 SendPan(application, Gesture::Started, touchPos);
2297 Wait(application, 100);
2299 for(int i = 0;i<20;i++)
2301 SendPan(application, Gesture::Continuing, touchPos);
2306 SendPan(application, Gesture::Finished, touchPos);
2309 // Release the grab handle.
2310 event = Dali::Integration::TouchEvent();
2311 event.AddPoint( GetPointUpInside( touchPos ) );
2312 application.ProcessEvent( event );
2314 // Render and notify
2315 application.SendNotification();
2316 application.Render();
2322 int utcDaliTextEditorUnderPropertyStringP(void)
2324 ToolkitTestApplication application;
2325 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2326 TextEditor editor = TextEditor::New();
2327 DALI_TEST_CHECK( editor );
2329 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2331 Stage::GetCurrent().Add( editor );
2333 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2334 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2336 tet_infoline("Set underline settings with a map");
2337 // Check the input underline property
2338 Property::Map underlineMapSet;
2339 Property::Map underlineMapGet;
2340 underlineMapSet.Insert( "enable", "true" );
2341 underlineMapSet.Insert( "color", "blue" );
2342 underlineMapSet.Insert( "height", "2" );
2344 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2345 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2346 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2347 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2349 tet_infoline("Set underline settings with a string");
2350 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2351 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2354 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2356 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2357 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2358 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2359 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2361 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2366 int utcDaliTextEditorShadowPropertyStringP(void)
2368 ToolkitTestApplication application;
2369 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2371 TextEditor editor = TextEditor::New();
2373 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2375 Stage::GetCurrent().Add( editor );
2377 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2379 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2383 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2388 int utcDaliTextEditorFontStylePropertyStringP(void)
2390 ToolkitTestApplication application;
2391 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2393 TextEditor editor = TextEditor::New();
2395 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2397 Stage::GetCurrent().Add( editor );
2399 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2401 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2405 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2410 int utcDaliTextEditorGetPropertyLinecountP(void)
2412 ToolkitTestApplication application;
2414 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2418 TextEditor editor = TextEditor::New();
2419 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2420 editor.SetProperty( TextEditor::Property::TEXT,
2421 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2423 Stage::GetCurrent().Add( editor );
2425 editor.SetSize( 100.0f, 100.0f );
2426 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2427 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2429 editor.SetSize( 50.0f, 100.0f );
2430 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2431 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2436 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2439 ToolkitTestApplication application;
2440 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2442 TextEditor editor = TextEditor::New();
2443 DALI_TEST_CHECK( editor );
2445 Stage::GetCurrent().Add( editor );
2447 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2448 editor.SetSize( 50.f, 50.f );
2449 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2450 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2451 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2452 editor.SetKeyboardFocusable(true);
2454 bool startedCalled = false;
2455 bool finishedCalled = false;
2457 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2458 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2460 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2462 // Render and notify
2463 application.SendNotification();
2464 application.Render();
2466 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2467 application.SendNotification();
2468 application.Render(6000);
2470 application.SendNotification();
2471 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2472 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2477 int UtcDaliToolkitTextEditorTextWrapMode(void)
2479 ToolkitTestApplication application;
2480 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2484 TextEditor editor = TextEditor::New();
2485 editor.SetSize( 150.0f, 300.f );
2486 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2488 Stage::GetCurrent().Add( editor );
2490 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2491 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2493 application.SendNotification();
2494 application.Render();
2496 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2497 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2499 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2500 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2502 application.SendNotification();
2503 application.Render();
2505 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2506 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2508 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2509 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2511 application.SendNotification();
2512 application.Render();
2514 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2515 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2517 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2518 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2520 application.SendNotification();
2521 application.Render();
2523 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2524 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2529 int UtcDaliTextEditorSetPaddingProperty(void)
2531 ToolkitTestApplication application;
2532 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2534 TextEditor editor = TextEditor::New();
2535 DALI_TEST_CHECK( editor );
2536 editor.SetSize( 300.f, 50.f );
2537 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2538 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2539 Stage::GetCurrent().Add( editor );
2541 application.SendNotification();
2542 application.Render();
2544 Vector3 originalSize = editor.GetNaturalSize();
2546 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2548 application.SendNotification();
2549 application.Render();
2551 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2553 Vector3 paddingAddedSize = editor.GetNaturalSize();
2555 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2557 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2562 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
2564 ToolkitTestApplication application;
2565 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
2567 TextEditor editor = TextEditor::New();
2568 DALI_TEST_CHECK( editor );
2569 editor.SetSize( 300.f, 50.f );
2570 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2571 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2572 Stage::GetCurrent().Add( editor );
2574 application.SendNotification();
2575 application.Render();
2577 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2578 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2580 // Check the enable shift selection property
2581 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2582 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2584 application.SendNotification();
2585 application.Render();