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_GRAB_HANDLE_COLOR = "grabHandleColor";
111 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
112 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
113 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
115 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
116 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
118 const float RENDER_FRAME_INTERVAL = 16.66f;
120 const unsigned int DEFAULT_FONT_SIZE = 1152u;
121 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
123 const int KEY_A_CODE = 38;
124 const int KEY_D_CODE = 40;
125 const int KEY_C_CODE = 54;
126 const int KEY_V_CODE = 55;
127 const int KEY_X_CODE = 53;
128 const int KEY_WHITE_SPACE_CODE = 65;
130 const int KEY_SHIFT_MODIFIER = 257;
131 const int KEY_CONTROL_MODIFIER = 258;
133 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
134 const char* HANDLE_LEFT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_left.png";
135 const char* HANDLE_RIGHT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_right.png";
137 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
139 static bool gSelectionChangedCallbackCalled;
140 static uint32_t oldSelectionStart;
141 static uint32_t oldSelectionEnd;
142 static bool gSelectionClearedCallbackCalled;
143 static bool gAnchorClickedCallBackCalled;
144 static bool gAnchorClickedCallBackNotCalled;
145 static bool gTextChangedCallBackCalled;
146 static bool gInputFilteredAcceptedCallbackCalled;
147 static bool gInputFilteredRejectedCallbackCalled;
148 static bool gInputStyleChangedCallbackCalled;
149 static bool gMaxCharactersCallBackCalled;
150 static bool gCursorPositionChangedCallbackCalled;
151 static uint32_t oldCursorPos;
152 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
154 struct CallbackFunctor
156 CallbackFunctor(bool* callbackFlag)
157 : mCallbackFlag( callbackFlag )
163 *mCallbackFlag = true;
168 static void TestSelectionClearedCallback(TextEditor control)
170 tet_infoline(" TestSelectionClearedCallback");
172 gSelectionClearedCallbackCalled = true;
175 static void TestSelectionChangedCallback(TextEditor control, uint32_t oldStart, uint32_t oldEnd)
177 tet_infoline(" TestSelectionChangedCallback");
179 gSelectionChangedCallbackCalled = true;
180 oldSelectionStart = oldStart;
181 oldSelectionEnd = oldEnd;
184 static void TestAnchorClickedCallback(TextEditor control, const char* href, unsigned int hrefLength)
186 tet_infoline(" TestAnchorClickedCallback");
188 gAnchorClickedCallBackNotCalled = false;
190 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
192 gAnchorClickedCallBackCalled = true;
196 static void TestCursorPositionChangedCallback( TextEditor control, unsigned int oldPos )
198 tet_infoline(" TestCursorPositionChangedCallback");
200 gCursorPositionChangedCallbackCalled = true;
201 oldCursorPos = oldPos;
204 static void TestTextChangedCallback( TextEditor control )
206 tet_infoline(" TestTextChangedCallback");
208 gTextChangedCallBackCalled = true;
211 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
213 tet_infoline(" TestInputStyleChangedCallback");
215 gInputStyleChangedCallbackCalled = true;
216 gInputStyleMask = mask;
219 static void TestMaxLengthReachedCallback( TextEditor control )
221 tet_infoline(" TestMaxLengthReachedCallback");
223 gMaxCharactersCallBackCalled = true;
226 static void TestInputFilteredCallback(TextEditor control, Toolkit::InputFilter::Property::Type type)
228 tet_infoline(" TestInputFilteredCallback");
230 if(type == Toolkit::InputFilter::Property::ACCEPTED)
232 gInputFilteredAcceptedCallbackCalled = true;
234 else if(type == Toolkit::InputFilter::Property::REJECTED)
236 gInputFilteredRejectedCallbackCalled = true;
240 // Generate a KeyEvent to send to Core.
241 Integration::KeyEvent GenerateKey( const std::string& keyName,
242 const std::string& logicalKey,
243 const std::string& keyString,
246 unsigned long timeStamp,
247 const Integration::KeyEvent::State& keyState,
248 const std::string& compose = "",
249 const std::string& deviceName = DEFAULT_DEVICE_NAME,
250 const Device::Class::Type& deviceClass = Device::Class::NONE,
251 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
253 return Integration::KeyEvent( keyName,
266 Dali::Integration::Point GetPointDownInside( Vector2& pos )
268 Dali::Integration::Point point;
269 point.SetState( PointState::DOWN );
270 point.SetScreenPosition( pos );
274 Dali::Integration::Point GetPointUpInside( Vector2& pos )
276 Dali::Integration::Point point;
277 point.SetState( PointState::UP );
278 point.SetScreenPosition( pos );
282 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
284 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
286 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
288 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
290 Property::Value* valueSet = NULL;
291 if ( valueGet.first.type == Property::Key::INDEX )
293 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
297 // Get Key is a string so searching Set Map for a string key
298 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
301 if( NULL != valueSet )
303 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
305 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
308 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
310 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
313 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
315 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
318 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
320 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
323 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
325 Vector2 vector2Get = valueGet.second.Get<Vector2>();
326 Vector2 vector2Set = valueSet->Get<Vector2>();
327 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
330 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
332 Vector4 vector4Get = valueGet.second.Get<Vector4>();
333 Vector4 vector4Set = valueSet->Get<Vector4>();
334 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 );
340 if ( valueGet.first.type == Property::Key::INDEX )
342 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
346 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
356 class ScrollStateChangeCallback : public Dali::ConnectionTracker
359 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
360 : mStartedCalled( startedCalled ),
361 mFinishedCalled( finishedCalled )
365 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
367 if( type == TextEditor::Scroll::STARTED )
369 mStartedCalled = true;
371 else if( type == TextEditor::Scroll::FINISHED )
373 mFinishedCalled = true;
377 bool& mStartedCalled;
378 bool& mFinishedCalled;
383 int UtcDaliToolkitTextEditorConstructorP(void)
385 ToolkitTestApplication application;
386 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
387 TextEditor textEditor;
388 DALI_TEST_CHECK( !textEditor );
392 int UtcDaliToolkitTextEditorNewP(void)
394 ToolkitTestApplication application;
395 tet_infoline(" UtcDaliToolkitTextEditorNewP");
396 TextEditor textEditor = TextEditor::New();
397 DALI_TEST_CHECK( textEditor );
401 int UtcDaliToolkitTextEditorDownCastP(void)
403 ToolkitTestApplication application;
404 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
405 TextEditor textEditor1 = TextEditor::New();
406 BaseHandle object( textEditor1 );
408 TextEditor textEditor2 = TextEditor::DownCast( object );
409 DALI_TEST_CHECK( textEditor2 );
411 TextEditor textEditor3 = DownCast< TextEditor >( object );
412 DALI_TEST_CHECK( textEditor3 );
416 int UtcDaliToolkitTextEditorDownCastN(void)
418 ToolkitTestApplication application;
419 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
420 BaseHandle uninitializedObject;
421 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
422 DALI_TEST_CHECK( !textEditor1 );
424 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
425 DALI_TEST_CHECK( !textEditor2 );
429 int UtcDaliToolkitTextEditorCopyConstructorP(void)
431 ToolkitTestApplication application;
432 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
433 TextEditor textEditor = TextEditor::New();
434 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
436 TextEditor copy( textEditor );
437 DALI_TEST_CHECK( copy );
438 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
442 int UtcDaliTextEditorMoveConstructor(void)
444 ToolkitTestApplication application;
446 TextEditor textEditor = TextEditor::New();
447 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
448 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
450 TextEditor moved = std::move( textEditor );
451 DALI_TEST_CHECK( moved );
452 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
453 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
454 DALI_TEST_CHECK( !textEditor );
459 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
461 ToolkitTestApplication application;
462 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
463 TextEditor textEditor = TextEditor::New();
464 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
466 TextEditor copy = textEditor;
467 DALI_TEST_CHECK( copy );
468 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
472 int UtcDaliTextEditorMoveAssignment(void)
474 ToolkitTestApplication application;
476 TextEditor textEditor = TextEditor::New();
477 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
478 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
481 moved = std::move( textEditor );
482 DALI_TEST_CHECK( moved );
483 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
484 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
485 DALI_TEST_CHECK( !textEditor );
490 int UtcDaliTextEditorNewP(void)
492 ToolkitTestApplication application;
493 tet_infoline(" UtcDaliToolkitTextEditorNewP");
494 TextEditor textEditor = TextEditor::New();
495 DALI_TEST_CHECK( textEditor );
499 // Positive test case for a method
500 int UtcDaliTextEditorGetPropertyP(void)
502 ToolkitTestApplication application;
503 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
504 TextEditor editor = TextEditor::New();
505 DALI_TEST_CHECK( editor );
507 // Check Property Indices are correct
508 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextEditor::Property::RENDERING_BACKEND );
509 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
510 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
511 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
512 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
513 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
514 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
515 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
516 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
517 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
518 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
519 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
520 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
521 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
522 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
523 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
524 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
525 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
526 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
527 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
528 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
529 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
530 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
531 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
532 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
533 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
534 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
535 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
536 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
537 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
539 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
540 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
541 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
542 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
543 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
544 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
545 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
546 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
547 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
548 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
549 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_STRIKETHROUGH ) == DevelTextEditor::Property::STRIKETHROUGH );
550 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_STRIKETHROUGH ) == DevelTextEditor::Property::INPUT_STRIKETHROUGH );
551 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
552 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
553 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
554 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
555 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
556 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
557 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
558 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
559 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
560 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextEditor::Property::FONT_SIZE_SCALE );
561 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
562 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
563 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
564 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
565 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
566 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == DevelTextEditor::Property::MAX_LENGTH );
567 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextEditor::Property::GRAB_HANDLE_COLOR );
568 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP );
569 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == DevelTextEditor::Property::INPUT_METHOD_SETTINGS );
570 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FILTER ) == DevelTextEditor::Property::INPUT_FILTER );
571 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_STRIKETHROUGH ) == DevelTextEditor::Property::STRIKETHROUGH );
572 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_STRIKETHROUGH ) == DevelTextEditor::Property::INPUT_STRIKETHROUGH );
577 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
580 Property::Map imageMap;
581 imageMap[mapKey] =mapValue;
583 editor.SetProperty( property , imageMap );
584 Property::Value propValue = editor.GetProperty( property );
585 Property::Map* resultMap = propValue.GetMap();
587 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
595 // Positive test case for a method
596 int UtcDaliTextEditorSetPropertyP(void)
598 ToolkitTestApplication application;
599 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
600 TextEditor editor = TextEditor::New();
601 DALI_TEST_CHECK( editor );
602 application.GetScene().Add( editor );
604 // Note - we can't check the defaults since the stylesheets are platform-specific
606 // Check the render backend property.
607 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
608 DALI_TEST_EQUALS( (DevelText::RenderingType)editor.GetProperty<int>( DevelTextEditor::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
610 // Check text property.
611 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
612 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
614 // Check text's color property
615 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
616 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
618 // Check font properties.
619 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
620 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
622 Property::Map fontStyleMapSet;
623 Property::Map fontStyleMapGet;
624 Property::Value* slantValue = NULL;
626 fontStyleMapSet.Insert( "weight", "bold" );
627 fontStyleMapSet.Insert( "width", "condensed" );
628 fontStyleMapSet.Insert( "slant", "italic" );
630 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
631 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
632 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
633 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
635 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
636 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
638 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 2.5f );
639 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
640 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 1.0f );
643 fontStyleMapSet.Clear();
644 fontStyleMapSet.Insert( "weight", "normal" );
645 fontStyleMapSet.Insert( "slant", "oblique" );
646 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
647 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
648 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
649 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
651 fontStyleMapSet.Clear();
652 fontStyleMapSet.Insert( "slant", "roman" );
653 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
654 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
656 // Replace 'roman' for 'normal'.
657 slantValue = fontStyleMapGet.Find( "slant" );
658 if( NULL != slantValue )
660 if( "normal" == slantValue->Get<std::string>() )
662 fontStyleMapGet["slant"] = "roman";
665 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
666 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
668 fontStyleMapSet.Clear();
670 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
671 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
672 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
673 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
675 // Check that the Alignment properties can be correctly set
676 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
677 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
679 // Check scroll properties.
680 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
681 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
682 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
683 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
685 // Check cursor properties
686 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
687 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
688 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
689 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
691 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
692 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
693 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
694 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
695 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
696 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
697 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
698 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
700 // Check handle images
701 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
702 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
703 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
704 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
705 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
707 // Check handle images
708 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
709 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
710 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
711 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
712 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
713 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
715 // Check the highlight color
716 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
717 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
719 // Decoration bounding box
720 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
721 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
723 // Check the enable markup property.
724 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
725 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
726 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
728 // Check input color property.
729 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
730 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
732 // Check input font properties.
733 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
734 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
736 fontStyleMapSet.Clear();
737 fontStyleMapSet.Insert( "weight", "bold" );
738 fontStyleMapSet.Insert( "width", "condensed" );
739 fontStyleMapSet.Insert( "slant", "italic" );
741 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
742 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
743 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
744 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
746 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
747 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
749 // Reset input font style.
750 fontStyleMapSet.Clear();
751 fontStyleMapSet.Insert( "weight", "normal" );
752 fontStyleMapSet.Insert( "slant", "oblique" );
754 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
755 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
756 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
757 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
759 fontStyleMapSet.Clear();
760 fontStyleMapSet.Insert( "slant", "roman" );
762 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
763 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
765 // Replace 'roman' for 'normal'.
766 slantValue = fontStyleMapGet.Find( "slant" );
767 if( NULL != slantValue )
769 if( "normal" == slantValue->Get<std::string>() )
771 fontStyleMapGet["slant"] = "roman";
774 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
775 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
777 fontStyleMapSet.Clear();
779 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
780 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
781 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
782 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
784 // Check the line spacing property
785 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
786 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
787 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
789 // Check the input line spacing property
790 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
791 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
792 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
794 // Check the underline property
796 Property::Map underlineMapSet;
797 Property::Map underlineMapGet;
799 underlineMapSet.Insert( "enable", true );
800 underlineMapSet.Insert( "color", Color::RED );
801 underlineMapSet.Insert( "height", 1 );
803 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
805 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
806 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
807 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
809 // Check the input underline property
810 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
811 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
813 // Check the shadow property
814 Property::Map shadowMapSet;
815 Property::Map shadowMapGet;
817 shadowMapSet.Insert( "color", Color::GREEN );
818 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
819 shadowMapSet.Insert( "blurRadius", 3.0f );
821 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
823 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
824 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
825 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
827 // Check the input shadow property
828 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
829 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
831 // Check the emboss property
832 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
833 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
835 // Check the input emboss property
836 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
837 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
839 // Check the outline property
841 // Test string type first
842 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
843 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
844 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
846 // Then test the property map type
847 Property::Map outlineMapSet;
848 Property::Map outlineMapGet;
850 outlineMapSet["color"] = Color::RED;
851 outlineMapSet["width"] = 2.0f;
853 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
855 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
856 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
857 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
859 // Check the input outline property
860 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
861 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
863 // Check the smooth scroll property
864 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
865 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
866 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
868 // Check the smooth scroll duration property
869 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
870 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
872 // Check the scroll bar property
873 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
874 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
875 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
877 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
878 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
879 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
880 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
882 // Check the pixel size of font
883 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
884 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
886 // Check placeholder text properties.
887 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
888 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
890 // Check placeholder text's color property.
891 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
892 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
894 // Check the enable selection property
895 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
896 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
898 // Check the placeholder property with pixel size
899 Property::Map placeholderPixelSizeMapSet;
900 Property::Map placeholderPixelSizeMapGet;
901 Property::Map placeholderFontstyleMap;
902 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
903 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
904 placeholderPixelSizeMapSet["color"] = Color::BLUE;
905 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
906 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
908 placeholderFontstyleMap.Insert( "weight", "bold" );
909 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
910 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
912 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
913 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
915 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
916 Property::Map placeholderConversionMap;
917 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
918 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
919 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
920 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
921 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
922 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
924 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
926 // Check the placeholder property with point size
927 Property::Map placeholderMapSet;
928 Property::Map placeholderMapGet;
929 placeholderMapSet["text"] = "Setting Placeholder Text";
930 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
931 placeholderMapSet["color"] = Color::RED;
932 placeholderMapSet["fontFamily"] = "Arial";
933 placeholderMapSet["pointSize"] = 12.0f;
934 // Check the placeholder font style property
935 placeholderFontstyleMap.Clear();
937 placeholderFontstyleMap.Insert( "weight", "bold" );
938 placeholderFontstyleMap.Insert( "width", "condensed" );
939 placeholderFontstyleMap.Insert( "slant", "italic" );
940 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
941 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
943 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
944 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
946 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
947 placeholderConversionMap.Clear();
948 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
949 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
950 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
951 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
952 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
953 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
954 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
957 placeholderFontstyleMap.Clear();
958 placeholderFontstyleMap.Insert( "weight", "normal" );
959 placeholderFontstyleMap.Insert( "slant", "oblique" );
960 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
961 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
963 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
964 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
965 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
966 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
968 placeholderFontstyleMap.Clear();
969 placeholderFontstyleMap.Insert( "slant", "roman" );
970 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
971 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
973 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
975 placeholderFontstyleMap.Clear();
976 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
978 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
979 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
980 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
981 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
982 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
984 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
985 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
987 // Check handle color
988 editor.SetProperty( DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN );
989 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
991 // Test the ENABLE_GRAB_HANDLE_POPUP property
992 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP, false );
993 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP ), false, TEST_LOCATION);
995 // Check the input method setting
996 Property::Map propertyMap;
997 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
998 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
999 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
1000 int inputVariation = 1;
1001 propertyMap["PANEL_LAYOUT"] = panelLayout;
1002 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
1003 propertyMap["BUTTON_ACTION"] = buttonAction;
1004 propertyMap["VARIATION"] = inputVariation;
1005 editor.SetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS, propertyMap );
1007 Property::Value value = editor.GetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS );
1009 DALI_TEST_CHECK( value.Get( map ) );
1012 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
1013 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
1016 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
1017 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
1020 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
1021 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
1024 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
1025 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
1027 // Check the input filter property
1028 Property::Map inputFilterMapSet;
1029 Property::Map inputFilterMapGet;
1030 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1031 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1033 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1035 inputFilterMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::INPUT_FILTER);
1036 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1039 inputFilterMapSet.Clear();
1040 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1042 // Check the strikethrough property
1044 Property::Map strikethroughMapSet;
1045 Property::Map strikethroughMapGet;
1047 application.SendNotification();
1048 application.Render();
1050 // Check the input strikethrough property
1052 strikethroughMapSet.Clear();
1053 strikethroughMapGet.Clear();
1054 strikethroughMapSet.Insert( "enable", true );
1055 strikethroughMapSet.Insert( "color", Color::BLUE );
1056 strikethroughMapSet.Insert( "height", 2.0f );
1058 editor.SetProperty( DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet );
1060 application.SendNotification();
1061 application.Render();
1063 strikethroughMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::STRIKETHROUGH );
1065 DALI_TEST_EQUALS( strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION );
1066 DALI_TEST_EQUALS( DaliTestCheckMaps( strikethroughMapSet, strikethroughMapGet ), true, TEST_LOCATION );
1068 // Check the input strikethrough property
1069 editor.SetProperty( DevelTextEditor::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties" );
1070 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::INPUT_STRIKETHROUGH ), std::string("Strikethrough input properties"), TEST_LOCATION );
1072 application.SendNotification();
1073 application.Render();
1075 // Check the line size property
1076 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::MIN_LINE_SIZE ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1077 editor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 50.f );
1078 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::MIN_LINE_SIZE ), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1083 // Positive Atlas Text Renderer test
1084 int utcDaliTextEditorAtlasRenderP(void)
1086 ToolkitTestApplication application;
1087 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
1088 StyleManager styleManager = StyleManager::Get();
1089 styleManager.ApplyDefaultTheme();
1090 TextEditor editor = TextEditor::New();
1091 DALI_TEST_CHECK( editor );
1093 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1095 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1097 application.GetScene().Add( editor );
1101 // Render some text with the shared atlas backend
1102 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1103 application.SendNotification();
1104 application.Render();
1108 tet_result(TET_FAIL);
1113 // Positive test for the anchorClicked signal.
1114 int utcDaliTextEditorAnchorClickedP(void)
1116 ToolkitTestApplication application;
1117 tet_infoline(" utcDaliTextEditorAnchorClickedP");
1118 TextEditor editor = TextEditor::New();
1119 DALI_TEST_CHECK(editor);
1121 application.GetScene().Add(editor);
1123 // connect to the anchor clicked signal.
1124 ConnectionTracker* testTracker = new ConnectionTracker();
1125 DevelTextEditor::AnchorClickedSignal(editor).Connect(&TestAnchorClickedCallback);
1126 bool anchorClickedSignal = false;
1127 editor.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1129 gAnchorClickedCallBackCalled = false;
1130 editor.SetProperty(TextEditor::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1131 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1132 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1133 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1134 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1136 application.SendNotification();
1137 application.Render();
1138 editor.SetKeyInputFocus();
1140 // Create a tap event to touch the text editor.
1141 TestGenerateTap(application, 5.0f, 5.0f);
1142 application.SendNotification();
1143 application.Render();
1145 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1146 DALI_TEST_CHECK(anchorClickedSignal);
1148 gAnchorClickedCallBackNotCalled = true;
1149 // Tap the outside of anchor, callback should not be called.
1150 TestGenerateTap(application, 150.f, 100.f);
1151 application.SendNotification();
1152 application.Render();
1154 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1159 // Positive test for the textChanged signal.
1160 int utcDaliTextEditorTextChangedP(void)
1162 ToolkitTestApplication application;
1163 tet_infoline(" utcDaliTextEditorTextChangedP");
1164 TextEditor editor = TextEditor::New();
1165 DALI_TEST_CHECK( editor );
1167 application.GetScene().Add( editor );
1169 // connect to the text changed signal.
1170 ConnectionTracker* testTracker = new ConnectionTracker();
1171 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
1172 bool textChangedSignal = false;
1173 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1175 gTextChangedCallBackCalled = false;
1176 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
1177 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1178 DALI_TEST_CHECK( textChangedSignal );
1180 application.SendNotification();
1181 editor.SetKeyInputFocus();
1183 gTextChangedCallBackCalled = false;
1184 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1185 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1188 editor.SetProperty( TextField::Property::TEXT, "" );
1190 // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
1191 gTextChangedCallBackCalled = false;
1192 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1193 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1195 // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
1196 gTextChangedCallBackCalled = false;
1197 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1198 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1203 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1205 ToolkitTestApplication application;
1206 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1207 TextEditor editor = TextEditor::New();
1208 DALI_TEST_CHECK( editor );
1211 application.GetScene().Add( editor );
1213 // connect to the text changed signal.
1214 ConnectionTracker* testTracker = new ConnectionTracker();
1215 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1216 bool textChangedSignal = false;
1217 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1220 // get InputMethodContext
1222 InputMethodContext::EventData imfEvent;
1223 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext( editor );
1225 editor.SetKeyInputFocus();
1226 editor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
1229 gTextChangedCallBackCalled = false;
1230 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1231 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1232 application.SendNotification();
1233 application.Render();
1234 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1235 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1237 gTextChangedCallBackCalled = false;
1238 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1239 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1240 application.SendNotification();
1241 application.Render();
1242 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1243 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호"), TEST_LOCATION );
1245 gTextChangedCallBackCalled = false;
1246 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1247 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1248 application.SendNotification();
1249 application.Render();
1250 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1251 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1253 gTextChangedCallBackCalled = false;
1254 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1255 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1256 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1258 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1259 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1260 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1262 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1263 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1264 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1266 application.SendNotification();
1267 application.Render();
1268 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1269 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1275 int utcDaliTextEditorInputStyleChanged01(void)
1277 // The text-editor emits signals when the input style changes. These changes of style are
1278 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1279 // can't be emitted during the size negotiation as the callbacks may update the UI.
1280 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1281 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1282 ToolkitTestApplication application;
1283 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1287 char* pathNamePtr = get_current_dir_name();
1288 const std::string pathName( pathNamePtr );
1289 free( pathNamePtr );
1291 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1292 fontClient.SetDpi( 93u, 93u );
1294 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1295 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1297 TextEditor editor = TextEditor::New();
1298 DALI_TEST_CHECK( editor );
1301 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1302 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1303 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1305 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1306 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1308 // connect to the text changed signal.
1309 ConnectionTracker* testTracker = new ConnectionTracker();
1310 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1311 bool inputStyleChangedSignal = false;
1312 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1314 application.GetScene().Add( editor );
1316 // Render and notify
1317 application.SendNotification();
1318 application.Render();
1320 // Executes the idle callbacks added by the text control on the change of input style.
1321 application.RunIdles();
1323 gInputStyleChangedCallbackCalled = false;
1324 gInputStyleMask = TextEditor::InputStyle::NONE;
1325 inputStyleChangedSignal = false;
1327 // Create a tap event to touch the text editor.
1328 TestGenerateTap( application, 18.0f, 25.0f );
1330 // Render and notify
1331 application.SendNotification();
1332 application.Render();
1334 // Executes the idle callbacks added by the text control on the change of input style.
1335 application.RunIdles();
1337 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1338 if( gInputStyleChangedCallbackCalled )
1340 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1342 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1343 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1345 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1346 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1348 DALI_TEST_CHECK( inputStyleChangedSignal );
1350 gInputStyleChangedCallbackCalled = false;
1351 gInputStyleMask = TextEditor::InputStyle::NONE;
1352 inputStyleChangedSignal = false;
1354 // Create a tap event to touch the text editor.
1355 TestGenerateTap( application, 30.0f, 25.0f );
1357 // Render and notify
1358 application.SendNotification();
1359 application.Render();
1361 // Executes the idle callbacks added by the text control on the change of input style.
1362 application.RunIdles();
1364 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1365 DALI_TEST_CHECK( !inputStyleChangedSignal );
1367 gInputStyleChangedCallbackCalled = false;
1368 gInputStyleMask = TextEditor::InputStyle::NONE;
1369 inputStyleChangedSignal = false;
1371 // Create a tap event to touch the text editor.
1372 TestGenerateTap( application, 43.0f, 25.0f );
1374 // Render and notify
1375 application.SendNotification();
1376 application.Render();
1378 // Executes the idle callbacks added by the text control on the change of input style.
1379 application.RunIdles();
1381 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1382 if( gInputStyleChangedCallbackCalled )
1384 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1386 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1387 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1389 DALI_TEST_CHECK( inputStyleChangedSignal );
1391 gInputStyleChangedCallbackCalled = false;
1392 gInputStyleMask = TextEditor::InputStyle::NONE;
1393 inputStyleChangedSignal = false;
1395 // Create a tap event to touch the text editor.
1396 TestGenerateTap( application, 88.0f, 25.0f );
1398 // Render and notify
1399 application.SendNotification();
1400 application.Render();
1402 // Executes the idle callbacks added by the text control on the change of input style.
1403 application.RunIdles();
1405 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1406 if( gInputStyleChangedCallbackCalled )
1408 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1410 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1411 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1413 Property::Map fontStyleMapSet;
1414 Property::Map fontStyleMapGet;
1416 fontStyleMapSet.Insert( "weight", "bold" );
1418 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1419 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1420 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1422 DALI_TEST_CHECK( inputStyleChangedSignal );
1424 gInputStyleChangedCallbackCalled = false;
1425 gInputStyleMask = TextEditor::InputStyle::NONE;
1426 inputStyleChangedSignal = false;
1428 // Create a tap event to touch the text editor.
1429 TestGenerateTap( application, 115.0f, 25.0f );
1431 // Render and notify
1432 application.SendNotification();
1433 application.Render();
1435 // Executes the idle callbacks added by the text control on the change of input style.
1436 application.RunIdles();
1438 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1439 DALI_TEST_CHECK( !inputStyleChangedSignal );
1441 gInputStyleChangedCallbackCalled = false;
1442 gInputStyleMask = TextEditor::InputStyle::NONE;
1443 inputStyleChangedSignal = false;
1445 // Create a tap event to touch the text editor.
1446 TestGenerateTap( application, 164.0f, 25.0f );
1448 // Render and notify
1449 application.SendNotification();
1450 application.Render();
1452 // Executes the idle callbacks added by the text control on the change of input style.
1453 application.RunIdles();
1455 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1456 if( gInputStyleChangedCallbackCalled )
1458 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1460 Property::Map fontStyleMapSet;
1461 Property::Map fontStyleMapGet;
1463 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1464 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1465 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1467 DALI_TEST_CHECK( inputStyleChangedSignal );
1469 gInputStyleChangedCallbackCalled = false;
1470 gInputStyleMask = TextEditor::InputStyle::NONE;
1471 inputStyleChangedSignal = false;
1473 // Create a tap event to touch the text editor.
1474 TestGenerateTap( application, 191.0f, 25.0f );
1476 // Render and notify
1477 application.SendNotification();
1478 application.Render();
1480 // Executes the idle callbacks added by the text control on the change of input style.
1481 application.RunIdles();
1483 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1484 DALI_TEST_CHECK( !inputStyleChangedSignal );
1489 int utcDaliTextEditorInputStyleChanged02(void)
1491 // The text-editor emits signals when the input style changes. These changes of style are
1492 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1493 // can't be emitted during the size negotiation as the callbacks may update the UI.
1494 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1495 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1496 ToolkitTestApplication application;
1497 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1501 char* pathNamePtr = get_current_dir_name();
1502 const std::string pathName( pathNamePtr );
1503 free( pathNamePtr );
1505 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1506 fontClient.SetDpi( 93u, 93u );
1508 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1509 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1511 TextEditor editor = TextEditor::New();
1512 DALI_TEST_CHECK( editor );
1515 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1516 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1517 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1519 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1520 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>" );
1522 // connect to the text changed signal.
1523 ConnectionTracker* testTracker = new ConnectionTracker();
1524 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1525 bool inputStyleChangedSignal = false;
1526 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1528 application.GetScene().Add( editor );
1530 // Render and notify
1531 application.SendNotification();
1532 application.Render();
1534 // Executes the idle callbacks added by the text control on the change of input style.
1535 application.RunIdles();
1537 gInputStyleChangedCallbackCalled = false;
1538 gInputStyleMask = TextEditor::InputStyle::NONE;
1539 inputStyleChangedSignal = false;
1541 // Create a tap event to touch the text editor.
1542 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1543 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1545 // Render and notify
1546 application.SendNotification();
1547 application.Render();
1549 // Executes the idle callbacks added by the text control on the change of input style.
1550 application.RunIdles();
1552 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1553 if( gInputStyleChangedCallbackCalled )
1555 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1556 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1557 TextEditor::InputStyle::POINT_SIZE |
1558 TextEditor::InputStyle::COLOR ),
1561 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1562 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1564 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1565 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1567 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1568 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1570 DALI_TEST_CHECK( inputStyleChangedSignal );
1572 gInputStyleChangedCallbackCalled = false;
1573 gInputStyleMask = TextEditor::InputStyle::NONE;
1574 inputStyleChangedSignal = false;
1576 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1578 // Render and notify
1579 application.SendNotification();
1580 application.Render();
1582 // Executes the idle callbacks added by the text control on the change of input style.
1583 application.RunIdles();
1585 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1586 if( gInputStyleChangedCallbackCalled )
1588 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1589 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1592 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1593 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1595 DALI_TEST_CHECK( inputStyleChangedSignal );
1597 gInputStyleChangedCallbackCalled = false;
1598 gInputStyleMask = TextEditor::InputStyle::NONE;
1599 inputStyleChangedSignal = false;
1601 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1603 // Render and notify
1604 application.SendNotification();
1605 application.Render();
1607 // Executes the idle callbacks added by the text control on the change of input style.
1608 application.RunIdles();
1610 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1611 DALI_TEST_CHECK( !inputStyleChangedSignal );
1613 gInputStyleChangedCallbackCalled = false;
1614 gInputStyleMask = TextEditor::InputStyle::NONE;
1615 inputStyleChangedSignal = false;
1617 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1619 // Render and notify
1620 application.SendNotification();
1621 application.Render();
1623 // Executes the idle callbacks added by the text control on the change of input style.
1624 application.RunIdles();
1626 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1627 if( gInputStyleChangedCallbackCalled )
1629 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1630 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1633 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1634 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1636 DALI_TEST_CHECK( inputStyleChangedSignal );
1638 gInputStyleChangedCallbackCalled = false;
1639 gInputStyleMask = TextEditor::InputStyle::NONE;
1640 inputStyleChangedSignal = false;
1642 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1644 Property::Map fontStyleMapSet;
1645 fontStyleMapSet.Insert( "weight", "thin" );
1646 fontStyleMapSet.Insert( "width", "condensed" );
1647 fontStyleMapSet.Insert( "slant", "italic" );
1649 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1650 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1651 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1653 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1654 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1655 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1656 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1657 editor.SetProperty( DevelTextEditor::Property::INPUT_STRIKETHROUGH, "strikethrough" );
1659 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1661 // Render and notify
1662 application.SendNotification();
1663 application.Render();
1665 // Executes the idle callbacks added by the text control on the change of input style.
1666 application.RunIdles();
1668 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1669 DALI_TEST_CHECK( !inputStyleChangedSignal );
1671 // Create a tap event to touch the text editor.
1672 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1674 // Render and notify
1675 application.SendNotification();
1676 application.Render();
1678 // Executes the idle callbacks added by the text control on the change of input style.
1679 application.RunIdles();
1681 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1682 if( gInputStyleChangedCallbackCalled )
1684 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1685 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1686 TextEditor::InputStyle::POINT_SIZE |
1687 TextEditor::InputStyle::FONT_STYLE |
1688 TextEditor::InputStyle::LINE_SPACING |
1689 TextEditor::InputStyle::UNDERLINE |
1690 TextEditor::InputStyle::SHADOW |
1691 TextEditor::InputStyle::EMBOSS |
1692 TextEditor::InputStyle::OUTLINE ),
1695 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1696 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1698 DALI_TEST_CHECK( inputStyleChangedSignal );
1700 gInputStyleChangedCallbackCalled = false;
1701 gInputStyleMask = TextEditor::InputStyle::NONE;
1702 inputStyleChangedSignal = false;
1704 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1706 fontStyleMapSet.Clear();
1707 fontStyleMapSet.Insert( "weight", "black" );
1708 fontStyleMapSet.Insert( "width", "expanded" );
1709 fontStyleMapSet.Insert( "slant", "oblique" );
1711 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1713 // Create a tap event to touch the text editor.
1714 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1716 // Render and notify
1717 application.SendNotification();
1718 application.Render();
1720 // Executes the idle callbacks added by the text control on the change of input style.
1721 application.RunIdles();
1723 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1724 if( gInputStyleChangedCallbackCalled )
1726 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1727 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1728 TextEditor::InputStyle::POINT_SIZE |
1729 TextEditor::InputStyle::FONT_STYLE ),
1732 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1733 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1735 DALI_TEST_CHECK( inputStyleChangedSignal );
1740 int utcDaliTextEditorEvent01(void)
1742 ToolkitTestApplication application;
1743 tet_infoline(" utcDaliTextEditorEvent01");
1745 // Creates a tap event. After creating a tap event the text editor should
1746 // have the focus and add text with key events should be possible.
1748 TextEditor editor = TextEditor::New();
1749 DALI_TEST_CHECK( editor );
1751 application.GetScene().Add( editor );
1753 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1754 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1755 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1757 // Avoid a crash when core load gl resources.
1758 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1760 // Render and notify
1761 application.SendNotification();
1762 application.Render();
1764 // Add a key event but as the text editor has not the focus it should do nothing.
1765 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1767 // Render and notify
1768 application.SendNotification();
1769 application.Render();
1771 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1773 // Create a tap event to touch the text editor.
1774 TestGenerateTap( application, 150.0f, 25.0f );
1776 // Render and notify
1777 application.SendNotification();
1778 application.Render();
1780 // Now the text editor has the focus, so it can handle the key events.
1781 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1782 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1784 // Render and notify
1785 application.SendNotification();
1786 application.Render();
1788 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1790 // Create a second text editor and send key events to it.
1791 TextEditor editor2 = TextEditor::New();
1793 editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1794 editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1795 editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1796 editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1798 application.GetScene().Add( editor2 );
1800 // Render and notify
1801 application.SendNotification();
1802 application.Render();
1804 // Create a tap event on the second text editor.
1805 TestGenerateTap( application, 150.0f, 125.0f );
1807 // Render and notify
1808 application.SendNotification();
1809 application.Render();
1811 // The second text editor has the focus. It should handle the key events.
1812 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1813 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1815 // Render and notify
1816 application.SendNotification();
1817 application.Render();
1819 // Check the text has been added to the second text editor.
1820 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1825 int utcDaliTextEditorEvent02(void)
1827 ToolkitTestApplication application;
1828 tet_infoline(" utcDaliTextEditorEvent02");
1830 // Checks if the right number of actors are created.
1832 TextEditor editor = TextEditor::New();
1833 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1834 DALI_TEST_CHECK( editor );
1836 application.GetScene().Add( editor );
1838 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1839 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1840 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1842 // Avoid a crash when core load gl resources.
1843 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1845 // Render and notify
1846 application.SendNotification();
1847 application.Render();
1849 // Check there are the expected number of children (the stencil).
1850 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1852 Actor stencil = editor.GetChildAt( 0u );
1854 // Create a tap event to touch the text editor.
1855 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1857 // Render and notify
1858 application.SendNotification();
1859 application.Render();
1861 Actor layer = editor.GetChildAt( 1u );
1862 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1863 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1865 // Now the text editor has the focus, so it can handle the key events.
1866 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1867 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1869 // Render and notify
1870 application.SendNotification();
1871 application.Render();
1873 // Checks the cursor and the renderer have been created.
1874 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1875 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1877 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1878 DALI_TEST_CHECK( cursor );
1880 // The stencil actor has a container with all the actors which contain the text renderers.
1881 Actor container = stencil.GetChildAt( 0u );
1882 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1884 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1885 DALI_TEST_CHECK( renderer );
1888 // Move the cursor and check the position changes.
1889 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1891 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1892 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1894 // Render and notify
1895 application.SendNotification();
1896 application.Render();
1898 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1900 DALI_TEST_CHECK( position2.x < position1.x );
1902 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1903 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1905 // Render and notify
1906 application.SendNotification();
1907 application.Render();
1909 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1911 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1913 // Send some taps and check the cursor positions.
1915 // Try to tap at the beginning.
1916 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1918 // Render and notify
1919 application.SendNotification();
1920 application.Render();
1922 // Cursor position should be the same than position1.
1923 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1925 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1927 // Tap away from the start position.
1928 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1930 // Render and notify
1931 application.SendNotification();
1932 application.Render();
1934 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1936 DALI_TEST_CHECK( position5.x > position4.x );
1938 // Remove all the text.
1939 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1940 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1941 editor.SetProperty( TextEditor::Property::TEXT, "" );
1943 // Render and notify
1944 application.SendNotification();
1945 application.Render();
1947 // Cursor position should be the same than position2.
1948 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1950 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1952 // Should not be a renderer.
1953 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1958 int utcDaliTextEditorEvent03(void)
1960 ToolkitTestApplication application;
1961 tet_infoline(" utcDaliTextEditorEvent03");
1963 // Checks if the highlight actor is created.
1965 TextEditor editor = TextEditor::New();
1966 DALI_TEST_CHECK( editor );
1968 application.GetScene().Add( editor );
1970 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1971 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1972 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1973 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1974 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1976 // Avoid a crash when core load gl resources.
1977 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1979 // Render and notify
1980 application.SendNotification();
1981 application.Render();
1983 // Send some taps and check text controller with clipboard window
1984 Dali::Clipboard clipboard = Clipboard::Get();
1985 clipboard.ShowClipboard();
1986 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1987 clipboard.HideClipboard();
1989 // Render and notify
1990 application.SendNotification();
1991 application.Render();
1993 // Tap first to get the focus.
1994 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1996 // Render and notify
1997 application.SendNotification();
1998 application.Render();
2000 // Double tap to select a word.
2001 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
2003 // Render and notify
2004 application.SendNotification();
2005 application.Render();
2007 // The stencil actor should have two actors: the renderer and the highlight actor.
2008 Actor stencil = editor.GetChildAt( 0u );
2010 // Highlight needs to be drawn before text, so should come first in child order
2011 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2012 DALI_TEST_CHECK( highlight );
2014 // The stencil actor has a container with all the actors which contain the text renderers.
2015 Actor container = stencil.GetChildAt( 1u );
2016 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2018 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2019 DALI_TEST_CHECK( renderer );
2022 // Double tap out of bounds
2023 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
2024 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
2026 // Render and notify
2027 application.SendNotification();
2028 application.Render();
2030 // The stencil actor should have one actors: the renderer actor.
2031 stencil = editor.GetChildAt( 0u );
2033 // The stencil actor has a container with all the actors which contain the text renderers.
2034 container = stencil.GetChildAt( 0u );
2035 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2037 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2038 DALI_TEST_CHECK( renderer );
2042 TestGenerateLongPress(application, 1.0f, 25.0f);
2044 // Render and notify
2045 application.SendNotification();
2046 application.Render();
2049 TestGenerateMiniPan(application);
2051 // Render and notify
2052 application.SendNotification();
2053 application.Render();
2058 int utcDaliTextEditorEvent04(void)
2060 ToolkitTestApplication application;
2061 tet_infoline(" utcDaliTextEditorEvent04");
2063 // Checks if the highlight actor is created.
2065 TextEditor editor = TextEditor::New();
2066 DALI_TEST_CHECK( editor );
2068 application.GetScene().Add( editor );
2070 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
2071 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2072 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2073 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2074 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2076 // Avoid a crash when core load gl resources.
2077 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2079 // Render and notify
2080 application.SendNotification();
2081 application.Render();
2083 // Tap on the text editor
2084 TestGenerateTap( application, 3.0f, 25.0f );
2086 // Render and notify
2087 application.SendNotification();
2088 application.Render();
2090 // Move at the end of the text.
2091 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2092 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2094 // Render and notify
2095 application.SendNotification();
2096 application.Render();
2098 for( unsigned int index = 0u; index < 10u; ++index )
2100 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2101 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2103 // Render and notify
2104 application.SendNotification();
2105 application.Render();
2109 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2111 // Render and notify
2112 application.SendNotification();
2113 application.Render();
2115 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2117 // Add some key events
2118 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2119 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2121 // Render and notify
2122 application.SendNotification();
2123 application.Render();
2125 for( unsigned int index = 0u; index < 10u; ++index )
2127 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2128 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2130 // Render and notify
2131 application.SendNotification();
2132 application.Render();
2136 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2138 // Render and notify
2139 application.SendNotification();
2140 application.Render();
2142 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2147 int utcDaliTextEditorEvent05(void)
2149 ToolkitTestApplication application;
2150 tet_infoline(" utcDaliTextEditorEvent05");
2152 // Checks if the highlight actor is created.
2154 TextEditor editor = TextEditor::New();
2155 DALI_TEST_CHECK( editor );
2157 application.GetScene().Add( editor );
2159 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
2160 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2161 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2162 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2163 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2164 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2165 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
2166 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2167 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
2168 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
2170 // Avoid a crash when core load gl resources.
2171 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2173 // Render and notify
2174 application.SendNotification();
2175 application.Render();
2177 // Tap on the text editor
2178 TestGenerateTap( application, 3.0f, 25.0f );
2180 // Render and notify
2181 application.SendNotification();
2182 application.Render();
2184 // Move at the end of the text.
2185 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2186 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2188 // Render and notify
2189 application.SendNotification();
2190 application.Render();
2192 for( unsigned int index = 0u; index < 10u; ++index )
2195 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2197 // Render and notify
2198 application.SendNotification();
2199 application.Render();
2201 // Modify duration after scroll is enabled
2202 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
2204 // Continuous scroll left to increase coverage
2205 for( unsigned int index = 0u; index < 10u; ++index )
2207 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2209 // Render and notify
2210 application.SendNotification();
2211 application.Render();
2213 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2214 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
2215 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
2216 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2217 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2219 // Press Escape to increase coverage
2220 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2221 application.SendNotification();
2222 application.Render();
2224 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
2229 int utcDaliTextEditorEvent06(void)
2231 ToolkitTestApplication application;
2232 tet_infoline(" utcDaliTextEditorEvent06");
2234 // Checks if the highlight actor is created.
2236 TextEditor editor = TextEditor::New();
2237 DALI_TEST_CHECK( editor );
2239 application.GetScene().Add( editor );
2241 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2242 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2243 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2244 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2245 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2247 // Avoid a crash when core load gl resources.
2248 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2250 // Render and notify
2251 application.SendNotification();
2252 application.Render();
2254 // Tap on the text editor
2255 TestGenerateTap( application, 3.0f, 25.0f );
2257 // Render and notify
2258 application.SendNotification();
2259 application.Render();
2261 // Move to seconds line of the text.
2262 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2264 // Render and notify
2265 application.SendNotification();
2266 application.Render();
2268 float layoutHeight = editor.GetHeightForWidth( 100.f );
2271 // Add another script characters ( glyph height is defferent )
2272 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2273 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2275 // Delete characters
2276 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2277 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2279 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2281 // Render and notify
2282 application.SendNotification();
2283 application.Render();
2285 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2288 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2289 application.SendNotification();
2290 application.Render();
2292 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2293 application.SendNotification();
2294 application.Render();
2296 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2297 application.SendNotification();
2298 application.Render();
2300 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2301 application.SendNotification();
2302 application.Render();
2304 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2305 application.SendNotification();
2306 application.Render();
2308 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2309 application.SendNotification();
2310 application.Render();
2312 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2313 application.SendNotification();
2314 application.Render();
2319 int utcDaliTextEditorEvent07(void)
2321 ToolkitTestApplication application;
2322 tet_infoline(" utcDaliTextEditorEvent07");
2324 // Checks if the highlight actor is created.
2326 TextEditor editor = TextEditor::New();
2327 DALI_TEST_CHECK( editor );
2329 application.GetScene().Add( editor );
2331 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2332 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2333 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2334 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2335 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2337 // Avoid a crash when core load gl resources.
2338 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2340 // Render and notify
2341 application.SendNotification();
2342 application.Render();
2344 // Tap on the text editor
2345 TestGenerateTap( application, 3.0f, 25.0f );
2347 // Render and notify
2348 application.SendNotification();
2349 application.Render();
2351 // Move to second line of the text.
2352 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2354 // Render and notify
2355 application.SendNotification();
2356 application.Render();
2358 // Select some text in the right of the current cursor position
2359 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2360 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2361 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2362 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2364 // Render and notify
2365 application.SendNotification();
2366 application.Render();
2368 // Cut the selected text
2369 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2370 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 ) );
2372 // Render and notify
2373 application.SendNotification();
2374 application.Render();
2376 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2378 // Select some text in the left of the current cursor position
2379 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2380 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2381 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2382 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2384 // Render and notify
2385 application.SendNotification();
2386 application.Render();
2388 // Copy the selected text
2389 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2390 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 ) );
2392 // Render and notify
2393 application.SendNotification();
2394 application.Render();
2396 // Move the cursor to the third line
2397 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2398 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2400 // Render and notify
2401 application.SendNotification();
2402 application.Render();
2404 // Paste the selected text at the current cursor position
2405 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2406 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 ) );
2408 // Render and notify
2409 application.SendNotification();
2410 application.Render();
2412 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2415 // Disable Shift Selection
2416 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2418 // Test to select some text in the right of the current cursor position
2419 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2420 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2421 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2422 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2424 // Render and notify
2425 application.SendNotification();
2426 application.Render();
2428 // Cut the selected text
2429 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2430 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 ) );
2432 // Render and notify
2433 application.SendNotification();
2434 application.Render();
2436 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2437 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2439 // Test to select some text in the left of the current cursor position
2440 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2441 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2442 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2443 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2445 // Render and notify
2446 application.SendNotification();
2447 application.Render();
2449 // Copy the selected text
2450 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2451 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 ) );
2453 // Render and notify
2454 application.SendNotification();
2455 application.Render();
2457 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2458 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2461 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 ) );
2463 // Render and notify
2464 application.SendNotification();
2465 application.Render();
2467 // replace text with "c"
2468 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2470 // Render and notify
2471 application.SendNotification();
2472 application.Render();
2475 DALI_TEST_EQUALS( "c", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2478 DevelTextEditor::SelectWholeText(editor);
2480 // Render and notify
2481 application.SendNotification();
2482 application.Render();
2484 // Copy the selected text using logical keys
2485 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2486 application.ProcessEvent( GenerateKey( "ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2488 // Render and notify
2489 application.SendNotification();
2490 application.Render();
2493 DevelTextEditor::SelectNone(editor);
2495 // Render and notify
2496 application.SendNotification();
2497 application.Render();
2499 // Paste the selected using logical keys
2500 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2501 application.ProcessEvent( GenerateKey( "ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2504 DALI_TEST_EQUALS( "cc", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2506 // select all using logical keys
2507 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2508 application.ProcessEvent( GenerateKey( "ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2510 // Render and notify
2511 application.SendNotification();
2512 application.Render();
2514 // cut text using logical keys
2515 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2516 application.ProcessEvent( GenerateKey( "ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2518 // Render and notify
2519 application.SendNotification();
2520 application.Render();
2523 DALI_TEST_EQUALS( "", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2528 int utcDaliTextEditorEvent08(void)
2530 ToolkitTestApplication application;
2531 tet_infoline(" utcDaliTextEditorEvent08");
2533 // Checks if the highlight actor is released correctly.
2535 TextEditor editor = TextEditor::New();
2536 DALI_TEST_CHECK( editor );
2538 application.GetScene().Add( editor );
2540 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2541 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2542 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2543 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2544 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2546 // Avoid a crash when core load gl resources.
2547 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2549 // Render and notify
2550 application.SendNotification();
2551 application.Render();
2553 // Tap on the text editor
2554 TestGenerateTap( application, 3.0f, 25.0f );
2556 // Render and notify
2557 application.SendNotification();
2558 application.Render();
2560 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2561 // Test to select some text in the left of the current cursor position
2562 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2563 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2564 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2565 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2567 // Render and notify
2568 application.SendNotification();
2569 application.Render();
2571 // Test to the left selection handle position and the right selection handle position
2572 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2573 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2574 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2575 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2577 // Render and notify
2578 application.SendNotification();
2579 application.Render();
2581 // Test to select full text in the left of the current cursor position
2582 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2583 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2584 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2585 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2586 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2587 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2589 // Render and notify
2590 application.SendNotification();
2591 application.Render();
2593 // Test to release the current full text selection
2594 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2595 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2597 // Render and notify
2598 application.SendNotification();
2599 application.Render();
2601 // Test to move the current cursor position correctly
2602 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2604 // Render and notify
2605 application.SendNotification();
2606 application.Render();
2609 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2611 // Render and notify
2612 application.SendNotification();
2613 application.Render();
2615 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2617 // Test to select some text in the right of the current cursor position
2618 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2619 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2620 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2622 // Render and notify
2623 application.SendNotification();
2624 application.Render();
2626 // Test the cursor position with right arrow key
2627 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2629 // Render and notify
2630 application.SendNotification();
2631 application.Render();
2634 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2636 // Render and notify
2637 application.SendNotification();
2638 application.Render();
2640 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2642 // Test to select some text in the left of the current cursor position
2643 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2644 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2645 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2646 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2647 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2649 // Render and notify
2650 application.SendNotification();
2651 application.Render();
2653 // Test the cursor position with left arrow key
2654 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2656 // Render and notify
2657 application.SendNotification();
2658 application.Render();
2661 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2663 // Render and notify
2664 application.SendNotification();
2665 application.Render();
2667 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2669 // Test to select some text in the right of the current cursor position
2670 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2671 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2672 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2673 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2675 // Render and notify
2676 application.SendNotification();
2677 application.Render();
2679 // Test the cursor position with left arrow key
2680 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2682 // Render and notify
2683 application.SendNotification();
2684 application.Render();
2687 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2689 // Render and notify
2690 application.SendNotification();
2691 application.Render();
2693 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2695 // Test to select some text in the left of the current cursor position
2696 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2697 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2698 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2699 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2701 // Render and notify
2702 application.SendNotification();
2703 application.Render();
2705 // Test the cursor position with right arrow key
2706 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2708 // Render and notify
2709 application.SendNotification();
2710 application.Render();
2713 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2715 // Render and notify
2716 application.SendNotification();
2717 application.Render();
2719 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2724 int utcDaliTextEditorHandles(void)
2726 ToolkitTestApplication application;
2727 tet_infoline(" utcDaliTextEditorHandles");
2729 TextEditor editor = TextEditor::New();
2730 DALI_TEST_CHECK( editor );
2732 application.GetScene().Add( editor );
2734 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2735 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2736 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2737 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2739 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2740 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2741 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2742 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2744 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2745 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2746 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2748 // Avoid a crash when core load gl resources.
2749 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2751 // Render and notify
2752 application.SendNotification();
2753 application.Render();
2755 // Tap first to get the focus.
2756 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2758 // Render and notify
2759 application.SendNotification();
2760 application.Render();
2762 // Tap to create the grab handle.
2763 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2765 // Render and notify
2766 application.SendNotification();
2767 application.Render();
2769 // Get the active layer where the text's decoration is added.
2770 Actor activeLayer = editor.GetChildAt( 1u );
2772 // Get the handle's actor.
2773 Actor handle = activeLayer.GetChildAt( 1u );
2774 handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2776 // Render and notify
2777 application.SendNotification();
2778 application.Render();
2780 // Touch the grab handle to set it as pressed.
2781 Vector2 touchPos( 10.0f, 50.0f );
2782 Dali::Integration::TouchEvent event;
2783 event = Dali::Integration::TouchEvent();
2784 event.AddPoint( GetPointDownInside( touchPos ) );
2785 application.ProcessEvent( event );
2787 // Render and notify
2788 application.SendNotification();
2789 application.Render();
2791 // Pan the grab handle
2792 uint32_t time = 100;
2793 TestStartPan( application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time );
2794 TestMovePan( application, Vector2(10.0f, 30.0f), time );
2795 TestEndPan( application, Vector2(10.0f, 50.0f), time);
2796 application.SendNotification();
2797 application.Render();
2800 // Release the grab handle.
2801 event = Dali::Integration::TouchEvent();
2802 event.AddPoint( GetPointUpInside( touchPos ) );
2803 application.ProcessEvent( event );
2805 // Render and notify
2806 application.SendNotification();
2807 application.Render();
2809 // Tap first to get the focus.
2810 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2812 // Render and notify
2813 application.SendNotification();
2814 application.Render();
2816 // Double tap to select a word and create the selection handles.
2817 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2819 // Render and notify
2820 application.SendNotification();
2821 application.Render();
2823 touchPos = Vector2( 10.0f, 50.0f );
2825 // Touch the left selection handle to set it as pressed.
2826 event = Dali::Integration::TouchEvent();
2827 event.AddPoint( GetPointDownInside( touchPos ) );
2828 application.ProcessEvent( event );
2830 // Render and notify
2831 application.SendNotification();
2832 application.Render();
2834 // Release the left selection handle.
2835 event = Dali::Integration::TouchEvent();
2836 event.AddPoint( GetPointUpInside( touchPos ) );
2837 application.ProcessEvent( event );
2839 // Render and notify
2840 application.SendNotification();
2841 application.Render();
2846 int utcDaliTextEditorUnderPropertyStringP(void)
2848 ToolkitTestApplication application;
2849 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2850 TextEditor editor = TextEditor::New();
2851 DALI_TEST_CHECK( editor );
2853 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2855 application.GetScene().Add( editor );
2857 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2858 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2860 tet_infoline("Set underline settings with a map");
2861 // Check the input underline property
2862 Property::Map underlineMapSet;
2863 Property::Map underlineMapGet;
2864 underlineMapSet.Insert( "enable", true );
2865 underlineMapSet.Insert( "color", Color::BLUE );
2866 underlineMapSet.Insert( "height", 2 );
2868 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2869 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2870 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2871 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2873 tet_infoline("Set underline settings with a string");
2874 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2875 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2878 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2880 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2881 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2882 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2883 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2885 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2890 int utcDaliTextEditorStrikethroughPropertyStringP(void)
2892 ToolkitTestApplication application;
2893 tet_infoline(" utcDaliTextEditorStrikethroughPropertyStringP");
2894 TextEditor editor = TextEditor::New();
2895 DALI_TEST_CHECK( editor );
2897 std::string strikethroughSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"2\"}" );
2899 application.GetScene().Add( editor );
2901 editor.SetProperty( DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettings1 );
2902 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::STRIKETHROUGH ), strikethroughSettings1, TEST_LOCATION );
2904 tet_infoline("Set strikethrough settings with a map");
2905 // Check the input strikethrough property
2906 Property::Map strikethroughMapSet;
2907 Property::Map strikethroughMapGet;
2908 strikethroughMapSet.Insert( "enable", true );
2909 strikethroughMapSet.Insert( "color", Color::BLUE );
2910 strikethroughMapSet.Insert( "height", 2.0f );
2912 editor.SetProperty( DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet );
2913 strikethroughMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::STRIKETHROUGH );
2914 DALI_TEST_EQUALS( strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION );
2915 DALI_TEST_EQUALS( DaliTestCheckMaps( strikethroughMapSet, strikethroughMapGet ), true, TEST_LOCATION );
2917 tet_infoline("Set strikethrough settings with a string");
2918 editor.SetProperty( DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettings1 );
2919 Property::Value value = editor.GetProperty( DevelTextEditor::Property::STRIKETHROUGH );
2922 DALI_TEST_EQUALS( result , strikethroughSettings1, TEST_LOCATION );
2924 tet_infoline("Trying to set invalid strikethrough settings, should not update and stay at previous settings");
2925 std::string strikethroughSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"height\":\"2\"}" );
2926 editor.SetProperty( DevelTextEditor::Property::STRIKETHROUGH, strikethroughSettingsVoid );
2927 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2929 DALI_TEST_EQUALS( result , strikethroughSettings1, TEST_LOCATION );
2934 int utcDaliTextEditorShadowPropertyStringP(void)
2936 ToolkitTestApplication application;
2937 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2939 TextEditor editor = TextEditor::New();
2941 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2943 application.GetScene().Add( editor );
2945 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2947 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2951 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2956 int utcDaliTextEditorFontStylePropertyStringP(void)
2958 ToolkitTestApplication application;
2959 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2961 TextEditor editor = TextEditor::New();
2963 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2965 application.GetScene().Add( editor );
2967 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2969 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2973 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2978 int utcDaliTextEditorGetPropertyLinecountP(void)
2980 ToolkitTestApplication application;
2982 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2986 TextEditor editor = TextEditor::New();
2987 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2988 editor.SetProperty( TextEditor::Property::TEXT,
2989 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2991 application.GetScene().Add( editor );
2993 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2994 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2995 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2997 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
2998 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2999 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
3004 int utcDaliTextEditorScrollStateChangedSignalTest(void)
3007 ToolkitTestApplication application;
3008 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
3010 TextEditor editor = TextEditor::New();
3011 DALI_TEST_CHECK( editor );
3013 application.GetScene().Add( editor );
3015 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
3016 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
3017 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3018 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3019 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
3020 editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
3022 bool startedCalled = false;
3023 bool finishedCalled = false;
3025 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
3026 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
3028 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
3030 // Render and notify
3031 application.SendNotification();
3032 application.Render();
3034 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
3035 application.SendNotification();
3036 application.Render(6000);
3038 application.SendNotification();
3039 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
3040 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
3045 int UtcDaliToolkitTextEditorTextWrapMode(void)
3047 ToolkitTestApplication application;
3048 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
3052 TextEditor editor = TextEditor::New();
3053 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
3054 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
3056 application.GetScene().Add( editor );
3058 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
3059 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
3061 application.SendNotification();
3062 application.Render();
3064 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3065 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
3067 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
3068 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
3070 application.SendNotification();
3071 application.Render();
3073 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3074 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
3076 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
3077 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
3079 application.SendNotification();
3080 application.Render();
3082 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3083 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
3085 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
3086 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
3088 application.SendNotification();
3089 application.Render();
3091 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3092 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
3097 int UtcDaliTextEditorSetPaddingProperty(void)
3099 ToolkitTestApplication application;
3100 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
3102 TextEditor editor = TextEditor::New();
3103 DALI_TEST_CHECK( editor );
3104 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3105 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3106 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3107 application.GetScene().Add( editor );
3109 application.SendNotification();
3110 application.Render();
3112 Vector3 originalSize = editor.GetNaturalSize();
3114 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
3116 application.SendNotification();
3117 application.Render();
3119 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
3121 Vector3 paddingAddedSize = editor.GetNaturalSize();
3123 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3125 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3130 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
3132 ToolkitTestApplication application;
3133 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
3135 TextEditor editor = TextEditor::New();
3136 DALI_TEST_CHECK( editor );
3137 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3138 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3139 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3140 application.GetScene().Add( editor );
3142 application.SendNotification();
3143 application.Render();
3145 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3146 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
3148 // Check the enable shift selection property
3149 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
3150 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
3152 application.SendNotification();
3153 application.Render();
3158 int UtcDaliTextEditorEnableGrabHandleProperty(void)
3160 ToolkitTestApplication application;
3161 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
3163 TextEditor editor = TextEditor::New();
3164 DALI_TEST_CHECK( editor );
3165 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3166 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3167 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3168 application.GetScene().Add( editor );
3170 application.SendNotification();
3171 application.Render();
3173 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3174 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
3176 // Check the enable grab handle property
3177 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
3178 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
3180 application.SendNotification();
3181 application.Render();
3186 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
3188 ToolkitTestApplication application;
3189 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
3191 TextEditor editor = TextEditor::New();
3192 DALI_TEST_CHECK( editor );
3193 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3194 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3195 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3196 application.GetScene().Add( editor );
3198 application.SendNotification();
3199 application.Render();
3201 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3202 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
3204 // Check the disable match system language direction property
3205 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
3206 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
3208 application.SendNotification();
3209 application.Render();
3214 int UtcDaliTextEditorGetInputMethodContext(void)
3216 ToolkitTestApplication application;
3217 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
3219 TextEditor editor = TextEditor::New();
3220 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );
3225 int utcDaliTextEditorMaxCharactersReached(void)
3227 ToolkitTestApplication application;
3228 tet_infoline("utcDaliTextEditorMaxCharactersReached");
3230 TextEditor editor = TextEditor::New();
3231 DALI_TEST_CHECK( editor );
3233 application.GetScene().Add( editor );
3235 const int maxNumberOfCharacters = 1;
3236 editor.SetProperty( DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters );
3237 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelTextEditor::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
3239 editor.SetKeyInputFocus();
3241 // connect to the text changed signal.
3242 ConnectionTracker* testTracker = new ConnectionTracker();
3243 DevelTextEditor::MaxLengthReachedSignal( editor ).Connect(&TestMaxLengthReachedCallback);
3244 bool maxLengthReachedSignal = false;
3245 editor.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
3247 gMaxCharactersCallBackCalled = false;
3249 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3250 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3252 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
3253 DALI_TEST_CHECK( maxLengthReachedSignal );
3258 int utcDaliTextEditorInputFiltered(void)
3260 ToolkitTestApplication application;
3261 tet_infoline(" utcDaliTextEditorInputFiltered");
3262 TextEditor editor = TextEditor::New();
3263 DALI_TEST_CHECK(editor);
3265 application.GetScene().Add(editor);
3267 Property::Map inputFilter;
3269 // Only digit is accepted.
3270 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
3272 // Set input filter to TextEditor.
3273 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3275 editor.SetKeyInputFocus();
3277 // connect to the input filtered signal.
3278 ConnectionTracker* testTracker = new ConnectionTracker();
3279 DevelTextEditor::InputFilteredSignal(editor).Connect(&TestInputFilteredCallback);
3280 bool inputFilteredSignal = false;
3281 editor.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
3283 gInputFilteredAcceptedCallbackCalled = false;
3285 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ));
3287 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3288 DALI_TEST_CHECK(inputFilteredSignal);
3290 // Word is rejected.
3291 inputFilter[InputFilter::Property::ACCEPTED] = "";
3292 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
3294 // Set input filter to TextEditor.
3295 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3297 editor.SetKeyInputFocus();
3299 inputFilteredSignal = false;
3300 gInputFilteredRejectedCallbackCalled = false;
3302 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3304 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3305 DALI_TEST_CHECK(inputFilteredSignal);
3310 int UtcDaliTextEditorSelectWholeText(void)
3312 ToolkitTestApplication application;
3313 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3315 TextEditor textEditor = TextEditor::New();
3317 application.GetScene().Add( textEditor );
3319 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3320 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3321 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3323 // Avoid a crash when core load gl resources.
3324 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3326 application.SendNotification();
3327 application.Render();
3329 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3331 DevelTextEditor::SelectWholeText( textEditor );
3333 application.SendNotification();
3334 application.Render();
3336 // Nothing should have been selected. The number of children is still 1
3337 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3339 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3341 application.SendNotification();
3342 application.Render();
3344 DevelTextEditor::SelectWholeText( textEditor );
3346 application.SendNotification();
3347 application.Render();
3349 // Should be 2 children, the stencil and the layer
3350 DALI_TEST_EQUALS( 2u, textEditor.GetChildCount(), TEST_LOCATION );
3352 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3353 Actor stencil = textEditor.GetChildAt( 0u );
3355 // The highlight actor is drawn first, so is the first actor in the list
3356 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3357 DALI_TEST_CHECK( highlight );
3362 int UtcDaliTextEditorSelectText(void)
3364 ToolkitTestApplication application;
3365 tet_infoline(" UtcDaliTextEditorSelectText ");
3367 TextEditor textEditor = TextEditor::New();
3369 application.GetScene().Add( textEditor );
3371 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3372 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3373 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3375 // Avoid a crash when core load gl resources.
3376 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3378 application.SendNotification();
3379 application.Render();
3381 DevelTextEditor::SelectText( textEditor ,0, 5 );
3383 application.SendNotification();
3384 application.Render();
3386 // Nothing is selected
3387 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3388 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3390 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3392 application.SendNotification();
3393 application.Render();
3395 DevelTextEditor::SelectText( textEditor, 0, 5 );
3397 application.SendNotification();
3398 application.Render();
3400 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3401 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3403 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3404 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3406 // world is selected
3407 DevelTextEditor::SelectText( textEditor, 6, 11 );
3409 application.SendNotification();
3410 application.Render();
3412 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3413 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3415 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3416 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3421 int UtcDaliTextEditorSelectNone(void)
3423 ToolkitTestApplication application;
3424 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3426 TextEditor textEditor = TextEditor::New();
3428 application.GetScene().Add( textEditor );
3430 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3431 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3432 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3434 // Avoid a crash when core load gl resources.
3435 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3437 application.SendNotification();
3438 application.Render();
3440 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3442 application.SendNotification();
3443 application.Render();
3445 // Nothing is selected
3446 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3447 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3449 DevelTextEditor::SelectWholeText( textEditor );
3451 application.SendNotification();
3452 application.Render();
3454 // whole text is selected
3455 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3456 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3458 DevelTextEditor::SelectNone( textEditor );
3460 application.SendNotification();
3461 application.Render();
3463 // Nothing is selected
3464 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3465 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3470 int UtcDaliTextEditorSelectRange(void)
3472 ToolkitTestApplication application;
3473 tet_infoline("utcDaliTextEditorSelectRange");
3475 TextEditor textEditor = TextEditor::New();
3476 DALI_TEST_CHECK( textEditor );
3478 application.GetScene().Add( textEditor );
3480 // Avoid a crash when core load gl resources.
3481 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3483 application.SendNotification();
3484 application.Render();
3486 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3488 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_START, 0 );
3489 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_END, 5 );
3491 // Hello is selected
3492 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3493 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3495 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3496 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3501 int UtcDaliTextEditorEnableEditing(void)
3503 ToolkitTestApplication application;
3504 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3506 TextEditor textEditor = TextEditor::New();
3508 application.GetScene().Add( textEditor );
3510 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3511 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3512 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3514 // Avoid a crash when core load gl resources.
3515 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3517 application.SendNotification();
3518 application.Render();
3520 textEditor.SetKeyInputFocus();
3521 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, false );
3522 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3524 // Render and notify
3525 application.SendNotification();
3526 application.Render();
3528 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3529 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3531 textEditor.SetKeyInputFocus();
3532 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
3533 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3535 // Render and notify
3536 application.SendNotification();
3537 application.Render();
3539 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3540 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3545 int UtcDaliTextEditorScrolling(void)
3547 ToolkitTestApplication application;
3548 tet_infoline(" UtcDaliTextEditorScrolling ");
3550 TextEditor textEditor = TextEditor::New();
3551 DALI_TEST_CHECK( textEditor );
3553 application.GetScene().Add( textEditor );
3555 // Avoid a crash when core load gl resources.
3556 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3558 application.SendNotification();
3559 application.Render();
3561 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
3562 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
3563 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
3564 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
3566 application.SendNotification();
3567 application.Render();
3569 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3570 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3573 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
3575 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, TEST_LOCATION );
3576 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3578 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
3580 DALI_TEST_NOT_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, 0.1f, TEST_LOCATION );
3581 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3583 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION , 0.0f);
3584 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION , 0.0f);
3586 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3587 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3592 int UtcDaliToolkitTextEditorFontSizeScale(void)
3594 ToolkitTestApplication application;
3595 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
3597 TextEditor textEditor = TextEditor::New();
3598 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 30.f );
3599 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3600 Vector3 nonScaledSize = textEditor.GetNaturalSize();
3602 TextEditor textEditorScaled = TextEditor::New();
3603 textEditorScaled.SetProperty( TextEditor::Property::POINT_SIZE, 15.f );
3604 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3605 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3606 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
3608 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3610 textEditor.SetProperty( TextEditor::Property::PIXEL_SIZE, 30.f );
3611 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3612 nonScaledSize = textEditor.GetNaturalSize();
3614 textEditorScaled.SetProperty( TextEditor::Property::PIXEL_SIZE, 15.f );
3615 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3616 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3617 scaledSize = textEditorScaled.GetNaturalSize();
3619 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3624 int UtcDaliTextEditorPrimaryCursorPosition(void)
3626 ToolkitTestApplication application;
3627 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
3629 TextEditor textEditor = TextEditor::New();
3631 application.GetScene().Add( textEditor );
3633 textEditor.SetProperty( TextEditor::Property::TEXT, "ABCEF");
3634 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3635 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3636 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3638 // Avoid a crash when core load gl resources.
3639 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3641 textEditor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
3642 application.SendNotification();
3643 application.Render();
3644 textEditor.SetKeyInputFocus();
3646 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3648 // Render and notify
3649 application.SendNotification();
3650 application.Render();
3652 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3653 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3658 int UtcDaliTextEditorLineCountAfterGetNaturalSize(void)
3660 ToolkitTestApplication application;
3661 tet_infoline(" UtcDaliTextEditorLineCountAfterGetNaturalSize ");
3663 TextEditor textEditor = TextEditor::New();
3664 textEditor.SetProperty(TextEditor::Property::TEXT, "A\nB\nC\nD\nE\nF\n");
3665 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3666 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3667 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3668 application.GetScene().Add( textEditor );
3670 application.SendNotification();
3671 application.Render();
3674 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3675 DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3677 textEditor.GetNaturalSize();
3679 // Create a tap event to touch the text editor.
3680 TestGenerateTap( application, 18.0f, 25.0f );
3682 application.SendNotification();
3683 application.Render();
3685 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3686 DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3692 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase(void)
3694 ToolkitTestApplication application;
3696 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase ");
3698 int lineCountBefore =0 ;
3699 int lineCountAfter =0 ;
3701 // Create a text editor
3702 TextEditor textEditor = TextEditor::New();
3703 //Set very large font-size using point-size
3704 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3705 //Specify font-family
3706 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3708 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3709 //Set text longer than width of textEditor
3710 textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3712 application.GetScene().Add( textEditor );
3714 application.SendNotification();
3715 application.Render();
3717 //Failed case is the GetHeightForWidth change LineCount then the scrollor will not arrive to latest line
3718 //GetHeightForWidth is a retrieval method which should not modify object
3719 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3720 textEditor.GetHeightForWidth(200.f);
3722 //This is to simulate focus into text editor after calling GetHeightForWidth
3723 //Create a tap event to touch the text editor.
3724 TestGenerateTap( application, 18.0f, 25.0f );
3726 application.SendNotification();
3727 application.Render();
3729 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3731 //The LineCount must not be changed when calling GetHeightForWidth.
3732 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3737 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase(void)
3739 ToolkitTestApplication application;
3741 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase ");
3743 int lineCountBefore =0 ;
3744 int lineCountAfter =0 ;
3746 // Create a text editor
3747 TextEditor textEditor = TextEditor::New();
3748 //Set very large font-size using point-size
3749 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3750 //Specify font-family
3751 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3753 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3754 //Set text longer than width of textEditor
3755 textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3756 //Set line wrap mode Character
3757 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3759 application.GetScene().Add( textEditor );
3761 application.SendNotification();
3762 application.Render();
3764 //Failed case is the GetHeightForWidth change LineCount which make position of cursor invalid in TextEditor
3765 //GetHeightForWidth is a retrieval method which should not modify object
3766 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3767 textEditor.GetHeightForWidth(200.f);
3769 //This is to simulate focus into text editor after calling GetHeightForWidth
3770 //Create a tap event to touch the text editor.
3771 TestGenerateTap( application, 18.0f, 25.0f );
3773 application.SendNotification();
3774 application.Render();
3776 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3778 //The LineCount must not be changed when calling GetHeightForWidth.
3779 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3784 int utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged(void)
3786 ToolkitTestApplication application;
3788 tet_infoline(" utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged ");
3790 int lineCountBefore =0 ;
3791 int lineCountAfter =0 ;
3793 // Create a text editor
3794 TextEditor textEditor = TextEditor::New();
3795 //Set very large font-size using point-size
3796 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3797 //Specify font-family
3798 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3800 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 100.f ) );
3801 //Set text longer than width of textEditor
3802 textEditor.SetProperty( TextEditor::Property::TEXT, "Short text");
3803 //Set line wrap mode Character
3804 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3806 application.GetScene().Add( textEditor );
3808 application.SendNotification();
3809 application.Render();
3812 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3814 textEditor.SetProperty( TextEditor::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
3815 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3817 // When the text changed, the Line-count should be updated according to new text.
3818 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
3819 DALI_TEST_EQUALS( lineCountBefore ,1, TEST_LOCATION );
3820 DALI_TEST_GREATER( lineCountAfter,1, TEST_LOCATION );
3827 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase(void)
3829 ToolkitTestApplication application;
3831 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase ");
3833 int lineCountBefore =0 ;
3834 int lineCountAfter =0 ;
3836 // Create a text editor
3837 TextEditor textEditor = TextEditor::New();
3838 //Set very large font-size using point-size
3839 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3840 //Specify font-family
3841 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3843 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3844 //Set text longer than width of textEditor
3845 textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3847 application.GetScene().Add( textEditor );
3849 application.SendNotification();
3850 application.Render();
3852 //Failed case is the GetNaturalSize change LineCount then the scrollor will not arrive to latest line
3853 //GetNaturalSize is a retrieval method which should not modify object
3854 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3855 textEditor.GetNaturalSize();
3857 //This is to simulate focus into text editor after calling GetNaturalSize
3858 //Create a tap event to touch the text editor.
3859 TestGenerateTap( application, 18.0f, 25.0f );
3861 application.SendNotification();
3862 application.Render();
3864 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3866 //The LineCount must not be changed when calling GetNaturalSize.
3867 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3872 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase(void)
3874 ToolkitTestApplication application;
3876 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase ");
3878 int lineCountBefore =0 ;
3879 int lineCountAfter =0 ;
3881 // Create a text editor
3882 TextEditor textEditor = TextEditor::New();
3883 //Set very large font-size using point-size
3884 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3885 //Specify font-family
3886 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3888 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3889 //Set text longer than width of textEditor
3890 textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3891 //Set line wrap mode Character
3892 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3894 application.GetScene().Add( textEditor );
3896 application.SendNotification();
3897 application.Render();
3899 //Failed case is the GetNaturalSize change LineCount which make position of cursor invalid in TextEditor
3900 //GetNaturalSize is a retrieval method which should not modify object
3901 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3902 textEditor.GetNaturalSize( );
3904 //This is to simulate focus into text editor after calling GetNaturalSize
3905 //Create a tap event to touch the text editor.
3906 TestGenerateTap( application, 18.0f, 25.0f );
3908 application.SendNotification();
3909 application.Render();
3911 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3913 //The LineCount must not be changed when calling GetNaturalSize.
3914 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3919 int UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize(void)
3921 ToolkitTestApplication application;
3922 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize ");
3924 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3925 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3926 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3928 // Create a text editor
3929 TextEditor textEditor = TextEditor::New();
3931 //Set size to avoid automatic eliding
3932 textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3933 //Set very large font-size using point-size
3934 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 1000) ;
3935 //Specify font-family
3936 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3937 //Set text to check if appear or not
3938 textEditor.SetProperty( TextEditor::Property::TEXT, "A");
3940 application.GetScene().Add( textEditor );
3942 application.SendNotification();
3943 application.Render();
3944 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3945 Vector3 naturalSize = textEditor.GetNaturalSize();
3947 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3948 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3953 int UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases(void)
3955 ToolkitTestApplication application;
3956 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases ");
3958 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3959 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3960 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3962 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3963 // Create a text editor
3964 TextEditor textEditor = TextEditor::New();
3965 //Set size to avoid automatic eliding
3966 textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3967 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3968 textEditor.SetProperty( TextEditor::Property::TEXT, "A");
3970 const int numberOfCases = 6;
3971 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
3973 for (int index=0; index < numberOfCases; index++)
3975 tet_printf(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
3976 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, arrayCases[index]) ;
3977 application.GetScene().Add( textEditor );
3978 application.SendNotification();
3979 application.Render();
3980 naturalSize = textEditor.GetNaturalSize();
3981 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3982 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3989 int UtcDaliTextEditorHyphenWrapMode(void)
3991 ToolkitTestApplication application;
3992 tet_infoline(" UtcDaliTextEditorHyphenWrapMode ");
3995 TextEditor textEditor = TextEditor::New();
3997 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
3999 application.GetScene().Add( textEditor );
4000 application.SendNotification();
4001 application.Render();
4003 textEditor.SetProperty( TextEditor::Property::TEXT, "Hi Experimen" );
4004 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
4005 DALI_TEST_EQUALS( textEditor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::HYPHENATION ), TEST_LOCATION );
4007 application.SendNotification();
4008 application.Render();
4010 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
4016 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
4018 textEditor.SetProperty( TextEditor::Property::TEXT, "Hi Experimen" );
4019 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
4020 DALI_TEST_EQUALS( textEditor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::MIXED ), TEST_LOCATION );
4022 application.SendNotification();
4023 application.Render();
4025 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
4032 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
4037 int UtcDaliToolkitTextEditorEllipsisPositionProperty(void)
4039 ToolkitTestApplication application;
4040 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty ");
4041 TextEditor textEditor = TextEditor::New();
4043 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Default is END");
4044 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4046 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START");
4047 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
4048 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4050 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE");
4051 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
4052 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4054 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END");
4055 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
4056 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4058 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START using integer");
4059 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 1);
4060 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4062 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE using integer");
4063 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 2);
4064 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4066 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END using integer");
4067 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 0);
4068 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4070 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
4071 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "START");
4072 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4074 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4075 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "MIDDLE");
4076 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4078 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4079 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "END");
4080 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4082 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4083 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "start");
4084 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4086 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4087 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "middle");
4088 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4090 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4091 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "end");
4092 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4097 int UtcDaliTextEditorCopyText(void)
4099 ToolkitTestApplication application;
4100 tet_infoline(" UtcDaliTextEditorCopyText ");
4102 TextEditor textEditor = TextEditor::New();
4104 std::string selectedText = "";
4105 std::string copiedText = "";
4107 application.GetScene().Add( textEditor );
4109 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4110 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4111 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4113 // Avoid a crash when core load gl resources.
4114 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4116 application.SendNotification();
4117 application.Render();
4119 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
4121 application.SendNotification();
4122 application.Render();
4124 // Hello is selected
4125 DevelTextEditor::SelectText( textEditor, 0, 5 );
4127 application.SendNotification();
4128 application.Render();
4130 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4131 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4133 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4134 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4137 copiedText = DevelTextEditor::CopyText( textEditor );
4138 DALI_TEST_EQUALS( "Hello", copiedText, TEST_LOCATION );
4140 // world is selected
4141 DevelTextEditor::SelectText( textEditor, 6, 11 );
4143 application.SendNotification();
4144 application.Render();
4146 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4147 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
4149 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
4150 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
4153 copiedText = DevelTextEditor::CopyText( textEditor );
4154 DALI_TEST_EQUALS( "world", copiedText, TEST_LOCATION );
4156 // "lo wo" is selected
4157 DevelTextEditor::SelectText( textEditor, 3, 8 );
4159 application.SendNotification();
4160 application.Render();
4162 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4163 DALI_TEST_EQUALS( "lo wo", selectedText, TEST_LOCATION );
4165 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 3, TEST_LOCATION );
4166 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 8, TEST_LOCATION );
4168 // "lo wo" is copied
4169 copiedText = DevelTextEditor::CopyText( textEditor );
4170 DALI_TEST_EQUALS( "lo wo", copiedText, TEST_LOCATION );
4175 int UtcDaliTextEditorCutText(void)
4177 ToolkitTestApplication application;
4178 tet_infoline(" UtcDaliTextEditorCutText ");
4180 TextEditor textEditor = TextEditor::New();
4182 std::string selectedText = "";
4184 application.GetScene().Add( textEditor );
4186 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4187 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4188 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4190 // Avoid a crash when core load gl resources.
4191 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4193 application.SendNotification();
4194 application.Render();
4196 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
4198 application.SendNotification();
4199 application.Render();
4201 // Hello is selected
4202 DevelTextEditor::SelectText( textEditor, 0, 5 );
4204 application.SendNotification();
4205 application.Render();
4207 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4208 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4210 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4211 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4214 DALI_TEST_EQUALS( "Hello", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4216 application.SendNotification();
4217 application.Render();
4219 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), " world", TEST_LOCATION );
4222 DevelTextEditor::SelectText( textEditor, 0, 2 );
4224 application.SendNotification();
4225 application.Render();
4227 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4228 DALI_TEST_EQUALS( " w", selectedText, TEST_LOCATION );
4230 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4231 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4234 DALI_TEST_EQUALS( " w", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4236 application.SendNotification();
4237 application.Render();
4239 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "orld", TEST_LOCATION );
4241 // Test Cut from the middle
4244 DevelTextEditor::SelectText( textEditor, 1, 3 );
4246 application.SendNotification();
4247 application.Render();
4249 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4250 DALI_TEST_EQUALS( "rl", selectedText, TEST_LOCATION );
4252 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4253 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 3, TEST_LOCATION );
4256 DALI_TEST_EQUALS( "rl", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4258 application.SendNotification();
4259 application.Render();
4261 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "od", TEST_LOCATION );
4263 // Test Cut from the end
4266 DevelTextEditor::SelectText( textEditor, 1, 2 );
4268 application.SendNotification();
4269 application.Render();
4271 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4272 DALI_TEST_EQUALS( "d", selectedText, TEST_LOCATION );
4274 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4275 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4278 DALI_TEST_EQUALS( "d", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4280 application.SendNotification();
4281 application.Render();
4283 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "o", TEST_LOCATION );
4288 int UtcDaliTextEditorPasteText(void)
4290 ToolkitTestApplication application;
4291 tet_infoline(" UtcDaliTextEditorPasteText ");
4293 TextEditor editor = TextEditor::New();
4294 DALI_TEST_CHECK( editor );
4296 application.GetScene().Add( editor );
4298 std::string cutText = "";
4299 std::string copiedText = "";
4301 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4302 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4303 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4304 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4305 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4307 // Avoid a crash when core load gl resources.
4308 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4310 // Render and notify
4311 application.SendNotification();
4312 application.Render();
4314 // Tap on the text editor
4315 TestGenerateTap( application, 3.0f, 25.0f );
4317 // Render and notify
4318 application.SendNotification();
4319 application.Render();
4321 // Move to second line of the text.
4322 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4324 // Render and notify
4325 application.SendNotification();
4326 application.Render();
4328 // Select some text in the right of the current cursor position
4329 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4330 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4331 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4332 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4334 // Render and notify
4335 application.SendNotification();
4336 application.Render();
4338 // Cut the selected text
4339 cutText = DevelTextEditor::CutText(editor);
4341 // Render and notify
4342 application.SendNotification();
4343 application.Render();
4345 DALI_TEST_EQUALS( "wor", cutText, TEST_LOCATION );
4346 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
4348 // Select some text in the left of the current cursor position
4349 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4350 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4351 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4352 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4354 // Render and notify
4355 application.SendNotification();
4356 application.Render();
4358 // Copy the selected text
4359 copiedText = DevelTextEditor::CopyText(editor);
4361 // Render and notify
4362 application.SendNotification();
4363 application.Render();
4365 DALI_TEST_EQUALS( "lo\n", copiedText, TEST_LOCATION );
4366 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
4369 // Move the cursor to the third line
4370 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4371 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4373 // Render and notify
4374 application.SendNotification();
4375 application.Render();
4377 // Paste the selected text at the current cursor position
4378 DevelTextEditor::PasteText(editor);
4380 // Render and notify
4381 application.SendNotification();
4382 application.Render();
4384 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
4388 int UtcDaliTextEditorLineSpacing(void)
4390 ToolkitTestApplication application;
4391 tet_infoline(" UtcDaliTextEditorLineSpacing ");
4393 TextEditor textEditor = TextEditor::New();
4394 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.f ) );
4395 application.GetScene().Add( textEditor );
4396 application.SendNotification();
4397 application.Render();
4399 textEditor.SetProperty( TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3" );
4400 textEditor.SetProperty( DevelTextEditor::Property::LINE_SPACING, 0 );
4402 Vector3 sizeBefore = textEditor.GetNaturalSize();
4404 textEditor.SetProperty( DevelTextEditor::Property::LINE_SPACING, 20 );
4406 //add 20 for each line 20 * 3
4407 DALI_TEST_EQUALS(sizeBefore.height + 60.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4412 int UtcDaliTextEditorMinLineSize(void)
4414 ToolkitTestApplication application;
4415 tet_infoline(" UtcDaliTextEditorMinLineSize ");
4417 TextEditor textEditor = TextEditor::New();
4418 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.f ) );
4419 application.GetScene().Add( textEditor );
4420 application.SendNotification();
4421 application.Render();
4423 textEditor.SetProperty( TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3" );
4424 textEditor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 0 );
4426 Vector3 sizeBefore = textEditor.GetNaturalSize();
4428 textEditor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 60 );
4430 DALI_TEST_NOT_EQUALS( sizeBefore, textEditor.GetNaturalSize(), 0.0f, TEST_LOCATION);
4433 DALI_TEST_EQUALS(180.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4438 int utcDaliTextEditorCursorPositionChangedSignal(void)
4440 ToolkitTestApplication application;
4441 tet_infoline(" utcDaliTextEditorCursorPositionChangedSignal");
4443 TextEditor editor = TextEditor::New();
4444 DALI_TEST_CHECK( editor );
4446 application.GetScene().Add( editor );
4448 // connect to the selection changed signal.
4449 ConnectionTracker* testTracker = new ConnectionTracker();
4450 DevelTextEditor::CursorPositionChangedSignal(editor).Connect(&TestCursorPositionChangedCallback);
4451 bool cursorPositionChangedSignal = false;
4452 editor.ConnectSignal( testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal) );
4454 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4455 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4456 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4457 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4458 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4460 // Avoid a crash when core load gl resources.
4461 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4463 // Render and notify
4464 application.SendNotification();
4465 application.Render();
4467 editor.SetKeyInputFocus();
4469 // Tap on the text editor
4470 TestGenerateTap( application, 3.0f, 25.0f );
4472 // Render and notify
4473 application.SendNotification();
4474 application.Render();
4476 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4477 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4479 gCursorPositionChangedCallbackCalled = false;
4482 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4484 // Render and notify
4485 application.SendNotification();
4486 application.Render();
4488 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4489 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4491 gCursorPositionChangedCallbackCalled = false;
4494 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4496 // Render and notify
4497 application.SendNotification();
4498 application.Render();
4500 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4501 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4503 gCursorPositionChangedCallbackCalled = false;
4505 //delete one character
4506 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4508 // Render and notify
4509 application.SendNotification();
4510 application.Render();
4512 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4513 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4515 gCursorPositionChangedCallbackCalled = false;
4517 editor.SetProperty( TextEditor::Property::TEXT, "Hello" );
4519 // Render and notify
4520 application.SendNotification();
4521 application.Render();
4523 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4524 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4526 gCursorPositionChangedCallbackCalled = false;
4528 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4530 // Render and notify
4531 application.SendNotification();
4532 application.Render();
4534 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4535 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4540 int utcDaliTextEditorGeometryEllipsisStart(void)
4542 ToolkitTestApplication application;
4543 tet_infoline(" utcDaliTextEditorGeometryEllipsisStart");
4545 TextEditor editor = TextEditor::New();
4546 DALI_TEST_CHECK( editor );
4548 application.GetScene().Add( editor );
4550 editor.SetProperty( TextEditor::Property::POINT_SIZE, 7.f );
4551 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4552 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4553 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4554 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4555 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, false );
4556 editor.SetProperty( DevelTextEditor::Property::ELLIPSIS, true );
4557 editor.SetProperty( DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START );
4558 editor.SetProperty( TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4" );
4560 // Avoid a crash when core load gl resources.
4561 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4563 // Render and notify
4564 application.SendNotification();
4565 application.Render();
4567 unsigned int expectedCount = 2;
4568 unsigned int startIndex = 0;
4569 unsigned int endIndex = 24;
4571 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4572 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4574 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4575 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4577 Vector<Vector2> expectedSizes;
4578 Vector<Vector2> expectedPositions;
4580 expectedPositions.PushBack(Vector2(37, 0));
4581 expectedSizes.PushBack(Vector2(20, 25));
4583 expectedPositions.PushBack(Vector2(-1, 25));
4584 expectedSizes.PushBack(Vector2(52, 25));
4586 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4591 int utcDaliTextEditorGeometryEllipsisMiddle(void)
4593 ToolkitTestApplication application;
4594 tet_infoline(" utcDaliTextEditorGeometryEllipsisMiddle");
4596 TextEditor editor = TextEditor::New();
4597 DALI_TEST_CHECK( editor );
4599 application.GetScene().Add( editor );
4601 editor.SetProperty( TextEditor::Property::POINT_SIZE, 7.f );
4602 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4603 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4604 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4605 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4606 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, false );
4607 editor.SetProperty( DevelTextEditor::Property::ELLIPSIS, true );
4608 editor.SetProperty( DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE );
4609 editor.SetProperty( TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4" );
4611 // Avoid a crash when core load gl resources.
4612 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4614 // Render and notify
4615 application.SendNotification();
4616 application.Render();
4618 unsigned int expectedCount = 2;
4619 unsigned int startIndex = 0;
4620 unsigned int endIndex = 24;
4622 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4623 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4625 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4626 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4628 Vector<Vector2> expectedSizes;
4629 Vector<Vector2> expectedPositions;
4631 expectedPositions.PushBack(Vector2(-1, 0));
4632 expectedSizes.PushBack(Vector2(25, 25));
4634 expectedPositions.PushBack(Vector2(-1, 25));
4635 expectedSizes.PushBack(Vector2(52, 25));
4637 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4642 int utcDaliTextEditorGeometryEllipsisEnd(void)
4644 ToolkitTestApplication application;
4645 tet_infoline(" utcDaliTextEditorGeometryEllipsisEnd");
4647 TextEditor editor = TextEditor::New();
4648 DALI_TEST_CHECK( editor );
4650 application.GetScene().Add( editor );
4652 editor.SetProperty( TextEditor::Property::POINT_SIZE, 7.f );
4653 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4654 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4655 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4656 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4657 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, false );
4658 editor.SetProperty( DevelTextEditor::Property::ELLIPSIS, true );
4659 editor.SetProperty( DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END );
4660 editor.SetProperty( TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4" );
4662 // Avoid a crash when core load gl resources.
4663 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4665 // Render and notify
4666 application.SendNotification();
4667 application.Render();
4669 unsigned int expectedCount = 2;
4670 unsigned int startIndex = 0;
4671 unsigned int endIndex = 24;
4673 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4674 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4676 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4677 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4679 Vector<Vector2> expectedSizes;
4680 Vector<Vector2> expectedPositions;
4682 expectedPositions.PushBack(Vector2(-1, 0));
4683 expectedSizes.PushBack(Vector2(59, 25));
4685 expectedPositions.PushBack(Vector2(-1, 25));
4686 expectedSizes.PushBack(Vector2(25, 25));
4688 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4693 int utcDaliTextEditorGeometryRTL(void)
4695 ToolkitTestApplication application;
4696 tet_infoline(" utcDaliTextEditorGeometryRTL");
4698 TextEditor editor = TextEditor::New();
4699 DALI_TEST_CHECK( editor );
4701 application.GetScene().Add( editor );
4703 editor.SetProperty( TextEditor::Property::POINT_SIZE, 7.f );
4704 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4705 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4706 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4707 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4708 editor.SetProperty( TextEditor::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر" );
4710 // Avoid a crash when core load gl resources.
4711 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4713 // Render and notify
4714 application.SendNotification();
4715 application.Render();
4717 unsigned int expectedCount = 4;
4718 unsigned int startIndex = 3;
4719 unsigned int endIndex = 24;
4721 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4722 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4724 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4725 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4727 Vector<Vector2> expectedSizes;
4728 Vector<Vector2> expectedPositions;
4730 expectedPositions.PushBack(Vector2(24, 0));
4731 expectedSizes.PushBack(Vector2(33, 25));
4733 expectedPositions.PushBack(Vector2(-1, 25));
4734 expectedSizes.PushBack(Vector2(52, 25));
4736 expectedPositions.PushBack(Vector2(-1, 50));
4737 expectedSizes.PushBack(Vector2(59, 25));
4739 expectedPositions.PushBack(Vector2(61, 75));
4740 expectedSizes.PushBack(Vector2(37, 25));
4742 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4747 int utcDaliTextEditorGeometryGlyphMiddle(void)
4749 ToolkitTestApplication application;
4750 tet_infoline(" utcDaliTextEditorGeometryGlyphMiddle");
4752 TextEditor editor = TextEditor::New();
4753 DALI_TEST_CHECK( editor );
4755 application.GetScene().Add( editor );
4757 editor.SetProperty( TextEditor::Property::POINT_SIZE, 7.f );
4758 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.f, 200.f ) );
4759 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4760 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4761 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4762 editor.SetProperty( TextEditor::Property::TEXT, "لا تحتوي على لا" );
4764 // Avoid a crash when core load gl resources.
4765 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4767 // Render and notify
4768 application.SendNotification();
4769 application.Render();
4771 unsigned int expectedCount = 1;
4772 unsigned int startIndex = 1;
4773 unsigned int endIndex = 13;
4775 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4776 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4778 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4779 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4781 Vector<Vector2> expectedSizes;
4782 Vector<Vector2> expectedPositions;
4784 expectedPositions.PushBack(Vector2(6, 0));
4785 expectedSizes.PushBack(Vector2(124, 25));
4787 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4792 int utcDaliTextEditorSelectionClearedSignal(void)
4794 ToolkitTestApplication application;
4795 tet_infoline(" utcDaliTextEditorSelectionClearedSignal");
4797 TextEditor editor = TextEditor::New();
4798 DALI_TEST_CHECK( editor );
4800 application.GetScene().Add( editor );
4802 // connect to the selection changed signal.
4803 ConnectionTracker* testTracker = new ConnectionTracker();
4804 DevelTextEditor::SelectionClearedSignal(editor).Connect(&TestSelectionClearedCallback);
4805 bool selectionClearedSignal = false;
4806 editor.ConnectSignal( testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal) );
4808 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4809 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4810 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4811 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4812 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4814 // Avoid a crash when core load gl resources.
4815 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4817 // Render and notify
4818 application.SendNotification();
4819 application.Render();
4821 // Tap on the text editor
4822 TestGenerateTap( application, 3.0f, 25.0f );
4824 // Render and notify
4825 application.SendNotification();
4826 application.Render();
4828 // Move to second line of the text & Select some text in the right of the current cursor position
4829 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4830 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4833 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4835 // Render and notify
4836 application.SendNotification();
4837 application.Render();
4839 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4841 // Render and notify
4842 application.SendNotification();
4843 application.Render();
4845 // Tap on the text editor
4846 TestGenerateTap( application, 3.0f, 25.0f );
4848 // Render and notify
4849 application.SendNotification();
4850 application.Render();
4852 gSelectionClearedCallbackCalled = false;
4854 // Move to second line of the text & select.
4855 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4856 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4859 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4861 // Render and notify
4862 application.SendNotification();
4863 application.Render();
4865 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4867 gSelectionClearedCallbackCalled = false;
4869 // Render and notify
4870 application.SendNotification();
4871 application.Render();
4873 // Move to second line of the text & select.
4874 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4875 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4877 // replace C with selected text
4878 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4880 // Render and notify
4881 application.SendNotification();
4882 application.Render();
4884 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4886 gSelectionClearedCallbackCalled = false;
4888 // Render and notify
4889 application.SendNotification();
4890 application.Render();
4892 DevelTextEditor::SelectText( editor ,1, 3 );
4894 // Render and notify
4895 application.SendNotification();
4896 application.Render();
4898 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4900 // Render and notify
4901 application.SendNotification();
4902 application.Render();
4904 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4906 gSelectionClearedCallbackCalled = false;
4908 DevelTextEditor::SelectText( editor ,1, 3 );
4910 // Render and notify
4911 application.SendNotification();
4912 application.Render();
4915 DevelTextEditor::SelectNone(editor);
4917 // Render and notify
4918 application.SendNotification();
4919 application.Render();
4921 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4926 int utcDaliTextEditorSelectionChangedSignal(void)
4928 ToolkitTestApplication application;
4929 tet_infoline(" utcDaliTextEditorSelectionChangedSignal");
4931 TextEditor editor = TextEditor::New();
4932 DALI_TEST_CHECK( editor );
4934 application.GetScene().Add( editor );
4936 // connect to the selection changed signal.
4937 ConnectionTracker* testTracker = new ConnectionTracker();
4938 DevelTextEditor::SelectionChangedSignal(editor).Connect(&TestSelectionChangedCallback);
4939 bool selectionChangedSignal = false;
4940 editor.ConnectSignal( testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal) );
4942 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4943 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4944 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4945 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4946 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4948 // Avoid a crash when core load gl resources.
4949 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4951 // Render and notify
4952 application.SendNotification();
4953 application.Render();
4955 // Tap on the text editor
4956 TestGenerateTap( application, 3.0f, 25.0f );
4958 // Render and notify
4959 application.SendNotification();
4960 application.Render();
4962 // Move to second line of the text.
4963 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4965 // Render and notify
4966 application.SendNotification();
4967 application.Render();
4969 // Select some text in the right of the current cursor position
4970 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4971 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4973 // Render and notify
4974 application.SendNotification();
4975 application.Render();
4977 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4978 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4980 gSelectionChangedCallbackCalled = false;
4982 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4984 // Render and notify
4985 application.SendNotification();
4986 application.Render();
4988 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4989 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
4990 DALI_TEST_EQUALS(oldSelectionEnd, 7, TEST_LOCATION);
4992 gSelectionChangedCallbackCalled = false;
4994 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4996 // Render and notify
4997 application.SendNotification();
4998 application.Render();
5000 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5001 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
5002 DALI_TEST_EQUALS(oldSelectionEnd, 8, TEST_LOCATION);
5004 gSelectionChangedCallbackCalled = false;
5005 editor.SetKeyInputFocus();
5007 // Render and notify
5008 application.SendNotification();
5009 application.Render();
5011 DevelTextEditor::SelectText( editor ,0, 5 );
5013 application.SendNotification();
5014 application.Render();
5016 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5017 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5019 gSelectionChangedCallbackCalled = false;
5021 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
5023 // Render and notify
5024 application.SendNotification();
5025 application.Render();
5027 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5028 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5029 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
5031 gSelectionChangedCallbackCalled = false;
5034 DevelTextEditor::SelectWholeText(editor);
5036 // Render and notify
5037 application.SendNotification();
5038 application.Render();
5040 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5041 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5043 gSelectionChangedCallbackCalled = false;
5046 DevelTextEditor::SelectNone(editor);
5048 // Render and notify
5049 application.SendNotification();
5050 application.Render();
5052 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5053 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5054 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5059 int UtcDaliToolkitTextEditorStrikethroughGeneration(void)
5061 ToolkitTestApplication application;
5062 tet_infoline(" UtcDaliToolkitTextEditorStrikethroughGeneration");
5064 TextEditor textEditor = TextEditor::New();
5065 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
5066 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 200.0f, 100.f ) );
5067 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
5068 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
5070 application.GetScene().Add( textEditor );
5071 application.SendNotification();
5072 application.Render();
5074 Property::Map strikethroughMapSet;
5075 Property::Map strikethroughMapGet;
5077 strikethroughMapSet.Insert( "enable", true );
5078 strikethroughMapSet.Insert( "color", Color::RED );
5079 strikethroughMapSet.Insert( "height", 2.0f );
5081 // Check the strikethrough property
5082 textEditor.SetProperty( DevelTextEditor::Property::STRIKETHROUGH, strikethroughMapSet );
5083 strikethroughMapGet = textEditor.GetProperty<Property::Map>( DevelTextEditor::Property::STRIKETHROUGH );
5084 textEditor.SetProperty( TextEditor::Property::TEXT, "Test1" );
5085 DALI_TEST_EQUALS( strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION );
5086 DALI_TEST_EQUALS( DaliTestCheckMaps( strikethroughMapGet, strikethroughMapSet ), true, TEST_LOCATION );
5088 // Render and notify
5089 application.SendNotification();
5090 application.Render();
5092 strikethroughMapSet.Clear();
5093 strikethroughMapGet.Clear();
5098 int utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize(void)
5101 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5102 //DaliException on vector: "Iterator not inside vector"
5104 ToolkitTestApplication application;
5105 tet_infoline(" utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize");
5107 TextEditor editor = TextEditor::New();
5108 DALI_TEST_CHECK( editor );
5110 application.GetScene().Add( editor );
5112 // Avoid a crash when core load gl resources.
5113 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
5115 //Set multilines text
5116 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5117 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
5118 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
5120 //Set ResizePolicy to NaturalSize
5121 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5123 // Render and notify
5124 application.SendNotification();
5125 application.Render();
5127 // Create a tap event to touch the text editor.
5128 TestGenerateTap( application, 5.0f, 5.0f );
5130 // Render and notify
5131 application.SendNotification();
5132 application.Render();
5134 // Set currsor and add character (in first line)
5135 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5136 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5137 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5139 // Render and notify
5140 application.SendNotification();
5141 application.Render();
5143 //Check the changed text and cursor position
5144 DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "Hellod \n World", TEST_LOCATION );
5145 DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 6, TEST_LOCATION );
5147 // Render and notify
5148 application.SendNotification();
5149 application.Render();
5154 int utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize(void)
5157 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5158 //DaliException on vector: "Iterator not inside vector"
5160 ToolkitTestApplication application;
5161 tet_infoline(" utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize");
5163 TextEditor editor = TextEditor::New();
5164 DALI_TEST_CHECK( editor );
5166 application.GetScene().Add( editor );
5168 // Avoid a crash when core load gl resources.
5169 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
5171 //Set multilines text
5172 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5173 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
5174 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
5176 //Set ResizePolicy to NaturalSize
5177 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5180 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5181 application.SendNotification();
5182 application.Render();
5184 // Set focus and remove character
5185 editor.SetKeyInputFocus();
5186 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5188 // Render and notify
5189 application.SendNotification();
5190 application.Render();
5192 //Check the changed text and cursor position
5193 DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "Hell \n World", TEST_LOCATION );
5194 DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
5196 // Render and notify
5197 application.SendNotification();
5198 application.Render();
5203 int utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize(void)
5206 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5207 //DaliException on vector: "Iterator not inside vector"
5209 ToolkitTestApplication application;
5210 tet_infoline(" utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize");
5212 TextEditor editor = TextEditor::New();
5213 DALI_TEST_CHECK( editor );
5215 application.GetScene().Add( editor );
5217 // Avoid a crash when core load gl resources.
5218 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
5220 //Set multilines text
5221 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5222 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
5223 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
5225 //Set ResizePolicy to NaturalSize
5226 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5228 //Select text at initialization (before the first render)
5229 DevelTextEditor::SelectText( editor ,3, 5 );
5231 // Render and notify
5232 application.SendNotification();
5233 application.Render();
5236 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5237 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 ) );
5239 // Render and notify
5240 application.SendNotification();
5241 application.Render();
5243 //Check the changed text and cursor position
5244 DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "Hel \n World", TEST_LOCATION );
5245 DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 3, TEST_LOCATION );
5247 // Render and notify
5248 application.SendNotification();
5249 application.Render();
5255 int utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize(void)
5258 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5259 //DaliException on vector: "Iterator not inside vector"
5261 ToolkitTestApplication application;
5262 tet_infoline(" utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize");
5264 TextEditor editor = TextEditor::New();
5265 DALI_TEST_CHECK( editor );
5267 application.GetScene().Add( editor );
5269 // Avoid a crash when core load gl resources.
5270 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
5272 //Set multilines text
5273 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5274 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
5275 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
5277 //Set ResizePolicy to NaturalSize
5278 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5281 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5282 application.SendNotification();
5283 application.Render();
5285 // Set focus and double enter (new line)
5286 editor.SetKeyInputFocus();
5287 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5288 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5290 // Render and notify
5291 application.SendNotification();
5292 application.Render();
5294 //Check the changed text and cursor position
5295 DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "Hello\n\n \n World", TEST_LOCATION );
5296 DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 7, TEST_LOCATION );
5298 // Render and notify
5299 application.SendNotification();
5300 application.Render();