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>
34 using namespace Toolkit;
36 void dali_texteditor_startup(void)
38 test_return_value = TET_UNDEF;
41 void dali_texteditor_cleanup(void)
43 test_return_value = TET_PASS;
49 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
50 const char* const PROPERTY_NAME_TEXT = "text";
51 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
52 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
53 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
54 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
55 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
56 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
57 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
58 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
59 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
60 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
61 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
62 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
63 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
64 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
65 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
66 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
71 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
72 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
73 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
74 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
75 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
76 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
77 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
78 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
80 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
81 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
82 const char* const PROPERTY_NAME_UNDERLINE = "underline";
83 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
84 const char* const PROPERTY_NAME_SHADOW = "shadow";
85 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
86 const char* const PROPERTY_NAME_EMBOSS = "emboss";
87 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
88 const char* const PROPERTY_NAME_OUTLINE = "outline";
89 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
91 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
92 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
93 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
94 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
95 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
96 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
97 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
98 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
99 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
100 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
101 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
102 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
103 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
104 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
105 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
106 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
107 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
108 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
109 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
110 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
112 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
113 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
115 const float RENDER_FRAME_INTERVAL = 16.66f;
117 const unsigned int DEFAULT_FONT_SIZE = 1152u;
118 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
120 const int KEY_A_CODE = 38;
121 const int KEY_D_CODE = 40;
122 const int KEY_C_CODE = 54;
123 const int KEY_V_CODE = 55;
124 const int KEY_X_CODE = 53;
125 const int KEY_WHITE_SPACE_CODE = 65;
127 const int KEY_SHIFT_MODIFIER = 257;
128 const int KEY_CONTROL_MODIFIER = 258;
130 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
131 const char* HANDLE_LEFT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_left.png";
132 const char* HANDLE_RIGHT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_right.png";
134 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
136 static bool gSelectionChangedCallbackCalled;
137 static uint32_t oldSelectionStart;
138 static uint32_t oldSelectionEnd;
139 static bool gSelectionClearedCallbackCalled;
140 static bool gAnchorClickedCallBackCalled;
141 static bool gAnchorClickedCallBackNotCalled;
142 static bool gTextChangedCallBackCalled;
143 static bool gInputFilteredAcceptedCallbackCalled;
144 static bool gInputFilteredRejectedCallbackCalled;
145 static bool gInputStyleChangedCallbackCalled;
146 static bool gMaxCharactersCallBackCalled;
147 static bool gCursorPositionChangedCallbackCalled;
148 static uint32_t oldCursorPos;
149 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
151 struct CallbackFunctor
153 CallbackFunctor(bool* callbackFlag)
154 : mCallbackFlag( callbackFlag )
160 *mCallbackFlag = true;
165 static void TestSelectionClearedCallback(TextEditor control)
167 tet_infoline(" TestSelectionClearedCallback");
169 gSelectionClearedCallbackCalled = true;
172 static void TestSelectionChangedCallback(TextEditor control, uint32_t oldStart, uint32_t oldEnd)
174 tet_infoline(" TestSelectionChangedCallback");
176 gSelectionChangedCallbackCalled = true;
177 oldSelectionStart = oldStart;
178 oldSelectionEnd = oldEnd;
181 static void TestAnchorClickedCallback(TextEditor control, const char* href, unsigned int hrefLength)
183 tet_infoline(" TestAnchorClickedCallback");
185 gAnchorClickedCallBackNotCalled = false;
187 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
189 gAnchorClickedCallBackCalled = true;
193 static void TestCursorPositionChangedCallback( TextEditor control, unsigned int oldPos )
195 tet_infoline(" TestCursorPositionChangedCallback");
197 gCursorPositionChangedCallbackCalled = true;
198 oldCursorPos = oldPos;
201 static void TestTextChangedCallback( TextEditor control )
203 tet_infoline(" TestTextChangedCallback");
205 gTextChangedCallBackCalled = true;
208 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
210 tet_infoline(" TestInputStyleChangedCallback");
212 gInputStyleChangedCallbackCalled = true;
213 gInputStyleMask = mask;
216 static void TestMaxLengthReachedCallback( TextEditor control )
218 tet_infoline(" TestMaxLengthReachedCallback");
220 gMaxCharactersCallBackCalled = true;
223 static void TestInputFilteredCallback(TextEditor control, Toolkit::InputFilter::Property::Type type)
225 tet_infoline(" TestInputFilteredCallback");
227 if(type == Toolkit::InputFilter::Property::ACCEPTED)
229 gInputFilteredAcceptedCallbackCalled = true;
231 else if(type == Toolkit::InputFilter::Property::REJECTED)
233 gInputFilteredRejectedCallbackCalled = true;
237 // Generate a KeyEvent to send to Core.
238 Integration::KeyEvent GenerateKey( const std::string& keyName,
239 const std::string& logicalKey,
240 const std::string& keyString,
243 unsigned long timeStamp,
244 const Integration::KeyEvent::State& keyState,
245 const std::string& compose = "",
246 const std::string& deviceName = DEFAULT_DEVICE_NAME,
247 const Device::Class::Type& deviceClass = Device::Class::NONE,
248 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
250 return Integration::KeyEvent( keyName,
263 Dali::Integration::Point GetPointDownInside( Vector2& pos )
265 Dali::Integration::Point point;
266 point.SetState( PointState::DOWN );
267 point.SetScreenPosition( pos );
271 Dali::Integration::Point GetPointUpInside( Vector2& pos )
273 Dali::Integration::Point point;
274 point.SetState( PointState::UP );
275 point.SetScreenPosition( pos );
279 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
281 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
283 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
285 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
287 Property::Value* valueSet = NULL;
288 if ( valueGet.first.type == Property::Key::INDEX )
290 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
294 // Get Key is a string so searching Set Map for a string key
295 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
298 if( NULL != valueSet )
300 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
302 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
305 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
307 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
310 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
312 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
315 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
317 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
320 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
322 Vector2 vector2Get = valueGet.second.Get<Vector2>();
323 Vector2 vector2Set = valueSet->Get<Vector2>();
324 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
327 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
329 Vector4 vector4Get = valueGet.second.Get<Vector4>();
330 Vector4 vector4Set = valueSet->Get<Vector4>();
331 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 );
337 if ( valueGet.first.type == Property::Key::INDEX )
339 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
343 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
353 class ScrollStateChangeCallback : public Dali::ConnectionTracker
356 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
357 : mStartedCalled( startedCalled ),
358 mFinishedCalled( finishedCalled )
362 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
364 if( type == TextEditor::Scroll::STARTED )
366 mStartedCalled = true;
368 else if( type == TextEditor::Scroll::FINISHED )
370 mFinishedCalled = true;
374 bool& mStartedCalled;
375 bool& mFinishedCalled;
380 int UtcDaliToolkitTextEditorConstructorP(void)
382 ToolkitTestApplication application;
383 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
384 TextEditor textEditor;
385 DALI_TEST_CHECK( !textEditor );
389 int UtcDaliToolkitTextEditorNewP(void)
391 ToolkitTestApplication application;
392 tet_infoline(" UtcDaliToolkitTextEditorNewP");
393 TextEditor textEditor = TextEditor::New();
394 DALI_TEST_CHECK( textEditor );
398 int UtcDaliToolkitTextEditorDownCastP(void)
400 ToolkitTestApplication application;
401 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
402 TextEditor textEditor1 = TextEditor::New();
403 BaseHandle object( textEditor1 );
405 TextEditor textEditor2 = TextEditor::DownCast( object );
406 DALI_TEST_CHECK( textEditor2 );
408 TextEditor textEditor3 = DownCast< TextEditor >( object );
409 DALI_TEST_CHECK( textEditor3 );
413 int UtcDaliToolkitTextEditorDownCastN(void)
415 ToolkitTestApplication application;
416 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
417 BaseHandle uninitializedObject;
418 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
419 DALI_TEST_CHECK( !textEditor1 );
421 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
422 DALI_TEST_CHECK( !textEditor2 );
426 int UtcDaliToolkitTextEditorCopyConstructorP(void)
428 ToolkitTestApplication application;
429 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
430 TextEditor textEditor = TextEditor::New();
431 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
433 TextEditor copy( textEditor );
434 DALI_TEST_CHECK( copy );
435 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
439 int UtcDaliTextEditorMoveConstructor(void)
441 ToolkitTestApplication application;
443 TextEditor textEditor = TextEditor::New();
444 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
445 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
447 TextEditor moved = std::move( textEditor );
448 DALI_TEST_CHECK( moved );
449 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
450 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
451 DALI_TEST_CHECK( !textEditor );
456 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
458 ToolkitTestApplication application;
459 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
460 TextEditor textEditor = TextEditor::New();
461 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
463 TextEditor copy = textEditor;
464 DALI_TEST_CHECK( copy );
465 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
469 int UtcDaliTextEditorMoveAssignment(void)
471 ToolkitTestApplication application;
473 TextEditor textEditor = TextEditor::New();
474 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
475 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
478 moved = std::move( textEditor );
479 DALI_TEST_CHECK( moved );
480 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
481 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
482 DALI_TEST_CHECK( !textEditor );
487 int UtcDaliTextEditorNewP(void)
489 ToolkitTestApplication application;
490 tet_infoline(" UtcDaliToolkitTextEditorNewP");
491 TextEditor textEditor = TextEditor::New();
492 DALI_TEST_CHECK( textEditor );
496 // Positive test case for a method
497 int UtcDaliTextEditorGetPropertyP(void)
499 ToolkitTestApplication application;
500 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
501 TextEditor editor = TextEditor::New();
502 DALI_TEST_CHECK( editor );
504 // Check Property Indices are correct
505 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextEditor::Property::RENDERING_BACKEND );
506 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
507 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
508 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
509 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
510 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
511 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
512 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
513 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
514 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
515 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
516 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
517 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
518 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
519 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
520 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
521 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
522 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
523 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
524 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
525 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
526 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
527 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
528 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
529 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
530 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
531 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
532 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
533 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
534 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
536 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
537 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
538 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
539 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
540 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
541 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
542 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
543 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
544 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
545 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
546 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
547 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
548 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
549 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
550 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
551 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
552 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
553 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
554 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
555 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextEditor::Property::FONT_SIZE_SCALE );
556 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
557 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
558 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
559 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
560 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
561 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == DevelTextEditor::Property::MAX_LENGTH );
562 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextEditor::Property::GRAB_HANDLE_COLOR );
563 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP );
564 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == DevelTextEditor::Property::INPUT_METHOD_SETTINGS );
565 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FILTER ) == DevelTextEditor::Property::INPUT_FILTER );
570 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
573 Property::Map imageMap;
574 imageMap[mapKey] =mapValue;
576 editor.SetProperty( property , imageMap );
577 Property::Value propValue = editor.GetProperty( property );
578 Property::Map* resultMap = propValue.GetMap();
580 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
588 // Positive test case for a method
589 int UtcDaliTextEditorSetPropertyP(void)
591 ToolkitTestApplication application;
592 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
593 TextEditor editor = TextEditor::New();
594 DALI_TEST_CHECK( editor );
595 application.GetScene().Add( editor );
597 // Note - we can't check the defaults since the stylesheets are platform-specific
599 // Check the render backend property.
600 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
601 DALI_TEST_EQUALS( (DevelText::RenderingType)editor.GetProperty<int>( DevelTextEditor::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
603 // Check text property.
604 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
605 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
607 // Check text's color property
608 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
609 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
611 // Check font properties.
612 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
613 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
615 Property::Map fontStyleMapSet;
616 Property::Map fontStyleMapGet;
617 Property::Value* slantValue = NULL;
619 fontStyleMapSet.Insert( "weight", "bold" );
620 fontStyleMapSet.Insert( "width", "condensed" );
621 fontStyleMapSet.Insert( "slant", "italic" );
623 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
624 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
625 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
626 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
628 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
629 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
631 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 2.5f );
632 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
633 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 1.0f );
636 fontStyleMapSet.Clear();
637 fontStyleMapSet.Insert( "weight", "normal" );
638 fontStyleMapSet.Insert( "slant", "oblique" );
639 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
640 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
641 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
642 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
644 fontStyleMapSet.Clear();
645 fontStyleMapSet.Insert( "slant", "roman" );
646 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
647 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
649 // Replace 'roman' for 'normal'.
650 slantValue = fontStyleMapGet.Find( "slant" );
651 if( NULL != slantValue )
653 if( "normal" == slantValue->Get<std::string>() )
655 fontStyleMapGet["slant"] = "roman";
658 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
659 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
661 fontStyleMapSet.Clear();
663 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
664 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
665 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
666 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
668 // Check that the Alignment properties can be correctly set
669 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
670 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
672 // Check scroll properties.
673 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
674 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
675 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
676 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
678 // Check cursor properties
679 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
680 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
681 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
682 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
684 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
685 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
686 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
687 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
688 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
689 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
690 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
691 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
693 // Check handle images
694 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
695 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
696 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
697 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
698 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
700 // Check handle images
701 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
702 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
703 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
704 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
705 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
706 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
708 // Check the highlight color
709 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
710 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
712 // Decoration bounding box
713 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
714 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
716 // Check the enable markup property.
717 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
718 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
719 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
721 // Check input color property.
722 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
723 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
725 // Check input font properties.
726 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
727 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
729 fontStyleMapSet.Clear();
730 fontStyleMapSet.Insert( "weight", "bold" );
731 fontStyleMapSet.Insert( "width", "condensed" );
732 fontStyleMapSet.Insert( "slant", "italic" );
734 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
735 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
736 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
737 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
739 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
740 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
742 // Reset input font style.
743 fontStyleMapSet.Clear();
744 fontStyleMapSet.Insert( "weight", "normal" );
745 fontStyleMapSet.Insert( "slant", "oblique" );
747 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
748 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
749 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
750 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
752 fontStyleMapSet.Clear();
753 fontStyleMapSet.Insert( "slant", "roman" );
755 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
756 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
758 // Replace 'roman' for 'normal'.
759 slantValue = fontStyleMapGet.Find( "slant" );
760 if( NULL != slantValue )
762 if( "normal" == slantValue->Get<std::string>() )
764 fontStyleMapGet["slant"] = "roman";
767 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
768 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
770 fontStyleMapSet.Clear();
772 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
773 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
774 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
775 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
777 // Check the line spacing property
778 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
779 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
780 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
782 // Check the input line spacing property
783 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
784 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
785 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
787 // Check the underline property
789 Property::Map underlineMapSet;
790 Property::Map underlineMapGet;
792 underlineMapSet.Insert( "enable", true );
793 underlineMapSet.Insert( "color", Color::RED );
794 underlineMapSet.Insert( "height", 1 );
796 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
798 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
799 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
800 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
802 // Check the input underline property
803 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
804 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
806 // Check the shadow property
807 Property::Map shadowMapSet;
808 Property::Map shadowMapGet;
810 shadowMapSet.Insert( "color", Color::GREEN );
811 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
812 shadowMapSet.Insert( "blurRadius", 3.0f );
814 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
816 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
817 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
818 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
820 // Check the input shadow property
821 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
822 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
824 // Check the emboss property
825 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
826 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
828 // Check the input emboss property
829 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
830 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
832 // Check the outline property
834 // Test string type first
835 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
836 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
837 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
839 // Then test the property map type
840 Property::Map outlineMapSet;
841 Property::Map outlineMapGet;
843 outlineMapSet["color"] = Color::RED;
844 outlineMapSet["width"] = 2.0f;
846 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
848 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
849 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
850 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
852 // Check the input outline property
853 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
854 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
856 // Check the smooth scroll property
857 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
858 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
859 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
861 // Check the smooth scroll duration property
862 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
863 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
865 // Check the scroll bar property
866 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
867 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
868 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
870 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
871 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
872 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
873 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
875 // Check the pixel size of font
876 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
877 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
879 // Check placeholder text properties.
880 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
881 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
883 // Check placeholder text's color property.
884 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
885 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
887 // Check the enable selection property
888 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
889 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
891 // Check the placeholder property with pixel size
892 Property::Map placeholderPixelSizeMapSet;
893 Property::Map placeholderPixelSizeMapGet;
894 Property::Map placeholderFontstyleMap;
895 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
896 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
897 placeholderPixelSizeMapSet["color"] = Color::BLUE;
898 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
899 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
901 placeholderFontstyleMap.Insert( "weight", "bold" );
902 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
903 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
905 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
906 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
908 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
909 Property::Map placeholderConversionMap;
910 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
911 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
912 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
913 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
914 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
915 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
917 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
919 // Check the placeholder property with point size
920 Property::Map placeholderMapSet;
921 Property::Map placeholderMapGet;
922 placeholderMapSet["text"] = "Setting Placeholder Text";
923 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
924 placeholderMapSet["color"] = Color::RED;
925 placeholderMapSet["fontFamily"] = "Arial";
926 placeholderMapSet["pointSize"] = 12.0f;
927 // Check the placeholder font style property
928 placeholderFontstyleMap.Clear();
930 placeholderFontstyleMap.Insert( "weight", "bold" );
931 placeholderFontstyleMap.Insert( "width", "condensed" );
932 placeholderFontstyleMap.Insert( "slant", "italic" );
933 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
934 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
936 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
937 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
939 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
940 placeholderConversionMap.Clear();
941 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
942 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
943 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
944 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
945 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
946 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
947 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
950 placeholderFontstyleMap.Clear();
951 placeholderFontstyleMap.Insert( "weight", "normal" );
952 placeholderFontstyleMap.Insert( "slant", "oblique" );
953 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
954 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
956 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
957 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
958 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
959 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
961 placeholderFontstyleMap.Clear();
962 placeholderFontstyleMap.Insert( "slant", "roman" );
963 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
964 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
966 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
968 placeholderFontstyleMap.Clear();
969 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
971 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
972 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
973 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
974 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
975 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
977 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
978 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
980 // Check handle color
981 editor.SetProperty( DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN );
982 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
984 // Test the ENABLE_GRAB_HANDLE_POPUP property
985 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP, false );
986 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP ), false, TEST_LOCATION);
988 // Check the input method setting
989 Property::Map propertyMap;
990 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
991 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
992 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
993 int inputVariation = 1;
994 propertyMap["PANEL_LAYOUT"] = panelLayout;
995 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
996 propertyMap["BUTTON_ACTION"] = buttonAction;
997 propertyMap["VARIATION"] = inputVariation;
998 editor.SetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS, propertyMap );
1000 Property::Value value = editor.GetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS );
1002 DALI_TEST_CHECK( value.Get( map ) );
1005 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
1006 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
1009 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
1010 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
1013 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
1014 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
1017 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
1018 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
1020 // Check the input filter property
1021 Property::Map inputFilterMapSet;
1022 Property::Map inputFilterMapGet;
1023 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1024 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1026 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1028 inputFilterMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::INPUT_FILTER);
1029 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1032 inputFilterMapSet.Clear();
1033 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1035 application.SendNotification();
1036 application.Render();
1038 // Check the line size property
1039 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::MIN_LINE_SIZE ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1040 editor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 50.f );
1041 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::MIN_LINE_SIZE ), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1046 // Positive Atlas Text Renderer test
1047 int utcDaliTextEditorAtlasRenderP(void)
1049 ToolkitTestApplication application;
1050 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
1051 StyleManager styleManager = StyleManager::Get();
1052 styleManager.ApplyDefaultTheme();
1053 TextEditor editor = TextEditor::New();
1054 DALI_TEST_CHECK( editor );
1056 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1058 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1060 application.GetScene().Add( editor );
1064 // Render some text with the shared atlas backend
1065 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1066 application.SendNotification();
1067 application.Render();
1071 tet_result(TET_FAIL);
1076 // Positive test for the anchorClicked signal.
1077 int utcDaliTextEditorAnchorClickedP(void)
1079 ToolkitTestApplication application;
1080 tet_infoline(" utcDaliTextEditorAnchorClickedP");
1081 TextEditor editor = TextEditor::New();
1082 DALI_TEST_CHECK(editor);
1084 application.GetScene().Add(editor);
1086 // connect to the anchor clicked signal.
1087 ConnectionTracker* testTracker = new ConnectionTracker();
1088 DevelTextEditor::AnchorClickedSignal(editor).Connect(&TestAnchorClickedCallback);
1089 bool anchorClickedSignal = false;
1090 editor.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1092 gAnchorClickedCallBackCalled = false;
1093 editor.SetProperty(TextEditor::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1094 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1095 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1096 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1097 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1099 application.SendNotification();
1100 application.Render();
1101 editor.SetKeyInputFocus();
1103 // Create a tap event to touch the text editor.
1104 TestGenerateTap(application, 5.0f, 5.0f);
1105 application.SendNotification();
1106 application.Render();
1108 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1109 DALI_TEST_CHECK(anchorClickedSignal);
1111 gAnchorClickedCallBackNotCalled = true;
1112 // Tap the outside of anchor, callback should not be called.
1113 TestGenerateTap(application, 150.f, 100.f);
1114 application.SendNotification();
1115 application.Render();
1117 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1122 // Positive test for the textChanged signal.
1123 int utcDaliTextEditorTextChangedP(void)
1125 ToolkitTestApplication application;
1126 tet_infoline(" utcDaliTextEditorTextChangedP");
1127 TextEditor editor = TextEditor::New();
1128 DALI_TEST_CHECK( editor );
1130 application.GetScene().Add( editor );
1132 // connect to the text changed signal.
1133 ConnectionTracker* testTracker = new ConnectionTracker();
1134 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
1135 bool textChangedSignal = false;
1136 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1138 gTextChangedCallBackCalled = false;
1139 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
1140 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1141 DALI_TEST_CHECK( textChangedSignal );
1143 application.SendNotification();
1144 editor.SetKeyInputFocus();
1146 gTextChangedCallBackCalled = false;
1147 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1148 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1151 editor.SetProperty( TextField::Property::TEXT, "" );
1153 // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
1154 gTextChangedCallBackCalled = false;
1155 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1156 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1158 // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
1159 gTextChangedCallBackCalled = false;
1160 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1161 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1166 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1168 ToolkitTestApplication application;
1169 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1170 TextEditor editor = TextEditor::New();
1171 DALI_TEST_CHECK( editor );
1174 application.GetScene().Add( editor );
1176 // connect to the text changed signal.
1177 ConnectionTracker* testTracker = new ConnectionTracker();
1178 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1179 bool textChangedSignal = false;
1180 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1183 // get InputMethodContext
1185 InputMethodContext::EventData imfEvent;
1186 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext( editor );
1188 editor.SetKeyInputFocus();
1189 editor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
1192 gTextChangedCallBackCalled = false;
1193 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1194 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1195 application.SendNotification();
1196 application.Render();
1197 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1198 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1200 gTextChangedCallBackCalled = false;
1201 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1202 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1203 application.SendNotification();
1204 application.Render();
1205 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1206 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호"), TEST_LOCATION );
1208 gTextChangedCallBackCalled = false;
1209 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1210 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1211 application.SendNotification();
1212 application.Render();
1213 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1214 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1216 gTextChangedCallBackCalled = false;
1217 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1218 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1219 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1221 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1222 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1223 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1225 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1226 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1227 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1229 application.SendNotification();
1230 application.Render();
1231 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1232 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1238 int utcDaliTextEditorInputStyleChanged01(void)
1240 // The text-editor emits signals when the input style changes. These changes of style are
1241 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1242 // can't be emitted during the size negotiation as the callbacks may update the UI.
1243 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1244 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1245 ToolkitTestApplication application;
1246 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1250 char* pathNamePtr = get_current_dir_name();
1251 const std::string pathName( pathNamePtr );
1252 free( pathNamePtr );
1254 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1255 fontClient.SetDpi( 93u, 93u );
1257 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1258 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1260 TextEditor editor = TextEditor::New();
1261 DALI_TEST_CHECK( editor );
1264 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1265 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1266 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1268 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1269 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1271 // connect to the text changed signal.
1272 ConnectionTracker* testTracker = new ConnectionTracker();
1273 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1274 bool inputStyleChangedSignal = false;
1275 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1277 application.GetScene().Add( editor );
1279 // Render and notify
1280 application.SendNotification();
1281 application.Render();
1283 // Executes the idle callbacks added by the text control on the change of input style.
1284 application.RunIdles();
1286 gInputStyleChangedCallbackCalled = false;
1287 gInputStyleMask = TextEditor::InputStyle::NONE;
1288 inputStyleChangedSignal = false;
1290 // Create a tap event to touch the text editor.
1291 TestGenerateTap( application, 18.0f, 25.0f );
1293 // Render and notify
1294 application.SendNotification();
1295 application.Render();
1297 // Executes the idle callbacks added by the text control on the change of input style.
1298 application.RunIdles();
1300 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1301 if( gInputStyleChangedCallbackCalled )
1303 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1305 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1306 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1308 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1309 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1311 DALI_TEST_CHECK( inputStyleChangedSignal );
1313 gInputStyleChangedCallbackCalled = false;
1314 gInputStyleMask = TextEditor::InputStyle::NONE;
1315 inputStyleChangedSignal = false;
1317 // Create a tap event to touch the text editor.
1318 TestGenerateTap( application, 30.0f, 25.0f );
1320 // Render and notify
1321 application.SendNotification();
1322 application.Render();
1324 // Executes the idle callbacks added by the text control on the change of input style.
1325 application.RunIdles();
1327 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1328 DALI_TEST_CHECK( !inputStyleChangedSignal );
1330 gInputStyleChangedCallbackCalled = false;
1331 gInputStyleMask = TextEditor::InputStyle::NONE;
1332 inputStyleChangedSignal = false;
1334 // Create a tap event to touch the text editor.
1335 TestGenerateTap( application, 43.0f, 25.0f );
1337 // Render and notify
1338 application.SendNotification();
1339 application.Render();
1341 // Executes the idle callbacks added by the text control on the change of input style.
1342 application.RunIdles();
1344 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1345 if( gInputStyleChangedCallbackCalled )
1347 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1349 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1350 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1352 DALI_TEST_CHECK( inputStyleChangedSignal );
1354 gInputStyleChangedCallbackCalled = false;
1355 gInputStyleMask = TextEditor::InputStyle::NONE;
1356 inputStyleChangedSignal = false;
1358 // Create a tap event to touch the text editor.
1359 TestGenerateTap( application, 88.0f, 25.0f );
1361 // Render and notify
1362 application.SendNotification();
1363 application.Render();
1365 // Executes the idle callbacks added by the text control on the change of input style.
1366 application.RunIdles();
1368 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1369 if( gInputStyleChangedCallbackCalled )
1371 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1373 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1374 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1376 Property::Map fontStyleMapSet;
1377 Property::Map fontStyleMapGet;
1379 fontStyleMapSet.Insert( "weight", "bold" );
1381 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1382 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1383 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1385 DALI_TEST_CHECK( inputStyleChangedSignal );
1387 gInputStyleChangedCallbackCalled = false;
1388 gInputStyleMask = TextEditor::InputStyle::NONE;
1389 inputStyleChangedSignal = false;
1391 // Create a tap event to touch the text editor.
1392 TestGenerateTap( application, 115.0f, 25.0f );
1394 // Render and notify
1395 application.SendNotification();
1396 application.Render();
1398 // Executes the idle callbacks added by the text control on the change of input style.
1399 application.RunIdles();
1401 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1402 DALI_TEST_CHECK( !inputStyleChangedSignal );
1404 gInputStyleChangedCallbackCalled = false;
1405 gInputStyleMask = TextEditor::InputStyle::NONE;
1406 inputStyleChangedSignal = false;
1408 // Create a tap event to touch the text editor.
1409 TestGenerateTap( application, 164.0f, 25.0f );
1411 // Render and notify
1412 application.SendNotification();
1413 application.Render();
1415 // Executes the idle callbacks added by the text control on the change of input style.
1416 application.RunIdles();
1418 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1419 if( gInputStyleChangedCallbackCalled )
1421 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1423 Property::Map fontStyleMapSet;
1424 Property::Map fontStyleMapGet;
1426 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1427 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1428 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1430 DALI_TEST_CHECK( inputStyleChangedSignal );
1432 gInputStyleChangedCallbackCalled = false;
1433 gInputStyleMask = TextEditor::InputStyle::NONE;
1434 inputStyleChangedSignal = false;
1436 // Create a tap event to touch the text editor.
1437 TestGenerateTap( application, 191.0f, 25.0f );
1439 // Render and notify
1440 application.SendNotification();
1441 application.Render();
1443 // Executes the idle callbacks added by the text control on the change of input style.
1444 application.RunIdles();
1446 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1447 DALI_TEST_CHECK( !inputStyleChangedSignal );
1452 int utcDaliTextEditorInputStyleChanged02(void)
1454 // The text-editor emits signals when the input style changes. These changes of style are
1455 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1456 // can't be emitted during the size negotiation as the callbacks may update the UI.
1457 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1458 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1459 ToolkitTestApplication application;
1460 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1464 char* pathNamePtr = get_current_dir_name();
1465 const std::string pathName( pathNamePtr );
1466 free( pathNamePtr );
1468 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1469 fontClient.SetDpi( 93u, 93u );
1471 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1472 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1474 TextEditor editor = TextEditor::New();
1475 DALI_TEST_CHECK( editor );
1478 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1479 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1480 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1482 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1483 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>" );
1485 // connect to the text changed signal.
1486 ConnectionTracker* testTracker = new ConnectionTracker();
1487 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1488 bool inputStyleChangedSignal = false;
1489 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1491 application.GetScene().Add( editor );
1493 // Render and notify
1494 application.SendNotification();
1495 application.Render();
1497 // Executes the idle callbacks added by the text control on the change of input style.
1498 application.RunIdles();
1500 gInputStyleChangedCallbackCalled = false;
1501 gInputStyleMask = TextEditor::InputStyle::NONE;
1502 inputStyleChangedSignal = false;
1504 // Create a tap event to touch the text editor.
1505 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1506 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1508 // Render and notify
1509 application.SendNotification();
1510 application.Render();
1512 // Executes the idle callbacks added by the text control on the change of input style.
1513 application.RunIdles();
1515 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1516 if( gInputStyleChangedCallbackCalled )
1518 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1519 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1520 TextEditor::InputStyle::POINT_SIZE |
1521 TextEditor::InputStyle::COLOR ),
1524 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1525 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1527 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1528 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1530 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1531 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1533 DALI_TEST_CHECK( inputStyleChangedSignal );
1535 gInputStyleChangedCallbackCalled = false;
1536 gInputStyleMask = TextEditor::InputStyle::NONE;
1537 inputStyleChangedSignal = false;
1539 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1541 // Render and notify
1542 application.SendNotification();
1543 application.Render();
1545 // Executes the idle callbacks added by the text control on the change of input style.
1546 application.RunIdles();
1548 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1549 if( gInputStyleChangedCallbackCalled )
1551 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1552 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1555 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1556 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1558 DALI_TEST_CHECK( inputStyleChangedSignal );
1560 gInputStyleChangedCallbackCalled = false;
1561 gInputStyleMask = TextEditor::InputStyle::NONE;
1562 inputStyleChangedSignal = false;
1564 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1566 // Render and notify
1567 application.SendNotification();
1568 application.Render();
1570 // Executes the idle callbacks added by the text control on the change of input style.
1571 application.RunIdles();
1573 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1574 DALI_TEST_CHECK( !inputStyleChangedSignal );
1576 gInputStyleChangedCallbackCalled = false;
1577 gInputStyleMask = TextEditor::InputStyle::NONE;
1578 inputStyleChangedSignal = false;
1580 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1582 // Render and notify
1583 application.SendNotification();
1584 application.Render();
1586 // Executes the idle callbacks added by the text control on the change of input style.
1587 application.RunIdles();
1589 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1590 if( gInputStyleChangedCallbackCalled )
1592 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1593 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1596 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1597 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1599 DALI_TEST_CHECK( inputStyleChangedSignal );
1601 gInputStyleChangedCallbackCalled = false;
1602 gInputStyleMask = TextEditor::InputStyle::NONE;
1603 inputStyleChangedSignal = false;
1605 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1607 Property::Map fontStyleMapSet;
1608 fontStyleMapSet.Insert( "weight", "thin" );
1609 fontStyleMapSet.Insert( "width", "condensed" );
1610 fontStyleMapSet.Insert( "slant", "italic" );
1612 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1613 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1614 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1616 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1617 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1618 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1619 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1621 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1623 // Render and notify
1624 application.SendNotification();
1625 application.Render();
1627 // Executes the idle callbacks added by the text control on the change of input style.
1628 application.RunIdles();
1630 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1631 DALI_TEST_CHECK( !inputStyleChangedSignal );
1633 // Create a tap event to touch the text editor.
1634 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1636 // Render and notify
1637 application.SendNotification();
1638 application.Render();
1640 // Executes the idle callbacks added by the text control on the change of input style.
1641 application.RunIdles();
1643 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1644 if( gInputStyleChangedCallbackCalled )
1646 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1647 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1648 TextEditor::InputStyle::POINT_SIZE |
1649 TextEditor::InputStyle::FONT_STYLE |
1650 TextEditor::InputStyle::LINE_SPACING |
1651 TextEditor::InputStyle::UNDERLINE |
1652 TextEditor::InputStyle::SHADOW |
1653 TextEditor::InputStyle::EMBOSS |
1654 TextEditor::InputStyle::OUTLINE ),
1657 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1658 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1660 DALI_TEST_CHECK( inputStyleChangedSignal );
1662 gInputStyleChangedCallbackCalled = false;
1663 gInputStyleMask = TextEditor::InputStyle::NONE;
1664 inputStyleChangedSignal = false;
1666 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1668 fontStyleMapSet.Clear();
1669 fontStyleMapSet.Insert( "weight", "black" );
1670 fontStyleMapSet.Insert( "width", "expanded" );
1671 fontStyleMapSet.Insert( "slant", "oblique" );
1673 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1675 // Create a tap event to touch the text editor.
1676 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1678 // Render and notify
1679 application.SendNotification();
1680 application.Render();
1682 // Executes the idle callbacks added by the text control on the change of input style.
1683 application.RunIdles();
1685 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1686 if( gInputStyleChangedCallbackCalled )
1688 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1689 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1690 TextEditor::InputStyle::POINT_SIZE |
1691 TextEditor::InputStyle::FONT_STYLE ),
1694 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1695 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1697 DALI_TEST_CHECK( inputStyleChangedSignal );
1702 int utcDaliTextEditorEvent01(void)
1704 ToolkitTestApplication application;
1705 tet_infoline(" utcDaliTextEditorEvent01");
1707 // Creates a tap event. After creating a tap event the text editor should
1708 // have the focus and add text with key events should be possible.
1710 TextEditor editor = TextEditor::New();
1711 DALI_TEST_CHECK( editor );
1713 application.GetScene().Add( editor );
1715 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1716 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1717 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1719 // Avoid a crash when core load gl resources.
1720 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1722 // Render and notify
1723 application.SendNotification();
1724 application.Render();
1726 // Add a key event but as the text editor has not the focus it should do nothing.
1727 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1729 // Render and notify
1730 application.SendNotification();
1731 application.Render();
1733 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1735 // Create a tap event to touch the text editor.
1736 TestGenerateTap( application, 150.0f, 25.0f );
1738 // Render and notify
1739 application.SendNotification();
1740 application.Render();
1742 // Now the text editor has the focus, so it can handle the key events.
1743 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1744 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1746 // Render and notify
1747 application.SendNotification();
1748 application.Render();
1750 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1752 // Create a second text editor and send key events to it.
1753 TextEditor editor2 = TextEditor::New();
1755 editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1756 editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1757 editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1758 editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1760 application.GetScene().Add( editor2 );
1762 // Render and notify
1763 application.SendNotification();
1764 application.Render();
1766 // Create a tap event on the second text editor.
1767 TestGenerateTap( application, 150.0f, 125.0f );
1769 // Render and notify
1770 application.SendNotification();
1771 application.Render();
1773 // The second text editor has the focus. It should handle the key events.
1774 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1775 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1777 // Render and notify
1778 application.SendNotification();
1779 application.Render();
1781 // Check the text has been added to the second text editor.
1782 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1787 int utcDaliTextEditorEvent02(void)
1789 ToolkitTestApplication application;
1790 tet_infoline(" utcDaliTextEditorEvent02");
1792 // Checks if the right number of actors are created.
1794 TextEditor editor = TextEditor::New();
1795 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1796 DALI_TEST_CHECK( editor );
1798 application.GetScene().Add( editor );
1800 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1801 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1802 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1804 // Avoid a crash when core load gl resources.
1805 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1807 // Render and notify
1808 application.SendNotification();
1809 application.Render();
1811 // Check there are the expected number of children (the stencil).
1812 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1814 Actor stencil = editor.GetChildAt( 0u );
1816 // Create a tap event to touch the text editor.
1817 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1819 // Render and notify
1820 application.SendNotification();
1821 application.Render();
1823 Actor layer = editor.GetChildAt( 1u );
1824 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1825 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1827 // Now the text editor has the focus, so it can handle the key events.
1828 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1829 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1831 // Render and notify
1832 application.SendNotification();
1833 application.Render();
1835 // Checks the cursor and the renderer have been created.
1836 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1837 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1839 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1840 DALI_TEST_CHECK( cursor );
1842 // The stencil actor has a container with all the actors which contain the text renderers.
1843 Actor container = stencil.GetChildAt( 0u );
1844 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1846 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1847 DALI_TEST_CHECK( renderer );
1850 // Move the cursor and check the position changes.
1851 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1853 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1854 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1856 // Render and notify
1857 application.SendNotification();
1858 application.Render();
1860 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1862 DALI_TEST_CHECK( position2.x < position1.x );
1864 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1865 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1867 // Render and notify
1868 application.SendNotification();
1869 application.Render();
1871 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1873 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1875 // Send some taps and check the cursor positions.
1877 // Try to tap at the beginning.
1878 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1880 // Render and notify
1881 application.SendNotification();
1882 application.Render();
1884 // Cursor position should be the same than position1.
1885 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1887 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1889 // Tap away from the start position.
1890 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1892 // Render and notify
1893 application.SendNotification();
1894 application.Render();
1896 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1898 DALI_TEST_CHECK( position5.x > position4.x );
1900 // Remove all the text.
1901 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1902 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1903 editor.SetProperty( TextEditor::Property::TEXT, "" );
1905 // Render and notify
1906 application.SendNotification();
1907 application.Render();
1909 // Cursor position should be the same than position2.
1910 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1912 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1914 // Should not be a renderer.
1915 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1920 int utcDaliTextEditorEvent03(void)
1922 ToolkitTestApplication application;
1923 tet_infoline(" utcDaliTextEditorEvent03");
1925 // Checks if the highlight actor is created.
1927 TextEditor editor = TextEditor::New();
1928 DALI_TEST_CHECK( editor );
1930 application.GetScene().Add( editor );
1932 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1933 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1934 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1935 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1936 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1938 // Avoid a crash when core load gl resources.
1939 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1941 // Render and notify
1942 application.SendNotification();
1943 application.Render();
1945 // Send some taps and check text controller with clipboard window
1946 Dali::Clipboard clipboard = Clipboard::Get();
1947 clipboard.ShowClipboard();
1948 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1949 clipboard.HideClipboard();
1951 // Render and notify
1952 application.SendNotification();
1953 application.Render();
1955 // Tap first to get the focus.
1956 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1958 // Render and notify
1959 application.SendNotification();
1960 application.Render();
1962 // Double tap to select a word.
1963 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1965 // Render and notify
1966 application.SendNotification();
1967 application.Render();
1969 // The stencil actor should have two actors: the renderer and the highlight actor.
1970 Actor stencil = editor.GetChildAt( 0u );
1972 // Highlight needs to be drawn before text, so should come first in child order
1973 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1974 DALI_TEST_CHECK( highlight );
1976 // The stencil actor has a container with all the actors which contain the text renderers.
1977 Actor container = stencil.GetChildAt( 1u );
1978 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1980 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1981 DALI_TEST_CHECK( renderer );
1984 // Double tap out of bounds
1985 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1986 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1988 // Render and notify
1989 application.SendNotification();
1990 application.Render();
1992 // The stencil actor should have one actors: the renderer actor.
1993 stencil = editor.GetChildAt( 0u );
1995 // The stencil actor has a container with all the actors which contain the text renderers.
1996 container = stencil.GetChildAt( 0u );
1997 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1999 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2000 DALI_TEST_CHECK( renderer );
2004 TestGenerateLongPress(application, 1.0f, 25.0f);
2006 // Render and notify
2007 application.SendNotification();
2008 application.Render();
2011 TestGenerateMiniPan(application);
2013 // Render and notify
2014 application.SendNotification();
2015 application.Render();
2020 int utcDaliTextEditorEvent04(void)
2022 ToolkitTestApplication application;
2023 tet_infoline(" utcDaliTextEditorEvent04");
2025 // Checks if the highlight actor is created.
2027 TextEditor editor = TextEditor::New();
2028 DALI_TEST_CHECK( editor );
2030 application.GetScene().Add( editor );
2032 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
2033 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2034 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2035 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2036 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2038 // Avoid a crash when core load gl resources.
2039 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2041 // Render and notify
2042 application.SendNotification();
2043 application.Render();
2045 // Tap on the text editor
2046 TestGenerateTap( application, 3.0f, 25.0f );
2048 // Render and notify
2049 application.SendNotification();
2050 application.Render();
2052 // Move at the end of the text.
2053 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2054 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2056 // Render and notify
2057 application.SendNotification();
2058 application.Render();
2060 for( unsigned int index = 0u; index < 10u; ++index )
2062 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2063 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2065 // Render and notify
2066 application.SendNotification();
2067 application.Render();
2071 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2073 // Render and notify
2074 application.SendNotification();
2075 application.Render();
2077 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2079 // Add some key events
2080 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2081 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2083 // Render and notify
2084 application.SendNotification();
2085 application.Render();
2087 for( unsigned int index = 0u; index < 10u; ++index )
2089 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2090 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2092 // Render and notify
2093 application.SendNotification();
2094 application.Render();
2098 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2100 // Render and notify
2101 application.SendNotification();
2102 application.Render();
2104 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2109 int utcDaliTextEditorEvent05(void)
2111 ToolkitTestApplication application;
2112 tet_infoline(" utcDaliTextEditorEvent05");
2114 // Checks if the highlight actor is created.
2116 TextEditor editor = TextEditor::New();
2117 DALI_TEST_CHECK( editor );
2119 application.GetScene().Add( editor );
2121 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
2122 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2123 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2124 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2125 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2126 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2127 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
2128 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2129 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
2130 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
2132 // Avoid a crash when core load gl resources.
2133 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2135 // Render and notify
2136 application.SendNotification();
2137 application.Render();
2139 // Tap on the text editor
2140 TestGenerateTap( application, 3.0f, 25.0f );
2142 // Render and notify
2143 application.SendNotification();
2144 application.Render();
2146 // Move at the end of the text.
2147 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2148 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2150 // Render and notify
2151 application.SendNotification();
2152 application.Render();
2154 for( unsigned int index = 0u; index < 10u; ++index )
2157 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2159 // Render and notify
2160 application.SendNotification();
2161 application.Render();
2163 // Modify duration after scroll is enabled
2164 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
2166 // Continuous scroll left to increase coverage
2167 for( unsigned int index = 0u; index < 10u; ++index )
2169 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2171 // Render and notify
2172 application.SendNotification();
2173 application.Render();
2175 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2176 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
2177 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
2178 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2179 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2181 // Press Escape to increase coverage
2182 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2183 application.SendNotification();
2184 application.Render();
2186 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
2191 int utcDaliTextEditorEvent06(void)
2193 ToolkitTestApplication application;
2194 tet_infoline(" utcDaliTextEditorEvent06");
2196 // Checks if the highlight actor is created.
2198 TextEditor editor = TextEditor::New();
2199 DALI_TEST_CHECK( editor );
2201 application.GetScene().Add( editor );
2203 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2204 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2205 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2206 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2207 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2209 // Avoid a crash when core load gl resources.
2210 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2212 // Render and notify
2213 application.SendNotification();
2214 application.Render();
2216 // Tap on the text editor
2217 TestGenerateTap( application, 3.0f, 25.0f );
2219 // Render and notify
2220 application.SendNotification();
2221 application.Render();
2223 // Move to seconds line of the text.
2224 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2226 // Render and notify
2227 application.SendNotification();
2228 application.Render();
2230 float layoutHeight = editor.GetHeightForWidth( 100.f );
2233 // Add another script characters ( glyph height is defferent )
2234 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2235 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2237 // Delete characters
2238 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2239 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2241 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2243 // Render and notify
2244 application.SendNotification();
2245 application.Render();
2247 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2250 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2251 application.SendNotification();
2252 application.Render();
2254 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2255 application.SendNotification();
2256 application.Render();
2258 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2259 application.SendNotification();
2260 application.Render();
2262 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2263 application.SendNotification();
2264 application.Render();
2266 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2267 application.SendNotification();
2268 application.Render();
2270 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2271 application.SendNotification();
2272 application.Render();
2274 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2275 application.SendNotification();
2276 application.Render();
2281 int utcDaliTextEditorEvent07(void)
2283 ToolkitTestApplication application;
2284 tet_infoline(" utcDaliTextEditorEvent07");
2286 // Checks if the highlight actor is created.
2288 TextEditor editor = TextEditor::New();
2289 DALI_TEST_CHECK( editor );
2291 application.GetScene().Add( editor );
2293 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2294 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2295 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2296 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2297 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2299 // Avoid a crash when core load gl resources.
2300 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2302 // Render and notify
2303 application.SendNotification();
2304 application.Render();
2306 // Tap on the text editor
2307 TestGenerateTap( application, 3.0f, 25.0f );
2309 // Render and notify
2310 application.SendNotification();
2311 application.Render();
2313 // Move to second line of the text.
2314 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2316 // Render and notify
2317 application.SendNotification();
2318 application.Render();
2320 // Select some text in the right of the current cursor position
2321 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2322 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 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 ) );
2326 // Render and notify
2327 application.SendNotification();
2328 application.Render();
2330 // Cut the selected text
2331 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2332 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 ) );
2334 // Render and notify
2335 application.SendNotification();
2336 application.Render();
2338 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2340 // Select some text in the left of the current cursor position
2341 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2342 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 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 ) );
2346 // Render and notify
2347 application.SendNotification();
2348 application.Render();
2350 // Copy the selected text
2351 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2352 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 ) );
2354 // Render and notify
2355 application.SendNotification();
2356 application.Render();
2358 // Move the cursor to the third line
2359 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2360 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2362 // Render and notify
2363 application.SendNotification();
2364 application.Render();
2366 // Paste the selected text at the current cursor position
2367 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2368 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 ) );
2370 // Render and notify
2371 application.SendNotification();
2372 application.Render();
2374 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2377 // Disable Shift Selection
2378 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2380 // Test to select some text in the right of the current cursor position
2381 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2382 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 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 ) );
2386 // Render and notify
2387 application.SendNotification();
2388 application.Render();
2390 // Cut the selected text
2391 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2392 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 ) );
2394 // Render and notify
2395 application.SendNotification();
2396 application.Render();
2398 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2399 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2401 // Test to select some text in the left of the current cursor position
2402 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2403 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 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 ) );
2407 // Render and notify
2408 application.SendNotification();
2409 application.Render();
2411 // Copy the selected text
2412 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2413 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 ) );
2415 // Render and notify
2416 application.SendNotification();
2417 application.Render();
2419 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2420 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2423 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 ) );
2425 // Render and notify
2426 application.SendNotification();
2427 application.Render();
2429 // replace text with "c"
2430 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2432 // Render and notify
2433 application.SendNotification();
2434 application.Render();
2437 DALI_TEST_EQUALS( "c", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2440 DevelTextEditor::SelectWholeText(editor);
2442 // Render and notify
2443 application.SendNotification();
2444 application.Render();
2446 // Copy the selected text using logical keys
2447 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2448 application.ProcessEvent( GenerateKey( "ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2450 // Render and notify
2451 application.SendNotification();
2452 application.Render();
2455 DevelTextEditor::SelectNone(editor);
2457 // Render and notify
2458 application.SendNotification();
2459 application.Render();
2461 // Paste the selected using logical keys
2462 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2463 application.ProcessEvent( GenerateKey( "ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2466 DALI_TEST_EQUALS( "cc", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2468 // select all using logical keys
2469 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2470 application.ProcessEvent( GenerateKey( "ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2472 // Render and notify
2473 application.SendNotification();
2474 application.Render();
2476 // cut text using logical keys
2477 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2478 application.ProcessEvent( GenerateKey( "ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2480 // Render and notify
2481 application.SendNotification();
2482 application.Render();
2485 DALI_TEST_EQUALS( "", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2490 int utcDaliTextEditorEvent08(void)
2492 ToolkitTestApplication application;
2493 tet_infoline(" utcDaliTextEditorEvent08");
2495 // Checks if the highlight actor is released correctly.
2497 TextEditor editor = TextEditor::New();
2498 DALI_TEST_CHECK( editor );
2500 application.GetScene().Add( editor );
2502 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2503 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2504 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2505 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2506 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2508 // Avoid a crash when core load gl resources.
2509 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2511 // Render and notify
2512 application.SendNotification();
2513 application.Render();
2515 // Tap on the text editor
2516 TestGenerateTap( application, 3.0f, 25.0f );
2518 // Render and notify
2519 application.SendNotification();
2520 application.Render();
2522 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2523 // Test to select some text in the left of the current cursor position
2524 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2525 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 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 ) );
2529 // Render and notify
2530 application.SendNotification();
2531 application.Render();
2533 // Test to the left selection handle position and the right selection handle position
2534 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2535 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 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 ) );
2539 // Render and notify
2540 application.SendNotification();
2541 application.Render();
2543 // Test to select full text in the left of the current cursor position
2544 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2545 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 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 ) );
2551 // Render and notify
2552 application.SendNotification();
2553 application.Render();
2555 // Test to release the current full text selection
2556 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2557 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2559 // Render and notify
2560 application.SendNotification();
2561 application.Render();
2563 // Test to move the current cursor position correctly
2564 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2566 // Render and notify
2567 application.SendNotification();
2568 application.Render();
2571 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2573 // Render and notify
2574 application.SendNotification();
2575 application.Render();
2577 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2579 // Test to select some text in the right of the current cursor position
2580 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2581 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2582 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2584 // Render and notify
2585 application.SendNotification();
2586 application.Render();
2588 // Test the cursor position with right arrow key
2589 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2591 // Render and notify
2592 application.SendNotification();
2593 application.Render();
2596 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2598 // Render and notify
2599 application.SendNotification();
2600 application.Render();
2602 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2604 // Test to select some text in the left of the current cursor position
2605 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2606 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 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 ) );
2611 // Render and notify
2612 application.SendNotification();
2613 application.Render();
2615 // Test the cursor position with left arrow key
2616 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2618 // Render and notify
2619 application.SendNotification();
2620 application.Render();
2623 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2625 // Render and notify
2626 application.SendNotification();
2627 application.Render();
2629 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2631 // Test to select some text in the right of the current cursor position
2632 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2633 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 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 ) );
2637 // Render and notify
2638 application.SendNotification();
2639 application.Render();
2641 // Test the cursor position with left arrow key
2642 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2644 // Render and notify
2645 application.SendNotification();
2646 application.Render();
2649 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2651 // Render and notify
2652 application.SendNotification();
2653 application.Render();
2655 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2657 // Test to select some text in the left of the current cursor position
2658 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2659 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 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 ) );
2663 // Render and notify
2664 application.SendNotification();
2665 application.Render();
2667 // Test the cursor position with right arrow key
2668 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2670 // Render and notify
2671 application.SendNotification();
2672 application.Render();
2675 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2677 // Render and notify
2678 application.SendNotification();
2679 application.Render();
2681 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2686 int utcDaliTextEditorHandles(void)
2688 ToolkitTestApplication application;
2689 tet_infoline(" utcDaliTextEditorHandles");
2691 TextEditor editor = TextEditor::New();
2692 DALI_TEST_CHECK( editor );
2694 application.GetScene().Add( editor );
2696 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2697 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2698 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2699 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2701 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2702 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2703 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2704 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2706 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2707 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2708 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2710 // Avoid a crash when core load gl resources.
2711 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2713 // Render and notify
2714 application.SendNotification();
2715 application.Render();
2717 // Tap first to get the focus.
2718 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2720 // Render and notify
2721 application.SendNotification();
2722 application.Render();
2724 // Tap to create the grab handle.
2725 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2727 // Render and notify
2728 application.SendNotification();
2729 application.Render();
2731 // Get the active layer where the text's decoration is added.
2732 Actor activeLayer = editor.GetChildAt( 1u );
2734 // Get the handle's actor.
2735 Actor handle = activeLayer.GetChildAt( 1u );
2736 handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2738 // Render and notify
2739 application.SendNotification();
2740 application.Render();
2742 // Touch the grab handle to set it as pressed.
2743 Vector2 touchPos( 10.0f, 50.0f );
2744 Dali::Integration::TouchEvent event;
2745 event = Dali::Integration::TouchEvent();
2746 event.AddPoint( GetPointDownInside( touchPos ) );
2747 application.ProcessEvent( event );
2749 // Render and notify
2750 application.SendNotification();
2751 application.Render();
2753 // Pan the grab handle
2754 uint32_t time = 100;
2755 TestStartPan( application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time );
2756 TestMovePan( application, Vector2(10.0f, 30.0f), time );
2757 TestEndPan( application, Vector2(10.0f, 50.0f), time);
2758 application.SendNotification();
2759 application.Render();
2762 // Release the grab handle.
2763 event = Dali::Integration::TouchEvent();
2764 event.AddPoint( GetPointUpInside( touchPos ) );
2765 application.ProcessEvent( event );
2767 // Render and notify
2768 application.SendNotification();
2769 application.Render();
2771 // Tap first to get the focus.
2772 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2774 // Render and notify
2775 application.SendNotification();
2776 application.Render();
2778 // Double tap to select a word and create the selection handles.
2779 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2781 // Render and notify
2782 application.SendNotification();
2783 application.Render();
2785 touchPos = Vector2( 10.0f, 50.0f );
2787 // Touch the left selection handle to set it as pressed.
2788 event = Dali::Integration::TouchEvent();
2789 event.AddPoint( GetPointDownInside( touchPos ) );
2790 application.ProcessEvent( event );
2792 // Render and notify
2793 application.SendNotification();
2794 application.Render();
2796 // Release the left selection handle.
2797 event = Dali::Integration::TouchEvent();
2798 event.AddPoint( GetPointUpInside( touchPos ) );
2799 application.ProcessEvent( event );
2801 // Render and notify
2802 application.SendNotification();
2803 application.Render();
2808 int utcDaliTextEditorUnderPropertyStringP(void)
2810 ToolkitTestApplication application;
2811 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2812 TextEditor editor = TextEditor::New();
2813 DALI_TEST_CHECK( editor );
2815 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2817 application.GetScene().Add( editor );
2819 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2820 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2822 tet_infoline("Set underline settings with a map");
2823 // Check the input underline property
2824 Property::Map underlineMapSet;
2825 Property::Map underlineMapGet;
2826 underlineMapSet.Insert( "enable", true );
2827 underlineMapSet.Insert( "color", Color::BLUE );
2828 underlineMapSet.Insert( "height", 2 );
2830 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2831 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2832 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2833 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2835 tet_infoline("Set underline settings with a string");
2836 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2837 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2840 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2842 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2843 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2844 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2845 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2847 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2852 int utcDaliTextEditorShadowPropertyStringP(void)
2854 ToolkitTestApplication application;
2855 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2857 TextEditor editor = TextEditor::New();
2859 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2861 application.GetScene().Add( editor );
2863 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2865 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2869 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2874 int utcDaliTextEditorFontStylePropertyStringP(void)
2876 ToolkitTestApplication application;
2877 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2879 TextEditor editor = TextEditor::New();
2881 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2883 application.GetScene().Add( editor );
2885 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2887 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2891 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2896 int utcDaliTextEditorGetPropertyLinecountP(void)
2898 ToolkitTestApplication application;
2900 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2904 TextEditor editor = TextEditor::New();
2905 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2906 editor.SetProperty( TextEditor::Property::TEXT,
2907 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2909 application.GetScene().Add( editor );
2911 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2912 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2913 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2915 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
2916 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2917 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2922 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2925 ToolkitTestApplication application;
2926 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2928 TextEditor editor = TextEditor::New();
2929 DALI_TEST_CHECK( editor );
2931 application.GetScene().Add( editor );
2933 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2934 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2935 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2936 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2937 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2938 editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2940 bool startedCalled = false;
2941 bool finishedCalled = false;
2943 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2944 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2946 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2948 // Render and notify
2949 application.SendNotification();
2950 application.Render();
2952 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2953 application.SendNotification();
2954 application.Render(6000);
2956 application.SendNotification();
2957 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2958 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2963 int UtcDaliToolkitTextEditorTextWrapMode(void)
2965 ToolkitTestApplication application;
2966 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2970 TextEditor editor = TextEditor::New();
2971 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
2972 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2974 application.GetScene().Add( editor );
2976 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2977 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2979 application.SendNotification();
2980 application.Render();
2982 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2983 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2985 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2986 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2988 application.SendNotification();
2989 application.Render();
2991 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2992 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2994 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2995 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2997 application.SendNotification();
2998 application.Render();
3000 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3001 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
3003 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
3004 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
3006 application.SendNotification();
3007 application.Render();
3009 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3010 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
3015 int UtcDaliTextEditorSetPaddingProperty(void)
3017 ToolkitTestApplication application;
3018 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
3020 TextEditor editor = TextEditor::New();
3021 DALI_TEST_CHECK( editor );
3022 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3023 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3024 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3025 application.GetScene().Add( editor );
3027 application.SendNotification();
3028 application.Render();
3030 Vector3 originalSize = editor.GetNaturalSize();
3032 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
3034 application.SendNotification();
3035 application.Render();
3037 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
3039 Vector3 paddingAddedSize = editor.GetNaturalSize();
3041 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3043 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3048 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
3050 ToolkitTestApplication application;
3051 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
3053 TextEditor editor = TextEditor::New();
3054 DALI_TEST_CHECK( editor );
3055 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3056 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3057 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3058 application.GetScene().Add( editor );
3060 application.SendNotification();
3061 application.Render();
3063 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3064 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
3066 // Check the enable shift selection property
3067 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
3068 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
3070 application.SendNotification();
3071 application.Render();
3076 int UtcDaliTextEditorEnableGrabHandleProperty(void)
3078 ToolkitTestApplication application;
3079 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
3081 TextEditor editor = TextEditor::New();
3082 DALI_TEST_CHECK( editor );
3083 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3084 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3085 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3086 application.GetScene().Add( editor );
3088 application.SendNotification();
3089 application.Render();
3091 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3092 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
3094 // Check the enable grab handle property
3095 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
3096 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
3098 application.SendNotification();
3099 application.Render();
3104 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
3106 ToolkitTestApplication application;
3107 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
3109 TextEditor editor = TextEditor::New();
3110 DALI_TEST_CHECK( editor );
3111 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3112 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3113 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3114 application.GetScene().Add( editor );
3116 application.SendNotification();
3117 application.Render();
3119 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3120 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
3122 // Check the disable match system language direction property
3123 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
3124 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
3126 application.SendNotification();
3127 application.Render();
3132 int UtcDaliTextEditorGetInputMethodContext(void)
3134 ToolkitTestApplication application;
3135 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
3137 TextEditor editor = TextEditor::New();
3138 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );
3143 int utcDaliTextEditorMaxCharactersReached(void)
3145 ToolkitTestApplication application;
3146 tet_infoline("utcDaliTextEditorMaxCharactersReached");
3148 TextEditor editor = TextEditor::New();
3149 DALI_TEST_CHECK( editor );
3151 application.GetScene().Add( editor );
3153 const int maxNumberOfCharacters = 1;
3154 editor.SetProperty( DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters );
3155 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelTextEditor::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
3157 editor.SetKeyInputFocus();
3159 // connect to the text changed signal.
3160 ConnectionTracker* testTracker = new ConnectionTracker();
3161 DevelTextEditor::MaxLengthReachedSignal( editor ).Connect(&TestMaxLengthReachedCallback);
3162 bool maxLengthReachedSignal = false;
3163 editor.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
3165 gMaxCharactersCallBackCalled = false;
3167 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3168 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3170 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
3171 DALI_TEST_CHECK( maxLengthReachedSignal );
3176 int utcDaliTextEditorInputFiltered(void)
3178 ToolkitTestApplication application;
3179 tet_infoline(" utcDaliTextEditorInputFiltered");
3180 TextEditor editor = TextEditor::New();
3181 DALI_TEST_CHECK(editor);
3183 application.GetScene().Add(editor);
3185 Property::Map inputFilter;
3187 // Only digit is accepted.
3188 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
3190 // Set input filter to TextEditor.
3191 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3193 editor.SetKeyInputFocus();
3195 // connect to the input filtered signal.
3196 ConnectionTracker* testTracker = new ConnectionTracker();
3197 DevelTextEditor::InputFilteredSignal(editor).Connect(&TestInputFilteredCallback);
3198 bool inputFilteredSignal = false;
3199 editor.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
3201 gInputFilteredAcceptedCallbackCalled = false;
3203 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ));
3205 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3206 DALI_TEST_CHECK(inputFilteredSignal);
3208 // Word is rejected.
3209 inputFilter[InputFilter::Property::ACCEPTED] = "";
3210 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
3212 // Set input filter to TextEditor.
3213 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3215 editor.SetKeyInputFocus();
3217 inputFilteredSignal = false;
3218 gInputFilteredRejectedCallbackCalled = false;
3220 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3222 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3223 DALI_TEST_CHECK(inputFilteredSignal);
3228 int UtcDaliTextEditorSelectWholeText(void)
3230 ToolkitTestApplication application;
3231 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3233 TextEditor textEditor = TextEditor::New();
3235 application.GetScene().Add( textEditor );
3237 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3238 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3239 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3241 // Avoid a crash when core load gl resources.
3242 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3244 application.SendNotification();
3245 application.Render();
3247 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3249 DevelTextEditor::SelectWholeText( textEditor );
3251 application.SendNotification();
3252 application.Render();
3254 // Nothing should have been selected. The number of children is still 1
3255 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3257 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3259 application.SendNotification();
3260 application.Render();
3262 DevelTextEditor::SelectWholeText( textEditor );
3264 application.SendNotification();
3265 application.Render();
3267 // Should be 2 children, the stencil and the layer
3268 DALI_TEST_EQUALS( 2u, textEditor.GetChildCount(), TEST_LOCATION );
3270 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3271 Actor stencil = textEditor.GetChildAt( 0u );
3273 // The highlight actor is drawn first, so is the first actor in the list
3274 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3275 DALI_TEST_CHECK( highlight );
3280 int UtcDaliTextEditorSelectText(void)
3282 ToolkitTestApplication application;
3283 tet_infoline(" UtcDaliTextEditorSelectText ");
3285 TextEditor textEditor = TextEditor::New();
3287 application.GetScene().Add( textEditor );
3289 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3290 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3291 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3293 // Avoid a crash when core load gl resources.
3294 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3296 application.SendNotification();
3297 application.Render();
3299 DevelTextEditor::SelectText( textEditor ,0, 5 );
3301 application.SendNotification();
3302 application.Render();
3304 // Nothing is selected
3305 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3306 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3308 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3310 application.SendNotification();
3311 application.Render();
3313 DevelTextEditor::SelectText( textEditor, 0, 5 );
3315 application.SendNotification();
3316 application.Render();
3318 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3319 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3321 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3322 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3324 // world is selected
3325 DevelTextEditor::SelectText( textEditor, 6, 11 );
3327 application.SendNotification();
3328 application.Render();
3330 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3331 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3333 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3334 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3339 int UtcDaliTextEditorSelectNone(void)
3341 ToolkitTestApplication application;
3342 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3344 TextEditor textEditor = TextEditor::New();
3346 application.GetScene().Add( textEditor );
3348 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3349 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3350 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3352 // Avoid a crash when core load gl resources.
3353 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3355 application.SendNotification();
3356 application.Render();
3358 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3360 application.SendNotification();
3361 application.Render();
3363 // Nothing is selected
3364 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3365 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3367 DevelTextEditor::SelectWholeText( textEditor );
3369 application.SendNotification();
3370 application.Render();
3372 // whole text is selected
3373 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3374 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3376 DevelTextEditor::SelectNone( textEditor );
3378 application.SendNotification();
3379 application.Render();
3381 // Nothing is selected
3382 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3383 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3388 int UtcDaliTextEditorSelectRange(void)
3390 ToolkitTestApplication application;
3391 tet_infoline("utcDaliTextEditorSelectRange");
3393 TextEditor textEditor = TextEditor::New();
3394 DALI_TEST_CHECK( textEditor );
3396 application.GetScene().Add( textEditor );
3398 // Avoid a crash when core load gl resources.
3399 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3401 application.SendNotification();
3402 application.Render();
3404 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3406 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_START, 0 );
3407 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_END, 5 );
3409 // Hello is selected
3410 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3411 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3413 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3414 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3419 int UtcDaliTextEditorEnableEditing(void)
3421 ToolkitTestApplication application;
3422 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3424 TextEditor textEditor = TextEditor::New();
3426 application.GetScene().Add( textEditor );
3428 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3429 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3430 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3432 // Avoid a crash when core load gl resources.
3433 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3435 application.SendNotification();
3436 application.Render();
3438 textEditor.SetKeyInputFocus();
3439 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, false );
3440 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3442 // Render and notify
3443 application.SendNotification();
3444 application.Render();
3446 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3447 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3449 textEditor.SetKeyInputFocus();
3450 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
3451 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3453 // Render and notify
3454 application.SendNotification();
3455 application.Render();
3457 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3458 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3463 int UtcDaliTextEditorScrolling(void)
3465 ToolkitTestApplication application;
3466 tet_infoline(" UtcDaliTextEditorScrolling ");
3468 TextEditor textEditor = TextEditor::New();
3469 DALI_TEST_CHECK( textEditor );
3471 application.GetScene().Add( textEditor );
3473 // Avoid a crash when core load gl resources.
3474 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3476 application.SendNotification();
3477 application.Render();
3479 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
3480 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
3481 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
3482 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
3484 application.SendNotification();
3485 application.Render();
3487 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3488 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3491 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
3493 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, TEST_LOCATION );
3494 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3496 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
3498 DALI_TEST_NOT_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, 0.1f, TEST_LOCATION );
3499 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3501 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION , 0.0f);
3502 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION , 0.0f);
3504 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3505 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3510 int UtcDaliToolkitTextEditorFontSizeScale(void)
3512 ToolkitTestApplication application;
3513 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
3515 TextEditor textEditor = TextEditor::New();
3516 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 30.f );
3517 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3518 Vector3 nonScaledSize = textEditor.GetNaturalSize();
3520 TextEditor textEditorScaled = TextEditor::New();
3521 textEditorScaled.SetProperty( TextEditor::Property::POINT_SIZE, 15.f );
3522 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3523 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3524 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
3526 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3528 textEditor.SetProperty( TextEditor::Property::PIXEL_SIZE, 30.f );
3529 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3530 nonScaledSize = textEditor.GetNaturalSize();
3532 textEditorScaled.SetProperty( TextEditor::Property::PIXEL_SIZE, 15.f );
3533 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3534 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3535 scaledSize = textEditorScaled.GetNaturalSize();
3537 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3542 int UtcDaliTextEditorPrimaryCursorPosition(void)
3544 ToolkitTestApplication application;
3545 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
3547 TextEditor textEditor = TextEditor::New();
3549 application.GetScene().Add( textEditor );
3551 textEditor.SetProperty( TextEditor::Property::TEXT, "ABCEF");
3552 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3553 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3554 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3556 // Avoid a crash when core load gl resources.
3557 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3559 textEditor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
3560 application.SendNotification();
3561 application.Render();
3562 textEditor.SetKeyInputFocus();
3564 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3566 // Render and notify
3567 application.SendNotification();
3568 application.Render();
3570 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3571 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3576 int UtcDaliTextEditorLineCountAfterGetNaturalSize(void)
3578 ToolkitTestApplication application;
3579 tet_infoline(" UtcDaliTextEditorLineCountAfterGetNaturalSize ");
3581 TextEditor textEditor = TextEditor::New();
3582 textEditor.SetProperty(TextEditor::Property::TEXT, "A\nB\nC\nD\nE\nF\n");
3583 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3584 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3585 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3586 application.GetScene().Add( textEditor );
3588 application.SendNotification();
3589 application.Render();
3592 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3593 DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3595 textEditor.GetNaturalSize();
3597 // Create a tap event to touch the text editor.
3598 TestGenerateTap( application, 18.0f, 25.0f );
3600 application.SendNotification();
3601 application.Render();
3603 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3604 DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3610 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase(void)
3612 ToolkitTestApplication application;
3614 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase ");
3616 int lineCountBefore =0 ;
3617 int lineCountAfter =0 ;
3619 // Create a text editor
3620 TextEditor textEditor = TextEditor::New();
3621 //Set very large font-size using point-size
3622 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3623 //Specify font-family
3624 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3626 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3627 //Set text longer than width of textEditor
3628 textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3630 application.GetScene().Add( textEditor );
3632 application.SendNotification();
3633 application.Render();
3635 //Failed case is the GetHeightForWidth change LineCount then the scrollor will not arrive to latest line
3636 //GetHeightForWidth is a retrieval method which should not modify object
3637 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3638 textEditor.GetHeightForWidth(200.f);
3640 //This is to simulate focus into text editor after calling GetHeightForWidth
3641 //Create a tap event to touch the text editor.
3642 TestGenerateTap( application, 18.0f, 25.0f );
3644 application.SendNotification();
3645 application.Render();
3647 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3649 //The LineCount must not be changed when calling GetHeightForWidth.
3650 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3655 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase(void)
3657 ToolkitTestApplication application;
3659 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase ");
3661 int lineCountBefore =0 ;
3662 int lineCountAfter =0 ;
3664 // Create a text editor
3665 TextEditor textEditor = TextEditor::New();
3666 //Set very large font-size using point-size
3667 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3668 //Specify font-family
3669 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3671 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3672 //Set text longer than width of textEditor
3673 textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3674 //Set line wrap mode Character
3675 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3677 application.GetScene().Add( textEditor );
3679 application.SendNotification();
3680 application.Render();
3682 //Failed case is the GetHeightForWidth change LineCount which make position of cursor invalid in TextEditor
3683 //GetHeightForWidth is a retrieval method which should not modify object
3684 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3685 textEditor.GetHeightForWidth(200.f);
3687 //This is to simulate focus into text editor after calling GetHeightForWidth
3688 //Create a tap event to touch the text editor.
3689 TestGenerateTap( application, 18.0f, 25.0f );
3691 application.SendNotification();
3692 application.Render();
3694 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3696 //The LineCount must not be changed when calling GetHeightForWidth.
3697 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3702 int utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged(void)
3704 ToolkitTestApplication application;
3706 tet_infoline(" utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged ");
3708 int lineCountBefore =0 ;
3709 int lineCountAfter =0 ;
3711 // Create a text editor
3712 TextEditor textEditor = TextEditor::New();
3713 //Set very large font-size using point-size
3714 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3715 //Specify font-family
3716 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3718 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 100.f ) );
3719 //Set text longer than width of textEditor
3720 textEditor.SetProperty( TextEditor::Property::TEXT, "Short text");
3721 //Set line wrap mode Character
3722 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3724 application.GetScene().Add( textEditor );
3726 application.SendNotification();
3727 application.Render();
3730 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3732 textEditor.SetProperty( TextEditor::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
3733 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3735 // When the text changed, the Line-count should be updated according to new text.
3736 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
3737 DALI_TEST_EQUALS( lineCountBefore ,1, TEST_LOCATION );
3738 DALI_TEST_GREATER( lineCountAfter,1, TEST_LOCATION );
3745 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase(void)
3747 ToolkitTestApplication application;
3749 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase ");
3751 int lineCountBefore =0 ;
3752 int lineCountAfter =0 ;
3754 // Create a text editor
3755 TextEditor textEditor = TextEditor::New();
3756 //Set very large font-size using point-size
3757 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3758 //Specify font-family
3759 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3761 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3762 //Set text longer than width of textEditor
3763 textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3765 application.GetScene().Add( textEditor );
3767 application.SendNotification();
3768 application.Render();
3770 //Failed case is the GetNaturalSize change LineCount then the scrollor will not arrive to latest line
3771 //GetNaturalSize is a retrieval method which should not modify object
3772 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3773 textEditor.GetNaturalSize();
3775 //This is to simulate focus into text editor after calling GetNaturalSize
3776 //Create a tap event to touch the text editor.
3777 TestGenerateTap( application, 18.0f, 25.0f );
3779 application.SendNotification();
3780 application.Render();
3782 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3784 //The LineCount must not be changed when calling GetNaturalSize.
3785 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3790 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase(void)
3792 ToolkitTestApplication application;
3794 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase ");
3796 int lineCountBefore =0 ;
3797 int lineCountAfter =0 ;
3799 // Create a text editor
3800 TextEditor textEditor = TextEditor::New();
3801 //Set very large font-size using point-size
3802 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3803 //Specify font-family
3804 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3806 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3807 //Set text longer than width of textEditor
3808 textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3809 //Set line wrap mode Character
3810 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3812 application.GetScene().Add( textEditor );
3814 application.SendNotification();
3815 application.Render();
3817 //Failed case is the GetNaturalSize change LineCount which make position of cursor invalid in TextEditor
3818 //GetNaturalSize is a retrieval method which should not modify object
3819 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3820 textEditor.GetNaturalSize( );
3822 //This is to simulate focus into text editor after calling GetNaturalSize
3823 //Create a tap event to touch the text editor.
3824 TestGenerateTap( application, 18.0f, 25.0f );
3826 application.SendNotification();
3827 application.Render();
3829 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3831 //The LineCount must not be changed when calling GetNaturalSize.
3832 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3837 int UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize(void)
3839 ToolkitTestApplication application;
3840 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize ");
3842 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3843 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3844 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3846 // Create a text editor
3847 TextEditor textEditor = TextEditor::New();
3849 //Set size to avoid automatic eliding
3850 textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3851 //Set very large font-size using point-size
3852 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 1000) ;
3853 //Specify font-family
3854 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3855 //Set text to check if appear or not
3856 textEditor.SetProperty( TextEditor::Property::TEXT, "A");
3858 application.GetScene().Add( textEditor );
3860 application.SendNotification();
3861 application.Render();
3862 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3863 Vector3 naturalSize = textEditor.GetNaturalSize();
3865 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3866 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3871 int UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases(void)
3873 ToolkitTestApplication application;
3874 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases ");
3876 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3877 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3878 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3880 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3881 // Create a text editor
3882 TextEditor textEditor = TextEditor::New();
3883 //Set size to avoid automatic eliding
3884 textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3885 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3886 textEditor.SetProperty( TextEditor::Property::TEXT, "A");
3888 const int numberOfCases = 6;
3889 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
3891 for (int index=0; index < numberOfCases; index++)
3893 tet_printf(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
3894 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, arrayCases[index]) ;
3895 application.GetScene().Add( textEditor );
3896 application.SendNotification();
3897 application.Render();
3898 naturalSize = textEditor.GetNaturalSize();
3899 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3900 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3907 int UtcDaliTextEditorHyphenWrapMode(void)
3909 ToolkitTestApplication application;
3910 tet_infoline(" UtcDaliTextEditorHyphenWrapMode ");
3913 TextEditor textEditor = TextEditor::New();
3915 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
3917 application.GetScene().Add( textEditor );
3918 application.SendNotification();
3919 application.Render();
3921 textEditor.SetProperty( TextEditor::Property::TEXT, "Hi Experimen" );
3922 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
3923 DALI_TEST_EQUALS( textEditor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::HYPHENATION ), TEST_LOCATION );
3925 application.SendNotification();
3926 application.Render();
3928 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3934 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
3936 textEditor.SetProperty( TextEditor::Property::TEXT, "Hi Experimen" );
3937 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
3938 DALI_TEST_EQUALS( textEditor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::MIXED ), TEST_LOCATION );
3940 application.SendNotification();
3941 application.Render();
3943 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3950 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
3955 int UtcDaliToolkitTextEditorEllipsisPositionProperty(void)
3957 ToolkitTestApplication application;
3958 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty ");
3959 TextEditor textEditor = TextEditor::New();
3961 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Default is END");
3962 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3964 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START");
3965 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
3966 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3968 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE");
3969 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
3970 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3972 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END");
3973 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
3974 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3976 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START using integer");
3977 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 1);
3978 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3980 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE using integer");
3981 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 2);
3982 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3984 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END using integer");
3985 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 0);
3986 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3988 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
3989 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "START");
3990 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3992 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
3993 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "MIDDLE");
3994 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3996 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
3997 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "END");
3998 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4000 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4001 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "start");
4002 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4004 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4005 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "middle");
4006 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4008 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4009 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "end");
4010 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4015 int UtcDaliTextEditorCopyText(void)
4017 ToolkitTestApplication application;
4018 tet_infoline(" UtcDaliTextEditorCopyText ");
4020 TextEditor textEditor = TextEditor::New();
4022 std::string selectedText = "";
4023 std::string copiedText = "";
4025 application.GetScene().Add( textEditor );
4027 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4028 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4029 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4031 // Avoid a crash when core load gl resources.
4032 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4034 application.SendNotification();
4035 application.Render();
4037 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
4039 application.SendNotification();
4040 application.Render();
4042 // Hello is selected
4043 DevelTextEditor::SelectText( textEditor, 0, 5 );
4045 application.SendNotification();
4046 application.Render();
4048 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4049 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4051 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4052 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4055 copiedText = DevelTextEditor::CopyText( textEditor );
4056 DALI_TEST_EQUALS( "Hello", copiedText, TEST_LOCATION );
4058 // world is selected
4059 DevelTextEditor::SelectText( textEditor, 6, 11 );
4061 application.SendNotification();
4062 application.Render();
4064 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4065 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
4067 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
4068 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
4071 copiedText = DevelTextEditor::CopyText( textEditor );
4072 DALI_TEST_EQUALS( "world", copiedText, TEST_LOCATION );
4074 // "lo wo" is selected
4075 DevelTextEditor::SelectText( textEditor, 3, 8 );
4077 application.SendNotification();
4078 application.Render();
4080 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4081 DALI_TEST_EQUALS( "lo wo", selectedText, TEST_LOCATION );
4083 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 3, TEST_LOCATION );
4084 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 8, TEST_LOCATION );
4086 // "lo wo" is copied
4087 copiedText = DevelTextEditor::CopyText( textEditor );
4088 DALI_TEST_EQUALS( "lo wo", copiedText, TEST_LOCATION );
4093 int UtcDaliTextEditorCutText(void)
4095 ToolkitTestApplication application;
4096 tet_infoline(" UtcDaliTextEditorCutText ");
4098 TextEditor textEditor = TextEditor::New();
4100 std::string selectedText = "";
4102 application.GetScene().Add( textEditor );
4104 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4105 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4106 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4108 // Avoid a crash when core load gl resources.
4109 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4111 application.SendNotification();
4112 application.Render();
4114 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
4116 application.SendNotification();
4117 application.Render();
4119 // Hello is selected
4120 DevelTextEditor::SelectText( textEditor, 0, 5 );
4122 application.SendNotification();
4123 application.Render();
4125 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4126 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4128 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4129 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4132 DALI_TEST_EQUALS( "Hello", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4134 application.SendNotification();
4135 application.Render();
4137 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), " world", TEST_LOCATION );
4140 DevelTextEditor::SelectText( textEditor, 0, 2 );
4142 application.SendNotification();
4143 application.Render();
4145 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4146 DALI_TEST_EQUALS( " w", selectedText, TEST_LOCATION );
4148 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4149 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4152 DALI_TEST_EQUALS( " w", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4154 application.SendNotification();
4155 application.Render();
4157 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "orld", TEST_LOCATION );
4159 // Test Cut from the middle
4162 DevelTextEditor::SelectText( textEditor, 1, 3 );
4164 application.SendNotification();
4165 application.Render();
4167 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4168 DALI_TEST_EQUALS( "rl", selectedText, TEST_LOCATION );
4170 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4171 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 3, TEST_LOCATION );
4174 DALI_TEST_EQUALS( "rl", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4176 application.SendNotification();
4177 application.Render();
4179 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "od", TEST_LOCATION );
4181 // Test Cut from the end
4184 DevelTextEditor::SelectText( textEditor, 1, 2 );
4186 application.SendNotification();
4187 application.Render();
4189 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4190 DALI_TEST_EQUALS( "d", selectedText, TEST_LOCATION );
4192 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4193 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4196 DALI_TEST_EQUALS( "d", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4198 application.SendNotification();
4199 application.Render();
4201 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "o", TEST_LOCATION );
4206 int UtcDaliTextEditorPasteText(void)
4208 ToolkitTestApplication application;
4209 tet_infoline(" UtcDaliTextEditorPasteText ");
4211 TextEditor editor = TextEditor::New();
4212 DALI_TEST_CHECK( editor );
4214 application.GetScene().Add( editor );
4216 std::string cutText = "";
4217 std::string copiedText = "";
4219 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4220 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4221 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4222 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4223 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4225 // Avoid a crash when core load gl resources.
4226 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4228 // Render and notify
4229 application.SendNotification();
4230 application.Render();
4232 // Tap on the text editor
4233 TestGenerateTap( application, 3.0f, 25.0f );
4235 // Render and notify
4236 application.SendNotification();
4237 application.Render();
4239 // Move to second line of the text.
4240 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4242 // Render and notify
4243 application.SendNotification();
4244 application.Render();
4246 // Select some text in the right of the current cursor position
4247 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4248 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 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 ) );
4252 // Render and notify
4253 application.SendNotification();
4254 application.Render();
4256 // Cut the selected text
4257 cutText = DevelTextEditor::CutText(editor);
4259 // Render and notify
4260 application.SendNotification();
4261 application.Render();
4263 DALI_TEST_EQUALS( "wor", cutText, TEST_LOCATION );
4264 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
4266 // Select some text in the left of the current cursor position
4267 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4268 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 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 ) );
4272 // Render and notify
4273 application.SendNotification();
4274 application.Render();
4276 // Copy the selected text
4277 copiedText = DevelTextEditor::CopyText(editor);
4279 // Render and notify
4280 application.SendNotification();
4281 application.Render();
4283 DALI_TEST_EQUALS( "lo\n", copiedText, TEST_LOCATION );
4284 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
4287 // Move the cursor to the third line
4288 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4289 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4291 // Render and notify
4292 application.SendNotification();
4293 application.Render();
4295 // Paste the selected text at the current cursor position
4296 DevelTextEditor::PasteText(editor);
4298 // Render and notify
4299 application.SendNotification();
4300 application.Render();
4302 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
4306 int UtcDaliTextEditorLineSpacing(void)
4308 ToolkitTestApplication application;
4309 tet_infoline(" UtcDaliTextEditorLineSpacing ");
4311 TextEditor textEditor = TextEditor::New();
4312 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.f ) );
4313 application.GetScene().Add( textEditor );
4314 application.SendNotification();
4315 application.Render();
4317 textEditor.SetProperty( TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3" );
4318 textEditor.SetProperty( DevelTextEditor::Property::LINE_SPACING, 0 );
4320 Vector3 sizeBefore = textEditor.GetNaturalSize();
4322 textEditor.SetProperty( DevelTextEditor::Property::LINE_SPACING, 20 );
4324 //add 20 for each line 20 * 3
4325 DALI_TEST_EQUALS(sizeBefore.height + 60.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4330 int UtcDaliTextEditorMinLineSize(void)
4332 ToolkitTestApplication application;
4333 tet_infoline(" UtcDaliTextEditorMinLineSize ");
4335 TextEditor textEditor = TextEditor::New();
4336 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.f ) );
4337 application.GetScene().Add( textEditor );
4338 application.SendNotification();
4339 application.Render();
4341 textEditor.SetProperty( TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3" );
4342 textEditor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 0 );
4344 Vector3 sizeBefore = textEditor.GetNaturalSize();
4346 textEditor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 60 );
4348 DALI_TEST_NOT_EQUALS( sizeBefore, textEditor.GetNaturalSize(), 0.0f, TEST_LOCATION);
4351 DALI_TEST_EQUALS(180.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4356 int utcDaliTextEditorCursorPositionChangedSignal(void)
4358 ToolkitTestApplication application;
4359 tet_infoline(" utcDaliTextEditorCursorPositionChangedSignal");
4361 TextEditor editor = TextEditor::New();
4362 DALI_TEST_CHECK( editor );
4364 application.GetScene().Add( editor );
4366 // connect to the selection changed signal.
4367 ConnectionTracker* testTracker = new ConnectionTracker();
4368 DevelTextEditor::CursorPositionChangedSignal(editor).Connect(&TestCursorPositionChangedCallback);
4369 bool cursorPositionChangedSignal = false;
4370 editor.ConnectSignal( testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal) );
4372 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4373 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4374 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4375 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4376 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4378 // Avoid a crash when core load gl resources.
4379 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4381 // Render and notify
4382 application.SendNotification();
4383 application.Render();
4385 editor.SetKeyInputFocus();
4387 // Tap on the text editor
4388 TestGenerateTap( application, 3.0f, 25.0f );
4390 // Render and notify
4391 application.SendNotification();
4392 application.Render();
4394 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4395 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4397 gCursorPositionChangedCallbackCalled = false;
4400 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4402 // Render and notify
4403 application.SendNotification();
4404 application.Render();
4406 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4407 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4409 gCursorPositionChangedCallbackCalled = false;
4412 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4414 // Render and notify
4415 application.SendNotification();
4416 application.Render();
4418 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4419 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4421 gCursorPositionChangedCallbackCalled = false;
4423 //delete one character
4424 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4426 // Render and notify
4427 application.SendNotification();
4428 application.Render();
4430 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4431 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4433 gCursorPositionChangedCallbackCalled = false;
4435 editor.SetProperty( TextEditor::Property::TEXT, "Hello" );
4437 // Render and notify
4438 application.SendNotification();
4439 application.Render();
4441 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4442 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4444 gCursorPositionChangedCallbackCalled = false;
4446 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4448 // Render and notify
4449 application.SendNotification();
4450 application.Render();
4452 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4453 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4458 int utcDaliTextEditorSelectionClearedSignal(void)
4460 ToolkitTestApplication application;
4461 tet_infoline(" utcDaliTextEditorSelectionClearedSignal");
4463 TextEditor editor = TextEditor::New();
4464 DALI_TEST_CHECK( editor );
4466 application.GetScene().Add( editor );
4468 // connect to the selection changed signal.
4469 ConnectionTracker* testTracker = new ConnectionTracker();
4470 DevelTextEditor::SelectionClearedSignal(editor).Connect(&TestSelectionClearedCallback);
4471 bool selectionClearedSignal = false;
4472 editor.ConnectSignal( testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal) );
4474 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4475 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4476 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4477 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4478 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4480 // Avoid a crash when core load gl resources.
4481 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4483 // Render and notify
4484 application.SendNotification();
4485 application.Render();
4487 // Tap on the text editor
4488 TestGenerateTap( application, 3.0f, 25.0f );
4490 // Render and notify
4491 application.SendNotification();
4492 application.Render();
4494 // Move to second line of the text & Select some text in the right of the current cursor position
4495 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4496 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4499 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4501 // Render and notify
4502 application.SendNotification();
4503 application.Render();
4505 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4507 // Render and notify
4508 application.SendNotification();
4509 application.Render();
4511 // Tap on the text editor
4512 TestGenerateTap( application, 3.0f, 25.0f );
4514 // Render and notify
4515 application.SendNotification();
4516 application.Render();
4518 gSelectionClearedCallbackCalled = false;
4520 // Move to second line of the text & select.
4521 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4522 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4525 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4527 // Render and notify
4528 application.SendNotification();
4529 application.Render();
4531 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4533 gSelectionClearedCallbackCalled = false;
4535 // Render and notify
4536 application.SendNotification();
4537 application.Render();
4539 // Move to second line of the text & select.
4540 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4541 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4543 // replace C with selected text
4544 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4546 // Render and notify
4547 application.SendNotification();
4548 application.Render();
4550 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4552 gSelectionClearedCallbackCalled = false;
4554 // Render and notify
4555 application.SendNotification();
4556 application.Render();
4558 DevelTextEditor::SelectText( editor ,1, 3 );
4560 // Render and notify
4561 application.SendNotification();
4562 application.Render();
4564 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4566 // Render and notify
4567 application.SendNotification();
4568 application.Render();
4570 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4572 gSelectionClearedCallbackCalled = false;
4574 DevelTextEditor::SelectText( editor ,1, 3 );
4576 // Render and notify
4577 application.SendNotification();
4578 application.Render();
4581 DevelTextEditor::SelectNone(editor);
4583 // Render and notify
4584 application.SendNotification();
4585 application.Render();
4587 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4592 int utcDaliTextEditorSelectionChangedSignal(void)
4594 ToolkitTestApplication application;
4595 tet_infoline(" utcDaliTextEditorSelectionChangedSignal");
4597 TextEditor editor = TextEditor::New();
4598 DALI_TEST_CHECK( editor );
4600 application.GetScene().Add( editor );
4602 // connect to the selection changed signal.
4603 ConnectionTracker* testTracker = new ConnectionTracker();
4604 DevelTextEditor::SelectionChangedSignal(editor).Connect(&TestSelectionChangedCallback);
4605 bool selectionChangedSignal = false;
4606 editor.ConnectSignal( testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal) );
4608 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4609 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4610 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4611 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4612 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4614 // Avoid a crash when core load gl resources.
4615 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4617 // Render and notify
4618 application.SendNotification();
4619 application.Render();
4621 // Tap on the text editor
4622 TestGenerateTap( application, 3.0f, 25.0f );
4624 // Render and notify
4625 application.SendNotification();
4626 application.Render();
4628 // Move to second line of the text.
4629 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4631 // Render and notify
4632 application.SendNotification();
4633 application.Render();
4635 // Select some text in the right of the current cursor position
4636 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4637 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4639 // Render and notify
4640 application.SendNotification();
4641 application.Render();
4643 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4644 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4646 gSelectionChangedCallbackCalled = false;
4648 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4650 // Render and notify
4651 application.SendNotification();
4652 application.Render();
4654 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4655 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
4656 DALI_TEST_EQUALS(oldSelectionEnd, 7, TEST_LOCATION);
4658 gSelectionChangedCallbackCalled = false;
4660 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4662 // Render and notify
4663 application.SendNotification();
4664 application.Render();
4666 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4667 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
4668 DALI_TEST_EQUALS(oldSelectionEnd, 8, TEST_LOCATION);
4670 gSelectionChangedCallbackCalled = false;
4671 editor.SetKeyInputFocus();
4673 // Render and notify
4674 application.SendNotification();
4675 application.Render();
4677 DevelTextEditor::SelectText( editor ,0, 5 );
4679 application.SendNotification();
4680 application.Render();
4682 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4683 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4685 gSelectionChangedCallbackCalled = false;
4687 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4689 // Render and notify
4690 application.SendNotification();
4691 application.Render();
4693 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4694 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4695 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
4697 gSelectionChangedCallbackCalled = false;
4700 DevelTextEditor::SelectWholeText(editor);
4702 // Render and notify
4703 application.SendNotification();
4704 application.Render();
4706 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4707 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4709 gSelectionChangedCallbackCalled = false;
4712 DevelTextEditor::SelectNone(editor);
4714 // Render and notify
4715 application.SendNotification();
4716 application.Render();
4718 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4719 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4720 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);