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";
92 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
93 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
94 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
95 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
96 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
97 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
98 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
99 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
100 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
101 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
102 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
103 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
104 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
105 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
106 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
107 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
108 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
109 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
110 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
111 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
113 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
114 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
116 const float RENDER_FRAME_INTERVAL = 16.66f;
118 const unsigned int DEFAULT_FONT_SIZE = 1152u;
119 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
121 const int KEY_A_CODE = 38;
122 const int KEY_D_CODE = 40;
123 const int KEY_C_CODE = 54;
124 const int KEY_V_CODE = 55;
125 const int KEY_X_CODE = 53;
126 const int KEY_WHITE_SPACE_CODE = 65;
128 const int KEY_SHIFT_MODIFIER = 257;
129 const int KEY_CONTROL_MODIFIER = 258;
131 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
132 const char* HANDLE_LEFT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_left.png";
133 const char* HANDLE_RIGHT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_right.png";
135 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
137 static bool gSelectionChangedCallbackCalled;
138 static uint32_t oldSelectionStart;
139 static uint32_t oldSelectionEnd;
140 static bool gSelectionClearedCallbackCalled;
141 static bool gAnchorClickedCallBackCalled;
142 static bool gAnchorClickedCallBackNotCalled;
143 static bool gTextChangedCallBackCalled;
144 static bool gInputFilteredAcceptedCallbackCalled;
145 static bool gInputFilteredRejectedCallbackCalled;
146 static bool gInputStyleChangedCallbackCalled;
147 static bool gMaxCharactersCallBackCalled;
148 static bool gCursorPositionChangedCallbackCalled;
149 static uint32_t oldCursorPos;
150 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
152 struct CallbackFunctor
154 CallbackFunctor(bool* callbackFlag)
155 : mCallbackFlag( callbackFlag )
161 *mCallbackFlag = true;
166 static void TestSelectionClearedCallback(TextEditor control)
168 tet_infoline(" TestSelectionClearedCallback");
170 gSelectionClearedCallbackCalled = true;
173 static void TestSelectionChangedCallback(TextEditor control, uint32_t oldStart, uint32_t oldEnd)
175 tet_infoline(" TestSelectionChangedCallback");
177 gSelectionChangedCallbackCalled = true;
178 oldSelectionStart = oldStart;
179 oldSelectionEnd = oldEnd;
182 static void TestAnchorClickedCallback(TextEditor control, const char* href, unsigned int hrefLength)
184 tet_infoline(" TestAnchorClickedCallback");
186 gAnchorClickedCallBackNotCalled = false;
188 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
190 gAnchorClickedCallBackCalled = true;
194 static void TestCursorPositionChangedCallback( TextEditor control, unsigned int oldPos )
196 tet_infoline(" TestCursorPositionChangedCallback");
198 gCursorPositionChangedCallbackCalled = true;
199 oldCursorPos = oldPos;
202 static void TestTextChangedCallback( TextEditor control )
204 tet_infoline(" TestTextChangedCallback");
206 gTextChangedCallBackCalled = true;
209 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
211 tet_infoline(" TestInputStyleChangedCallback");
213 gInputStyleChangedCallbackCalled = true;
214 gInputStyleMask = mask;
217 static void TestMaxLengthReachedCallback( TextEditor control )
219 tet_infoline(" TestMaxLengthReachedCallback");
221 gMaxCharactersCallBackCalled = true;
224 static void TestInputFilteredCallback(TextEditor control, Toolkit::InputFilter::Property::Type type)
226 tet_infoline(" TestInputFilteredCallback");
228 if(type == Toolkit::InputFilter::Property::ACCEPTED)
230 gInputFilteredAcceptedCallbackCalled = true;
232 else if(type == Toolkit::InputFilter::Property::REJECTED)
234 gInputFilteredRejectedCallbackCalled = true;
238 // Generate a KeyEvent to send to Core.
239 Integration::KeyEvent GenerateKey( const std::string& keyName,
240 const std::string& logicalKey,
241 const std::string& keyString,
244 unsigned long timeStamp,
245 const Integration::KeyEvent::State& keyState,
246 const std::string& compose = "",
247 const std::string& deviceName = DEFAULT_DEVICE_NAME,
248 const Device::Class::Type& deviceClass = Device::Class::NONE,
249 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
251 return Integration::KeyEvent( keyName,
264 Dali::Integration::Point GetPointDownInside( Vector2& pos )
266 Dali::Integration::Point point;
267 point.SetState( PointState::DOWN );
268 point.SetScreenPosition( pos );
272 Dali::Integration::Point GetPointUpInside( Vector2& pos )
274 Dali::Integration::Point point;
275 point.SetState( PointState::UP );
276 point.SetScreenPosition( pos );
280 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
282 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
284 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
286 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
288 Property::Value* valueSet = NULL;
289 if ( valueGet.first.type == Property::Key::INDEX )
291 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
295 // Get Key is a string so searching Set Map for a string key
296 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
299 if( NULL != valueSet )
301 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
303 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
306 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
308 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
311 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
313 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
316 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
318 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
321 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
323 Vector2 vector2Get = valueGet.second.Get<Vector2>();
324 Vector2 vector2Set = valueSet->Get<Vector2>();
325 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
328 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
330 Vector4 vector4Get = valueGet.second.Get<Vector4>();
331 Vector4 vector4Set = valueSet->Get<Vector4>();
332 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 );
338 if ( valueGet.first.type == Property::Key::INDEX )
340 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
344 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
354 class ScrollStateChangeCallback : public Dali::ConnectionTracker
357 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
358 : mStartedCalled( startedCalled ),
359 mFinishedCalled( finishedCalled )
363 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
365 if( type == TextEditor::Scroll::STARTED )
367 mStartedCalled = true;
369 else if( type == TextEditor::Scroll::FINISHED )
371 mFinishedCalled = true;
375 bool& mStartedCalled;
376 bool& mFinishedCalled;
381 int UtcDaliToolkitTextEditorConstructorP(void)
383 ToolkitTestApplication application;
384 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
385 TextEditor textEditor;
386 DALI_TEST_CHECK( !textEditor );
390 int UtcDaliToolkitTextEditorNewP(void)
392 ToolkitTestApplication application;
393 tet_infoline(" UtcDaliToolkitTextEditorNewP");
394 TextEditor textEditor = TextEditor::New();
395 DALI_TEST_CHECK( textEditor );
399 int UtcDaliToolkitTextEditorDownCastP(void)
401 ToolkitTestApplication application;
402 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
403 TextEditor textEditor1 = TextEditor::New();
404 BaseHandle object( textEditor1 );
406 TextEditor textEditor2 = TextEditor::DownCast( object );
407 DALI_TEST_CHECK( textEditor2 );
409 TextEditor textEditor3 = DownCast< TextEditor >( object );
410 DALI_TEST_CHECK( textEditor3 );
414 int UtcDaliToolkitTextEditorDownCastN(void)
416 ToolkitTestApplication application;
417 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
418 BaseHandle uninitializedObject;
419 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
420 DALI_TEST_CHECK( !textEditor1 );
422 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
423 DALI_TEST_CHECK( !textEditor2 );
427 int UtcDaliToolkitTextEditorCopyConstructorP(void)
429 ToolkitTestApplication application;
430 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
431 TextEditor textEditor = TextEditor::New();
432 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
434 TextEditor copy( textEditor );
435 DALI_TEST_CHECK( copy );
436 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
440 int UtcDaliTextEditorMoveConstructor(void)
442 ToolkitTestApplication application;
444 TextEditor textEditor = TextEditor::New();
445 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
446 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
448 TextEditor moved = std::move( textEditor );
449 DALI_TEST_CHECK( moved );
450 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
451 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
452 DALI_TEST_CHECK( !textEditor );
457 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
459 ToolkitTestApplication application;
460 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
461 TextEditor textEditor = TextEditor::New();
462 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
464 TextEditor copy = textEditor;
465 DALI_TEST_CHECK( copy );
466 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
470 int UtcDaliTextEditorMoveAssignment(void)
472 ToolkitTestApplication application;
474 TextEditor textEditor = TextEditor::New();
475 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
476 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
479 moved = std::move( textEditor );
480 DALI_TEST_CHECK( moved );
481 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
482 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
483 DALI_TEST_CHECK( !textEditor );
488 int UtcDaliTextEditorNewP(void)
490 ToolkitTestApplication application;
491 tet_infoline(" UtcDaliToolkitTextEditorNewP");
492 TextEditor textEditor = TextEditor::New();
493 DALI_TEST_CHECK( textEditor );
497 // Positive test case for a method
498 int UtcDaliTextEditorGetPropertyP(void)
500 ToolkitTestApplication application;
501 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
502 TextEditor editor = TextEditor::New();
503 DALI_TEST_CHECK( editor );
505 // Check Property Indices are correct
506 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextEditor::Property::RENDERING_BACKEND );
507 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
508 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
509 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
510 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
511 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
512 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
513 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
514 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
515 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
516 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
517 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
518 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
519 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
520 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
521 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
522 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
523 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
524 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
525 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
526 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
527 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
528 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
529 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
530 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
531 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
532 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
533 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
534 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
535 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
537 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
538 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
539 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
540 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
541 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
542 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
543 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
544 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
545 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
546 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
547 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
548 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
549 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
550 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
551 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
552 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
553 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
554 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
555 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
556 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextEditor::Property::FONT_SIZE_SCALE );
557 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
558 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
559 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
560 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
561 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
562 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == DevelTextEditor::Property::MAX_LENGTH );
563 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextEditor::Property::GRAB_HANDLE_COLOR );
564 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP );
565 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == DevelTextEditor::Property::INPUT_METHOD_SETTINGS );
566 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FILTER ) == DevelTextEditor::Property::INPUT_FILTER );
571 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
574 Property::Map imageMap;
575 imageMap[mapKey] =mapValue;
577 editor.SetProperty( property , imageMap );
578 Property::Value propValue = editor.GetProperty( property );
579 Property::Map* resultMap = propValue.GetMap();
581 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
589 // Positive test case for a method
590 int UtcDaliTextEditorSetPropertyP(void)
592 ToolkitTestApplication application;
593 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
594 TextEditor editor = TextEditor::New();
595 DALI_TEST_CHECK( editor );
596 application.GetScene().Add( editor );
598 // Note - we can't check the defaults since the stylesheets are platform-specific
600 // Check the render backend property.
601 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
602 DALI_TEST_EQUALS( (DevelText::RenderingType)editor.GetProperty<int>( DevelTextEditor::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
604 // Check text property.
605 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
606 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
608 // Check text's color property
609 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
610 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
612 // Check font properties.
613 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
614 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
616 Property::Map fontStyleMapSet;
617 Property::Map fontStyleMapGet;
618 Property::Value* slantValue = NULL;
620 fontStyleMapSet.Insert( "weight", "bold" );
621 fontStyleMapSet.Insert( "width", "condensed" );
622 fontStyleMapSet.Insert( "slant", "italic" );
624 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
625 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
626 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
627 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
629 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
630 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
632 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 2.5f );
633 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
634 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 1.0f );
637 fontStyleMapSet.Clear();
638 fontStyleMapSet.Insert( "weight", "normal" );
639 fontStyleMapSet.Insert( "slant", "oblique" );
640 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
641 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
642 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
643 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
645 fontStyleMapSet.Clear();
646 fontStyleMapSet.Insert( "slant", "roman" );
647 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
648 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
650 // Replace 'roman' for 'normal'.
651 slantValue = fontStyleMapGet.Find( "slant" );
652 if( NULL != slantValue )
654 if( "normal" == slantValue->Get<std::string>() )
656 fontStyleMapGet["slant"] = "roman";
659 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
660 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
662 fontStyleMapSet.Clear();
664 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
665 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
666 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
667 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
669 // Check that the Alignment properties can be correctly set
670 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
671 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
673 // Check scroll properties.
674 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
675 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
676 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
677 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
679 // Check cursor properties
680 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
681 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
682 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
683 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
685 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
686 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
687 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
688 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
689 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
690 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
691 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
692 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
694 // Check handle images
695 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
696 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
697 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
698 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
699 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
701 // Check handle images
702 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
703 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
704 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
705 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
706 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
707 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
709 // Check the highlight color
710 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
711 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
713 // Decoration bounding box
714 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
715 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
717 // Check the enable markup property.
718 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
719 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
720 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
722 // Check input color property.
723 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
724 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
726 // Check input font properties.
727 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
728 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
730 fontStyleMapSet.Clear();
731 fontStyleMapSet.Insert( "weight", "bold" );
732 fontStyleMapSet.Insert( "width", "condensed" );
733 fontStyleMapSet.Insert( "slant", "italic" );
735 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
736 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
737 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
738 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
740 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
741 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
743 // Reset input font style.
744 fontStyleMapSet.Clear();
745 fontStyleMapSet.Insert( "weight", "normal" );
746 fontStyleMapSet.Insert( "slant", "oblique" );
748 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
749 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
750 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
751 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
753 fontStyleMapSet.Clear();
754 fontStyleMapSet.Insert( "slant", "roman" );
756 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
757 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
759 // Replace 'roman' for 'normal'.
760 slantValue = fontStyleMapGet.Find( "slant" );
761 if( NULL != slantValue )
763 if( "normal" == slantValue->Get<std::string>() )
765 fontStyleMapGet["slant"] = "roman";
768 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
769 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
771 fontStyleMapSet.Clear();
773 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
774 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
775 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
776 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
778 // Check the line spacing property
779 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
780 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
781 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
783 // Check the input line spacing property
784 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
785 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
786 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
788 // Check the underline property
790 Property::Map underlineMapSet;
791 Property::Map underlineMapGet;
793 underlineMapSet.Insert( "enable", true );
794 underlineMapSet.Insert( "color", Color::RED );
795 underlineMapSet.Insert( "height", 1 );
797 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
799 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
800 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
801 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
803 // Check the input underline property
804 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
805 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
807 // Check the shadow property
808 Property::Map shadowMapSet;
809 Property::Map shadowMapGet;
811 shadowMapSet.Insert( "color", Color::GREEN );
812 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
813 shadowMapSet.Insert( "blurRadius", 3.0f );
815 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
817 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
818 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
819 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
821 // Check the input shadow property
822 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
823 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
825 // Check the emboss property
826 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
827 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
829 // Check the input emboss property
830 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
831 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
833 // Check the outline property
835 // Test string type first
836 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
837 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
838 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
840 // Then test the property map type
841 Property::Map outlineMapSet;
842 Property::Map outlineMapGet;
844 outlineMapSet["color"] = Color::RED;
845 outlineMapSet["width"] = 2.0f;
847 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
849 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
850 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
851 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
853 // Check the input outline property
854 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
855 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
857 // Check the smooth scroll property
858 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
859 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
860 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
862 // Check the smooth scroll duration property
863 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
864 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
866 // Check the scroll bar property
867 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
868 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
869 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
871 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
872 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
873 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
874 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
876 // Check the pixel size of font
877 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
878 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
880 // Check placeholder text properties.
881 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
882 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
884 // Check placeholder text's color property.
885 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
886 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
888 // Check the enable selection property
889 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
890 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
892 // Check the placeholder property with pixel size
893 Property::Map placeholderPixelSizeMapSet;
894 Property::Map placeholderPixelSizeMapGet;
895 Property::Map placeholderFontstyleMap;
896 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
897 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
898 placeholderPixelSizeMapSet["color"] = Color::BLUE;
899 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
900 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
902 placeholderFontstyleMap.Insert( "weight", "bold" );
903 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
904 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
906 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
907 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
909 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
910 Property::Map placeholderConversionMap;
911 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
912 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
913 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
914 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
915 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
916 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
918 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
920 // Check the placeholder property with point size
921 Property::Map placeholderMapSet;
922 Property::Map placeholderMapGet;
923 placeholderMapSet["text"] = "Setting Placeholder Text";
924 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
925 placeholderMapSet["color"] = Color::RED;
926 placeholderMapSet["fontFamily"] = "Arial";
927 placeholderMapSet["pointSize"] = 12.0f;
928 // Check the placeholder font style property
929 placeholderFontstyleMap.Clear();
931 placeholderFontstyleMap.Insert( "weight", "bold" );
932 placeholderFontstyleMap.Insert( "width", "condensed" );
933 placeholderFontstyleMap.Insert( "slant", "italic" );
934 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
935 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
937 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
938 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
940 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
941 placeholderConversionMap.Clear();
942 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
943 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
944 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
945 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
946 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
947 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
948 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
951 placeholderFontstyleMap.Clear();
952 placeholderFontstyleMap.Insert( "weight", "normal" );
953 placeholderFontstyleMap.Insert( "slant", "oblique" );
954 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
955 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
957 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
958 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
959 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
960 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
962 placeholderFontstyleMap.Clear();
963 placeholderFontstyleMap.Insert( "slant", "roman" );
964 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
965 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
967 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
969 placeholderFontstyleMap.Clear();
970 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
972 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
973 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
974 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
975 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
976 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
978 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
979 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
981 // Check handle color
982 editor.SetProperty( DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN );
983 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
985 // Test the ENABLE_GRAB_HANDLE_POPUP property
986 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP, false );
987 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP ), false, TEST_LOCATION);
989 // Check the input method setting
990 Property::Map propertyMap;
991 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
992 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
993 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
994 int inputVariation = 1;
995 propertyMap["PANEL_LAYOUT"] = panelLayout;
996 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
997 propertyMap["BUTTON_ACTION"] = buttonAction;
998 propertyMap["VARIATION"] = inputVariation;
999 editor.SetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS, propertyMap );
1001 Property::Value value = editor.GetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS );
1003 DALI_TEST_CHECK( value.Get( map ) );
1006 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
1007 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
1010 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
1011 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
1014 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
1015 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
1018 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
1019 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
1021 // Check the input filter property
1022 Property::Map inputFilterMapSet;
1023 Property::Map inputFilterMapGet;
1024 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1025 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1027 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1029 inputFilterMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::INPUT_FILTER);
1030 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1033 inputFilterMapSet.Clear();
1034 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1036 application.SendNotification();
1037 application.Render();
1039 // Check the line size property
1040 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::MIN_LINE_SIZE ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1041 editor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 50.f );
1042 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::MIN_LINE_SIZE ), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1047 // Positive Atlas Text Renderer test
1048 int utcDaliTextEditorAtlasRenderP(void)
1050 ToolkitTestApplication application;
1051 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
1052 StyleManager styleManager = StyleManager::Get();
1053 styleManager.ApplyDefaultTheme();
1054 TextEditor editor = TextEditor::New();
1055 DALI_TEST_CHECK( editor );
1057 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1059 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1061 application.GetScene().Add( editor );
1065 // Render some text with the shared atlas backend
1066 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1067 application.SendNotification();
1068 application.Render();
1072 tet_result(TET_FAIL);
1077 // Positive test for the anchorClicked signal.
1078 int utcDaliTextEditorAnchorClickedP(void)
1080 ToolkitTestApplication application;
1081 tet_infoline(" utcDaliTextEditorAnchorClickedP");
1082 TextEditor editor = TextEditor::New();
1083 DALI_TEST_CHECK(editor);
1085 application.GetScene().Add(editor);
1087 // connect to the anchor clicked signal.
1088 ConnectionTracker* testTracker = new ConnectionTracker();
1089 DevelTextEditor::AnchorClickedSignal(editor).Connect(&TestAnchorClickedCallback);
1090 bool anchorClickedSignal = false;
1091 editor.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1093 gAnchorClickedCallBackCalled = false;
1094 editor.SetProperty(TextEditor::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1095 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1096 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1097 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1098 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1100 application.SendNotification();
1101 application.Render();
1102 editor.SetKeyInputFocus();
1104 // Create a tap event to touch the text editor.
1105 TestGenerateTap(application, 5.0f, 5.0f);
1106 application.SendNotification();
1107 application.Render();
1109 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1110 DALI_TEST_CHECK(anchorClickedSignal);
1112 gAnchorClickedCallBackNotCalled = true;
1113 // Tap the outside of anchor, callback should not be called.
1114 TestGenerateTap(application, 150.f, 100.f);
1115 application.SendNotification();
1116 application.Render();
1118 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1123 // Positive test for the textChanged signal.
1124 int utcDaliTextEditorTextChangedP(void)
1126 ToolkitTestApplication application;
1127 tet_infoline(" utcDaliTextEditorTextChangedP");
1128 TextEditor editor = TextEditor::New();
1129 DALI_TEST_CHECK( editor );
1131 application.GetScene().Add( editor );
1133 // connect to the text changed signal.
1134 ConnectionTracker* testTracker = new ConnectionTracker();
1135 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
1136 bool textChangedSignal = false;
1137 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1139 gTextChangedCallBackCalled = false;
1140 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
1141 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1142 DALI_TEST_CHECK( textChangedSignal );
1144 application.SendNotification();
1145 editor.SetKeyInputFocus();
1147 gTextChangedCallBackCalled = false;
1148 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1149 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1152 editor.SetProperty( TextField::Property::TEXT, "" );
1154 // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
1155 gTextChangedCallBackCalled = false;
1156 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1157 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1159 // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
1160 gTextChangedCallBackCalled = false;
1161 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1162 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1167 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1169 ToolkitTestApplication application;
1170 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1171 TextEditor editor = TextEditor::New();
1172 DALI_TEST_CHECK( editor );
1175 application.GetScene().Add( editor );
1177 // connect to the text changed signal.
1178 ConnectionTracker* testTracker = new ConnectionTracker();
1179 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1180 bool textChangedSignal = false;
1181 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1184 // get InputMethodContext
1186 InputMethodContext::EventData imfEvent;
1187 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext( editor );
1189 editor.SetKeyInputFocus();
1190 editor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
1193 gTextChangedCallBackCalled = false;
1194 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1195 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1196 application.SendNotification();
1197 application.Render();
1198 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1199 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1201 gTextChangedCallBackCalled = false;
1202 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1203 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1204 application.SendNotification();
1205 application.Render();
1206 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1207 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호"), TEST_LOCATION );
1209 gTextChangedCallBackCalled = false;
1210 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1211 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1212 application.SendNotification();
1213 application.Render();
1214 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1215 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1217 gTextChangedCallBackCalled = false;
1218 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1219 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1220 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1222 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1223 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1224 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1226 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1227 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1228 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1230 application.SendNotification();
1231 application.Render();
1232 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1233 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1239 int utcDaliTextEditorInputStyleChanged01(void)
1241 // The text-editor emits signals when the input style changes. These changes of style are
1242 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1243 // can't be emitted during the size negotiation as the callbacks may update the UI.
1244 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1245 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1246 ToolkitTestApplication application;
1247 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1251 char* pathNamePtr = get_current_dir_name();
1252 const std::string pathName( pathNamePtr );
1253 free( pathNamePtr );
1255 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1256 fontClient.SetDpi( 93u, 93u );
1258 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1259 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1261 TextEditor editor = TextEditor::New();
1262 DALI_TEST_CHECK( editor );
1265 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1266 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1267 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1269 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1270 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1272 // connect to the text changed signal.
1273 ConnectionTracker* testTracker = new ConnectionTracker();
1274 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1275 bool inputStyleChangedSignal = false;
1276 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1278 application.GetScene().Add( editor );
1280 // Render and notify
1281 application.SendNotification();
1282 application.Render();
1284 // Executes the idle callbacks added by the text control on the change of input style.
1285 application.RunIdles();
1287 gInputStyleChangedCallbackCalled = false;
1288 gInputStyleMask = TextEditor::InputStyle::NONE;
1289 inputStyleChangedSignal = false;
1291 // Create a tap event to touch the text editor.
1292 TestGenerateTap( application, 18.0f, 25.0f );
1294 // Render and notify
1295 application.SendNotification();
1296 application.Render();
1298 // Executes the idle callbacks added by the text control on the change of input style.
1299 application.RunIdles();
1301 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1302 if( gInputStyleChangedCallbackCalled )
1304 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1306 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1307 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1309 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1310 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1312 DALI_TEST_CHECK( inputStyleChangedSignal );
1314 gInputStyleChangedCallbackCalled = false;
1315 gInputStyleMask = TextEditor::InputStyle::NONE;
1316 inputStyleChangedSignal = false;
1318 // Create a tap event to touch the text editor.
1319 TestGenerateTap( application, 30.0f, 25.0f );
1321 // Render and notify
1322 application.SendNotification();
1323 application.Render();
1325 // Executes the idle callbacks added by the text control on the change of input style.
1326 application.RunIdles();
1328 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1329 DALI_TEST_CHECK( !inputStyleChangedSignal );
1331 gInputStyleChangedCallbackCalled = false;
1332 gInputStyleMask = TextEditor::InputStyle::NONE;
1333 inputStyleChangedSignal = false;
1335 // Create a tap event to touch the text editor.
1336 TestGenerateTap( application, 43.0f, 25.0f );
1338 // Render and notify
1339 application.SendNotification();
1340 application.Render();
1342 // Executes the idle callbacks added by the text control on the change of input style.
1343 application.RunIdles();
1345 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1346 if( gInputStyleChangedCallbackCalled )
1348 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1350 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1351 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1353 DALI_TEST_CHECK( inputStyleChangedSignal );
1355 gInputStyleChangedCallbackCalled = false;
1356 gInputStyleMask = TextEditor::InputStyle::NONE;
1357 inputStyleChangedSignal = false;
1359 // Create a tap event to touch the text editor.
1360 TestGenerateTap( application, 88.0f, 25.0f );
1362 // Render and notify
1363 application.SendNotification();
1364 application.Render();
1366 // Executes the idle callbacks added by the text control on the change of input style.
1367 application.RunIdles();
1369 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1370 if( gInputStyleChangedCallbackCalled )
1372 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1374 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1375 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1377 Property::Map fontStyleMapSet;
1378 Property::Map fontStyleMapGet;
1380 fontStyleMapSet.Insert( "weight", "bold" );
1382 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1383 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1384 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1386 DALI_TEST_CHECK( inputStyleChangedSignal );
1388 gInputStyleChangedCallbackCalled = false;
1389 gInputStyleMask = TextEditor::InputStyle::NONE;
1390 inputStyleChangedSignal = false;
1392 // Create a tap event to touch the text editor.
1393 TestGenerateTap( application, 115.0f, 25.0f );
1395 // Render and notify
1396 application.SendNotification();
1397 application.Render();
1399 // Executes the idle callbacks added by the text control on the change of input style.
1400 application.RunIdles();
1402 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1403 DALI_TEST_CHECK( !inputStyleChangedSignal );
1405 gInputStyleChangedCallbackCalled = false;
1406 gInputStyleMask = TextEditor::InputStyle::NONE;
1407 inputStyleChangedSignal = false;
1409 // Create a tap event to touch the text editor.
1410 TestGenerateTap( application, 164.0f, 25.0f );
1412 // Render and notify
1413 application.SendNotification();
1414 application.Render();
1416 // Executes the idle callbacks added by the text control on the change of input style.
1417 application.RunIdles();
1419 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1420 if( gInputStyleChangedCallbackCalled )
1422 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1424 Property::Map fontStyleMapSet;
1425 Property::Map fontStyleMapGet;
1427 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1428 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1429 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1431 DALI_TEST_CHECK( inputStyleChangedSignal );
1433 gInputStyleChangedCallbackCalled = false;
1434 gInputStyleMask = TextEditor::InputStyle::NONE;
1435 inputStyleChangedSignal = false;
1437 // Create a tap event to touch the text editor.
1438 TestGenerateTap( application, 191.0f, 25.0f );
1440 // Render and notify
1441 application.SendNotification();
1442 application.Render();
1444 // Executes the idle callbacks added by the text control on the change of input style.
1445 application.RunIdles();
1447 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1448 DALI_TEST_CHECK( !inputStyleChangedSignal );
1453 int utcDaliTextEditorInputStyleChanged02(void)
1455 // The text-editor emits signals when the input style changes. These changes of style are
1456 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1457 // can't be emitted during the size negotiation as the callbacks may update the UI.
1458 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1459 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1460 ToolkitTestApplication application;
1461 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1465 char* pathNamePtr = get_current_dir_name();
1466 const std::string pathName( pathNamePtr );
1467 free( pathNamePtr );
1469 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1470 fontClient.SetDpi( 93u, 93u );
1472 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1473 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1475 TextEditor editor = TextEditor::New();
1476 DALI_TEST_CHECK( editor );
1479 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1480 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1481 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1483 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1484 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>" );
1486 // connect to the text changed signal.
1487 ConnectionTracker* testTracker = new ConnectionTracker();
1488 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1489 bool inputStyleChangedSignal = false;
1490 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1492 application.GetScene().Add( editor );
1494 // Render and notify
1495 application.SendNotification();
1496 application.Render();
1498 // Executes the idle callbacks added by the text control on the change of input style.
1499 application.RunIdles();
1501 gInputStyleChangedCallbackCalled = false;
1502 gInputStyleMask = TextEditor::InputStyle::NONE;
1503 inputStyleChangedSignal = false;
1505 // Create a tap event to touch the text editor.
1506 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1507 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1509 // Render and notify
1510 application.SendNotification();
1511 application.Render();
1513 // Executes the idle callbacks added by the text control on the change of input style.
1514 application.RunIdles();
1516 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1517 if( gInputStyleChangedCallbackCalled )
1519 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1520 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1521 TextEditor::InputStyle::POINT_SIZE |
1522 TextEditor::InputStyle::COLOR ),
1525 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1526 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1528 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1529 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1531 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1532 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1534 DALI_TEST_CHECK( inputStyleChangedSignal );
1536 gInputStyleChangedCallbackCalled = false;
1537 gInputStyleMask = TextEditor::InputStyle::NONE;
1538 inputStyleChangedSignal = false;
1540 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1542 // Render and notify
1543 application.SendNotification();
1544 application.Render();
1546 // Executes the idle callbacks added by the text control on the change of input style.
1547 application.RunIdles();
1549 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1550 if( gInputStyleChangedCallbackCalled )
1552 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1553 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1556 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1557 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1559 DALI_TEST_CHECK( inputStyleChangedSignal );
1561 gInputStyleChangedCallbackCalled = false;
1562 gInputStyleMask = TextEditor::InputStyle::NONE;
1563 inputStyleChangedSignal = false;
1565 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1567 // Render and notify
1568 application.SendNotification();
1569 application.Render();
1571 // Executes the idle callbacks added by the text control on the change of input style.
1572 application.RunIdles();
1574 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1575 DALI_TEST_CHECK( !inputStyleChangedSignal );
1577 gInputStyleChangedCallbackCalled = false;
1578 gInputStyleMask = TextEditor::InputStyle::NONE;
1579 inputStyleChangedSignal = false;
1581 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1583 // Render and notify
1584 application.SendNotification();
1585 application.Render();
1587 // Executes the idle callbacks added by the text control on the change of input style.
1588 application.RunIdles();
1590 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1591 if( gInputStyleChangedCallbackCalled )
1593 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1594 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1597 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1598 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1600 DALI_TEST_CHECK( inputStyleChangedSignal );
1602 gInputStyleChangedCallbackCalled = false;
1603 gInputStyleMask = TextEditor::InputStyle::NONE;
1604 inputStyleChangedSignal = false;
1606 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1608 Property::Map fontStyleMapSet;
1609 fontStyleMapSet.Insert( "weight", "thin" );
1610 fontStyleMapSet.Insert( "width", "condensed" );
1611 fontStyleMapSet.Insert( "slant", "italic" );
1613 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1614 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1615 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1617 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1618 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1619 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1620 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1622 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1624 // Render and notify
1625 application.SendNotification();
1626 application.Render();
1628 // Executes the idle callbacks added by the text control on the change of input style.
1629 application.RunIdles();
1631 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1632 DALI_TEST_CHECK( !inputStyleChangedSignal );
1634 // Create a tap event to touch the text editor.
1635 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1637 // Render and notify
1638 application.SendNotification();
1639 application.Render();
1641 // Executes the idle callbacks added by the text control on the change of input style.
1642 application.RunIdles();
1644 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1645 if( gInputStyleChangedCallbackCalled )
1647 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1648 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1649 TextEditor::InputStyle::POINT_SIZE |
1650 TextEditor::InputStyle::FONT_STYLE |
1651 TextEditor::InputStyle::LINE_SPACING |
1652 TextEditor::InputStyle::UNDERLINE |
1653 TextEditor::InputStyle::SHADOW |
1654 TextEditor::InputStyle::EMBOSS |
1655 TextEditor::InputStyle::OUTLINE ),
1658 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1659 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1661 DALI_TEST_CHECK( inputStyleChangedSignal );
1663 gInputStyleChangedCallbackCalled = false;
1664 gInputStyleMask = TextEditor::InputStyle::NONE;
1665 inputStyleChangedSignal = false;
1667 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1669 fontStyleMapSet.Clear();
1670 fontStyleMapSet.Insert( "weight", "black" );
1671 fontStyleMapSet.Insert( "width", "expanded" );
1672 fontStyleMapSet.Insert( "slant", "oblique" );
1674 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1676 // Create a tap event to touch the text editor.
1677 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1679 // Render and notify
1680 application.SendNotification();
1681 application.Render();
1683 // Executes the idle callbacks added by the text control on the change of input style.
1684 application.RunIdles();
1686 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1687 if( gInputStyleChangedCallbackCalled )
1689 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1690 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1691 TextEditor::InputStyle::POINT_SIZE |
1692 TextEditor::InputStyle::FONT_STYLE ),
1695 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1696 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1698 DALI_TEST_CHECK( inputStyleChangedSignal );
1703 int utcDaliTextEditorEvent01(void)
1705 ToolkitTestApplication application;
1706 tet_infoline(" utcDaliTextEditorEvent01");
1708 // Creates a tap event. After creating a tap event the text editor should
1709 // have the focus and add text with key events should be possible.
1711 TextEditor editor = TextEditor::New();
1712 DALI_TEST_CHECK( editor );
1714 application.GetScene().Add( editor );
1716 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1717 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1718 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1720 // Avoid a crash when core load gl resources.
1721 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1723 // Render and notify
1724 application.SendNotification();
1725 application.Render();
1727 // Add a key event but as the text editor has not the focus it should do nothing.
1728 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1730 // Render and notify
1731 application.SendNotification();
1732 application.Render();
1734 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1736 // Create a tap event to touch the text editor.
1737 TestGenerateTap( application, 150.0f, 25.0f );
1739 // Render and notify
1740 application.SendNotification();
1741 application.Render();
1743 // Now the text editor has the focus, so it can handle the key events.
1744 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1745 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1747 // Render and notify
1748 application.SendNotification();
1749 application.Render();
1751 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1753 // Create a second text editor and send key events to it.
1754 TextEditor editor2 = TextEditor::New();
1756 editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1757 editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1758 editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1759 editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1761 application.GetScene().Add( editor2 );
1763 // Render and notify
1764 application.SendNotification();
1765 application.Render();
1767 // Create a tap event on the second text editor.
1768 TestGenerateTap( application, 150.0f, 125.0f );
1770 // Render and notify
1771 application.SendNotification();
1772 application.Render();
1774 // The second text editor has the focus. It should handle the key events.
1775 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1776 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1778 // Render and notify
1779 application.SendNotification();
1780 application.Render();
1782 // Check the text has been added to the second text editor.
1783 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1788 int utcDaliTextEditorEvent02(void)
1790 ToolkitTestApplication application;
1791 tet_infoline(" utcDaliTextEditorEvent02");
1793 // Checks if the right number of actors are created.
1795 TextEditor editor = TextEditor::New();
1796 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1797 DALI_TEST_CHECK( editor );
1799 application.GetScene().Add( editor );
1801 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1802 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1803 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1805 // Avoid a crash when core load gl resources.
1806 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1808 // Render and notify
1809 application.SendNotification();
1810 application.Render();
1812 // Check there are the expected number of children (the stencil).
1813 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1815 Actor stencil = editor.GetChildAt( 0u );
1817 // Create a tap event to touch the text editor.
1818 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1820 // Render and notify
1821 application.SendNotification();
1822 application.Render();
1824 Actor layer = editor.GetChildAt( 1u );
1825 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1826 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1828 // Now the text editor has the focus, so it can handle the key events.
1829 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1830 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1832 // Render and notify
1833 application.SendNotification();
1834 application.Render();
1836 // Checks the cursor and the renderer have been created.
1837 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1838 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1840 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1841 DALI_TEST_CHECK( cursor );
1843 // The stencil actor has a container with all the actors which contain the text renderers.
1844 Actor container = stencil.GetChildAt( 0u );
1845 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1847 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1848 DALI_TEST_CHECK( renderer );
1851 // Move the cursor and check the position changes.
1852 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1854 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1855 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1857 // Render and notify
1858 application.SendNotification();
1859 application.Render();
1861 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1863 DALI_TEST_CHECK( position2.x < position1.x );
1865 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1866 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1868 // Render and notify
1869 application.SendNotification();
1870 application.Render();
1872 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1874 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1876 // Send some taps and check the cursor positions.
1878 // Try to tap at the beginning.
1879 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1881 // Render and notify
1882 application.SendNotification();
1883 application.Render();
1885 // Cursor position should be the same than position1.
1886 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1888 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1890 // Tap away from the start position.
1891 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1893 // Render and notify
1894 application.SendNotification();
1895 application.Render();
1897 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1899 DALI_TEST_CHECK( position5.x > position4.x );
1901 // Remove all the text.
1902 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1903 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1904 editor.SetProperty( TextEditor::Property::TEXT, "" );
1906 // Render and notify
1907 application.SendNotification();
1908 application.Render();
1910 // Cursor position should be the same than position2.
1911 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1913 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1915 // Should not be a renderer.
1916 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1921 int utcDaliTextEditorEvent03(void)
1923 ToolkitTestApplication application;
1924 tet_infoline(" utcDaliTextEditorEvent03");
1926 // Checks if the highlight actor is created.
1928 TextEditor editor = TextEditor::New();
1929 DALI_TEST_CHECK( editor );
1931 application.GetScene().Add( editor );
1933 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1934 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1935 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1936 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1937 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1939 // Avoid a crash when core load gl resources.
1940 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1942 // Render and notify
1943 application.SendNotification();
1944 application.Render();
1946 // Send some taps and check text controller with clipboard window
1947 Dali::Clipboard clipboard = Clipboard::Get();
1948 clipboard.ShowClipboard();
1949 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1950 clipboard.HideClipboard();
1952 // Render and notify
1953 application.SendNotification();
1954 application.Render();
1956 // Tap first to get the focus.
1957 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1959 // Render and notify
1960 application.SendNotification();
1961 application.Render();
1963 // Double tap to select a word.
1964 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1966 // Render and notify
1967 application.SendNotification();
1968 application.Render();
1970 // The stencil actor should have two actors: the renderer and the highlight actor.
1971 Actor stencil = editor.GetChildAt( 0u );
1973 // Highlight needs to be drawn before text, so should come first in child order
1974 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1975 DALI_TEST_CHECK( highlight );
1977 // The stencil actor has a container with all the actors which contain the text renderers.
1978 Actor container = stencil.GetChildAt( 1u );
1979 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1981 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1982 DALI_TEST_CHECK( renderer );
1985 // Double tap out of bounds
1986 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1987 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1989 // Render and notify
1990 application.SendNotification();
1991 application.Render();
1993 // The stencil actor should have one actors: the renderer actor.
1994 stencil = editor.GetChildAt( 0u );
1996 // The stencil actor has a container with all the actors which contain the text renderers.
1997 container = stencil.GetChildAt( 0u );
1998 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2000 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2001 DALI_TEST_CHECK( renderer );
2005 TestGenerateLongPress(application, 1.0f, 25.0f);
2007 // Render and notify
2008 application.SendNotification();
2009 application.Render();
2012 TestGenerateMiniPan(application);
2014 // Render and notify
2015 application.SendNotification();
2016 application.Render();
2021 int utcDaliTextEditorEvent04(void)
2023 ToolkitTestApplication application;
2024 tet_infoline(" utcDaliTextEditorEvent04");
2026 // Checks if the highlight actor is created.
2028 TextEditor editor = TextEditor::New();
2029 DALI_TEST_CHECK( editor );
2031 application.GetScene().Add( editor );
2033 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
2034 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2035 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2036 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2037 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2039 // Avoid a crash when core load gl resources.
2040 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2042 // Render and notify
2043 application.SendNotification();
2044 application.Render();
2046 // Tap on the text editor
2047 TestGenerateTap( application, 3.0f, 25.0f );
2049 // Render and notify
2050 application.SendNotification();
2051 application.Render();
2053 // Move at the end of the text.
2054 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2055 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2057 // Render and notify
2058 application.SendNotification();
2059 application.Render();
2061 for( unsigned int index = 0u; index < 10u; ++index )
2063 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2064 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2066 // Render and notify
2067 application.SendNotification();
2068 application.Render();
2072 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2074 // Render and notify
2075 application.SendNotification();
2076 application.Render();
2078 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2080 // Add some key events
2081 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2082 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2084 // Render and notify
2085 application.SendNotification();
2086 application.Render();
2088 for( unsigned int index = 0u; index < 10u; ++index )
2090 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2091 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2093 // Render and notify
2094 application.SendNotification();
2095 application.Render();
2099 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2101 // Render and notify
2102 application.SendNotification();
2103 application.Render();
2105 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2110 int utcDaliTextEditorEvent05(void)
2112 ToolkitTestApplication application;
2113 tet_infoline(" utcDaliTextEditorEvent05");
2115 // Checks if the highlight actor is created.
2117 TextEditor editor = TextEditor::New();
2118 DALI_TEST_CHECK( editor );
2120 application.GetScene().Add( editor );
2122 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
2123 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2124 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2125 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2126 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2127 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2128 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
2129 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2130 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
2131 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
2133 // Avoid a crash when core load gl resources.
2134 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2136 // Render and notify
2137 application.SendNotification();
2138 application.Render();
2140 // Tap on the text editor
2141 TestGenerateTap( application, 3.0f, 25.0f );
2143 // Render and notify
2144 application.SendNotification();
2145 application.Render();
2147 // Move at the end of the text.
2148 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2149 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2151 // Render and notify
2152 application.SendNotification();
2153 application.Render();
2155 for( unsigned int index = 0u; index < 10u; ++index )
2158 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2160 // Render and notify
2161 application.SendNotification();
2162 application.Render();
2164 // Modify duration after scroll is enabled
2165 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
2167 // Continuous scroll left to increase coverage
2168 for( unsigned int index = 0u; index < 10u; ++index )
2170 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2172 // Render and notify
2173 application.SendNotification();
2174 application.Render();
2176 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2177 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
2178 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
2179 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2180 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2182 // Press Escape to increase coverage
2183 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2184 application.SendNotification();
2185 application.Render();
2187 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
2192 int utcDaliTextEditorEvent06(void)
2194 ToolkitTestApplication application;
2195 tet_infoline(" utcDaliTextEditorEvent06");
2197 // Checks if the highlight actor is created.
2199 TextEditor editor = TextEditor::New();
2200 DALI_TEST_CHECK( editor );
2202 application.GetScene().Add( editor );
2204 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2205 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2206 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2207 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2208 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2210 // Avoid a crash when core load gl resources.
2211 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2213 // Render and notify
2214 application.SendNotification();
2215 application.Render();
2217 // Tap on the text editor
2218 TestGenerateTap( application, 3.0f, 25.0f );
2220 // Render and notify
2221 application.SendNotification();
2222 application.Render();
2224 // Move to seconds line of the text.
2225 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2227 // Render and notify
2228 application.SendNotification();
2229 application.Render();
2231 float layoutHeight = editor.GetHeightForWidth( 100.f );
2234 // Add another script characters ( glyph height is defferent )
2235 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2236 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2238 // Delete characters
2239 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2240 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2242 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2244 // Render and notify
2245 application.SendNotification();
2246 application.Render();
2248 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2251 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2252 application.SendNotification();
2253 application.Render();
2255 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2256 application.SendNotification();
2257 application.Render();
2259 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2260 application.SendNotification();
2261 application.Render();
2263 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2264 application.SendNotification();
2265 application.Render();
2267 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2268 application.SendNotification();
2269 application.Render();
2271 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2272 application.SendNotification();
2273 application.Render();
2275 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2276 application.SendNotification();
2277 application.Render();
2282 int utcDaliTextEditorEvent07(void)
2284 ToolkitTestApplication application;
2285 tet_infoline(" utcDaliTextEditorEvent07");
2287 // Checks if the highlight actor is created.
2289 TextEditor editor = TextEditor::New();
2290 DALI_TEST_CHECK( editor );
2292 application.GetScene().Add( editor );
2294 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2295 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2296 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2297 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2298 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2300 // Avoid a crash when core load gl resources.
2301 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2303 // Render and notify
2304 application.SendNotification();
2305 application.Render();
2307 // Tap on the text editor
2308 TestGenerateTap( application, 3.0f, 25.0f );
2310 // Render and notify
2311 application.SendNotification();
2312 application.Render();
2314 // Move to second line of the text.
2315 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2317 // Render and notify
2318 application.SendNotification();
2319 application.Render();
2321 // Select some text in the right of the current cursor position
2322 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2323 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2324 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2325 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2327 // Render and notify
2328 application.SendNotification();
2329 application.Render();
2331 // Cut the selected text
2332 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2333 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 ) );
2335 // Render and notify
2336 application.SendNotification();
2337 application.Render();
2339 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2341 // Select some text in the left of the current cursor position
2342 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2343 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2344 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2345 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2347 // Render and notify
2348 application.SendNotification();
2349 application.Render();
2351 // Copy the selected text
2352 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2353 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 ) );
2355 // Render and notify
2356 application.SendNotification();
2357 application.Render();
2359 // Move the cursor to the third line
2360 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2361 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2363 // Render and notify
2364 application.SendNotification();
2365 application.Render();
2367 // Paste the selected text at the current cursor position
2368 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2369 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 ) );
2371 // Render and notify
2372 application.SendNotification();
2373 application.Render();
2375 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2378 // Disable Shift Selection
2379 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2381 // Test to select some text in the right of the current cursor position
2382 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2383 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2384 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2385 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2387 // Render and notify
2388 application.SendNotification();
2389 application.Render();
2391 // Cut the selected text
2392 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2393 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 ) );
2395 // Render and notify
2396 application.SendNotification();
2397 application.Render();
2399 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2400 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2402 // Test to select some text in the left of the current cursor position
2403 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2404 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2405 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2406 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2408 // Render and notify
2409 application.SendNotification();
2410 application.Render();
2412 // Copy the selected text
2413 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2414 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 ) );
2416 // Render and notify
2417 application.SendNotification();
2418 application.Render();
2420 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2421 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2424 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 ) );
2426 // Render and notify
2427 application.SendNotification();
2428 application.Render();
2430 // replace text with "c"
2431 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2433 // Render and notify
2434 application.SendNotification();
2435 application.Render();
2438 DALI_TEST_EQUALS( "c", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2441 DevelTextEditor::SelectWholeText(editor);
2443 // Render and notify
2444 application.SendNotification();
2445 application.Render();
2447 // Copy the selected text using logical keys
2448 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2449 application.ProcessEvent( GenerateKey( "ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2451 // Render and notify
2452 application.SendNotification();
2453 application.Render();
2456 DevelTextEditor::SelectNone(editor);
2458 // Render and notify
2459 application.SendNotification();
2460 application.Render();
2462 // Paste the selected using logical keys
2463 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2464 application.ProcessEvent( GenerateKey( "ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2467 DALI_TEST_EQUALS( "cc", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2469 // select all using logical keys
2470 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2471 application.ProcessEvent( GenerateKey( "ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2473 // Render and notify
2474 application.SendNotification();
2475 application.Render();
2477 // cut text using logical keys
2478 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2479 application.ProcessEvent( GenerateKey( "ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2481 // Render and notify
2482 application.SendNotification();
2483 application.Render();
2486 DALI_TEST_EQUALS( "", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2491 int utcDaliTextEditorEvent08(void)
2493 ToolkitTestApplication application;
2494 tet_infoline(" utcDaliTextEditorEvent08");
2496 // Checks if the highlight actor is released correctly.
2498 TextEditor editor = TextEditor::New();
2499 DALI_TEST_CHECK( editor );
2501 application.GetScene().Add( editor );
2503 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2504 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2505 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2506 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2507 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2509 // Avoid a crash when core load gl resources.
2510 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2512 // Render and notify
2513 application.SendNotification();
2514 application.Render();
2516 // Tap on the text editor
2517 TestGenerateTap( application, 3.0f, 25.0f );
2519 // Render and notify
2520 application.SendNotification();
2521 application.Render();
2523 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2524 // Test to select some text in the left of the current cursor position
2525 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2526 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2527 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2528 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2530 // Render and notify
2531 application.SendNotification();
2532 application.Render();
2534 // Test to the left selection handle position and the right selection handle position
2535 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2536 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2537 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2538 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2540 // Render and notify
2541 application.SendNotification();
2542 application.Render();
2544 // Test to select full text in the left of the current cursor position
2545 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2546 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2547 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2548 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2549 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2550 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2552 // Render and notify
2553 application.SendNotification();
2554 application.Render();
2556 // Test to release the current full text selection
2557 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2558 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2560 // Render and notify
2561 application.SendNotification();
2562 application.Render();
2564 // Test to move the current cursor position correctly
2565 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2567 // Render and notify
2568 application.SendNotification();
2569 application.Render();
2572 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2574 // Render and notify
2575 application.SendNotification();
2576 application.Render();
2578 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2580 // Test to select some text in the right of the current cursor position
2581 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2582 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2583 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2585 // Render and notify
2586 application.SendNotification();
2587 application.Render();
2589 // Test the cursor position with right arrow key
2590 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2592 // Render and notify
2593 application.SendNotification();
2594 application.Render();
2597 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2599 // Render and notify
2600 application.SendNotification();
2601 application.Render();
2603 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2605 // Test to select some text in the left of the current cursor position
2606 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2607 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2608 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2609 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2610 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2612 // Render and notify
2613 application.SendNotification();
2614 application.Render();
2616 // Test the cursor position with left arrow key
2617 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2619 // Render and notify
2620 application.SendNotification();
2621 application.Render();
2624 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2626 // Render and notify
2627 application.SendNotification();
2628 application.Render();
2630 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2632 // Test to select some text in the right of the current cursor position
2633 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2634 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2635 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2636 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2638 // Render and notify
2639 application.SendNotification();
2640 application.Render();
2642 // Test the cursor position with left arrow key
2643 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2645 // Render and notify
2646 application.SendNotification();
2647 application.Render();
2650 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2652 // Render and notify
2653 application.SendNotification();
2654 application.Render();
2656 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2658 // Test to select some text in the left of the current cursor position
2659 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2660 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2661 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2662 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2664 // Render and notify
2665 application.SendNotification();
2666 application.Render();
2668 // Test the cursor position with right arrow key
2669 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2671 // Render and notify
2672 application.SendNotification();
2673 application.Render();
2676 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2678 // Render and notify
2679 application.SendNotification();
2680 application.Render();
2682 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2687 int utcDaliTextEditorHandles(void)
2689 ToolkitTestApplication application;
2690 tet_infoline(" utcDaliTextEditorHandles");
2692 TextEditor editor = TextEditor::New();
2693 DALI_TEST_CHECK( editor );
2695 application.GetScene().Add( editor );
2697 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2698 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2699 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2700 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2702 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2703 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2704 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2705 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2707 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2708 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2709 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2711 // Avoid a crash when core load gl resources.
2712 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2714 // Render and notify
2715 application.SendNotification();
2716 application.Render();
2718 // Tap first to get the focus.
2719 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2721 // Render and notify
2722 application.SendNotification();
2723 application.Render();
2725 // Tap to create the grab handle.
2726 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2728 // Render and notify
2729 application.SendNotification();
2730 application.Render();
2732 // Get the active layer where the text's decoration is added.
2733 Actor activeLayer = editor.GetChildAt( 1u );
2735 // Get the handle's actor.
2736 Actor handle = activeLayer.GetChildAt( 1u );
2737 handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2739 // Render and notify
2740 application.SendNotification();
2741 application.Render();
2743 // Touch the grab handle to set it as pressed.
2744 Vector2 touchPos( 10.0f, 50.0f );
2745 Dali::Integration::TouchEvent event;
2746 event = Dali::Integration::TouchEvent();
2747 event.AddPoint( GetPointDownInside( touchPos ) );
2748 application.ProcessEvent( event );
2750 // Render and notify
2751 application.SendNotification();
2752 application.Render();
2754 // Pan the grab handle
2755 uint32_t time = 100;
2756 TestStartPan( application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time );
2757 TestMovePan( application, Vector2(10.0f, 30.0f), time );
2758 TestEndPan( application, Vector2(10.0f, 50.0f), time);
2759 application.SendNotification();
2760 application.Render();
2763 // Release the grab handle.
2764 event = Dali::Integration::TouchEvent();
2765 event.AddPoint( GetPointUpInside( touchPos ) );
2766 application.ProcessEvent( event );
2768 // Render and notify
2769 application.SendNotification();
2770 application.Render();
2772 // Tap first to get the focus.
2773 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2775 // Render and notify
2776 application.SendNotification();
2777 application.Render();
2779 // Double tap to select a word and create the selection handles.
2780 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2782 // Render and notify
2783 application.SendNotification();
2784 application.Render();
2786 touchPos = Vector2( 10.0f, 50.0f );
2788 // Touch the left selection handle to set it as pressed.
2789 event = Dali::Integration::TouchEvent();
2790 event.AddPoint( GetPointDownInside( touchPos ) );
2791 application.ProcessEvent( event );
2793 // Render and notify
2794 application.SendNotification();
2795 application.Render();
2797 // Release the left selection handle.
2798 event = Dali::Integration::TouchEvent();
2799 event.AddPoint( GetPointUpInside( touchPos ) );
2800 application.ProcessEvent( event );
2802 // Render and notify
2803 application.SendNotification();
2804 application.Render();
2809 int utcDaliTextEditorUnderPropertyStringP(void)
2811 ToolkitTestApplication application;
2812 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2813 TextEditor editor = TextEditor::New();
2814 DALI_TEST_CHECK( editor );
2816 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2818 application.GetScene().Add( editor );
2820 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2821 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2823 tet_infoline("Set underline settings with a map");
2824 // Check the input underline property
2825 Property::Map underlineMapSet;
2826 Property::Map underlineMapGet;
2827 underlineMapSet.Insert( "enable", true );
2828 underlineMapSet.Insert( "color", Color::BLUE );
2829 underlineMapSet.Insert( "height", 2 );
2831 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2832 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2833 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2834 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2836 tet_infoline("Set underline settings with a string");
2837 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2838 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2841 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2843 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2844 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2845 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2846 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2848 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2853 int utcDaliTextEditorShadowPropertyStringP(void)
2855 ToolkitTestApplication application;
2856 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2858 TextEditor editor = TextEditor::New();
2860 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2862 application.GetScene().Add( editor );
2864 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2866 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2870 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2875 int utcDaliTextEditorFontStylePropertyStringP(void)
2877 ToolkitTestApplication application;
2878 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2880 TextEditor editor = TextEditor::New();
2882 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2884 application.GetScene().Add( editor );
2886 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2888 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2892 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2897 int utcDaliTextEditorGetPropertyLinecountP(void)
2899 ToolkitTestApplication application;
2901 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2905 TextEditor editor = TextEditor::New();
2906 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2907 editor.SetProperty( TextEditor::Property::TEXT,
2908 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2910 application.GetScene().Add( editor );
2912 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2913 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2914 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2916 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
2917 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2918 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2923 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2926 ToolkitTestApplication application;
2927 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2929 TextEditor editor = TextEditor::New();
2930 DALI_TEST_CHECK( editor );
2932 application.GetScene().Add( editor );
2934 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2935 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2936 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2937 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2938 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2939 editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2941 bool startedCalled = false;
2942 bool finishedCalled = false;
2944 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2945 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2947 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2949 // Render and notify
2950 application.SendNotification();
2951 application.Render();
2953 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2954 application.SendNotification();
2955 application.Render(6000);
2957 application.SendNotification();
2958 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2959 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2964 int UtcDaliToolkitTextEditorTextWrapMode(void)
2966 ToolkitTestApplication application;
2967 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2971 TextEditor editor = TextEditor::New();
2972 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
2973 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2975 application.GetScene().Add( editor );
2977 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2978 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2980 application.SendNotification();
2981 application.Render();
2983 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2984 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2986 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2987 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2989 application.SendNotification();
2990 application.Render();
2992 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2993 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2995 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2996 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2998 application.SendNotification();
2999 application.Render();
3001 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3002 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
3004 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
3005 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
3007 application.SendNotification();
3008 application.Render();
3010 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3011 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
3016 int UtcDaliTextEditorSetPaddingProperty(void)
3018 ToolkitTestApplication application;
3019 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
3021 TextEditor editor = TextEditor::New();
3022 DALI_TEST_CHECK( editor );
3023 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3024 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3025 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3026 application.GetScene().Add( editor );
3028 application.SendNotification();
3029 application.Render();
3031 Vector3 originalSize = editor.GetNaturalSize();
3033 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
3035 application.SendNotification();
3036 application.Render();
3038 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
3040 Vector3 paddingAddedSize = editor.GetNaturalSize();
3042 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3044 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3049 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
3051 ToolkitTestApplication application;
3052 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
3054 TextEditor editor = TextEditor::New();
3055 DALI_TEST_CHECK( editor );
3056 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3057 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3058 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3059 application.GetScene().Add( editor );
3061 application.SendNotification();
3062 application.Render();
3064 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3065 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
3067 // Check the enable shift selection property
3068 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
3069 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
3071 application.SendNotification();
3072 application.Render();
3077 int UtcDaliTextEditorEnableGrabHandleProperty(void)
3079 ToolkitTestApplication application;
3080 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
3082 TextEditor editor = TextEditor::New();
3083 DALI_TEST_CHECK( editor );
3084 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3085 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3086 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3087 application.GetScene().Add( editor );
3089 application.SendNotification();
3090 application.Render();
3092 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3093 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
3095 // Check the enable grab handle property
3096 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
3097 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
3099 application.SendNotification();
3100 application.Render();
3105 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
3107 ToolkitTestApplication application;
3108 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
3110 TextEditor editor = TextEditor::New();
3111 DALI_TEST_CHECK( editor );
3112 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3113 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3114 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3115 application.GetScene().Add( editor );
3117 application.SendNotification();
3118 application.Render();
3120 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3121 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
3123 // Check the disable match system language direction property
3124 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
3125 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
3127 application.SendNotification();
3128 application.Render();
3133 int UtcDaliTextEditorGetInputMethodContext(void)
3135 ToolkitTestApplication application;
3136 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
3138 TextEditor editor = TextEditor::New();
3139 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );
3144 int utcDaliTextEditorMaxCharactersReached(void)
3146 ToolkitTestApplication application;
3147 tet_infoline("utcDaliTextEditorMaxCharactersReached");
3149 TextEditor editor = TextEditor::New();
3150 DALI_TEST_CHECK( editor );
3152 application.GetScene().Add( editor );
3154 const int maxNumberOfCharacters = 1;
3155 editor.SetProperty( DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters );
3156 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelTextEditor::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
3158 editor.SetKeyInputFocus();
3160 // connect to the text changed signal.
3161 ConnectionTracker* testTracker = new ConnectionTracker();
3162 DevelTextEditor::MaxLengthReachedSignal( editor ).Connect(&TestMaxLengthReachedCallback);
3163 bool maxLengthReachedSignal = false;
3164 editor.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
3166 gMaxCharactersCallBackCalled = false;
3168 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3169 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3171 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
3172 DALI_TEST_CHECK( maxLengthReachedSignal );
3177 int utcDaliTextEditorInputFiltered(void)
3179 ToolkitTestApplication application;
3180 tet_infoline(" utcDaliTextEditorInputFiltered");
3181 TextEditor editor = TextEditor::New();
3182 DALI_TEST_CHECK(editor);
3184 application.GetScene().Add(editor);
3186 Property::Map inputFilter;
3188 // Only digit is accepted.
3189 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
3191 // Set input filter to TextEditor.
3192 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3194 editor.SetKeyInputFocus();
3196 // connect to the input filtered signal.
3197 ConnectionTracker* testTracker = new ConnectionTracker();
3198 DevelTextEditor::InputFilteredSignal(editor).Connect(&TestInputFilteredCallback);
3199 bool inputFilteredSignal = false;
3200 editor.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
3202 gInputFilteredAcceptedCallbackCalled = false;
3204 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ));
3206 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3207 DALI_TEST_CHECK(inputFilteredSignal);
3209 // Word is rejected.
3210 inputFilter[InputFilter::Property::ACCEPTED] = "";
3211 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
3213 // Set input filter to TextEditor.
3214 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3216 editor.SetKeyInputFocus();
3218 inputFilteredSignal = false;
3219 gInputFilteredRejectedCallbackCalled = false;
3221 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3223 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3224 DALI_TEST_CHECK(inputFilteredSignal);
3229 int UtcDaliTextEditorSelectWholeText(void)
3231 ToolkitTestApplication application;
3232 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3234 TextEditor textEditor = TextEditor::New();
3236 application.GetScene().Add( textEditor );
3238 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3239 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3240 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3242 // Avoid a crash when core load gl resources.
3243 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3245 application.SendNotification();
3246 application.Render();
3248 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3250 DevelTextEditor::SelectWholeText( textEditor );
3252 application.SendNotification();
3253 application.Render();
3255 // Nothing should have been selected. The number of children is still 1
3256 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3258 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3260 application.SendNotification();
3261 application.Render();
3263 DevelTextEditor::SelectWholeText( textEditor );
3265 application.SendNotification();
3266 application.Render();
3268 // Should be 2 children, the stencil and the layer
3269 DALI_TEST_EQUALS( 2u, textEditor.GetChildCount(), TEST_LOCATION );
3271 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3272 Actor stencil = textEditor.GetChildAt( 0u );
3274 // The highlight actor is drawn first, so is the first actor in the list
3275 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3276 DALI_TEST_CHECK( highlight );
3281 int UtcDaliTextEditorSelectText(void)
3283 ToolkitTestApplication application;
3284 tet_infoline(" UtcDaliTextEditorSelectText ");
3286 TextEditor textEditor = TextEditor::New();
3288 application.GetScene().Add( textEditor );
3290 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3291 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3292 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3294 // Avoid a crash when core load gl resources.
3295 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3297 application.SendNotification();
3298 application.Render();
3300 DevelTextEditor::SelectText( textEditor ,0, 5 );
3302 application.SendNotification();
3303 application.Render();
3305 // Nothing is selected
3306 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3307 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3309 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3311 application.SendNotification();
3312 application.Render();
3314 DevelTextEditor::SelectText( textEditor, 0, 5 );
3316 application.SendNotification();
3317 application.Render();
3319 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3320 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3322 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3323 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3325 // world is selected
3326 DevelTextEditor::SelectText( textEditor, 6, 11 );
3328 application.SendNotification();
3329 application.Render();
3331 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3332 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3334 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3335 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3340 int UtcDaliTextEditorSelectNone(void)
3342 ToolkitTestApplication application;
3343 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3345 TextEditor textEditor = TextEditor::New();
3347 application.GetScene().Add( textEditor );
3349 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3350 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3351 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3353 // Avoid a crash when core load gl resources.
3354 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3356 application.SendNotification();
3357 application.Render();
3359 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3361 application.SendNotification();
3362 application.Render();
3364 // Nothing is selected
3365 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3366 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3368 DevelTextEditor::SelectWholeText( textEditor );
3370 application.SendNotification();
3371 application.Render();
3373 // whole text is selected
3374 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3375 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3377 DevelTextEditor::SelectNone( textEditor );
3379 application.SendNotification();
3380 application.Render();
3382 // Nothing is selected
3383 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3384 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3389 int UtcDaliTextEditorSelectRange(void)
3391 ToolkitTestApplication application;
3392 tet_infoline("utcDaliTextEditorSelectRange");
3394 TextEditor textEditor = TextEditor::New();
3395 DALI_TEST_CHECK( textEditor );
3397 application.GetScene().Add( textEditor );
3399 // Avoid a crash when core load gl resources.
3400 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3402 application.SendNotification();
3403 application.Render();
3405 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3407 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_START, 0 );
3408 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_END, 5 );
3410 // Hello is selected
3411 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3412 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3414 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3415 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3420 int UtcDaliTextEditorEnableEditing(void)
3422 ToolkitTestApplication application;
3423 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3425 TextEditor textEditor = TextEditor::New();
3427 application.GetScene().Add( textEditor );
3429 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3430 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3431 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3433 // Avoid a crash when core load gl resources.
3434 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3436 application.SendNotification();
3437 application.Render();
3439 textEditor.SetKeyInputFocus();
3440 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, false );
3441 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3443 // Render and notify
3444 application.SendNotification();
3445 application.Render();
3447 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3448 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3450 textEditor.SetKeyInputFocus();
3451 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
3452 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3454 // Render and notify
3455 application.SendNotification();
3456 application.Render();
3458 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3459 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3464 int UtcDaliTextEditorScrolling(void)
3466 ToolkitTestApplication application;
3467 tet_infoline(" UtcDaliTextEditorScrolling ");
3469 TextEditor textEditor = TextEditor::New();
3470 DALI_TEST_CHECK( textEditor );
3472 application.GetScene().Add( textEditor );
3474 // Avoid a crash when core load gl resources.
3475 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3477 application.SendNotification();
3478 application.Render();
3480 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
3481 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
3482 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
3483 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
3485 application.SendNotification();
3486 application.Render();
3488 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3489 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3492 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
3494 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, TEST_LOCATION );
3495 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3497 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
3499 DALI_TEST_NOT_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, 0.1f, TEST_LOCATION );
3500 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3502 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION , 0.0f);
3503 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION , 0.0f);
3505 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3506 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3511 int UtcDaliToolkitTextEditorFontSizeScale(void)
3513 ToolkitTestApplication application;
3514 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
3516 TextEditor textEditor = TextEditor::New();
3517 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 30.f );
3518 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3519 Vector3 nonScaledSize = textEditor.GetNaturalSize();
3521 TextEditor textEditorScaled = TextEditor::New();
3522 textEditorScaled.SetProperty( TextEditor::Property::POINT_SIZE, 15.f );
3523 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3524 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3525 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
3527 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3529 textEditor.SetProperty( TextEditor::Property::PIXEL_SIZE, 30.f );
3530 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3531 nonScaledSize = textEditor.GetNaturalSize();
3533 textEditorScaled.SetProperty( TextEditor::Property::PIXEL_SIZE, 15.f );
3534 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3535 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3536 scaledSize = textEditorScaled.GetNaturalSize();
3538 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3543 int UtcDaliTextEditorPrimaryCursorPosition(void)
3545 ToolkitTestApplication application;
3546 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
3548 TextEditor textEditor = TextEditor::New();
3550 application.GetScene().Add( textEditor );
3552 textEditor.SetProperty( TextEditor::Property::TEXT, "ABCEF");
3553 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3554 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3555 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3557 // Avoid a crash when core load gl resources.
3558 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3560 textEditor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
3561 application.SendNotification();
3562 application.Render();
3563 textEditor.SetKeyInputFocus();
3565 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3567 // Render and notify
3568 application.SendNotification();
3569 application.Render();
3571 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3572 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3577 int UtcDaliTextEditorLineCountAfterGetNaturalSize(void)
3579 ToolkitTestApplication application;
3580 tet_infoline(" UtcDaliTextEditorLineCountAfterGetNaturalSize ");
3582 TextEditor textEditor = TextEditor::New();
3583 textEditor.SetProperty(TextEditor::Property::TEXT, "A\nB\nC\nD\nE\nF\n");
3584 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3585 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3586 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3587 application.GetScene().Add( textEditor );
3589 application.SendNotification();
3590 application.Render();
3593 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3594 DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3596 textEditor.GetNaturalSize();
3598 // Create a tap event to touch the text editor.
3599 TestGenerateTap( application, 18.0f, 25.0f );
3601 application.SendNotification();
3602 application.Render();
3604 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3605 DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3611 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase(void)
3613 ToolkitTestApplication application;
3615 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase ");
3617 int lineCountBefore =0 ;
3618 int lineCountAfter =0 ;
3620 // Create a text editor
3621 TextEditor textEditor = TextEditor::New();
3622 //Set very large font-size using point-size
3623 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3624 //Specify font-family
3625 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3627 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3628 //Set text longer than width of textEditor
3629 textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3631 application.GetScene().Add( textEditor );
3633 application.SendNotification();
3634 application.Render();
3636 //Failed case is the GetHeightForWidth change LineCount then the scrollor will not arrive to latest line
3637 //GetHeightForWidth is a retrieval method which should not modify object
3638 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3639 textEditor.GetHeightForWidth(200.f);
3641 //This is to simulate focus into text editor after calling GetHeightForWidth
3642 //Create a tap event to touch the text editor.
3643 TestGenerateTap( application, 18.0f, 25.0f );
3645 application.SendNotification();
3646 application.Render();
3648 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3650 //The LineCount must not be changed when calling GetHeightForWidth.
3651 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3656 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase(void)
3658 ToolkitTestApplication application;
3660 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase ");
3662 int lineCountBefore =0 ;
3663 int lineCountAfter =0 ;
3665 // Create a text editor
3666 TextEditor textEditor = TextEditor::New();
3667 //Set very large font-size using point-size
3668 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3669 //Specify font-family
3670 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3672 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3673 //Set text longer than width of textEditor
3674 textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3675 //Set line wrap mode Character
3676 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3678 application.GetScene().Add( textEditor );
3680 application.SendNotification();
3681 application.Render();
3683 //Failed case is the GetHeightForWidth change LineCount which make position of cursor invalid in TextEditor
3684 //GetHeightForWidth is a retrieval method which should not modify object
3685 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3686 textEditor.GetHeightForWidth(200.f);
3688 //This is to simulate focus into text editor after calling GetHeightForWidth
3689 //Create a tap event to touch the text editor.
3690 TestGenerateTap( application, 18.0f, 25.0f );
3692 application.SendNotification();
3693 application.Render();
3695 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3697 //The LineCount must not be changed when calling GetHeightForWidth.
3698 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3703 int utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged(void)
3705 ToolkitTestApplication application;
3707 tet_infoline(" utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged ");
3709 int lineCountBefore =0 ;
3710 int lineCountAfter =0 ;
3712 // Create a text editor
3713 TextEditor textEditor = TextEditor::New();
3714 //Set very large font-size using point-size
3715 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3716 //Specify font-family
3717 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3719 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 100.f ) );
3720 //Set text longer than width of textEditor
3721 textEditor.SetProperty( TextEditor::Property::TEXT, "Short text");
3722 //Set line wrap mode Character
3723 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3725 application.GetScene().Add( textEditor );
3727 application.SendNotification();
3728 application.Render();
3731 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3733 textEditor.SetProperty( TextEditor::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
3734 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3736 // When the text changed, the Line-count should be updated according to new text.
3737 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
3738 DALI_TEST_EQUALS( lineCountBefore ,1, TEST_LOCATION );
3739 DALI_TEST_GREATER( lineCountAfter,1, TEST_LOCATION );
3746 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase(void)
3748 ToolkitTestApplication application;
3750 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase ");
3752 int lineCountBefore =0 ;
3753 int lineCountAfter =0 ;
3755 // Create a text editor
3756 TextEditor textEditor = TextEditor::New();
3757 //Set very large font-size using point-size
3758 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3759 //Specify font-family
3760 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3762 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3763 //Set text longer than width of textEditor
3764 textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3766 application.GetScene().Add( textEditor );
3768 application.SendNotification();
3769 application.Render();
3771 //Failed case is the GetNaturalSize change LineCount then the scrollor will not arrive to latest line
3772 //GetNaturalSize is a retrieval method which should not modify object
3773 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3774 textEditor.GetNaturalSize();
3776 //This is to simulate focus into text editor after calling GetNaturalSize
3777 //Create a tap event to touch the text editor.
3778 TestGenerateTap( application, 18.0f, 25.0f );
3780 application.SendNotification();
3781 application.Render();
3783 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3785 //The LineCount must not be changed when calling GetNaturalSize.
3786 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3791 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase(void)
3793 ToolkitTestApplication application;
3795 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase ");
3797 int lineCountBefore =0 ;
3798 int lineCountAfter =0 ;
3800 // Create a text editor
3801 TextEditor textEditor = TextEditor::New();
3802 //Set very large font-size using point-size
3803 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3804 //Specify font-family
3805 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3807 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3808 //Set text longer than width of textEditor
3809 textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3810 //Set line wrap mode Character
3811 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3813 application.GetScene().Add( textEditor );
3815 application.SendNotification();
3816 application.Render();
3818 //Failed case is the GetNaturalSize change LineCount which make position of cursor invalid in TextEditor
3819 //GetNaturalSize is a retrieval method which should not modify object
3820 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3821 textEditor.GetNaturalSize( );
3823 //This is to simulate focus into text editor after calling GetNaturalSize
3824 //Create a tap event to touch the text editor.
3825 TestGenerateTap( application, 18.0f, 25.0f );
3827 application.SendNotification();
3828 application.Render();
3830 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3832 //The LineCount must not be changed when calling GetNaturalSize.
3833 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3838 int UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize(void)
3840 ToolkitTestApplication application;
3841 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize ");
3843 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3844 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3845 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3847 // Create a text editor
3848 TextEditor textEditor = TextEditor::New();
3850 //Set size to avoid automatic eliding
3851 textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3852 //Set very large font-size using point-size
3853 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 1000) ;
3854 //Specify font-family
3855 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3856 //Set text to check if appear or not
3857 textEditor.SetProperty( TextEditor::Property::TEXT, "A");
3859 application.GetScene().Add( textEditor );
3861 application.SendNotification();
3862 application.Render();
3863 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3864 Vector3 naturalSize = textEditor.GetNaturalSize();
3866 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3867 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3872 int UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases(void)
3874 ToolkitTestApplication application;
3875 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases ");
3877 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3878 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3879 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3881 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3882 // Create a text editor
3883 TextEditor textEditor = TextEditor::New();
3884 //Set size to avoid automatic eliding
3885 textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3886 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3887 textEditor.SetProperty( TextEditor::Property::TEXT, "A");
3889 const int numberOfCases = 6;
3890 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
3892 for (int index=0; index < numberOfCases; index++)
3894 tet_printf(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
3895 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, arrayCases[index]) ;
3896 application.GetScene().Add( textEditor );
3897 application.SendNotification();
3898 application.Render();
3899 naturalSize = textEditor.GetNaturalSize();
3900 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3901 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3908 int UtcDaliTextEditorHyphenWrapMode(void)
3910 ToolkitTestApplication application;
3911 tet_infoline(" UtcDaliTextEditorHyphenWrapMode ");
3914 TextEditor textEditor = TextEditor::New();
3916 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
3918 application.GetScene().Add( textEditor );
3919 application.SendNotification();
3920 application.Render();
3922 textEditor.SetProperty( TextEditor::Property::TEXT, "Hi Experimen" );
3923 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
3924 DALI_TEST_EQUALS( textEditor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::HYPHENATION ), TEST_LOCATION );
3926 application.SendNotification();
3927 application.Render();
3929 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3935 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
3937 textEditor.SetProperty( TextEditor::Property::TEXT, "Hi Experimen" );
3938 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
3939 DALI_TEST_EQUALS( textEditor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::MIXED ), TEST_LOCATION );
3941 application.SendNotification();
3942 application.Render();
3944 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3951 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
3956 int UtcDaliToolkitTextEditorEllipsisPositionProperty(void)
3958 ToolkitTestApplication application;
3959 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty ");
3960 TextEditor textEditor = TextEditor::New();
3962 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Default is END");
3963 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3965 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START");
3966 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
3967 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3969 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE");
3970 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
3971 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3973 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END");
3974 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
3975 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3977 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START using integer");
3978 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 1);
3979 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3981 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE using integer");
3982 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 2);
3983 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3985 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END using integer");
3986 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 0);
3987 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3989 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
3990 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "START");
3991 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3993 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
3994 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "MIDDLE");
3995 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3997 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
3998 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "END");
3999 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4001 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4002 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "start");
4003 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4005 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4006 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "middle");
4007 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4009 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4010 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "end");
4011 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4016 int UtcDaliTextEditorCopyText(void)
4018 ToolkitTestApplication application;
4019 tet_infoline(" UtcDaliTextEditorCopyText ");
4021 TextEditor textEditor = TextEditor::New();
4023 std::string selectedText = "";
4024 std::string copiedText = "";
4026 application.GetScene().Add( textEditor );
4028 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4029 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4030 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4032 // Avoid a crash when core load gl resources.
4033 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4035 application.SendNotification();
4036 application.Render();
4038 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
4040 application.SendNotification();
4041 application.Render();
4043 // Hello is selected
4044 DevelTextEditor::SelectText( textEditor, 0, 5 );
4046 application.SendNotification();
4047 application.Render();
4049 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4050 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4052 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4053 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4056 copiedText = DevelTextEditor::CopyText( textEditor );
4057 DALI_TEST_EQUALS( "Hello", copiedText, TEST_LOCATION );
4059 // world is selected
4060 DevelTextEditor::SelectText( textEditor, 6, 11 );
4062 application.SendNotification();
4063 application.Render();
4065 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4066 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
4068 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
4069 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
4072 copiedText = DevelTextEditor::CopyText( textEditor );
4073 DALI_TEST_EQUALS( "world", copiedText, TEST_LOCATION );
4075 // "lo wo" is selected
4076 DevelTextEditor::SelectText( textEditor, 3, 8 );
4078 application.SendNotification();
4079 application.Render();
4081 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4082 DALI_TEST_EQUALS( "lo wo", selectedText, TEST_LOCATION );
4084 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 3, TEST_LOCATION );
4085 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 8, TEST_LOCATION );
4087 // "lo wo" is copied
4088 copiedText = DevelTextEditor::CopyText( textEditor );
4089 DALI_TEST_EQUALS( "lo wo", copiedText, TEST_LOCATION );
4094 int UtcDaliTextEditorCutText(void)
4096 ToolkitTestApplication application;
4097 tet_infoline(" UtcDaliTextEditorCutText ");
4099 TextEditor textEditor = TextEditor::New();
4101 std::string selectedText = "";
4103 application.GetScene().Add( textEditor );
4105 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4106 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4107 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4109 // Avoid a crash when core load gl resources.
4110 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4112 application.SendNotification();
4113 application.Render();
4115 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
4117 application.SendNotification();
4118 application.Render();
4120 // Hello is selected
4121 DevelTextEditor::SelectText( textEditor, 0, 5 );
4123 application.SendNotification();
4124 application.Render();
4126 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4127 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4129 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4130 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4133 DALI_TEST_EQUALS( "Hello", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4135 application.SendNotification();
4136 application.Render();
4138 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), " world", TEST_LOCATION );
4141 DevelTextEditor::SelectText( textEditor, 0, 2 );
4143 application.SendNotification();
4144 application.Render();
4146 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4147 DALI_TEST_EQUALS( " w", selectedText, TEST_LOCATION );
4149 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4150 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4153 DALI_TEST_EQUALS( " w", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4155 application.SendNotification();
4156 application.Render();
4158 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "orld", TEST_LOCATION );
4160 // Test Cut from the middle
4163 DevelTextEditor::SelectText( textEditor, 1, 3 );
4165 application.SendNotification();
4166 application.Render();
4168 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4169 DALI_TEST_EQUALS( "rl", selectedText, TEST_LOCATION );
4171 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4172 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 3, TEST_LOCATION );
4175 DALI_TEST_EQUALS( "rl", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4177 application.SendNotification();
4178 application.Render();
4180 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "od", TEST_LOCATION );
4182 // Test Cut from the end
4185 DevelTextEditor::SelectText( textEditor, 1, 2 );
4187 application.SendNotification();
4188 application.Render();
4190 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4191 DALI_TEST_EQUALS( "d", selectedText, TEST_LOCATION );
4193 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4194 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4197 DALI_TEST_EQUALS( "d", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4199 application.SendNotification();
4200 application.Render();
4202 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "o", TEST_LOCATION );
4207 int UtcDaliTextEditorPasteText(void)
4209 ToolkitTestApplication application;
4210 tet_infoline(" UtcDaliTextEditorPasteText ");
4212 TextEditor editor = TextEditor::New();
4213 DALI_TEST_CHECK( editor );
4215 application.GetScene().Add( editor );
4217 std::string cutText = "";
4218 std::string copiedText = "";
4220 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4221 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4222 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4223 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4224 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4226 // Avoid a crash when core load gl resources.
4227 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4229 // Render and notify
4230 application.SendNotification();
4231 application.Render();
4233 // Tap on the text editor
4234 TestGenerateTap( application, 3.0f, 25.0f );
4236 // Render and notify
4237 application.SendNotification();
4238 application.Render();
4240 // Move to second line of the text.
4241 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4243 // Render and notify
4244 application.SendNotification();
4245 application.Render();
4247 // Select some text in the right of the current cursor position
4248 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4249 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4250 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4251 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4253 // Render and notify
4254 application.SendNotification();
4255 application.Render();
4257 // Cut the selected text
4258 cutText = DevelTextEditor::CutText(editor);
4260 // Render and notify
4261 application.SendNotification();
4262 application.Render();
4264 DALI_TEST_EQUALS( "wor", cutText, TEST_LOCATION );
4265 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
4267 // Select some text in the left of the current cursor position
4268 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4269 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4270 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4271 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4273 // Render and notify
4274 application.SendNotification();
4275 application.Render();
4277 // Copy the selected text
4278 copiedText = DevelTextEditor::CopyText(editor);
4280 // Render and notify
4281 application.SendNotification();
4282 application.Render();
4284 DALI_TEST_EQUALS( "lo\n", copiedText, TEST_LOCATION );
4285 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
4288 // Move the cursor to the third line
4289 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4290 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4292 // Render and notify
4293 application.SendNotification();
4294 application.Render();
4296 // Paste the selected text at the current cursor position
4297 DevelTextEditor::PasteText(editor);
4299 // Render and notify
4300 application.SendNotification();
4301 application.Render();
4303 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
4307 int UtcDaliTextEditorLineSpacing(void)
4309 ToolkitTestApplication application;
4310 tet_infoline(" UtcDaliTextEditorLineSpacing ");
4312 TextEditor textEditor = TextEditor::New();
4313 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.f ) );
4314 application.GetScene().Add( textEditor );
4315 application.SendNotification();
4316 application.Render();
4318 textEditor.SetProperty( TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3" );
4319 textEditor.SetProperty( DevelTextEditor::Property::LINE_SPACING, 0 );
4321 Vector3 sizeBefore = textEditor.GetNaturalSize();
4323 textEditor.SetProperty( DevelTextEditor::Property::LINE_SPACING, 20 );
4325 //add 20 for each line 20 * 3
4326 DALI_TEST_EQUALS(sizeBefore.height + 60.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4331 int UtcDaliTextEditorMinLineSize(void)
4333 ToolkitTestApplication application;
4334 tet_infoline(" UtcDaliTextEditorMinLineSize ");
4336 TextEditor textEditor = TextEditor::New();
4337 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.f ) );
4338 application.GetScene().Add( textEditor );
4339 application.SendNotification();
4340 application.Render();
4342 textEditor.SetProperty( TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3" );
4343 textEditor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 0 );
4345 Vector3 sizeBefore = textEditor.GetNaturalSize();
4347 textEditor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 60 );
4349 DALI_TEST_NOT_EQUALS( sizeBefore, textEditor.GetNaturalSize(), 0.0f, TEST_LOCATION);
4352 DALI_TEST_EQUALS(180.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4357 int utcDaliTextEditorCursorPositionChangedSignal(void)
4359 ToolkitTestApplication application;
4360 tet_infoline(" utcDaliTextEditorCursorPositionChangedSignal");
4362 TextEditor editor = TextEditor::New();
4363 DALI_TEST_CHECK( editor );
4365 application.GetScene().Add( editor );
4367 // connect to the selection changed signal.
4368 ConnectionTracker* testTracker = new ConnectionTracker();
4369 DevelTextEditor::CursorPositionChangedSignal(editor).Connect(&TestCursorPositionChangedCallback);
4370 bool cursorPositionChangedSignal = false;
4371 editor.ConnectSignal( testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal) );
4373 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4374 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4375 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4376 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4377 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4379 // Avoid a crash when core load gl resources.
4380 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4382 // Render and notify
4383 application.SendNotification();
4384 application.Render();
4386 editor.SetKeyInputFocus();
4388 // Tap on the text editor
4389 TestGenerateTap( application, 3.0f, 25.0f );
4391 // Render and notify
4392 application.SendNotification();
4393 application.Render();
4395 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4396 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4398 gCursorPositionChangedCallbackCalled = false;
4401 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4403 // Render and notify
4404 application.SendNotification();
4405 application.Render();
4407 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4408 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4410 gCursorPositionChangedCallbackCalled = false;
4413 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4415 // Render and notify
4416 application.SendNotification();
4417 application.Render();
4419 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4420 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4422 gCursorPositionChangedCallbackCalled = false;
4424 //delete one character
4425 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4427 // Render and notify
4428 application.SendNotification();
4429 application.Render();
4431 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4432 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4434 gCursorPositionChangedCallbackCalled = false;
4436 editor.SetProperty( TextEditor::Property::TEXT, "Hello" );
4438 // Render and notify
4439 application.SendNotification();
4440 application.Render();
4442 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4443 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4445 gCursorPositionChangedCallbackCalled = false;
4447 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4449 // Render and notify
4450 application.SendNotification();
4451 application.Render();
4453 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4454 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4459 int utcDaliTextEditorGeometryEllipsisStart(void)
4461 ToolkitTestApplication application;
4462 tet_infoline(" utcDaliTextEditorGeometryEllipsisStart");
4464 TextEditor editor = TextEditor::New();
4465 DALI_TEST_CHECK( editor );
4467 application.GetScene().Add( editor );
4469 editor.SetProperty( TextEditor::Property::POINT_SIZE, 7.f );
4470 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4471 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4472 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4473 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4474 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, false );
4475 editor.SetProperty( DevelTextEditor::Property::ELLIPSIS, true );
4476 editor.SetProperty( DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START );
4477 editor.SetProperty( TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4" );
4479 // Avoid a crash when core load gl resources.
4480 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4482 // Render and notify
4483 application.SendNotification();
4484 application.Render();
4486 unsigned int expectedCount = 2;
4487 unsigned int startIndex = 0;
4488 unsigned int endIndex = 24;
4490 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4491 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4493 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4494 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4496 Vector<Vector2> expectedSizes;
4497 Vector<Vector2> expectedPositions;
4499 expectedPositions.PushBack(Vector2(37, 0));
4500 expectedSizes.PushBack(Vector2(20, 25));
4502 expectedPositions.PushBack(Vector2(-1, 25));
4503 expectedSizes.PushBack(Vector2(52, 25));
4505 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4510 int utcDaliTextEditorGeometryEllipsisMiddle(void)
4512 ToolkitTestApplication application;
4513 tet_infoline(" utcDaliTextEditorGeometryEllipsisMiddle");
4515 TextEditor editor = TextEditor::New();
4516 DALI_TEST_CHECK( editor );
4518 application.GetScene().Add( editor );
4520 editor.SetProperty( TextEditor::Property::POINT_SIZE, 7.f );
4521 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4522 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4523 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4524 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4525 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, false );
4526 editor.SetProperty( DevelTextEditor::Property::ELLIPSIS, true );
4527 editor.SetProperty( DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE );
4528 editor.SetProperty( TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4" );
4530 // Avoid a crash when core load gl resources.
4531 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4533 // Render and notify
4534 application.SendNotification();
4535 application.Render();
4537 unsigned int expectedCount = 2;
4538 unsigned int startIndex = 0;
4539 unsigned int endIndex = 24;
4541 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4542 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4544 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4545 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4547 Vector<Vector2> expectedSizes;
4548 Vector<Vector2> expectedPositions;
4550 expectedPositions.PushBack(Vector2(-1, 0));
4551 expectedSizes.PushBack(Vector2(25, 25));
4553 expectedPositions.PushBack(Vector2(-1, 25));
4554 expectedSizes.PushBack(Vector2(52, 25));
4556 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4561 int utcDaliTextEditorGeometryEllipsisEnd(void)
4563 ToolkitTestApplication application;
4564 tet_infoline(" utcDaliTextEditorGeometryEllipsisEnd");
4566 TextEditor editor = TextEditor::New();
4567 DALI_TEST_CHECK( editor );
4569 application.GetScene().Add( editor );
4571 editor.SetProperty( TextEditor::Property::POINT_SIZE, 7.f );
4572 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4573 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4574 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4575 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4576 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, false );
4577 editor.SetProperty( DevelTextEditor::Property::ELLIPSIS, true );
4578 editor.SetProperty( DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END );
4579 editor.SetProperty( TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4" );
4581 // Avoid a crash when core load gl resources.
4582 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4584 // Render and notify
4585 application.SendNotification();
4586 application.Render();
4588 unsigned int expectedCount = 2;
4589 unsigned int startIndex = 0;
4590 unsigned int endIndex = 24;
4592 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4593 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4595 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4596 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4598 Vector<Vector2> expectedSizes;
4599 Vector<Vector2> expectedPositions;
4601 expectedPositions.PushBack(Vector2(-1, 0));
4602 expectedSizes.PushBack(Vector2(59, 25));
4604 expectedPositions.PushBack(Vector2(-1, 25));
4605 expectedSizes.PushBack(Vector2(25, 25));
4607 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4612 int utcDaliTextEditorGeometryRTL(void)
4614 ToolkitTestApplication application;
4615 tet_infoline(" utcDaliTextEditorGeometryRTL");
4617 TextEditor editor = TextEditor::New();
4618 DALI_TEST_CHECK( editor );
4620 application.GetScene().Add( editor );
4622 editor.SetProperty( TextEditor::Property::POINT_SIZE, 7.f );
4623 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4624 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4625 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4626 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4627 editor.SetProperty( TextEditor::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر" );
4629 // Avoid a crash when core load gl resources.
4630 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4632 // Render and notify
4633 application.SendNotification();
4634 application.Render();
4636 unsigned int expectedCount = 4;
4637 unsigned int startIndex = 3;
4638 unsigned int endIndex = 24;
4640 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4641 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4643 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4644 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4646 Vector<Vector2> expectedSizes;
4647 Vector<Vector2> expectedPositions;
4649 expectedPositions.PushBack(Vector2(24, 0));
4650 expectedSizes.PushBack(Vector2(33, 25));
4652 expectedPositions.PushBack(Vector2(-1, 25));
4653 expectedSizes.PushBack(Vector2(52, 25));
4655 expectedPositions.PushBack(Vector2(-1, 50));
4656 expectedSizes.PushBack(Vector2(59, 25));
4658 expectedPositions.PushBack(Vector2(61, 75));
4659 expectedSizes.PushBack(Vector2(37, 25));
4661 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4666 int utcDaliTextEditorGeometryGlyphMiddle(void)
4668 ToolkitTestApplication application;
4669 tet_infoline(" utcDaliTextEditorGeometryGlyphMiddle");
4671 TextEditor editor = TextEditor::New();
4672 DALI_TEST_CHECK( editor );
4674 application.GetScene().Add( editor );
4676 editor.SetProperty( TextEditor::Property::POINT_SIZE, 7.f );
4677 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.f, 200.f ) );
4678 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4679 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4680 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4681 editor.SetProperty( TextEditor::Property::TEXT, "لا تحتوي على لا" );
4683 // Avoid a crash when core load gl resources.
4684 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4686 // Render and notify
4687 application.SendNotification();
4688 application.Render();
4690 unsigned int expectedCount = 1;
4691 unsigned int startIndex = 1;
4692 unsigned int endIndex = 13;
4694 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4695 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4697 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4698 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4700 Vector<Vector2> expectedSizes;
4701 Vector<Vector2> expectedPositions;
4703 expectedPositions.PushBack(Vector2(6, 0));
4704 expectedSizes.PushBack(Vector2(124, 25));
4706 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4711 int utcDaliTextEditorSelectionClearedSignal(void)
4713 ToolkitTestApplication application;
4714 tet_infoline(" utcDaliTextEditorSelectionClearedSignal");
4716 TextEditor editor = TextEditor::New();
4717 DALI_TEST_CHECK( editor );
4719 application.GetScene().Add( editor );
4721 // connect to the selection changed signal.
4722 ConnectionTracker* testTracker = new ConnectionTracker();
4723 DevelTextEditor::SelectionClearedSignal(editor).Connect(&TestSelectionClearedCallback);
4724 bool selectionClearedSignal = false;
4725 editor.ConnectSignal( testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal) );
4727 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4728 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4729 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4730 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4731 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4733 // Avoid a crash when core load gl resources.
4734 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4736 // Render and notify
4737 application.SendNotification();
4738 application.Render();
4740 // Tap on the text editor
4741 TestGenerateTap( application, 3.0f, 25.0f );
4743 // Render and notify
4744 application.SendNotification();
4745 application.Render();
4747 // Move to second line of the text & Select some text in the right of the current cursor position
4748 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4749 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4752 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4754 // Render and notify
4755 application.SendNotification();
4756 application.Render();
4758 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4760 // Render and notify
4761 application.SendNotification();
4762 application.Render();
4764 // Tap on the text editor
4765 TestGenerateTap( application, 3.0f, 25.0f );
4767 // Render and notify
4768 application.SendNotification();
4769 application.Render();
4771 gSelectionClearedCallbackCalled = false;
4773 // Move to second line of the text & select.
4774 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4775 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4778 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4780 // Render and notify
4781 application.SendNotification();
4782 application.Render();
4784 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4786 gSelectionClearedCallbackCalled = false;
4788 // Render and notify
4789 application.SendNotification();
4790 application.Render();
4792 // Move to second line of the text & select.
4793 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4794 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4796 // replace C with selected text
4797 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4799 // Render and notify
4800 application.SendNotification();
4801 application.Render();
4803 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4805 gSelectionClearedCallbackCalled = false;
4807 // Render and notify
4808 application.SendNotification();
4809 application.Render();
4811 DevelTextEditor::SelectText( editor ,1, 3 );
4813 // Render and notify
4814 application.SendNotification();
4815 application.Render();
4817 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4819 // Render and notify
4820 application.SendNotification();
4821 application.Render();
4823 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4825 gSelectionClearedCallbackCalled = false;
4827 DevelTextEditor::SelectText( editor ,1, 3 );
4829 // Render and notify
4830 application.SendNotification();
4831 application.Render();
4834 DevelTextEditor::SelectNone(editor);
4836 // Render and notify
4837 application.SendNotification();
4838 application.Render();
4840 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4845 int utcDaliTextEditorSelectionChangedSignal(void)
4847 ToolkitTestApplication application;
4848 tet_infoline(" utcDaliTextEditorSelectionChangedSignal");
4850 TextEditor editor = TextEditor::New();
4851 DALI_TEST_CHECK( editor );
4853 application.GetScene().Add( editor );
4855 // connect to the selection changed signal.
4856 ConnectionTracker* testTracker = new ConnectionTracker();
4857 DevelTextEditor::SelectionChangedSignal(editor).Connect(&TestSelectionChangedCallback);
4858 bool selectionChangedSignal = false;
4859 editor.ConnectSignal( testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal) );
4861 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4862 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4863 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4864 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4865 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4867 // Avoid a crash when core load gl resources.
4868 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4870 // Render and notify
4871 application.SendNotification();
4872 application.Render();
4874 // Tap on the text editor
4875 TestGenerateTap( application, 3.0f, 25.0f );
4877 // Render and notify
4878 application.SendNotification();
4879 application.Render();
4881 // Move to second line of the text.
4882 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4884 // Render and notify
4885 application.SendNotification();
4886 application.Render();
4888 // Select some text in the right of the current cursor position
4889 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4890 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4892 // Render and notify
4893 application.SendNotification();
4894 application.Render();
4896 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4897 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4899 gSelectionChangedCallbackCalled = false;
4901 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4903 // Render and notify
4904 application.SendNotification();
4905 application.Render();
4907 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4908 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
4909 DALI_TEST_EQUALS(oldSelectionEnd, 7, TEST_LOCATION);
4911 gSelectionChangedCallbackCalled = false;
4913 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4915 // Render and notify
4916 application.SendNotification();
4917 application.Render();
4919 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4920 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
4921 DALI_TEST_EQUALS(oldSelectionEnd, 8, TEST_LOCATION);
4923 gSelectionChangedCallbackCalled = false;
4924 editor.SetKeyInputFocus();
4926 // Render and notify
4927 application.SendNotification();
4928 application.Render();
4930 DevelTextEditor::SelectText( editor ,0, 5 );
4932 application.SendNotification();
4933 application.Render();
4935 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4936 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4938 gSelectionChangedCallbackCalled = false;
4940 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4942 // Render and notify
4943 application.SendNotification();
4944 application.Render();
4946 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4947 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4948 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
4950 gSelectionChangedCallbackCalled = false;
4953 DevelTextEditor::SelectWholeText(editor);
4955 // Render and notify
4956 application.SendNotification();
4957 application.Render();
4959 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4960 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4962 gSelectionChangedCallbackCalled = false;
4965 DevelTextEditor::SelectNone(editor);
4967 // Render and notify
4968 application.SendNotification();
4969 application.Render();
4971 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4972 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4973 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
4979 int utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize(void)
4982 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
4983 //DaliException on vector: "Iterator not inside vector"
4985 ToolkitTestApplication application;
4986 tet_infoline(" utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize");
4988 TextEditor editor = TextEditor::New();
4989 DALI_TEST_CHECK( editor );
4991 application.GetScene().Add( editor );
4993 // Avoid a crash when core load gl resources.
4994 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4996 //Set multilines text
4997 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
4998 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4999 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
5001 //Set ResizePolicy to NaturalSize
5002 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5004 // Render and notify
5005 application.SendNotification();
5006 application.Render();
5008 // Create a tap event to touch the text editor.
5009 TestGenerateTap( application, 5.0f, 5.0f );
5011 // Render and notify
5012 application.SendNotification();
5013 application.Render();
5015 // Set currsor and add character (in first line)
5016 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5017 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5018 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5020 // Render and notify
5021 application.SendNotification();
5022 application.Render();
5024 //Check the changed text and cursor position
5025 DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "Hellod \n World", TEST_LOCATION );
5026 DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 6, TEST_LOCATION );
5028 // Render and notify
5029 application.SendNotification();
5030 application.Render();
5035 int utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize(void)
5038 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5039 //DaliException on vector: "Iterator not inside vector"
5041 ToolkitTestApplication application;
5042 tet_infoline(" utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize");
5044 TextEditor editor = TextEditor::New();
5045 DALI_TEST_CHECK( editor );
5047 application.GetScene().Add( editor );
5049 // Avoid a crash when core load gl resources.
5050 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
5052 //Set multilines text
5053 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5054 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
5055 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
5057 //Set ResizePolicy to NaturalSize
5058 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5061 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5062 application.SendNotification();
5063 application.Render();
5065 // Set focus and remove character
5066 editor.SetKeyInputFocus();
5067 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5069 // Render and notify
5070 application.SendNotification();
5071 application.Render();
5073 //Check the changed text and cursor position
5074 DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "Hell \n World", TEST_LOCATION );
5075 DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
5077 // Render and notify
5078 application.SendNotification();
5079 application.Render();
5084 int utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize(void)
5087 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5088 //DaliException on vector: "Iterator not inside vector"
5090 ToolkitTestApplication application;
5091 tet_infoline(" utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize");
5093 TextEditor editor = TextEditor::New();
5094 DALI_TEST_CHECK( editor );
5096 application.GetScene().Add( editor );
5098 // Avoid a crash when core load gl resources.
5099 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
5101 //Set multilines text
5102 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5103 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
5104 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
5106 //Set ResizePolicy to NaturalSize
5107 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5109 //Select text at initialization (before the first render)
5110 DevelTextEditor::SelectText( editor ,3, 5 );
5112 // Render and notify
5113 application.SendNotification();
5114 application.Render();
5117 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5118 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 ) );
5120 // Render and notify
5121 application.SendNotification();
5122 application.Render();
5124 //Check the changed text and cursor position
5125 DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "Hel \n World", TEST_LOCATION );
5126 DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 3, TEST_LOCATION );
5128 // Render and notify
5129 application.SendNotification();
5130 application.Render();
5136 int utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize(void)
5139 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5140 //DaliException on vector: "Iterator not inside vector"
5142 ToolkitTestApplication application;
5143 tet_infoline(" utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize");
5145 TextEditor editor = TextEditor::New();
5146 DALI_TEST_CHECK( editor );
5148 application.GetScene().Add( editor );
5150 // Avoid a crash when core load gl resources.
5151 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
5153 //Set multilines text
5154 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5155 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
5156 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
5158 //Set ResizePolicy to NaturalSize
5159 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5162 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5163 application.SendNotification();
5164 application.Render();
5166 // Set focus and double enter (new line)
5167 editor.SetKeyInputFocus();
5168 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5169 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5171 // Render and notify
5172 application.SendNotification();
5173 application.Render();
5175 //Check the changed text and cursor position
5176 DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "Hello\n\n \n World", TEST_LOCATION );
5177 DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 7, TEST_LOCATION );
5179 // Render and notify
5180 application.SendNotification();
5181 application.Render();