2 * Copyright (c) 2021 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/devel-api/text-abstraction/font-client.h>
25 #include <dali/integration-api/events/key-event-integ.h>
26 #include <dali/integration-api/events/touch-event-integ.h>
27 #include <dali-toolkit-test-suite-utils.h>
28 #include <dali-toolkit/dali-toolkit.h>
29 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
30 #include <dali-toolkit/devel-api/text/rendering-backend.h>
31 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
32 #include "test-text-geometry-utils.h"
35 using namespace Toolkit;
37 void dali_texteditor_startup(void)
39 test_return_value = TET_UNDEF;
42 void dali_texteditor_cleanup(void)
44 test_return_value = TET_PASS;
50 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
51 const char* const PROPERTY_NAME_TEXT = "text";
52 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
53 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
54 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
55 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
56 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
57 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
58 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
59 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
60 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
61 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
62 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
63 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
64 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
65 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
66 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
71 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
72 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
73 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
74 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
75 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
76 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
77 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
78 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
79 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
81 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
82 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
83 const char* const PROPERTY_NAME_UNDERLINE = "underline";
84 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
85 const char* const PROPERTY_NAME_SHADOW = "shadow";
86 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
87 const char* const PROPERTY_NAME_EMBOSS = "emboss";
88 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
89 const char* const PROPERTY_NAME_OUTLINE = "outline";
90 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
91 const char* const PROPERTY_NAME_STRIKETHROUGH = "strikethrough";
92 const char* const PROPERTY_NAME_INPUT_STRIKETHROUGH = "inputStrikethrough";
94 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
95 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
96 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
97 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
98 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
99 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
100 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
101 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
102 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
103 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
104 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
105 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
106 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
107 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
108 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
109 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
110 const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE = "enableFontSizeScale";
111 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
112 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
113 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
114 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
116 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
117 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
119 const float RENDER_FRAME_INTERVAL = 16.66f;
121 const unsigned int DEFAULT_FONT_SIZE = 1152u;
122 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
124 const int KEY_A_CODE = 38;
125 const int KEY_D_CODE = 40;
126 const int KEY_C_CODE = 54;
127 const int KEY_V_CODE = 55;
128 const int KEY_X_CODE = 53;
129 const int KEY_WHITE_SPACE_CODE = 65;
131 const int KEY_SHIFT_MODIFIER = 257;
132 const int KEY_CONTROL_MODIFIER = 258;
134 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
135 const char* HANDLE_LEFT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_left.png";
136 const char* HANDLE_RIGHT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_right.png";
138 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
140 static bool gSelectionChangedCallbackCalled;
141 static uint32_t oldSelectionStart;
142 static uint32_t oldSelectionEnd;
143 static bool gSelectionClearedCallbackCalled;
144 static bool gAnchorClickedCallBackCalled;
145 static bool gAnchorClickedCallBackNotCalled;
146 static bool gTextChangedCallBackCalled;
147 static bool gInputFilteredAcceptedCallbackCalled;
148 static bool gInputFilteredRejectedCallbackCalled;
149 static bool gInputStyleChangedCallbackCalled;
150 static bool gMaxCharactersCallBackCalled;
151 static bool gCursorPositionChangedCallbackCalled;
152 static uint32_t oldCursorPos;
153 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
155 struct CallbackFunctor
157 CallbackFunctor(bool* callbackFlag)
158 : mCallbackFlag( callbackFlag )
164 *mCallbackFlag = true;
169 static void TestSelectionClearedCallback(TextEditor control)
171 tet_infoline(" TestSelectionClearedCallback");
173 gSelectionClearedCallbackCalled = true;
176 static void TestSelectionChangedCallback(TextEditor control, uint32_t oldStart, uint32_t oldEnd)
178 tet_infoline(" TestSelectionChangedCallback");
180 gSelectionChangedCallbackCalled = true;
181 oldSelectionStart = oldStart;
182 oldSelectionEnd = oldEnd;
185 static void TestAnchorClickedCallback(TextEditor control, const char* href, unsigned int hrefLength)
187 tet_infoline(" TestAnchorClickedCallback");
189 gAnchorClickedCallBackNotCalled = false;
191 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
193 gAnchorClickedCallBackCalled = true;
197 static void TestCursorPositionChangedCallback( TextEditor control, unsigned int oldPos )
199 tet_infoline(" TestCursorPositionChangedCallback");
201 gCursorPositionChangedCallbackCalled = true;
202 oldCursorPos = oldPos;
205 static void TestTextChangedCallback( TextEditor control )
207 tet_infoline(" TestTextChangedCallback");
209 gTextChangedCallBackCalled = true;
212 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
214 tet_infoline(" TestInputStyleChangedCallback");
216 gInputStyleChangedCallbackCalled = true;
217 gInputStyleMask = mask;
220 static void TestMaxLengthReachedCallback( TextEditor control )
222 tet_infoline(" TestMaxLengthReachedCallback");
224 gMaxCharactersCallBackCalled = true;
227 static void TestInputFilteredCallback(TextEditor control, Toolkit::InputFilter::Property::Type type)
229 tet_infoline(" TestInputFilteredCallback");
231 if(type == Toolkit::InputFilter::Property::ACCEPTED)
233 gInputFilteredAcceptedCallbackCalled = true;
235 else if(type == Toolkit::InputFilter::Property::REJECTED)
237 gInputFilteredRejectedCallbackCalled = true;
241 // Generate a KeyEvent to send to Core.
242 Integration::KeyEvent GenerateKey( const std::string& keyName,
243 const std::string& logicalKey,
244 const std::string& keyString,
247 unsigned long timeStamp,
248 const Integration::KeyEvent::State& keyState,
249 const std::string& compose = "",
250 const std::string& deviceName = DEFAULT_DEVICE_NAME,
251 const Device::Class::Type& deviceClass = Device::Class::NONE,
252 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
254 return Integration::KeyEvent( keyName,
267 Dali::Integration::Point GetPointDownInside( Vector2& pos )
269 Dali::Integration::Point point;
270 point.SetState( PointState::DOWN );
271 point.SetScreenPosition( pos );
275 Dali::Integration::Point GetPointUpInside( Vector2& pos )
277 Dali::Integration::Point point;
278 point.SetState( PointState::UP );
279 point.SetScreenPosition( pos );
283 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
285 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
287 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
289 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
291 Property::Value* valueSet = NULL;
292 if ( valueGet.first.type == Property::Key::INDEX )
294 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
298 // Get Key is a string so searching Set Map for a string key
299 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
302 if( NULL != valueSet )
304 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
306 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
309 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
311 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
314 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
316 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
319 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
321 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
324 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
326 Vector2 vector2Get = valueGet.second.Get<Vector2>();
327 Vector2 vector2Set = valueSet->Get<Vector2>();
328 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
331 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
333 Vector4 vector4Get = valueGet.second.Get<Vector4>();
334 Vector4 vector4Set = valueSet->Get<Vector4>();
335 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 );
341 if ( valueGet.first.type == Property::Key::INDEX )
343 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
347 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
357 class ScrollStateChangeCallback : public Dali::ConnectionTracker
360 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
361 : mStartedCalled( startedCalled ),
362 mFinishedCalled( finishedCalled )
366 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
368 if( type == TextEditor::Scroll::STARTED )
370 mStartedCalled = true;
372 else if( type == TextEditor::Scroll::FINISHED )
374 mFinishedCalled = true;
378 bool& mStartedCalled;
379 bool& mFinishedCalled;
384 int UtcDaliToolkitTextEditorConstructorP(void)
386 ToolkitTestApplication application;
387 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
388 TextEditor textEditor;
389 DALI_TEST_CHECK( !textEditor );
393 int UtcDaliToolkitTextEditorNewP(void)
395 ToolkitTestApplication application;
396 tet_infoline(" UtcDaliToolkitTextEditorNewP");
397 TextEditor textEditor = TextEditor::New();
398 DALI_TEST_CHECK( textEditor );
402 int UtcDaliToolkitTextEditorDownCastP(void)
404 ToolkitTestApplication application;
405 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
406 TextEditor textEditor1 = TextEditor::New();
407 BaseHandle object( textEditor1 );
409 TextEditor textEditor2 = TextEditor::DownCast( object );
410 DALI_TEST_CHECK( textEditor2 );
412 TextEditor textEditor3 = DownCast< TextEditor >( object );
413 DALI_TEST_CHECK( textEditor3 );
417 int UtcDaliToolkitTextEditorDownCastN(void)
419 ToolkitTestApplication application;
420 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
421 BaseHandle uninitializedObject;
422 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
423 DALI_TEST_CHECK( !textEditor1 );
425 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
426 DALI_TEST_CHECK( !textEditor2 );
430 int UtcDaliToolkitTextEditorCopyConstructorP(void)
432 ToolkitTestApplication application;
433 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
434 TextEditor textEditor = TextEditor::New();
435 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
437 TextEditor copy( textEditor );
438 DALI_TEST_CHECK( copy );
439 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
443 int UtcDaliTextEditorMoveConstructor(void)
445 ToolkitTestApplication application;
447 TextEditor textEditor = TextEditor::New();
448 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
449 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
451 TextEditor moved = std::move( textEditor );
452 DALI_TEST_CHECK( moved );
453 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
454 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
455 DALI_TEST_CHECK( !textEditor );
460 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
462 ToolkitTestApplication application;
463 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
464 TextEditor textEditor = TextEditor::New();
465 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
467 TextEditor copy = textEditor;
468 DALI_TEST_CHECK( copy );
469 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
473 int UtcDaliTextEditorMoveAssignment(void)
475 ToolkitTestApplication application;
477 TextEditor textEditor = TextEditor::New();
478 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
479 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
482 moved = std::move( textEditor );
483 DALI_TEST_CHECK( moved );
484 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
485 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
486 DALI_TEST_CHECK( !textEditor );
491 int UtcDaliTextEditorNewP(void)
493 ToolkitTestApplication application;
494 tet_infoline(" UtcDaliToolkitTextEditorNewP");
495 TextEditor textEditor = TextEditor::New();
496 DALI_TEST_CHECK( textEditor );
500 // Positive test case for a method
501 int UtcDaliTextEditorGetPropertyP(void)
503 ToolkitTestApplication application;
504 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
505 TextEditor editor = TextEditor::New();
506 DALI_TEST_CHECK( editor );
508 // Check Property Indices are correct
509 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextEditor::Property::RENDERING_BACKEND );
510 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
511 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
512 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
513 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
514 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
515 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
516 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
517 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
518 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
519 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
520 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
521 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
522 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
523 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
524 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
525 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
526 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
527 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
528 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
529 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
530 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
531 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
532 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
533 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
534 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
535 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
536 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
537 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
538 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
540 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
541 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
542 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
543 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
544 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
545 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
546 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
547 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
548 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
549 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
550 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_STRIKETHROUGH ) == DevelTextEditor::Property::STRIKETHROUGH );
551 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_STRIKETHROUGH ) == DevelTextEditor::Property::INPUT_STRIKETHROUGH );
552 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
553 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
554 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
555 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
556 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
557 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
558 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
559 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
560 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
561 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextEditor::Property::FONT_SIZE_SCALE );
562 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE ) == DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE );
563 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
564 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
565 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
566 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
567 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
568 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == DevelTextEditor::Property::MAX_LENGTH );
569 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextEditor::Property::GRAB_HANDLE_COLOR );
570 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP );
571 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == DevelTextEditor::Property::INPUT_METHOD_SETTINGS );
572 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FILTER ) == DevelTextEditor::Property::INPUT_FILTER );
573 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_STRIKETHROUGH ) == DevelTextEditor::Property::STRIKETHROUGH );
574 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_STRIKETHROUGH ) == DevelTextEditor::Property::INPUT_STRIKETHROUGH );
579 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
582 Property::Map imageMap;
583 imageMap[mapKey] =mapValue;
585 editor.SetProperty( property , imageMap );
586 Property::Value propValue = editor.GetProperty( property );
587 Property::Map* resultMap = propValue.GetMap();
589 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
597 // Positive test case for a method
598 int UtcDaliTextEditorSetPropertyP(void)
600 ToolkitTestApplication application;
601 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
602 TextEditor editor = TextEditor::New();
603 DALI_TEST_CHECK( editor );
604 application.GetScene().Add( editor );
606 // Note - we can't check the defaults since the stylesheets are platform-specific
608 // Check the render backend property.
609 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
610 DALI_TEST_EQUALS( (DevelText::RenderingType)editor.GetProperty<int>( DevelTextEditor::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
612 // Check text property.
613 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
614 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
616 // Check text's color property
617 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
618 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
620 // Check font properties.
621 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
622 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
624 Property::Map fontStyleMapSet;
625 Property::Map fontStyleMapGet;
626 Property::Value* slantValue = NULL;
628 fontStyleMapSet.Insert( "weight", "bold" );
629 fontStyleMapSet.Insert( "width", "condensed" );
630 fontStyleMapSet.Insert( "slant", "italic" );
632 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
633 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
634 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
635 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
637 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
638 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
640 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 2.5f );
641 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
642 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 1.0f );
644 editor.SetProperty( DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE, false );
645 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE ), false, TEST_LOCATION );
646 editor.SetProperty( DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE, true );
649 fontStyleMapSet.Clear();
650 fontStyleMapSet.Insert( "weight", "normal" );
651 fontStyleMapSet.Insert( "slant", "oblique" );
652 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
653 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
654 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
655 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
657 fontStyleMapSet.Clear();
658 fontStyleMapSet.Insert( "slant", "roman" );
659 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
660 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
662 // Replace 'roman' for 'normal'.
663 slantValue = fontStyleMapGet.Find( "slant" );
664 if( NULL != slantValue )
666 if( "normal" == slantValue->Get<std::string>() )
668 fontStyleMapGet["slant"] = "roman";
671 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
672 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
674 fontStyleMapSet.Clear();
676 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
677 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
678 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
679 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
681 // Check that the Alignment properties can be correctly set
682 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
683 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
685 // Check scroll properties.
686 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
687 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
688 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
689 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
691 // Check cursor properties
692 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
693 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
694 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
695 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
697 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
698 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
699 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
700 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
701 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
702 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
703 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
704 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
706 // Check handle images
707 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
708 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
709 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
710 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
711 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
713 // Check handle images
714 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
715 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
716 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
717 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
718 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
719 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
721 // Check the highlight color
722 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
723 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
725 // Decoration bounding box
726 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
727 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
729 // Check the enable markup property.
730 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
731 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
732 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
734 // Check input color property.
735 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
736 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
738 // Check input font properties.
739 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
740 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
742 fontStyleMapSet.Clear();
743 fontStyleMapSet.Insert( "weight", "bold" );
744 fontStyleMapSet.Insert( "width", "condensed" );
745 fontStyleMapSet.Insert( "slant", "italic" );
747 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
748 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
749 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
750 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
752 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
753 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
755 // Reset input font style.
756 fontStyleMapSet.Clear();
757 fontStyleMapSet.Insert( "weight", "normal" );
758 fontStyleMapSet.Insert( "slant", "oblique" );
760 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
761 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
762 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
763 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
765 fontStyleMapSet.Clear();
766 fontStyleMapSet.Insert( "slant", "roman" );
768 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
769 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
771 // Replace 'roman' for 'normal'.
772 slantValue = fontStyleMapGet.Find( "slant" );
773 if( NULL != slantValue )
775 if( "normal" == slantValue->Get<std::string>() )
777 fontStyleMapGet["slant"] = "roman";
780 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
781 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
783 fontStyleMapSet.Clear();
785 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
786 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
787 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
788 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
790 // Check the line spacing property
791 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
792 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
793 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
795 // Check the input line spacing property
796 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
797 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
798 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
800 // Check the underline property
802 Property::Map underlineMapSet;
803 Property::Map underlineMapGet;
805 underlineMapSet.Insert( "enable", true );
806 underlineMapSet.Insert( "color", Color::RED );
807 underlineMapSet.Insert( "height", 1 );
809 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
811 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
812 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
813 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
815 // Check the input underline property
816 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
817 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
819 // Check the shadow property
820 Property::Map shadowMapSet;
821 Property::Map shadowMapGet;
823 shadowMapSet.Insert( "color", Color::GREEN );
824 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
825 shadowMapSet.Insert( "blurRadius", 3.0f );
827 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
829 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
830 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
831 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
833 // Check the input shadow property
834 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
835 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
837 // Check the emboss property
838 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
839 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
841 // Check the input emboss property
842 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
843 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
845 // Check the outline property
847 // Test string type first
848 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
849 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
850 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
852 // Then test the property map type
853 Property::Map outlineMapSet;
854 Property::Map outlineMapGet;
856 outlineMapSet["color"] = Color::RED;
857 outlineMapSet["width"] = 2.0f;
859 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
861 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
862 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
863 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
865 // Check the input outline property
866 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
867 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
869 // Check the smooth scroll property
870 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
871 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
872 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
874 // Check the smooth scroll duration property
875 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
876 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
878 // Check the scroll bar property
879 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
880 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
881 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
883 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
884 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
885 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
886 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
888 // Check the pixel size of font
889 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
890 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
892 // Check placeholder text properties.
893 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
894 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
896 // Check placeholder text's color property.
897 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
898 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
900 // Check the enable selection property
901 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
902 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
904 // Check the placeholder property with pixel size
905 Property::Map placeholderPixelSizeMapSet;
906 Property::Map placeholderPixelSizeMapGet;
907 Property::Map placeholderFontstyleMap;
908 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
909 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
910 placeholderPixelSizeMapSet["color"] = Color::BLUE;
911 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
912 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
914 placeholderFontstyleMap.Insert( "weight", "bold" );
915 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
916 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
918 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
919 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
921 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
922 Property::Map placeholderConversionMap;
923 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
924 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
925 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
926 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
927 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
928 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
930 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
932 // Check the placeholder property with point size
933 Property::Map placeholderMapSet;
934 Property::Map placeholderMapGet;
935 placeholderMapSet["text"] = "Setting Placeholder Text";
936 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
937 placeholderMapSet["color"] = Color::RED;
938 placeholderMapSet["fontFamily"] = "Arial";
939 placeholderMapSet["pointSize"] = 12.0f;
940 // Check the placeholder font style property
941 placeholderFontstyleMap.Clear();
943 placeholderFontstyleMap.Insert( "weight", "bold" );
944 placeholderFontstyleMap.Insert( "width", "condensed" );
945 placeholderFontstyleMap.Insert( "slant", "italic" );
946 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
947 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
949 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
950 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
952 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
953 placeholderConversionMap.Clear();
954 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
955 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
956 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
957 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
958 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
959 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
960 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
963 placeholderFontstyleMap.Clear();
964 placeholderFontstyleMap.Insert( "weight", "normal" );
965 placeholderFontstyleMap.Insert( "slant", "oblique" );
966 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
967 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
969 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
970 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
971 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
972 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
974 placeholderFontstyleMap.Clear();
975 placeholderFontstyleMap.Insert( "slant", "roman" );
976 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
977 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
979 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
981 placeholderFontstyleMap.Clear();
982 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
984 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
985 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
986 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
987 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
988 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
990 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
991 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
993 // Check handle color
994 editor.SetProperty( DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN );
995 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
997 // Test the ENABLE_GRAB_HANDLE_POPUP property
998 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP, false );
999 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP ), false, TEST_LOCATION);
1001 // Check the input method setting
1002 Property::Map propertyMap;
1003 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
1004 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
1005 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
1006 int inputVariation = 1;
1007 propertyMap["PANEL_LAYOUT"] = panelLayout;
1008 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
1009 propertyMap["BUTTON_ACTION"] = buttonAction;
1010 propertyMap["VARIATION"] = inputVariation;
1011 editor.SetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS, propertyMap );
1013 Property::Value value = editor.GetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS );
1015 DALI_TEST_CHECK( value.Get( map ) );
1018 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
1019 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
1022 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
1023 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
1026 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
1027 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
1030 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
1031 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
1033 // Check the input filter property
1034 Property::Map inputFilterMapSet;
1035 Property::Map inputFilterMapGet;
1036 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1037 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1039 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1041 inputFilterMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::INPUT_FILTER);
1042 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1045 inputFilterMapSet.Clear();
1046 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1048 // Check the strikethrough property
1050 Property::Map strikethroughMapSet;
1051 Property::Map strikethroughMapGet;
1053 application.SendNotification();
1054 application.Render();
1056 // Check the input strikethrough property
1058 strikethroughMapSet.Clear();
1059 strikethroughMapGet.Clear();
1060 strikethroughMapSet.Insert( "enable", true );
1061 strikethroughMapSet.Insert( "color", Color::BLUE );
1062 strikethroughMapSet.Insert( "height", 2.0f );
1064 editor.SetProperty( DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet );
1066 application.SendNotification();
1067 application.Render();
1069 strikethroughMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::STRIKETHROUGH );
1071 DALI_TEST_EQUALS( strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION );
1072 DALI_TEST_EQUALS( DaliTestCheckMaps( strikethroughMapSet, strikethroughMapGet ), true, TEST_LOCATION );
1074 // Check the input strikethrough property
1075 editor.SetProperty( DevelTextEditor::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties" );
1076 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::INPUT_STRIKETHROUGH ), std::string("Strikethrough input properties"), TEST_LOCATION );
1078 application.SendNotification();
1079 application.Render();
1081 // Check the line size property
1082 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::MIN_LINE_SIZE ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1083 editor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 50.f );
1084 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::MIN_LINE_SIZE ), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1089 // Positive Atlas Text Renderer test
1090 int utcDaliTextEditorAtlasRenderP(void)
1092 ToolkitTestApplication application;
1093 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
1094 StyleManager styleManager = StyleManager::Get();
1095 styleManager.ApplyDefaultTheme();
1096 TextEditor editor = TextEditor::New();
1097 DALI_TEST_CHECK( editor );
1099 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1101 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1103 application.GetScene().Add( editor );
1107 // Render some text with the shared atlas backend
1108 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1109 application.SendNotification();
1110 application.Render();
1114 tet_result(TET_FAIL);
1119 // Positive test for the anchorClicked signal.
1120 int utcDaliTextEditorAnchorClickedP(void)
1122 ToolkitTestApplication application;
1123 tet_infoline(" utcDaliTextEditorAnchorClickedP");
1124 TextEditor editor = TextEditor::New();
1125 DALI_TEST_CHECK(editor);
1127 application.GetScene().Add(editor);
1129 // connect to the anchor clicked signal.
1130 ConnectionTracker* testTracker = new ConnectionTracker();
1131 DevelTextEditor::AnchorClickedSignal(editor).Connect(&TestAnchorClickedCallback);
1132 bool anchorClickedSignal = false;
1133 editor.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1135 gAnchorClickedCallBackCalled = false;
1136 editor.SetProperty(TextEditor::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1137 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1138 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1139 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1140 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1142 application.SendNotification();
1143 application.Render();
1144 editor.SetKeyInputFocus();
1146 // Create a tap event to touch the text editor.
1147 TestGenerateTap(application, 5.0f, 5.0f);
1148 application.SendNotification();
1149 application.Render();
1151 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1152 DALI_TEST_CHECK(anchorClickedSignal);
1154 gAnchorClickedCallBackNotCalled = true;
1155 // Tap the outside of anchor, callback should not be called.
1156 TestGenerateTap(application, 150.f, 100.f);
1157 application.SendNotification();
1158 application.Render();
1160 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1165 // Positive test for the textChanged signal.
1166 int utcDaliTextEditorTextChangedP(void)
1168 ToolkitTestApplication application;
1169 tet_infoline(" utcDaliTextEditorTextChangedP");
1170 TextEditor editor = TextEditor::New();
1171 DALI_TEST_CHECK( editor );
1173 application.GetScene().Add( editor );
1175 // connect to the text changed signal.
1176 ConnectionTracker* testTracker = new ConnectionTracker();
1177 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
1178 bool textChangedSignal = false;
1179 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1181 gTextChangedCallBackCalled = false;
1182 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
1183 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1184 DALI_TEST_CHECK( textChangedSignal );
1186 application.SendNotification();
1187 editor.SetKeyInputFocus();
1189 gTextChangedCallBackCalled = false;
1190 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1191 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1194 editor.SetProperty( TextField::Property::TEXT, "" );
1196 // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
1197 gTextChangedCallBackCalled = false;
1198 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1199 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1201 // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
1202 gTextChangedCallBackCalled = false;
1203 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1204 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1209 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1211 ToolkitTestApplication application;
1212 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1213 TextEditor editor = TextEditor::New();
1214 DALI_TEST_CHECK( editor );
1217 application.GetScene().Add( editor );
1219 // connect to the text changed signal.
1220 ConnectionTracker* testTracker = new ConnectionTracker();
1221 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1222 bool textChangedSignal = false;
1223 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1226 // get InputMethodContext
1228 InputMethodContext::EventData imfEvent;
1229 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext( editor );
1231 editor.SetKeyInputFocus();
1232 editor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
1235 gTextChangedCallBackCalled = false;
1236 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1237 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1238 application.SendNotification();
1239 application.Render();
1240 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1241 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1243 gTextChangedCallBackCalled = false;
1244 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1245 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1246 application.SendNotification();
1247 application.Render();
1248 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1249 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호"), TEST_LOCATION );
1251 gTextChangedCallBackCalled = false;
1252 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1253 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1254 application.SendNotification();
1255 application.Render();
1256 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1257 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1259 gTextChangedCallBackCalled = false;
1260 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1261 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1262 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1264 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1265 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1266 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1268 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1269 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1270 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1272 application.SendNotification();
1273 application.Render();
1274 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1275 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1281 int utcDaliTextEditorInputStyleChanged01(void)
1283 // The text-editor emits signals when the input style changes. These changes of style are
1284 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1285 // can't be emitted during the size negotiation as the callbacks may update the UI.
1286 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1287 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1288 ToolkitTestApplication application;
1289 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1293 char* pathNamePtr = get_current_dir_name();
1294 const std::string pathName( pathNamePtr );
1295 free( pathNamePtr );
1297 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1298 fontClient.SetDpi( 93u, 93u );
1300 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1301 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1303 TextEditor editor = TextEditor::New();
1304 DALI_TEST_CHECK( editor );
1307 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1308 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1309 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1311 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1312 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1314 // connect to the text changed signal.
1315 ConnectionTracker* testTracker = new ConnectionTracker();
1316 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1317 bool inputStyleChangedSignal = false;
1318 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1320 application.GetScene().Add( editor );
1322 // Render and notify
1323 application.SendNotification();
1324 application.Render();
1326 // Executes the idle callbacks added by the text control on the change of input style.
1327 application.RunIdles();
1329 gInputStyleChangedCallbackCalled = false;
1330 gInputStyleMask = TextEditor::InputStyle::NONE;
1331 inputStyleChangedSignal = false;
1333 // Create a tap event to touch the text editor.
1334 TestGenerateTap( application, 18.0f, 25.0f );
1336 // Render and notify
1337 application.SendNotification();
1338 application.Render();
1340 // Executes the idle callbacks added by the text control on the change of input style.
1341 application.RunIdles();
1343 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1344 if( gInputStyleChangedCallbackCalled )
1346 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1348 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1349 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1351 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1352 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1354 DALI_TEST_CHECK( inputStyleChangedSignal );
1356 gInputStyleChangedCallbackCalled = false;
1357 gInputStyleMask = TextEditor::InputStyle::NONE;
1358 inputStyleChangedSignal = false;
1360 // Create a tap event to touch the text editor.
1361 TestGenerateTap( application, 30.0f, 25.0f );
1363 // Render and notify
1364 application.SendNotification();
1365 application.Render();
1367 // Executes the idle callbacks added by the text control on the change of input style.
1368 application.RunIdles();
1370 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1371 DALI_TEST_CHECK( !inputStyleChangedSignal );
1373 gInputStyleChangedCallbackCalled = false;
1374 gInputStyleMask = TextEditor::InputStyle::NONE;
1375 inputStyleChangedSignal = false;
1377 // Create a tap event to touch the text editor.
1378 TestGenerateTap( application, 43.0f, 25.0f );
1380 // Render and notify
1381 application.SendNotification();
1382 application.Render();
1384 // Executes the idle callbacks added by the text control on the change of input style.
1385 application.RunIdles();
1387 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1388 if( gInputStyleChangedCallbackCalled )
1390 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1392 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1393 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1395 DALI_TEST_CHECK( inputStyleChangedSignal );
1397 gInputStyleChangedCallbackCalled = false;
1398 gInputStyleMask = TextEditor::InputStyle::NONE;
1399 inputStyleChangedSignal = false;
1401 // Create a tap event to touch the text editor.
1402 TestGenerateTap( application, 88.0f, 25.0f );
1404 // Render and notify
1405 application.SendNotification();
1406 application.Render();
1408 // Executes the idle callbacks added by the text control on the change of input style.
1409 application.RunIdles();
1411 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1412 if( gInputStyleChangedCallbackCalled )
1414 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1416 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1417 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1419 Property::Map fontStyleMapSet;
1420 Property::Map fontStyleMapGet;
1422 fontStyleMapSet.Insert( "weight", "bold" );
1424 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1425 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1426 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1428 DALI_TEST_CHECK( inputStyleChangedSignal );
1430 gInputStyleChangedCallbackCalled = false;
1431 gInputStyleMask = TextEditor::InputStyle::NONE;
1432 inputStyleChangedSignal = false;
1434 // Create a tap event to touch the text editor.
1435 TestGenerateTap( application, 115.0f, 25.0f );
1437 // Render and notify
1438 application.SendNotification();
1439 application.Render();
1441 // Executes the idle callbacks added by the text control on the change of input style.
1442 application.RunIdles();
1444 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1445 DALI_TEST_CHECK( !inputStyleChangedSignal );
1447 gInputStyleChangedCallbackCalled = false;
1448 gInputStyleMask = TextEditor::InputStyle::NONE;
1449 inputStyleChangedSignal = false;
1451 // Create a tap event to touch the text editor.
1452 TestGenerateTap( application, 164.0f, 25.0f );
1454 // Render and notify
1455 application.SendNotification();
1456 application.Render();
1458 // Executes the idle callbacks added by the text control on the change of input style.
1459 application.RunIdles();
1461 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1462 if( gInputStyleChangedCallbackCalled )
1464 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1466 Property::Map fontStyleMapSet;
1467 Property::Map fontStyleMapGet;
1469 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1470 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1471 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1473 DALI_TEST_CHECK( inputStyleChangedSignal );
1475 gInputStyleChangedCallbackCalled = false;
1476 gInputStyleMask = TextEditor::InputStyle::NONE;
1477 inputStyleChangedSignal = false;
1479 // Create a tap event to touch the text editor.
1480 TestGenerateTap( application, 191.0f, 25.0f );
1482 // Render and notify
1483 application.SendNotification();
1484 application.Render();
1486 // Executes the idle callbacks added by the text control on the change of input style.
1487 application.RunIdles();
1489 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1490 DALI_TEST_CHECK( !inputStyleChangedSignal );
1495 int utcDaliTextEditorInputStyleChanged02(void)
1497 // The text-editor emits signals when the input style changes. These changes of style are
1498 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1499 // can't be emitted during the size negotiation as the callbacks may update the UI.
1500 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1501 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1502 ToolkitTestApplication application;
1503 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1507 char* pathNamePtr = get_current_dir_name();
1508 const std::string pathName( pathNamePtr );
1509 free( pathNamePtr );
1511 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1512 fontClient.SetDpi( 93u, 93u );
1514 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1515 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1517 TextEditor editor = TextEditor::New();
1518 DALI_TEST_CHECK( editor );
1521 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1522 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1523 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1525 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1526 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>" );
1528 // connect to the text changed signal.
1529 ConnectionTracker* testTracker = new ConnectionTracker();
1530 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1531 bool inputStyleChangedSignal = false;
1532 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1534 application.GetScene().Add( editor );
1536 // Render and notify
1537 application.SendNotification();
1538 application.Render();
1540 // Executes the idle callbacks added by the text control on the change of input style.
1541 application.RunIdles();
1543 gInputStyleChangedCallbackCalled = false;
1544 gInputStyleMask = TextEditor::InputStyle::NONE;
1545 inputStyleChangedSignal = false;
1547 // Create a tap event to touch the text editor.
1548 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1549 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1551 // Render and notify
1552 application.SendNotification();
1553 application.Render();
1555 // Executes the idle callbacks added by the text control on the change of input style.
1556 application.RunIdles();
1558 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1559 if( gInputStyleChangedCallbackCalled )
1561 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1562 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1563 TextEditor::InputStyle::POINT_SIZE |
1564 TextEditor::InputStyle::COLOR ),
1567 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1568 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1570 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1571 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1573 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1574 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1576 DALI_TEST_CHECK( inputStyleChangedSignal );
1578 gInputStyleChangedCallbackCalled = false;
1579 gInputStyleMask = TextEditor::InputStyle::NONE;
1580 inputStyleChangedSignal = false;
1582 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1584 // Render and notify
1585 application.SendNotification();
1586 application.Render();
1588 // Executes the idle callbacks added by the text control on the change of input style.
1589 application.RunIdles();
1591 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1592 if( gInputStyleChangedCallbackCalled )
1594 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1595 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1598 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1599 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1601 DALI_TEST_CHECK( inputStyleChangedSignal );
1603 gInputStyleChangedCallbackCalled = false;
1604 gInputStyleMask = TextEditor::InputStyle::NONE;
1605 inputStyleChangedSignal = false;
1607 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1609 // Render and notify
1610 application.SendNotification();
1611 application.Render();
1613 // Executes the idle callbacks added by the text control on the change of input style.
1614 application.RunIdles();
1616 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1617 DALI_TEST_CHECK( !inputStyleChangedSignal );
1619 gInputStyleChangedCallbackCalled = false;
1620 gInputStyleMask = TextEditor::InputStyle::NONE;
1621 inputStyleChangedSignal = false;
1623 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1625 // Render and notify
1626 application.SendNotification();
1627 application.Render();
1629 // Executes the idle callbacks added by the text control on the change of input style.
1630 application.RunIdles();
1632 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1633 if( gInputStyleChangedCallbackCalled )
1635 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1636 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1639 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1640 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1642 DALI_TEST_CHECK( inputStyleChangedSignal );
1644 gInputStyleChangedCallbackCalled = false;
1645 gInputStyleMask = TextEditor::InputStyle::NONE;
1646 inputStyleChangedSignal = false;
1648 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1650 Property::Map fontStyleMapSet;
1651 fontStyleMapSet.Insert( "weight", "thin" );
1652 fontStyleMapSet.Insert( "width", "condensed" );
1653 fontStyleMapSet.Insert( "slant", "italic" );
1655 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1656 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1657 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1659 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1660 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1661 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1662 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1663 editor.SetProperty( DevelTextEditor::Property::INPUT_STRIKETHROUGH, "strikethrough" );
1665 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1667 // Render and notify
1668 application.SendNotification();
1669 application.Render();
1671 // Executes the idle callbacks added by the text control on the change of input style.
1672 application.RunIdles();
1674 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1675 DALI_TEST_CHECK( !inputStyleChangedSignal );
1677 // Create a tap event to touch the text editor.
1678 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1680 // Render and notify
1681 application.SendNotification();
1682 application.Render();
1684 // Executes the idle callbacks added by the text control on the change of input style.
1685 application.RunIdles();
1687 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1688 if( gInputStyleChangedCallbackCalled )
1690 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1691 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1692 TextEditor::InputStyle::POINT_SIZE |
1693 TextEditor::InputStyle::FONT_STYLE |
1694 TextEditor::InputStyle::LINE_SPACING |
1695 TextEditor::InputStyle::UNDERLINE |
1696 TextEditor::InputStyle::SHADOW |
1697 TextEditor::InputStyle::EMBOSS |
1698 TextEditor::InputStyle::OUTLINE ),
1701 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1702 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1704 DALI_TEST_CHECK( inputStyleChangedSignal );
1706 gInputStyleChangedCallbackCalled = false;
1707 gInputStyleMask = TextEditor::InputStyle::NONE;
1708 inputStyleChangedSignal = false;
1710 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1712 fontStyleMapSet.Clear();
1713 fontStyleMapSet.Insert( "weight", "black" );
1714 fontStyleMapSet.Insert( "width", "expanded" );
1715 fontStyleMapSet.Insert( "slant", "oblique" );
1717 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1719 // Create a tap event to touch the text editor.
1720 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1722 // Render and notify
1723 application.SendNotification();
1724 application.Render();
1726 // Executes the idle callbacks added by the text control on the change of input style.
1727 application.RunIdles();
1729 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1730 if( gInputStyleChangedCallbackCalled )
1732 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1733 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1734 TextEditor::InputStyle::POINT_SIZE |
1735 TextEditor::InputStyle::FONT_STYLE ),
1738 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1739 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1741 DALI_TEST_CHECK( inputStyleChangedSignal );
1746 int utcDaliTextEditorEvent01(void)
1748 ToolkitTestApplication application;
1749 tet_infoline(" utcDaliTextEditorEvent01");
1751 // Creates a tap event. After creating a tap event the text editor should
1752 // have the focus and add text with key events should be possible.
1754 TextEditor editor = TextEditor::New();
1755 DALI_TEST_CHECK( editor );
1757 application.GetScene().Add( editor );
1759 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1760 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1761 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1763 // Avoid a crash when core load gl resources.
1764 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1766 // Render and notify
1767 application.SendNotification();
1768 application.Render();
1770 // Add a key event but as the text editor has not the focus it should do nothing.
1771 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1773 // Render and notify
1774 application.SendNotification();
1775 application.Render();
1777 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1779 // Create a tap event to touch the text editor.
1780 TestGenerateTap( application, 150.0f, 25.0f );
1782 // Render and notify
1783 application.SendNotification();
1784 application.Render();
1786 // Now the text editor has the focus, so it can handle the key events.
1787 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1788 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1790 // Render and notify
1791 application.SendNotification();
1792 application.Render();
1794 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1796 // Create a second text editor and send key events to it.
1797 TextEditor editor2 = TextEditor::New();
1799 editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1800 editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1801 editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1802 editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1804 application.GetScene().Add( editor2 );
1806 // Render and notify
1807 application.SendNotification();
1808 application.Render();
1810 // Create a tap event on the second text editor.
1811 TestGenerateTap( application, 150.0f, 125.0f );
1813 // Render and notify
1814 application.SendNotification();
1815 application.Render();
1817 // The second text editor has the focus. It should handle the key events.
1818 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1819 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1821 // Render and notify
1822 application.SendNotification();
1823 application.Render();
1825 // Check the text has been added to the second text editor.
1826 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1831 int utcDaliTextEditorEvent02(void)
1833 ToolkitTestApplication application;
1834 tet_infoline(" utcDaliTextEditorEvent02");
1836 // Checks if the right number of actors are created.
1838 TextEditor editor = TextEditor::New();
1839 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1840 DALI_TEST_CHECK( editor );
1842 application.GetScene().Add( editor );
1844 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1845 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1846 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1848 // Avoid a crash when core load gl resources.
1849 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1851 // Render and notify
1852 application.SendNotification();
1853 application.Render();
1855 // Check there are the expected number of children (the stencil).
1856 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1858 Actor stencil = editor.GetChildAt( 0u );
1860 // Create a tap event to touch the text editor.
1861 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1863 // Render and notify
1864 application.SendNotification();
1865 application.Render();
1867 Actor layer = editor.GetChildAt( 1u );
1868 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1869 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1871 // Now the text editor has the focus, so it can handle the key events.
1872 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1873 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1875 // Render and notify
1876 application.SendNotification();
1877 application.Render();
1879 // Checks the cursor and the renderer have been created.
1880 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1881 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1883 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1884 DALI_TEST_CHECK( cursor );
1886 // The stencil actor has a container with all the actors which contain the text renderers.
1887 Actor container = stencil.GetChildAt( 0u );
1888 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1890 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1891 DALI_TEST_CHECK( renderer );
1894 // Move the cursor and check the position changes.
1895 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1897 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1898 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1900 // Render and notify
1901 application.SendNotification();
1902 application.Render();
1904 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1906 DALI_TEST_CHECK( position2.x < position1.x );
1908 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1909 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1911 // Render and notify
1912 application.SendNotification();
1913 application.Render();
1915 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1917 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1919 // Send some taps and check the cursor positions.
1921 // Try to tap at the beginning.
1922 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1924 // Render and notify
1925 application.SendNotification();
1926 application.Render();
1928 // Cursor position should be the same than position1.
1929 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1931 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1933 // Tap away from the start position.
1934 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1936 // Render and notify
1937 application.SendNotification();
1938 application.Render();
1940 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1942 DALI_TEST_CHECK( position5.x > position4.x );
1944 // Remove all the text.
1945 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1946 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1947 editor.SetProperty( TextEditor::Property::TEXT, "" );
1949 // Render and notify
1950 application.SendNotification();
1951 application.Render();
1953 // Cursor position should be the same than position2.
1954 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1956 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1958 // Should not be a renderer.
1959 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1964 int utcDaliTextEditorEvent03(void)
1966 ToolkitTestApplication application;
1967 tet_infoline(" utcDaliTextEditorEvent03");
1969 // Checks if the highlight actor is created.
1971 TextEditor editor = TextEditor::New();
1972 DALI_TEST_CHECK( editor );
1974 application.GetScene().Add( editor );
1976 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1977 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1978 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1979 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1980 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1982 // Avoid a crash when core load gl resources.
1983 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1985 // Render and notify
1986 application.SendNotification();
1987 application.Render();
1989 // Send some taps and check text controller with clipboard window
1990 Dali::Clipboard clipboard = Clipboard::Get();
1991 clipboard.ShowClipboard();
1992 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1993 clipboard.HideClipboard();
1995 // Render and notify
1996 application.SendNotification();
1997 application.Render();
1999 // Tap first to get the focus.
2000 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
2002 // Render and notify
2003 application.SendNotification();
2004 application.Render();
2006 // Double tap to select a word.
2007 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
2009 // Render and notify
2010 application.SendNotification();
2011 application.Render();
2013 // The stencil actor should have two actors: the renderer and the highlight actor.
2014 Actor stencil = editor.GetChildAt( 0u );
2016 // Highlight needs to be drawn before text, so should come first in child order
2017 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2018 DALI_TEST_CHECK( highlight );
2020 // The stencil actor has a container with all the actors which contain the text renderers.
2021 Actor container = stencil.GetChildAt( 1u );
2022 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2024 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2025 DALI_TEST_CHECK( renderer );
2028 // Double tap out of bounds
2029 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
2030 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
2032 // Render and notify
2033 application.SendNotification();
2034 application.Render();
2036 // The stencil actor should have one actors: the renderer actor.
2037 stencil = editor.GetChildAt( 0u );
2039 // The stencil actor has a container with all the actors which contain the text renderers.
2040 container = stencil.GetChildAt( 0u );
2041 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2043 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2044 DALI_TEST_CHECK( renderer );
2048 TestGenerateLongPress(application, 1.0f, 25.0f);
2050 // Render and notify
2051 application.SendNotification();
2052 application.Render();
2055 TestGenerateMiniPan(application);
2057 // Render and notify
2058 application.SendNotification();
2059 application.Render();
2064 int utcDaliTextEditorEvent04(void)
2066 ToolkitTestApplication application;
2067 tet_infoline(" utcDaliTextEditorEvent04");
2069 // Checks if the highlight actor is created.
2071 TextEditor editor = TextEditor::New();
2072 DALI_TEST_CHECK( editor );
2074 application.GetScene().Add( editor );
2076 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
2077 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2078 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2079 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2080 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2082 // Avoid a crash when core load gl resources.
2083 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2085 // Render and notify
2086 application.SendNotification();
2087 application.Render();
2089 // Tap on the text editor
2090 TestGenerateTap( application, 3.0f, 25.0f );
2092 // Render and notify
2093 application.SendNotification();
2094 application.Render();
2096 // Move at the end of the text.
2097 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2098 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2100 // Render and notify
2101 application.SendNotification();
2102 application.Render();
2104 for( unsigned int index = 0u; index < 10u; ++index )
2106 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2107 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2109 // Render and notify
2110 application.SendNotification();
2111 application.Render();
2115 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2117 // Render and notify
2118 application.SendNotification();
2119 application.Render();
2121 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2123 // Add some key events
2124 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2125 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2127 // Render and notify
2128 application.SendNotification();
2129 application.Render();
2131 for( unsigned int index = 0u; index < 10u; ++index )
2133 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2134 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2136 // Render and notify
2137 application.SendNotification();
2138 application.Render();
2142 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2144 // Render and notify
2145 application.SendNotification();
2146 application.Render();
2148 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2153 int utcDaliTextEditorEvent05(void)
2155 ToolkitTestApplication application;
2156 tet_infoline(" utcDaliTextEditorEvent05");
2158 // Checks if the highlight actor is created.
2160 TextEditor editor = TextEditor::New();
2161 DALI_TEST_CHECK( editor );
2163 application.GetScene().Add( editor );
2165 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
2166 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2167 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2168 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2169 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2170 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2171 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
2172 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2173 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
2174 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
2176 // Avoid a crash when core load gl resources.
2177 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2179 // Render and notify
2180 application.SendNotification();
2181 application.Render();
2183 // Tap on the text editor
2184 TestGenerateTap( application, 3.0f, 25.0f );
2186 // Render and notify
2187 application.SendNotification();
2188 application.Render();
2190 // Move at the end of the text.
2191 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2192 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2194 // Render and notify
2195 application.SendNotification();
2196 application.Render();
2198 for( unsigned int index = 0u; index < 10u; ++index )
2201 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2203 // Render and notify
2204 application.SendNotification();
2205 application.Render();
2207 // Modify duration after scroll is enabled
2208 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
2210 // Continuous scroll left to increase coverage
2211 for( unsigned int index = 0u; index < 10u; ++index )
2213 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2215 // Render and notify
2216 application.SendNotification();
2217 application.Render();
2219 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2220 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
2221 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
2222 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2223 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2225 // Press Escape to increase coverage
2226 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2227 application.SendNotification();
2228 application.Render();
2230 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
2235 int utcDaliTextEditorEvent06(void)
2237 ToolkitTestApplication application;
2238 tet_infoline(" utcDaliTextEditorEvent06");
2240 // Checks if the highlight actor is created.
2242 TextEditor editor = TextEditor::New();
2243 DALI_TEST_CHECK( editor );
2245 application.GetScene().Add( editor );
2247 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2248 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2249 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2250 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2251 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2253 // Avoid a crash when core load gl resources.
2254 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2256 // Render and notify
2257 application.SendNotification();
2258 application.Render();
2260 // Tap on the text editor
2261 TestGenerateTap( application, 3.0f, 25.0f );
2263 // Render and notify
2264 application.SendNotification();
2265 application.Render();
2267 // Move to seconds line of the text.
2268 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2270 // Render and notify
2271 application.SendNotification();
2272 application.Render();
2274 float layoutHeight = editor.GetHeightForWidth( 100.f );
2277 // Add another script characters ( glyph height is defferent )
2278 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2279 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2281 // Delete characters
2282 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2283 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2285 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2287 // Render and notify
2288 application.SendNotification();
2289 application.Render();
2291 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2294 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2295 application.SendNotification();
2296 application.Render();
2298 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2299 application.SendNotification();
2300 application.Render();
2302 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2303 application.SendNotification();
2304 application.Render();
2306 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2307 application.SendNotification();
2308 application.Render();
2310 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2311 application.SendNotification();
2312 application.Render();
2314 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2315 application.SendNotification();
2316 application.Render();
2318 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2319 application.SendNotification();
2320 application.Render();
2325 int utcDaliTextEditorEvent07(void)
2327 ToolkitTestApplication application;
2328 tet_infoline(" utcDaliTextEditorEvent07");
2330 // Checks if the highlight actor is created.
2332 TextEditor editor = TextEditor::New();
2333 DALI_TEST_CHECK( editor );
2335 application.GetScene().Add( editor );
2337 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2338 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2339 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2340 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2341 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2343 // Avoid a crash when core load gl resources.
2344 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2346 // Render and notify
2347 application.SendNotification();
2348 application.Render();
2350 // Tap on the text editor
2351 TestGenerateTap( application, 3.0f, 25.0f );
2353 // Render and notify
2354 application.SendNotification();
2355 application.Render();
2357 // Move to second line of the text.
2358 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2360 // Render and notify
2361 application.SendNotification();
2362 application.Render();
2364 // Select some text in the right of the current cursor position
2365 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2366 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2367 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2368 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2370 // Render and notify
2371 application.SendNotification();
2372 application.Render();
2374 // Cut the selected text
2375 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2376 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2378 // Render and notify
2379 application.SendNotification();
2380 application.Render();
2382 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2384 // Select some text in the left of the current cursor position
2385 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2386 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2387 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2388 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2390 // Render and notify
2391 application.SendNotification();
2392 application.Render();
2394 // Copy the selected text
2395 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2396 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2398 // Render and notify
2399 application.SendNotification();
2400 application.Render();
2402 // Move the cursor to the third line
2403 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2404 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2406 // Render and notify
2407 application.SendNotification();
2408 application.Render();
2410 // Paste the selected text at the current cursor position
2411 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2412 application.ProcessEvent( GenerateKey( "v", "", "v", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2414 // Render and notify
2415 application.SendNotification();
2416 application.Render();
2418 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2421 // Disable Shift Selection
2422 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2424 // Test to select some text in the right of the current cursor position
2425 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2426 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2427 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2428 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2430 // Render and notify
2431 application.SendNotification();
2432 application.Render();
2434 // Cut the selected text
2435 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2436 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2438 // Render and notify
2439 application.SendNotification();
2440 application.Render();
2442 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2443 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2445 // Test to select some text in the left of the current cursor position
2446 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2447 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2448 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2449 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2451 // Render and notify
2452 application.SendNotification();
2453 application.Render();
2455 // Copy the selected text
2456 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2457 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2459 // Render and notify
2460 application.SendNotification();
2461 application.Render();
2463 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2464 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2467 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2469 // Render and notify
2470 application.SendNotification();
2471 application.Render();
2473 // replace text with "c"
2474 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2476 // Render and notify
2477 application.SendNotification();
2478 application.Render();
2481 DALI_TEST_EQUALS( "c", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2484 DevelTextEditor::SelectWholeText(editor);
2486 // Render and notify
2487 application.SendNotification();
2488 application.Render();
2490 // Copy the selected text using logical keys
2491 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2492 application.ProcessEvent( GenerateKey( "ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2494 // Render and notify
2495 application.SendNotification();
2496 application.Render();
2499 DevelTextEditor::SelectNone(editor);
2501 // Render and notify
2502 application.SendNotification();
2503 application.Render();
2505 // Paste the selected using logical keys
2506 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2507 application.ProcessEvent( GenerateKey( "ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2510 DALI_TEST_EQUALS( "cc", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2512 // select all using logical keys
2513 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2514 application.ProcessEvent( GenerateKey( "ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2516 // Render and notify
2517 application.SendNotification();
2518 application.Render();
2520 // cut text using logical keys
2521 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2522 application.ProcessEvent( GenerateKey( "ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2524 // Render and notify
2525 application.SendNotification();
2526 application.Render();
2529 DALI_TEST_EQUALS( "", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2534 int utcDaliTextEditorEvent08(void)
2536 ToolkitTestApplication application;
2537 tet_infoline(" utcDaliTextEditorEvent08");
2539 // Checks if the highlight actor is released correctly.
2541 TextEditor editor = TextEditor::New();
2542 DALI_TEST_CHECK( editor );
2544 application.GetScene().Add( editor );
2546 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2547 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2548 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2549 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2550 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2552 // Avoid a crash when core load gl resources.
2553 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2555 // Render and notify
2556 application.SendNotification();
2557 application.Render();
2559 // Tap on the text editor
2560 TestGenerateTap( application, 3.0f, 25.0f );
2562 // Render and notify
2563 application.SendNotification();
2564 application.Render();
2566 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2567 // Test to select some text in the left of the current cursor position
2568 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2569 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2570 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2571 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2573 // Render and notify
2574 application.SendNotification();
2575 application.Render();
2577 // Test to the left selection handle position and the right selection handle position
2578 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2579 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2580 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2581 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2583 // Render and notify
2584 application.SendNotification();
2585 application.Render();
2587 // Test to select full text in the left of the current cursor position
2588 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2589 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2590 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2591 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2592 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2593 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2595 // Render and notify
2596 application.SendNotification();
2597 application.Render();
2599 // Test to release the current full text selection
2600 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2601 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2603 // Render and notify
2604 application.SendNotification();
2605 application.Render();
2607 // Test to move the current cursor position correctly
2608 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2610 // Render and notify
2611 application.SendNotification();
2612 application.Render();
2615 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2617 // Render and notify
2618 application.SendNotification();
2619 application.Render();
2621 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2623 // Test to select some text in the right of the current cursor position
2624 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2625 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2626 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2628 // Render and notify
2629 application.SendNotification();
2630 application.Render();
2632 // Test the cursor position with right arrow key
2633 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2635 // Render and notify
2636 application.SendNotification();
2637 application.Render();
2640 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2642 // Render and notify
2643 application.SendNotification();
2644 application.Render();
2646 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2648 // Test to select some text in the left of the current cursor position
2649 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2650 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2651 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2652 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2653 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2655 // Render and notify
2656 application.SendNotification();
2657 application.Render();
2659 // Test the cursor position with left arrow key
2660 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2662 // Render and notify
2663 application.SendNotification();
2664 application.Render();
2667 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2669 // Render and notify
2670 application.SendNotification();
2671 application.Render();
2673 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2675 // Test to select some text in the right of the current cursor position
2676 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2677 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2678 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2679 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2681 // Render and notify
2682 application.SendNotification();
2683 application.Render();
2685 // Test the cursor position with left arrow key
2686 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2688 // Render and notify
2689 application.SendNotification();
2690 application.Render();
2693 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2695 // Render and notify
2696 application.SendNotification();
2697 application.Render();
2699 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2701 // Test to select some text in the left of the current cursor position
2702 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2703 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2704 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2705 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2707 // Render and notify
2708 application.SendNotification();
2709 application.Render();
2711 // Test the cursor position with right arrow key
2712 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2714 // Render and notify
2715 application.SendNotification();
2716 application.Render();
2719 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2721 // Render and notify
2722 application.SendNotification();
2723 application.Render();
2725 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2730 int utcDaliTextEditorHandles(void)
2732 ToolkitTestApplication application;
2733 tet_infoline(" utcDaliTextEditorHandles");
2735 TextEditor editor = TextEditor::New();
2736 DALI_TEST_CHECK( editor );
2738 application.GetScene().Add( editor );
2740 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2741 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2742 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2743 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2745 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2746 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2747 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2748 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2750 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2751 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2752 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2754 // Avoid a crash when core load gl resources.
2755 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2757 // Render and notify
2758 application.SendNotification();
2759 application.Render();
2761 // Tap first to get the focus.
2762 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2764 // Render and notify
2765 application.SendNotification();
2766 application.Render();
2768 // Tap to create the grab handle.
2769 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2771 // Render and notify
2772 application.SendNotification();
2773 application.Render();
2775 // Get the active layer where the text's decoration is added.
2776 Actor activeLayer = editor.GetChildAt( 1u );
2778 // Get the handle's actor.
2779 Actor handle = activeLayer.GetChildAt( 1u );
2780 handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2782 // Render and notify
2783 application.SendNotification();
2784 application.Render();
2786 // Touch the grab handle to set it as pressed.
2787 Vector2 touchPos( 10.0f, 50.0f );
2788 Dali::Integration::TouchEvent event;
2789 event = Dali::Integration::TouchEvent();
2790 event.AddPoint( GetPointDownInside( touchPos ) );
2791 application.ProcessEvent( event );
2793 // Render and notify
2794 application.SendNotification();
2795 application.Render();
2797 // Pan the grab handle
2798 uint32_t time = 100;
2799 TestStartPan( application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time );
2800 TestMovePan( application, Vector2(10.0f, 30.0f), time );
2801 TestEndPan( application, Vector2(10.0f, 50.0f), time);
2802 application.SendNotification();
2803 application.Render();
2806 // Release the grab handle.
2807 event = Dali::Integration::TouchEvent();
2808 event.AddPoint( GetPointUpInside( touchPos ) );
2809 application.ProcessEvent( event );
2811 // Render and notify
2812 application.SendNotification();
2813 application.Render();
2815 // Tap first to get the focus.
2816 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2818 // Render and notify
2819 application.SendNotification();
2820 application.Render();
2822 // Double tap to select a word and create the selection handles.
2823 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2825 // Render and notify
2826 application.SendNotification();
2827 application.Render();
2829 touchPos = Vector2( 10.0f, 50.0f );
2831 // Touch the left selection handle to set it as pressed.
2832 event = Dali::Integration::TouchEvent();
2833 event.AddPoint( GetPointDownInside( touchPos ) );
2834 application.ProcessEvent( event );
2836 // Render and notify
2837 application.SendNotification();
2838 application.Render();
2840 // Release the left selection handle.
2841 event = Dali::Integration::TouchEvent();
2842 event.AddPoint( GetPointUpInside( touchPos ) );
2843 application.ProcessEvent( event );
2845 // Render and notify
2846 application.SendNotification();
2847 application.Render();
2852 int utcDaliTextEditorUnderPropertyStringP(void)
2854 ToolkitTestApplication application;
2855 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2856 TextEditor editor = TextEditor::New();
2857 DALI_TEST_CHECK( editor );
2859 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2861 application.GetScene().Add( editor );
2863 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2864 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2866 tet_infoline("Set underline settings with a map");
2867 // Check the input underline property
2868 Property::Map underlineMapSet;
2869 Property::Map underlineMapGet;
2870 underlineMapSet.Insert( "enable", true );
2871 underlineMapSet.Insert( "color", Color::BLUE );
2872 underlineMapSet.Insert( "height", 2 );
2874 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2875 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2876 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2877 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2879 tet_infoline("Set underline settings with a string");
2880 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2881 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2884 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2886 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2887 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2888 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2889 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2891 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2896 int utcDaliTextEditorStrikethroughPropertyStringP(void)
2898 ToolkitTestApplication application;
2899 tet_infoline(" utcDaliTextEditorStrikethroughPropertyStringP");
2900 TextEditor editor = TextEditor::New();
2901 DALI_TEST_CHECK( editor );
2903 std::string strikethroughSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}" );
2905 application.GetScene().Add( editor );
2907 editor.SetProperty( DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettings1 );
2908 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::STRIKETHROUGH ), strikethroughSettings1, TEST_LOCATION );
2910 tet_infoline("Set strikethrough settings with a map");
2911 // Check the input strikethrough property
2912 Property::Map strikethroughMapSet;
2913 Property::Map strikethroughMapGet;
2914 strikethroughMapSet.Insert( "enable", true );
2915 strikethroughMapSet.Insert( "color", Color::BLUE );
2916 strikethroughMapSet.Insert( "height", 2.0f );
2918 editor.SetProperty( DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet );
2919 strikethroughMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::STRIKETHROUGH );
2920 DALI_TEST_EQUALS( strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION );
2921 DALI_TEST_EQUALS( DaliTestCheckMaps( strikethroughMapSet, strikethroughMapGet ), true, TEST_LOCATION );
2923 tet_infoline("Set strikethrough settings with a string");
2924 editor.SetProperty( DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettings1 );
2925 Property::Value value = editor.GetProperty( DevelTextEditor::Property::STRIKETHROUGH );
2928 DALI_TEST_EQUALS( result , strikethroughSettings1, TEST_LOCATION );
2930 tet_infoline("Trying to set invalid strikethrough settings, should not update and stay at previous settings");
2931 std::string strikethroughSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"height\":\"2\"}" );
2932 editor.SetProperty( DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettingsVoid );
2933 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2935 DALI_TEST_EQUALS( result , strikethroughSettings1, TEST_LOCATION );
2940 int utcDaliTextEditorShadowPropertyStringP(void)
2942 ToolkitTestApplication application;
2943 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2945 TextEditor editor = TextEditor::New();
2947 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2949 application.GetScene().Add( editor );
2951 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2953 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2957 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2962 int utcDaliTextEditorFontStylePropertyStringP(void)
2964 ToolkitTestApplication application;
2965 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2967 TextEditor editor = TextEditor::New();
2969 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2971 application.GetScene().Add( editor );
2973 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2975 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2979 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2984 int utcDaliTextEditorGetPropertyLinecountP(void)
2986 ToolkitTestApplication application;
2988 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2992 TextEditor editor = TextEditor::New();
2993 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2994 editor.SetProperty( TextEditor::Property::TEXT,
2995 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2997 application.GetScene().Add( editor );
2999 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3000 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3001 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
3003 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3004 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3005 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
3010 int utcDaliTextEditorScrollStateChangedSignalTest(void)
3013 ToolkitTestApplication application;
3014 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
3016 TextEditor editor = TextEditor::New();
3017 DALI_TEST_CHECK( editor );
3019 application.GetScene().Add( editor );
3021 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
3022 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
3023 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3024 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3025 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
3026 editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
3028 bool startedCalled = false;
3029 bool finishedCalled = false;
3031 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
3032 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
3034 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
3036 // Render and notify
3037 application.SendNotification();
3038 application.Render();
3040 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
3041 application.SendNotification();
3042 application.Render(6000);
3044 application.SendNotification();
3045 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
3046 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
3051 int UtcDaliToolkitTextEditorTextWrapMode(void)
3053 ToolkitTestApplication application;
3054 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
3058 TextEditor editor = TextEditor::New();
3059 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
3060 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
3062 application.GetScene().Add( editor );
3064 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
3065 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
3067 application.SendNotification();
3068 application.Render();
3070 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3071 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
3073 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
3074 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
3076 application.SendNotification();
3077 application.Render();
3079 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3080 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
3082 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
3083 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
3085 application.SendNotification();
3086 application.Render();
3088 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3089 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
3091 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
3092 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
3094 application.SendNotification();
3095 application.Render();
3097 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3098 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
3103 int UtcDaliTextEditorSetPaddingProperty(void)
3105 ToolkitTestApplication application;
3106 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
3108 TextEditor editor = TextEditor::New();
3109 DALI_TEST_CHECK( editor );
3110 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3111 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3112 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3113 application.GetScene().Add( editor );
3115 application.SendNotification();
3116 application.Render();
3118 Vector3 originalSize = editor.GetNaturalSize();
3120 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
3122 application.SendNotification();
3123 application.Render();
3125 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
3127 Vector3 paddingAddedSize = editor.GetNaturalSize();
3129 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3131 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3136 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
3138 ToolkitTestApplication application;
3139 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
3141 TextEditor editor = TextEditor::New();
3142 DALI_TEST_CHECK( editor );
3143 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3144 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3145 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3146 application.GetScene().Add( editor );
3148 application.SendNotification();
3149 application.Render();
3151 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3152 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
3154 // Check the enable shift selection property
3155 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
3156 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
3158 application.SendNotification();
3159 application.Render();
3164 int UtcDaliTextEditorEnableGrabHandleProperty(void)
3166 ToolkitTestApplication application;
3167 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
3169 TextEditor editor = TextEditor::New();
3170 DALI_TEST_CHECK( editor );
3171 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3172 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3173 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3174 application.GetScene().Add( editor );
3176 application.SendNotification();
3177 application.Render();
3179 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3180 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
3182 // Check the enable grab handle property
3183 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
3184 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
3186 application.SendNotification();
3187 application.Render();
3192 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
3194 ToolkitTestApplication application;
3195 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
3197 TextEditor editor = TextEditor::New();
3198 DALI_TEST_CHECK( editor );
3199 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3200 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3201 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3202 application.GetScene().Add( editor );
3204 application.SendNotification();
3205 application.Render();
3207 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3208 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
3210 // Check the disable match system language direction property
3211 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
3212 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
3214 application.SendNotification();
3215 application.Render();
3220 int UtcDaliTextEditorGetInputMethodContext(void)
3222 ToolkitTestApplication application;
3223 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
3225 TextEditor editor = TextEditor::New();
3226 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );
3231 int utcDaliTextEditorMaxCharactersReached(void)
3233 ToolkitTestApplication application;
3234 tet_infoline("utcDaliTextEditorMaxCharactersReached");
3236 TextEditor editor = TextEditor::New();
3237 DALI_TEST_CHECK( editor );
3239 application.GetScene().Add( editor );
3241 const int maxNumberOfCharacters = 1;
3242 editor.SetProperty( DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters );
3243 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelTextEditor::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
3245 editor.SetKeyInputFocus();
3247 // connect to the text changed signal.
3248 ConnectionTracker* testTracker = new ConnectionTracker();
3249 DevelTextEditor::MaxLengthReachedSignal( editor ).Connect(&TestMaxLengthReachedCallback);
3250 bool maxLengthReachedSignal = false;
3251 editor.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
3253 gMaxCharactersCallBackCalled = false;
3255 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3256 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3258 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
3259 DALI_TEST_CHECK( maxLengthReachedSignal );
3264 int utcDaliTextEditorInputFiltered(void)
3266 ToolkitTestApplication application;
3267 tet_infoline(" utcDaliTextEditorInputFiltered");
3268 TextEditor editor = TextEditor::New();
3269 DALI_TEST_CHECK(editor);
3271 application.GetScene().Add(editor);
3273 Property::Map inputFilter;
3275 // Only digit is accepted.
3276 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
3278 // Set input filter to TextEditor.
3279 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3281 editor.SetKeyInputFocus();
3283 // connect to the input filtered signal.
3284 ConnectionTracker* testTracker = new ConnectionTracker();
3285 DevelTextEditor::InputFilteredSignal(editor).Connect(&TestInputFilteredCallback);
3286 bool inputFilteredSignal = false;
3287 editor.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
3289 gInputFilteredAcceptedCallbackCalled = false;
3291 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ));
3293 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3294 DALI_TEST_CHECK(inputFilteredSignal);
3296 // Word is rejected.
3297 inputFilter[InputFilter::Property::ACCEPTED] = "";
3298 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
3300 // Set input filter to TextEditor.
3301 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3303 editor.SetKeyInputFocus();
3305 inputFilteredSignal = false;
3306 gInputFilteredRejectedCallbackCalled = false;
3308 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3310 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3311 DALI_TEST_CHECK(inputFilteredSignal);
3316 int UtcDaliTextEditorSelectWholeText(void)
3318 ToolkitTestApplication application;
3319 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3321 TextEditor textEditor = TextEditor::New();
3323 application.GetScene().Add( textEditor );
3325 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3326 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3327 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3329 // Avoid a crash when core load gl resources.
3330 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3332 application.SendNotification();
3333 application.Render();
3335 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3337 DevelTextEditor::SelectWholeText( textEditor );
3339 application.SendNotification();
3340 application.Render();
3342 // Nothing should have been selected. The number of children is still 1
3343 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3345 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3347 application.SendNotification();
3348 application.Render();
3350 DevelTextEditor::SelectWholeText( textEditor );
3352 application.SendNotification();
3353 application.Render();
3355 // Should be 2 children, the stencil and the layer
3356 DALI_TEST_EQUALS( 2u, textEditor.GetChildCount(), TEST_LOCATION );
3358 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3359 Actor stencil = textEditor.GetChildAt( 0u );
3361 // The highlight actor is drawn first, so is the first actor in the list
3362 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3363 DALI_TEST_CHECK( highlight );
3368 int UtcDaliTextEditorSelectText(void)
3370 ToolkitTestApplication application;
3371 tet_infoline(" UtcDaliTextEditorSelectText ");
3373 TextEditor textEditor = TextEditor::New();
3375 application.GetScene().Add( textEditor );
3377 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3378 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3379 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3381 // Avoid a crash when core load gl resources.
3382 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3384 application.SendNotification();
3385 application.Render();
3387 DevelTextEditor::SelectText( textEditor ,0, 5 );
3389 application.SendNotification();
3390 application.Render();
3392 // Nothing is selected
3393 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3394 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3396 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3398 application.SendNotification();
3399 application.Render();
3401 DevelTextEditor::SelectText( textEditor, 0, 5 );
3403 application.SendNotification();
3404 application.Render();
3406 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3407 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3409 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3410 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3412 // world is selected
3413 DevelTextEditor::SelectText( textEditor, 6, 11 );
3415 application.SendNotification();
3416 application.Render();
3418 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3419 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3421 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3422 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3427 int UtcDaliTextEditorSelectNone(void)
3429 ToolkitTestApplication application;
3430 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3432 TextEditor textEditor = TextEditor::New();
3434 application.GetScene().Add( textEditor );
3436 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3437 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3438 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3440 // Avoid a crash when core load gl resources.
3441 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3443 application.SendNotification();
3444 application.Render();
3446 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3448 application.SendNotification();
3449 application.Render();
3451 // Nothing is selected
3452 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3453 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3455 DevelTextEditor::SelectWholeText( textEditor );
3457 application.SendNotification();
3458 application.Render();
3460 // whole text is selected
3461 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3462 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3464 DevelTextEditor::SelectNone( textEditor );
3466 application.SendNotification();
3467 application.Render();
3469 // Nothing is selected
3470 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3471 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3476 int UtcDaliTextEditorSelectRange(void)
3478 ToolkitTestApplication application;
3479 tet_infoline("utcDaliTextEditorSelectRange");
3481 TextEditor textEditor = TextEditor::New();
3482 DALI_TEST_CHECK( textEditor );
3484 application.GetScene().Add( textEditor );
3486 // Avoid a crash when core load gl resources.
3487 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3489 application.SendNotification();
3490 application.Render();
3492 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3494 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_START, 0 );
3495 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_END, 5 );
3497 // Hello is selected
3498 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3499 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3501 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3502 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3507 int UtcDaliTextEditorEnableEditing(void)
3509 ToolkitTestApplication application;
3510 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3512 TextEditor textEditor = TextEditor::New();
3514 application.GetScene().Add( textEditor );
3516 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3517 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3518 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3520 // Avoid a crash when core load gl resources.
3521 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3523 application.SendNotification();
3524 application.Render();
3526 textEditor.SetKeyInputFocus();
3527 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, false );
3528 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3530 // Render and notify
3531 application.SendNotification();
3532 application.Render();
3534 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3535 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3537 textEditor.SetKeyInputFocus();
3538 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
3539 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3541 // Render and notify
3542 application.SendNotification();
3543 application.Render();
3545 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3546 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3551 int UtcDaliTextEditorScrolling(void)
3553 ToolkitTestApplication application;
3554 tet_infoline(" UtcDaliTextEditorScrolling ");
3556 TextEditor textEditor = TextEditor::New();
3557 DALI_TEST_CHECK( textEditor );
3559 application.GetScene().Add( textEditor );
3561 // Avoid a crash when core load gl resources.
3562 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3564 application.SendNotification();
3565 application.Render();
3567 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
3568 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
3569 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
3570 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
3572 application.SendNotification();
3573 application.Render();
3575 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3576 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3579 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
3581 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, TEST_LOCATION );
3582 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3584 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
3586 DALI_TEST_NOT_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, 0.1f, TEST_LOCATION );
3587 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3589 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION , 0.0f);
3590 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION , 0.0f);
3592 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3593 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3598 int UtcDaliToolkitTextEditorFontSizeScale(void)
3600 ToolkitTestApplication application;
3601 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
3603 TextEditor textEditor = TextEditor::New();
3604 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 30.f );
3605 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3606 Vector3 nonScaledSize = textEditor.GetNaturalSize();
3608 TextEditor textEditorScaled = TextEditor::New();
3609 textEditorScaled.SetProperty( TextEditor::Property::POINT_SIZE, 15.f );
3610 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3611 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3612 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
3614 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3616 textEditor.SetProperty( TextEditor::Property::PIXEL_SIZE, 30.f );
3617 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3618 nonScaledSize = textEditor.GetNaturalSize();
3620 textEditorScaled.SetProperty( TextEditor::Property::PIXEL_SIZE, 15.f );
3621 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3622 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3623 scaledSize = textEditorScaled.GetNaturalSize();
3625 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3630 int UtcDaliTextEditorPrimaryCursorPosition(void)
3632 ToolkitTestApplication application;
3633 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
3635 TextEditor textEditor = TextEditor::New();
3637 application.GetScene().Add( textEditor );
3639 textEditor.SetProperty( TextEditor::Property::TEXT, "ABCEF");
3640 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3641 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3642 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3644 // Avoid a crash when core load gl resources.
3645 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3647 textEditor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
3648 application.SendNotification();
3649 application.Render();
3650 textEditor.SetKeyInputFocus();
3652 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3654 // Render and notify
3655 application.SendNotification();
3656 application.Render();
3658 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3659 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3664 int UtcDaliTextEditorLineCountAfterGetNaturalSize(void)
3666 ToolkitTestApplication application;
3667 tet_infoline(" UtcDaliTextEditorLineCountAfterGetNaturalSize ");
3669 TextEditor textEditor = TextEditor::New();
3670 textEditor.SetProperty(TextEditor::Property::TEXT, "A\nB\nC\nD\nE\nF\n");
3671 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3672 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3673 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3674 application.GetScene().Add( textEditor );
3676 application.SendNotification();
3677 application.Render();
3680 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3681 DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3683 textEditor.GetNaturalSize();
3685 // Create a tap event to touch the text editor.
3686 TestGenerateTap( application, 18.0f, 25.0f );
3688 application.SendNotification();
3689 application.Render();
3691 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3692 DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3698 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase(void)
3700 ToolkitTestApplication application;
3702 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase ");
3704 int lineCountBefore =0 ;
3705 int lineCountAfter =0 ;
3707 // Create a text editor
3708 TextEditor textEditor = TextEditor::New();
3709 //Set very large font-size using point-size
3710 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3711 //Specify font-family
3712 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3714 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3715 //Set text longer than width of textEditor
3716 textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3718 application.GetScene().Add( textEditor );
3720 application.SendNotification();
3721 application.Render();
3723 //Failed case is the GetHeightForWidth change LineCount then the scrollor will not arrive to latest line
3724 //GetHeightForWidth is a retrieval method which should not modify object
3725 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3726 textEditor.GetHeightForWidth(200.f);
3728 //This is to simulate focus into text editor after calling GetHeightForWidth
3729 //Create a tap event to touch the text editor.
3730 TestGenerateTap( application, 18.0f, 25.0f );
3732 application.SendNotification();
3733 application.Render();
3735 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3737 //The LineCount must not be changed when calling GetHeightForWidth.
3738 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3743 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase(void)
3745 ToolkitTestApplication application;
3747 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase ");
3749 int lineCountBefore =0 ;
3750 int lineCountAfter =0 ;
3752 // Create a text editor
3753 TextEditor textEditor = TextEditor::New();
3754 //Set very large font-size using point-size
3755 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3756 //Specify font-family
3757 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3759 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3760 //Set text longer than width of textEditor
3761 textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3762 //Set line wrap mode Character
3763 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3765 application.GetScene().Add( textEditor );
3767 application.SendNotification();
3768 application.Render();
3770 //Failed case is the GetHeightForWidth change LineCount which make position of cursor invalid in TextEditor
3771 //GetHeightForWidth is a retrieval method which should not modify object
3772 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3773 textEditor.GetHeightForWidth(200.f);
3775 //This is to simulate focus into text editor after calling GetHeightForWidth
3776 //Create a tap event to touch the text editor.
3777 TestGenerateTap( application, 18.0f, 25.0f );
3779 application.SendNotification();
3780 application.Render();
3782 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3784 //The LineCount must not be changed when calling GetHeightForWidth.
3785 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3790 int utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged(void)
3792 ToolkitTestApplication application;
3794 tet_infoline(" utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged ");
3796 int lineCountBefore =0 ;
3797 int lineCountAfter =0 ;
3799 // Create a text editor
3800 TextEditor textEditor = TextEditor::New();
3801 //Set very large font-size using point-size
3802 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3803 //Specify font-family
3804 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3806 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 100.f ) );
3807 //Set text longer than width of textEditor
3808 textEditor.SetProperty( TextEditor::Property::TEXT, "Short text");
3809 //Set line wrap mode Character
3810 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3812 application.GetScene().Add( textEditor );
3814 application.SendNotification();
3815 application.Render();
3818 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3820 textEditor.SetProperty( TextEditor::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
3821 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3823 // When the text changed, the Line-count should be updated according to new text.
3824 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
3825 DALI_TEST_EQUALS( lineCountBefore ,1, TEST_LOCATION );
3826 DALI_TEST_GREATER( lineCountAfter,1, TEST_LOCATION );
3833 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase(void)
3835 ToolkitTestApplication application;
3837 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase ");
3839 int lineCountBefore =0 ;
3840 int lineCountAfter =0 ;
3842 // Create a text editor
3843 TextEditor textEditor = TextEditor::New();
3844 //Set very large font-size using point-size
3845 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3846 //Specify font-family
3847 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3849 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3850 //Set text longer than width of textEditor
3851 textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3853 application.GetScene().Add( textEditor );
3855 application.SendNotification();
3856 application.Render();
3858 //Failed case is the GetNaturalSize change LineCount then the scrollor will not arrive to latest line
3859 //GetNaturalSize is a retrieval method which should not modify object
3860 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3861 textEditor.GetNaturalSize();
3863 //This is to simulate focus into text editor after calling GetNaturalSize
3864 //Create a tap event to touch the text editor.
3865 TestGenerateTap( application, 18.0f, 25.0f );
3867 application.SendNotification();
3868 application.Render();
3870 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3872 //The LineCount must not be changed when calling GetNaturalSize.
3873 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3878 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase(void)
3880 ToolkitTestApplication application;
3882 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase ");
3884 int lineCountBefore =0 ;
3885 int lineCountAfter =0 ;
3887 // Create a text editor
3888 TextEditor textEditor = TextEditor::New();
3889 //Set very large font-size using point-size
3890 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3891 //Specify font-family
3892 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3894 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3895 //Set text longer than width of textEditor
3896 textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3897 //Set line wrap mode Character
3898 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3900 application.GetScene().Add( textEditor );
3902 application.SendNotification();
3903 application.Render();
3905 //Failed case is the GetNaturalSize change LineCount which make position of cursor invalid in TextEditor
3906 //GetNaturalSize is a retrieval method which should not modify object
3907 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3908 textEditor.GetNaturalSize( );
3910 //This is to simulate focus into text editor after calling GetNaturalSize
3911 //Create a tap event to touch the text editor.
3912 TestGenerateTap( application, 18.0f, 25.0f );
3914 application.SendNotification();
3915 application.Render();
3917 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3919 //The LineCount must not be changed when calling GetNaturalSize.
3920 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3925 int UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize(void)
3927 ToolkitTestApplication application;
3928 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize ");
3930 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3931 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3932 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3934 // Create a text editor
3935 TextEditor textEditor = TextEditor::New();
3937 //Set size to avoid automatic eliding
3938 textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3939 //Set very large font-size using point-size
3940 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 1000) ;
3941 //Specify font-family
3942 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3943 //Set text to check if appear or not
3944 textEditor.SetProperty( TextEditor::Property::TEXT, "A");
3946 application.GetScene().Add( textEditor );
3948 application.SendNotification();
3949 application.Render();
3950 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3951 Vector3 naturalSize = textEditor.GetNaturalSize();
3953 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3954 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3959 int UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases(void)
3961 ToolkitTestApplication application;
3962 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases ");
3964 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3965 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3966 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3968 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3969 // Create a text editor
3970 TextEditor textEditor = TextEditor::New();
3971 //Set size to avoid automatic eliding
3972 textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3973 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3974 textEditor.SetProperty( TextEditor::Property::TEXT, "A");
3976 const int numberOfCases = 6;
3977 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
3979 for (int index=0; index < numberOfCases; index++)
3981 tet_printf(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
3982 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, arrayCases[index]) ;
3983 application.GetScene().Add( textEditor );
3984 application.SendNotification();
3985 application.Render();
3986 naturalSize = textEditor.GetNaturalSize();
3987 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3988 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3995 int UtcDaliTextEditorHyphenWrapMode(void)
3997 ToolkitTestApplication application;
3998 tet_infoline(" UtcDaliTextEditorHyphenWrapMode ");
4001 TextEditor textEditor = TextEditor::New();
4003 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
4005 application.GetScene().Add( textEditor );
4006 application.SendNotification();
4007 application.Render();
4009 textEditor.SetProperty( TextEditor::Property::TEXT, "Hi Experimen" );
4010 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
4011 DALI_TEST_EQUALS( textEditor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::HYPHENATION ), TEST_LOCATION );
4013 application.SendNotification();
4014 application.Render();
4016 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
4022 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
4024 textEditor.SetProperty( TextEditor::Property::TEXT, "Hi Experimen" );
4025 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
4026 DALI_TEST_EQUALS( textEditor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::MIXED ), TEST_LOCATION );
4028 application.SendNotification();
4029 application.Render();
4031 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
4038 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
4043 int UtcDaliToolkitTextEditorEllipsisPositionProperty(void)
4045 ToolkitTestApplication application;
4046 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty ");
4047 TextEditor textEditor = TextEditor::New();
4049 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Default is END");
4050 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4052 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START");
4053 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4054 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4056 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE");
4057 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4058 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4060 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END");
4061 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4062 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4064 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START using integer");
4065 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 1);
4066 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4068 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE using integer");
4069 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 2);
4070 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4072 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END using integer");
4073 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 0);
4074 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4076 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4077 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "START");
4078 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4080 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4081 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "MIDDLE");
4082 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4084 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4085 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "END");
4086 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4088 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4089 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "start");
4090 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4092 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4093 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "middle");
4094 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4096 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4097 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "end");
4098 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4103 int UtcDaliTextEditorCopyText(void)
4105 ToolkitTestApplication application;
4106 tet_infoline(" UtcDaliTextEditorCopyText ");
4108 TextEditor textEditor = TextEditor::New();
4110 std::string selectedText = "";
4111 std::string copiedText = "";
4113 application.GetScene().Add( textEditor );
4115 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4116 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4117 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4119 // Avoid a crash when core load gl resources.
4120 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4122 application.SendNotification();
4123 application.Render();
4125 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
4127 application.SendNotification();
4128 application.Render();
4130 // Hello is selected
4131 DevelTextEditor::SelectText( textEditor, 0, 5 );
4133 application.SendNotification();
4134 application.Render();
4136 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4137 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4139 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4140 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4143 copiedText = DevelTextEditor::CopyText( textEditor );
4144 DALI_TEST_EQUALS( "Hello", copiedText, TEST_LOCATION );
4146 // world is selected
4147 DevelTextEditor::SelectText( textEditor, 6, 11 );
4149 application.SendNotification();
4150 application.Render();
4152 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4153 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
4155 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
4156 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
4159 copiedText = DevelTextEditor::CopyText( textEditor );
4160 DALI_TEST_EQUALS( "world", copiedText, TEST_LOCATION );
4162 // "lo wo" is selected
4163 DevelTextEditor::SelectText( textEditor, 3, 8 );
4165 application.SendNotification();
4166 application.Render();
4168 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4169 DALI_TEST_EQUALS( "lo wo", selectedText, TEST_LOCATION );
4171 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 3, TEST_LOCATION );
4172 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 8, TEST_LOCATION );
4174 // "lo wo" is copied
4175 copiedText = DevelTextEditor::CopyText( textEditor );
4176 DALI_TEST_EQUALS( "lo wo", copiedText, TEST_LOCATION );
4181 int UtcDaliTextEditorCutText(void)
4183 ToolkitTestApplication application;
4184 tet_infoline(" UtcDaliTextEditorCutText ");
4186 TextEditor textEditor = TextEditor::New();
4188 std::string selectedText = "";
4190 application.GetScene().Add( textEditor );
4192 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4193 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4194 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4196 // Avoid a crash when core load gl resources.
4197 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4199 application.SendNotification();
4200 application.Render();
4202 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
4204 application.SendNotification();
4205 application.Render();
4207 // Hello is selected
4208 DevelTextEditor::SelectText( textEditor, 0, 5 );
4210 application.SendNotification();
4211 application.Render();
4213 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4214 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4216 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4217 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4220 DALI_TEST_EQUALS( "Hello", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4222 application.SendNotification();
4223 application.Render();
4225 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), " world", TEST_LOCATION );
4228 DevelTextEditor::SelectText( textEditor, 0, 2 );
4230 application.SendNotification();
4231 application.Render();
4233 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4234 DALI_TEST_EQUALS( " w", selectedText, TEST_LOCATION );
4236 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4237 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4240 DALI_TEST_EQUALS( " w", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4242 application.SendNotification();
4243 application.Render();
4245 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "orld", TEST_LOCATION );
4247 // Test Cut from the middle
4250 DevelTextEditor::SelectText( textEditor, 1, 3 );
4252 application.SendNotification();
4253 application.Render();
4255 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4256 DALI_TEST_EQUALS( "rl", selectedText, TEST_LOCATION );
4258 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4259 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 3, TEST_LOCATION );
4262 DALI_TEST_EQUALS( "rl", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4264 application.SendNotification();
4265 application.Render();
4267 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "od", TEST_LOCATION );
4269 // Test Cut from the end
4272 DevelTextEditor::SelectText( textEditor, 1, 2 );
4274 application.SendNotification();
4275 application.Render();
4277 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4278 DALI_TEST_EQUALS( "d", selectedText, TEST_LOCATION );
4280 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4281 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4284 DALI_TEST_EQUALS( "d", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4286 application.SendNotification();
4287 application.Render();
4289 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "o", TEST_LOCATION );
4294 int UtcDaliTextEditorPasteText(void)
4296 ToolkitTestApplication application;
4297 tet_infoline(" UtcDaliTextEditorPasteText ");
4299 TextEditor editor = TextEditor::New();
4300 DALI_TEST_CHECK( editor );
4302 application.GetScene().Add( editor );
4304 std::string cutText = "";
4305 std::string copiedText = "";
4307 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4308 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4309 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4310 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4311 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4313 // Avoid a crash when core load gl resources.
4314 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4316 // Render and notify
4317 application.SendNotification();
4318 application.Render();
4320 // Tap on the text editor
4321 TestGenerateTap( application, 3.0f, 25.0f );
4323 // Render and notify
4324 application.SendNotification();
4325 application.Render();
4327 // Move to second line of the text.
4328 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4330 // Render and notify
4331 application.SendNotification();
4332 application.Render();
4334 // Select some text in the right of the current cursor position
4335 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4336 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4337 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4338 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4340 // Render and notify
4341 application.SendNotification();
4342 application.Render();
4344 // Cut the selected text
4345 cutText = DevelTextEditor::CutText(editor);
4347 // Render and notify
4348 application.SendNotification();
4349 application.Render();
4351 DALI_TEST_EQUALS( "wor", cutText, TEST_LOCATION );
4352 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
4354 // Select some text in the left of the current cursor position
4355 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4356 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4357 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4358 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4360 // Render and notify
4361 application.SendNotification();
4362 application.Render();
4364 // Copy the selected text
4365 copiedText = DevelTextEditor::CopyText(editor);
4367 // Render and notify
4368 application.SendNotification();
4369 application.Render();
4371 DALI_TEST_EQUALS( "lo\n", copiedText, TEST_LOCATION );
4372 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
4375 // Move the cursor to the third line
4376 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4377 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4379 // Render and notify
4380 application.SendNotification();
4381 application.Render();
4383 // Paste the selected text at the current cursor position
4384 DevelTextEditor::PasteText(editor);
4386 // Render and notify
4387 application.SendNotification();
4388 application.Render();
4390 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
4394 int UtcDaliTextEditorLineSpacing(void)
4396 ToolkitTestApplication application;
4397 tet_infoline(" UtcDaliTextEditorLineSpacing ");
4399 TextEditor textEditor = TextEditor::New();
4400 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.f ) );
4401 application.GetScene().Add( textEditor );
4402 application.SendNotification();
4403 application.Render();
4405 textEditor.SetProperty( TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3" );
4406 textEditor.SetProperty( DevelTextEditor::Property::LINE_SPACING, 0 );
4408 Vector3 sizeBefore = textEditor.GetNaturalSize();
4410 textEditor.SetProperty( DevelTextEditor::Property::LINE_SPACING, 20 );
4412 //add 20 for each line 20 * 3
4413 DALI_TEST_EQUALS(sizeBefore.height + 60.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4418 int UtcDaliTextEditorMinLineSize(void)
4420 ToolkitTestApplication application;
4421 tet_infoline(" UtcDaliTextEditorMinLineSize ");
4423 TextEditor textEditor = TextEditor::New();
4424 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.f ) );
4425 application.GetScene().Add( textEditor );
4426 application.SendNotification();
4427 application.Render();
4429 textEditor.SetProperty( TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3" );
4430 textEditor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 0 );
4432 Vector3 sizeBefore = textEditor.GetNaturalSize();
4434 textEditor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 60 );
4436 DALI_TEST_NOT_EQUALS( sizeBefore, textEditor.GetNaturalSize(), 0.0f, TEST_LOCATION);
4439 DALI_TEST_EQUALS(180.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4444 int utcDaliTextEditorCursorPositionChangedSignal(void)
4446 ToolkitTestApplication application;
4447 tet_infoline(" utcDaliTextEditorCursorPositionChangedSignal");
4449 TextEditor editor = TextEditor::New();
4450 DALI_TEST_CHECK( editor );
4452 application.GetScene().Add( editor );
4454 // connect to the selection changed signal.
4455 ConnectionTracker* testTracker = new ConnectionTracker();
4456 DevelTextEditor::CursorPositionChangedSignal(editor).Connect(&TestCursorPositionChangedCallback);
4457 bool cursorPositionChangedSignal = false;
4458 editor.ConnectSignal( testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal) );
4460 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4461 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4462 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4463 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4464 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4466 // Avoid a crash when core load gl resources.
4467 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4469 // Render and notify
4470 application.SendNotification();
4471 application.Render();
4473 editor.SetKeyInputFocus();
4475 // Tap on the text editor
4476 TestGenerateTap( application, 3.0f, 25.0f );
4478 // Render and notify
4479 application.SendNotification();
4480 application.Render();
4482 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4483 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4485 gCursorPositionChangedCallbackCalled = false;
4488 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4490 // Render and notify
4491 application.SendNotification();
4492 application.Render();
4494 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4495 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4497 gCursorPositionChangedCallbackCalled = false;
4500 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4502 // Render and notify
4503 application.SendNotification();
4504 application.Render();
4506 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4507 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4509 gCursorPositionChangedCallbackCalled = false;
4511 //delete one character
4512 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4514 // Render and notify
4515 application.SendNotification();
4516 application.Render();
4518 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4519 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4521 gCursorPositionChangedCallbackCalled = false;
4523 editor.SetProperty( TextEditor::Property::TEXT, "Hello" );
4525 // Render and notify
4526 application.SendNotification();
4527 application.Render();
4529 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4530 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4532 gCursorPositionChangedCallbackCalled = false;
4534 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4536 // Render and notify
4537 application.SendNotification();
4538 application.Render();
4540 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4541 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4546 int utcDaliTextEditorGeometryEllipsisStart(void)
4548 ToolkitTestApplication application;
4549 tet_infoline(" utcDaliTextEditorGeometryEllipsisStart");
4551 TextEditor editor = TextEditor::New();
4552 DALI_TEST_CHECK( editor );
4554 application.GetScene().Add( editor );
4556 editor.SetProperty( TextEditor::Property::POINT_SIZE, 7.f );
4557 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4558 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4559 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4560 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4561 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, false );
4562 editor.SetProperty( DevelTextEditor::Property::ELLIPSIS, true );
4563 editor.SetProperty( DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START );
4564 editor.SetProperty( TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4" );
4566 // Avoid a crash when core load gl resources.
4567 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4569 // Render and notify
4570 application.SendNotification();
4571 application.Render();
4573 unsigned int expectedCount = 2;
4574 unsigned int startIndex = 0;
4575 unsigned int endIndex = 24;
4577 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4578 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4580 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4581 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4583 Vector<Vector2> expectedSizes;
4584 Vector<Vector2> expectedPositions;
4586 expectedPositions.PushBack(Vector2(37, 0));
4587 expectedSizes.PushBack(Vector2(20, 25));
4589 expectedPositions.PushBack(Vector2(-1, 25));
4590 expectedSizes.PushBack(Vector2(52, 25));
4592 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4597 int utcDaliTextEditorGeometryEllipsisMiddle(void)
4599 ToolkitTestApplication application;
4600 tet_infoline(" utcDaliTextEditorGeometryEllipsisMiddle");
4602 TextEditor editor = TextEditor::New();
4603 DALI_TEST_CHECK( editor );
4605 application.GetScene().Add( editor );
4607 editor.SetProperty( TextEditor::Property::POINT_SIZE, 7.f );
4608 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4609 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4610 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4611 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4612 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, false );
4613 editor.SetProperty( DevelTextEditor::Property::ELLIPSIS, true );
4614 editor.SetProperty( DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE );
4615 editor.SetProperty( TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4" );
4617 // Avoid a crash when core load gl resources.
4618 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4620 // Render and notify
4621 application.SendNotification();
4622 application.Render();
4624 unsigned int expectedCount = 2;
4625 unsigned int startIndex = 0;
4626 unsigned int endIndex = 24;
4628 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4629 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4631 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4632 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4634 Vector<Vector2> expectedSizes;
4635 Vector<Vector2> expectedPositions;
4637 expectedPositions.PushBack(Vector2(-1, 0));
4638 expectedSizes.PushBack(Vector2(25, 25));
4640 expectedPositions.PushBack(Vector2(-1, 25));
4641 expectedSizes.PushBack(Vector2(52, 25));
4643 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4648 int utcDaliTextEditorGeometryEllipsisEnd(void)
4650 ToolkitTestApplication application;
4651 tet_infoline(" utcDaliTextEditorGeometryEllipsisEnd");
4653 TextEditor editor = TextEditor::New();
4654 DALI_TEST_CHECK( editor );
4656 application.GetScene().Add( editor );
4658 editor.SetProperty( TextEditor::Property::POINT_SIZE, 7.f );
4659 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4660 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4661 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4662 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4663 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, false );
4664 editor.SetProperty( DevelTextEditor::Property::ELLIPSIS, true );
4665 editor.SetProperty( DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END );
4666 editor.SetProperty( TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4" );
4668 // Avoid a crash when core load gl resources.
4669 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4671 // Render and notify
4672 application.SendNotification();
4673 application.Render();
4675 unsigned int expectedCount = 2;
4676 unsigned int startIndex = 0;
4677 unsigned int endIndex = 24;
4679 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4680 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4682 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4683 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4685 Vector<Vector2> expectedSizes;
4686 Vector<Vector2> expectedPositions;
4688 expectedPositions.PushBack(Vector2(-1, 0));
4689 expectedSizes.PushBack(Vector2(59, 25));
4691 expectedPositions.PushBack(Vector2(-1, 25));
4692 expectedSizes.PushBack(Vector2(25, 25));
4694 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4699 int utcDaliTextEditorGeometryRTL(void)
4701 ToolkitTestApplication application;
4702 tet_infoline(" utcDaliTextEditorGeometryRTL");
4704 TextEditor editor = TextEditor::New();
4705 DALI_TEST_CHECK( editor );
4707 application.GetScene().Add( editor );
4709 editor.SetProperty( TextEditor::Property::POINT_SIZE, 7.f );
4710 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4711 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4712 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4713 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4714 editor.SetProperty( TextEditor::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر" );
4716 // Avoid a crash when core load gl resources.
4717 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4719 // Render and notify
4720 application.SendNotification();
4721 application.Render();
4723 unsigned int expectedCount = 4;
4724 unsigned int startIndex = 3;
4725 unsigned int endIndex = 24;
4727 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4728 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4730 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4731 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4733 Vector<Vector2> expectedSizes;
4734 Vector<Vector2> expectedPositions;
4736 expectedPositions.PushBack(Vector2(24, 0));
4737 expectedSizes.PushBack(Vector2(33, 25));
4739 expectedPositions.PushBack(Vector2(-1, 25));
4740 expectedSizes.PushBack(Vector2(52, 25));
4742 expectedPositions.PushBack(Vector2(-1, 50));
4743 expectedSizes.PushBack(Vector2(59, 25));
4745 expectedPositions.PushBack(Vector2(61, 75));
4746 expectedSizes.PushBack(Vector2(37, 25));
4748 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4753 int utcDaliTextEditorGeometryGlyphMiddle(void)
4755 ToolkitTestApplication application;
4756 tet_infoline(" utcDaliTextEditorGeometryGlyphMiddle");
4758 TextEditor editor = TextEditor::New();
4759 DALI_TEST_CHECK( editor );
4761 application.GetScene().Add( editor );
4763 editor.SetProperty( TextEditor::Property::POINT_SIZE, 7.f );
4764 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.f, 200.f ) );
4765 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4766 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4767 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4768 editor.SetProperty( TextEditor::Property::TEXT, "لا تحتوي على لا" );
4770 // Avoid a crash when core load gl resources.
4771 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4773 // Render and notify
4774 application.SendNotification();
4775 application.Render();
4777 unsigned int expectedCount = 1;
4778 unsigned int startIndex = 1;
4779 unsigned int endIndex = 13;
4781 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4782 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4784 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4785 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4787 Vector<Vector2> expectedSizes;
4788 Vector<Vector2> expectedPositions;
4790 expectedPositions.PushBack(Vector2(6, 0));
4791 expectedSizes.PushBack(Vector2(124, 25));
4793 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4798 int utcDaliTextEditorSelectionClearedSignal(void)
4800 ToolkitTestApplication application;
4801 tet_infoline(" utcDaliTextEditorSelectionClearedSignal");
4803 TextEditor editor = TextEditor::New();
4804 DALI_TEST_CHECK( editor );
4806 application.GetScene().Add( editor );
4808 // connect to the selection changed signal.
4809 ConnectionTracker* testTracker = new ConnectionTracker();
4810 DevelTextEditor::SelectionClearedSignal(editor).Connect(&TestSelectionClearedCallback);
4811 bool selectionClearedSignal = false;
4812 editor.ConnectSignal( testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal) );
4814 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4815 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4816 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4817 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4818 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4820 // Avoid a crash when core load gl resources.
4821 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4823 // Render and notify
4824 application.SendNotification();
4825 application.Render();
4827 // Tap on the text editor
4828 TestGenerateTap( application, 3.0f, 25.0f );
4830 // Render and notify
4831 application.SendNotification();
4832 application.Render();
4834 // Move to second line of the text & Select some text in the right of the current cursor position
4835 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4836 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4839 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4841 // Render and notify
4842 application.SendNotification();
4843 application.Render();
4845 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4847 // Render and notify
4848 application.SendNotification();
4849 application.Render();
4851 // Tap on the text editor
4852 TestGenerateTap( application, 3.0f, 25.0f );
4854 // Render and notify
4855 application.SendNotification();
4856 application.Render();
4858 gSelectionClearedCallbackCalled = false;
4860 // Move to second line of the text & select.
4861 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4862 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4865 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4867 // Render and notify
4868 application.SendNotification();
4869 application.Render();
4871 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4873 gSelectionClearedCallbackCalled = false;
4875 // Render and notify
4876 application.SendNotification();
4877 application.Render();
4879 // Move to second line of the text & select.
4880 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4881 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4883 // replace C with selected text
4884 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4886 // Render and notify
4887 application.SendNotification();
4888 application.Render();
4890 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4892 gSelectionClearedCallbackCalled = false;
4894 // Render and notify
4895 application.SendNotification();
4896 application.Render();
4898 DevelTextEditor::SelectText( editor ,1, 3 );
4900 // Render and notify
4901 application.SendNotification();
4902 application.Render();
4904 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4906 // Render and notify
4907 application.SendNotification();
4908 application.Render();
4910 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4912 gSelectionClearedCallbackCalled = false;
4914 DevelTextEditor::SelectText( editor ,1, 3 );
4916 // Render and notify
4917 application.SendNotification();
4918 application.Render();
4921 DevelTextEditor::SelectNone(editor);
4923 // Render and notify
4924 application.SendNotification();
4925 application.Render();
4927 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4932 int utcDaliTextEditorSelectionWithSecondaryCursor(void)
4934 ToolkitTestApplication application;
4935 tet_infoline(" utcDaliTextEditorSelectionWithSecondaryCursor");
4937 // Checks if the actor is created.
4939 TextEditor editor = TextEditor::New();
4940 DALI_TEST_CHECK( editor );
4942 application.GetScene().Add( editor );
4944 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4945 editor.SetProperty( TextEditor::Property::TEXT, "اللغة العربية\nمرحبا بالجميع\nالسلام عليكم <span font-size='12' font-family='DejaVu Sans' >Hello world</span>" );
4946 editor.SetProperty( TextEditor::Property::POINT_SIZE, 12.f );
4947 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4948 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4949 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4950 editor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 50.f );
4951 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
4953 // Avoid a crash when core load gl resources.
4954 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4956 // Render and notify
4957 application.SendNotification();
4958 application.Render();
4960 // Tap on the text editor
4961 TestGenerateTap( application, 3.0f, 25.0f );
4963 // Render and notify
4964 application.SendNotification();
4965 application.Render();
4967 //Select the last Arabic word (RTL) & some the space before the English (LTR) letters.
4968 DevelTextEditor::SelectText( editor, 35, 41 );// This will activate the alternative cursor position and thus 'cursorInfo.isSecondaryCursor' will be true.
4970 application.SendNotification();
4971 application.Render();
4973 std::string selectedText = editor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4974 DALI_TEST_EQUALS( "عليكم ", selectedText, TEST_LOCATION );
4979 int utcDaliTextEditorSelectionChangedSignal(void)
4981 ToolkitTestApplication application;
4982 tet_infoline(" utcDaliTextEditorSelectionChangedSignal");
4984 TextEditor editor = TextEditor::New();
4985 DALI_TEST_CHECK( editor );
4987 application.GetScene().Add( editor );
4989 // connect to the selection changed signal.
4990 ConnectionTracker* testTracker = new ConnectionTracker();
4991 DevelTextEditor::SelectionChangedSignal(editor).Connect(&TestSelectionChangedCallback);
4992 bool selectionChangedSignal = false;
4993 editor.ConnectSignal( testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal) );
4995 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4996 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4997 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4998 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4999 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
5001 // Avoid a crash when core load gl resources.
5002 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
5004 // Render and notify
5005 application.SendNotification();
5006 application.Render();
5008 // Tap on the text editor
5009 TestGenerateTap( application, 3.0f, 25.0f );
5011 // Render and notify
5012 application.SendNotification();
5013 application.Render();
5015 // Move to second line of the text.
5016 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5018 // Render and notify
5019 application.SendNotification();
5020 application.Render();
5022 // Select some text in the right of the current cursor position
5023 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5024 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5026 // Render and notify
5027 application.SendNotification();
5028 application.Render();
5030 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5031 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5033 gSelectionChangedCallbackCalled = false;
5035 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5037 // Render and notify
5038 application.SendNotification();
5039 application.Render();
5041 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5042 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
5043 DALI_TEST_EQUALS(oldSelectionEnd, 7, TEST_LOCATION);
5045 gSelectionChangedCallbackCalled = false;
5047 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5049 // Render and notify
5050 application.SendNotification();
5051 application.Render();
5053 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5054 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
5055 DALI_TEST_EQUALS(oldSelectionEnd, 8, TEST_LOCATION);
5057 gSelectionChangedCallbackCalled = false;
5058 editor.SetKeyInputFocus();
5060 // Render and notify
5061 application.SendNotification();
5062 application.Render();
5064 DevelTextEditor::SelectText( editor ,0, 5 );
5066 application.SendNotification();
5067 application.Render();
5069 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5070 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5072 gSelectionChangedCallbackCalled = false;
5074 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5076 // Render and notify
5077 application.SendNotification();
5078 application.Render();
5080 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5081 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5082 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
5084 gSelectionChangedCallbackCalled = false;
5087 DevelTextEditor::SelectWholeText(editor);
5089 // Render and notify
5090 application.SendNotification();
5091 application.Render();
5093 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5094 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5096 gSelectionChangedCallbackCalled = false;
5099 DevelTextEditor::SelectNone(editor);
5101 // Render and notify
5102 application.SendNotification();
5103 application.Render();
5105 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5106 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5107 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5112 int UtcDaliToolkitTextEditorStrikethroughGeneration(void)
5114 ToolkitTestApplication application;
5115 tet_infoline(" UtcDaliToolkitTextEditorStrikethroughGeneration");
5117 TextEditor textEditor = TextEditor::New();
5118 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
5119 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 200.0f, 100.f ) );
5120 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
5121 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5123 application.GetScene().Add( textEditor );
5124 application.SendNotification();
5125 application.Render();
5127 Property::Map strikethroughMapSet;
5128 Property::Map strikethroughMapGet;
5130 strikethroughMapSet.Insert( "enable", true );
5131 strikethroughMapSet.Insert( "color", Color::RED );
5132 strikethroughMapSet.Insert( "height", 2.0f );
5134 // Check the strikethrough property
5135 textEditor.SetProperty( DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet );
5136 strikethroughMapGet = textEditor.GetProperty<Property::Map>( DevelTextEditor::Property::STRIKETHROUGH );
5137 textEditor.SetProperty( TextEditor::Property::TEXT, "Test1" );
5138 DALI_TEST_EQUALS( strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION );
5139 DALI_TEST_EQUALS( DaliTestCheckMaps( strikethroughMapGet, strikethroughMapSet ), true, TEST_LOCATION );
5141 // Render and notify
5142 application.SendNotification();
5143 application.Render();
5145 strikethroughMapSet.Clear();
5146 strikethroughMapGet.Clear();
5151 int utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize(void)
5154 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5155 //DaliException on vector: "Iterator not inside vector"
5157 ToolkitTestApplication application;
5158 tet_infoline(" utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize");
5160 TextEditor editor = TextEditor::New();
5161 DALI_TEST_CHECK( editor );
5163 application.GetScene().Add( editor );
5165 // Avoid a crash when core load gl resources.
5166 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
5168 //Set multilines text
5169 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5170 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
5171 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
5173 //Set ResizePolicy to NaturalSize
5174 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5176 // Render and notify
5177 application.SendNotification();
5178 application.Render();
5180 // Create a tap event to touch the text editor.
5181 TestGenerateTap( application, 5.0f, 5.0f );
5183 // Render and notify
5184 application.SendNotification();
5185 application.Render();
5187 // Set currsor and add character (in first line)
5188 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5189 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5190 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5192 // Render and notify
5193 application.SendNotification();
5194 application.Render();
5196 //Check the changed text and cursor position
5197 DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "Hellod \n World", TEST_LOCATION );
5198 DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 6, TEST_LOCATION );
5200 // Render and notify
5201 application.SendNotification();
5202 application.Render();
5207 int utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize(void)
5210 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5211 //DaliException on vector: "Iterator not inside vector"
5213 ToolkitTestApplication application;
5214 tet_infoline(" utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize");
5216 TextEditor editor = TextEditor::New();
5217 DALI_TEST_CHECK( editor );
5219 application.GetScene().Add( editor );
5221 // Avoid a crash when core load gl resources.
5222 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
5224 //Set multilines text
5225 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5226 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
5227 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
5229 //Set ResizePolicy to NaturalSize
5230 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5233 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5234 application.SendNotification();
5235 application.Render();
5237 // Set focus and remove character
5238 editor.SetKeyInputFocus();
5239 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5241 // Render and notify
5242 application.SendNotification();
5243 application.Render();
5245 //Check the changed text and cursor position
5246 DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "Hell \n World", TEST_LOCATION );
5247 DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
5249 // Render and notify
5250 application.SendNotification();
5251 application.Render();
5256 int utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize(void)
5259 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5260 //DaliException on vector: "Iterator not inside vector"
5262 ToolkitTestApplication application;
5263 tet_infoline(" utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize");
5265 TextEditor editor = TextEditor::New();
5266 DALI_TEST_CHECK( editor );
5268 application.GetScene().Add( editor );
5270 // Avoid a crash when core load gl resources.
5271 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
5273 //Set multilines text
5274 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5275 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
5276 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
5278 //Set ResizePolicy to NaturalSize
5279 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5281 //Select text at initialization (before the first render)
5282 DevelTextEditor::SelectText( editor ,3, 5 );
5284 // Render and notify
5285 application.SendNotification();
5286 application.Render();
5289 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5290 application.ProcessEvent( GenerateKey( "x", "x", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5292 // Render and notify
5293 application.SendNotification();
5294 application.Render();
5296 //Check the changed text and cursor position
5297 DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "Hel \n World", TEST_LOCATION );
5298 DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 3, TEST_LOCATION );
5300 // Render and notify
5301 application.SendNotification();
5302 application.Render();
5308 int utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize(void)
5311 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5312 //DaliException on vector: "Iterator not inside vector"
5314 ToolkitTestApplication application;
5315 tet_infoline(" utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize");
5317 TextEditor editor = TextEditor::New();
5318 DALI_TEST_CHECK( editor );
5320 application.GetScene().Add( editor );
5322 // Avoid a crash when core load gl resources.
5323 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
5325 //Set multilines text
5326 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5327 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
5328 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
5330 //Set ResizePolicy to NaturalSize
5331 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5334 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5335 application.SendNotification();
5336 application.Render();
5338 // Set focus and double enter (new line)
5339 editor.SetKeyInputFocus();
5340 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5341 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5343 // Render and notify
5344 application.SendNotification();
5345 application.Render();
5347 //Check the changed text and cursor position
5348 DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "Hello\n\n \n World", TEST_LOCATION );
5349 DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 7, TEST_LOCATION );
5351 // Render and notify
5352 application.SendNotification();
5353 application.Render();