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 gAnchorClickedCallBackCalled;
137 static bool gAnchorClickedCallBackNotCalled;
138 static bool gTextChangedCallBackCalled;
139 static bool gInputFilteredAcceptedCallbackCalled;
140 static bool gInputFilteredRejectedCallbackCalled;
141 static bool gInputStyleChangedCallbackCalled;
142 static bool gMaxCharactersCallBackCalled;
143 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
145 struct CallbackFunctor
147 CallbackFunctor(bool* callbackFlag)
148 : mCallbackFlag( callbackFlag )
154 *mCallbackFlag = true;
159 static void TestAnchorClickedCallback(TextEditor control, const char* href, unsigned int hrefLength)
161 tet_infoline(" TestAnchorClickedCallback");
163 gAnchorClickedCallBackNotCalled = false;
165 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
167 gAnchorClickedCallBackCalled = true;
171 static void TestTextChangedCallback( TextEditor control )
173 tet_infoline(" TestTextChangedCallback");
175 gTextChangedCallBackCalled = true;
178 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
180 tet_infoline(" TestInputStyleChangedCallback");
182 gInputStyleChangedCallbackCalled = true;
183 gInputStyleMask = mask;
186 static void TestMaxLengthReachedCallback( TextEditor control )
188 tet_infoline(" TestMaxLengthReachedCallback");
190 gMaxCharactersCallBackCalled = true;
193 static void TestInputFilteredCallback(TextEditor control, Toolkit::InputFilter::Property::Type type)
195 tet_infoline(" TestInputFilteredCallback");
197 if(type == Toolkit::InputFilter::Property::ACCEPTED)
199 gInputFilteredAcceptedCallbackCalled = true;
201 else if(type == Toolkit::InputFilter::Property::REJECTED)
203 gInputFilteredRejectedCallbackCalled = true;
207 // Generate a KeyEvent to send to Core.
208 Integration::KeyEvent GenerateKey( const std::string& keyName,
209 const std::string& logicalKey,
210 const std::string& keyString,
213 unsigned long timeStamp,
214 const Integration::KeyEvent::State& keyState,
215 const std::string& compose = "",
216 const std::string& deviceName = DEFAULT_DEVICE_NAME,
217 const Device::Class::Type& deviceClass = Device::Class::NONE,
218 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
220 return Integration::KeyEvent( keyName,
233 Dali::Integration::Point GetPointDownInside( Vector2& pos )
235 Dali::Integration::Point point;
236 point.SetState( PointState::DOWN );
237 point.SetScreenPosition( pos );
241 Dali::Integration::Point GetPointUpInside( Vector2& pos )
243 Dali::Integration::Point point;
244 point.SetState( PointState::UP );
245 point.SetScreenPosition( pos );
249 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
251 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
253 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
255 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
257 Property::Value* valueSet = NULL;
258 if ( valueGet.first.type == Property::Key::INDEX )
260 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
264 // Get Key is a string so searching Set Map for a string key
265 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
268 if( NULL != valueSet )
270 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
272 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
275 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
277 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
280 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
282 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
285 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
287 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
290 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
292 Vector2 vector2Get = valueGet.second.Get<Vector2>();
293 Vector2 vector2Set = valueSet->Get<Vector2>();
294 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
297 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
299 Vector4 vector4Get = valueGet.second.Get<Vector4>();
300 Vector4 vector4Set = valueSet->Get<Vector4>();
301 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 );
307 if ( valueGet.first.type == Property::Key::INDEX )
309 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
313 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
323 class ScrollStateChangeCallback : public Dali::ConnectionTracker
326 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
327 : mStartedCalled( startedCalled ),
328 mFinishedCalled( finishedCalled )
332 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
334 if( type == TextEditor::Scroll::STARTED )
336 mStartedCalled = true;
338 else if( type == TextEditor::Scroll::FINISHED )
340 mFinishedCalled = true;
344 bool& mStartedCalled;
345 bool& mFinishedCalled;
350 int UtcDaliToolkitTextEditorConstructorP(void)
352 ToolkitTestApplication application;
353 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
354 TextEditor textEditor;
355 DALI_TEST_CHECK( !textEditor );
359 int UtcDaliToolkitTextEditorNewP(void)
361 ToolkitTestApplication application;
362 tet_infoline(" UtcDaliToolkitTextEditorNewP");
363 TextEditor textEditor = TextEditor::New();
364 DALI_TEST_CHECK( textEditor );
368 int UtcDaliToolkitTextEditorDownCastP(void)
370 ToolkitTestApplication application;
371 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
372 TextEditor textEditor1 = TextEditor::New();
373 BaseHandle object( textEditor1 );
375 TextEditor textEditor2 = TextEditor::DownCast( object );
376 DALI_TEST_CHECK( textEditor2 );
378 TextEditor textEditor3 = DownCast< TextEditor >( object );
379 DALI_TEST_CHECK( textEditor3 );
383 int UtcDaliToolkitTextEditorDownCastN(void)
385 ToolkitTestApplication application;
386 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
387 BaseHandle uninitializedObject;
388 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
389 DALI_TEST_CHECK( !textEditor1 );
391 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
392 DALI_TEST_CHECK( !textEditor2 );
396 int UtcDaliToolkitTextEditorCopyConstructorP(void)
398 ToolkitTestApplication application;
399 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
400 TextEditor textEditor = TextEditor::New();
401 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
403 TextEditor copy( textEditor );
404 DALI_TEST_CHECK( copy );
405 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
409 int UtcDaliTextEditorMoveConstructor(void)
411 ToolkitTestApplication application;
413 TextEditor textEditor = TextEditor::New();
414 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
415 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
417 TextEditor moved = std::move( textEditor );
418 DALI_TEST_CHECK( moved );
419 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
420 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
421 DALI_TEST_CHECK( !textEditor );
426 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
428 ToolkitTestApplication application;
429 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
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 UtcDaliTextEditorMoveAssignment(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" );
448 moved = std::move( textEditor );
449 DALI_TEST_CHECK( moved );
450 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
451 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
452 DALI_TEST_CHECK( !textEditor );
457 int UtcDaliTextEditorNewP(void)
459 ToolkitTestApplication application;
460 tet_infoline(" UtcDaliToolkitTextEditorNewP");
461 TextEditor textEditor = TextEditor::New();
462 DALI_TEST_CHECK( textEditor );
466 // Positive test case for a method
467 int UtcDaliTextEditorGetPropertyP(void)
469 ToolkitTestApplication application;
470 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
471 TextEditor editor = TextEditor::New();
472 DALI_TEST_CHECK( editor );
474 // Check Property Indices are correct
475 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextEditor::Property::RENDERING_BACKEND );
476 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
477 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
478 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
479 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
480 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
481 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
482 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
483 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
484 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
485 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
486 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
487 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
488 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
489 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
490 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
491 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
492 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
493 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
494 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
495 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
496 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
497 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
498 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
499 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
500 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
501 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
502 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
503 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
504 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
506 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
507 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
508 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
509 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
510 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
511 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
512 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
513 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
514 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
515 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
516 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
517 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
518 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
519 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
520 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
521 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
522 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
523 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
524 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
525 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextEditor::Property::FONT_SIZE_SCALE );
526 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
527 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
528 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
529 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
530 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
531 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == DevelTextEditor::Property::MAX_LENGTH );
532 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextEditor::Property::GRAB_HANDLE_COLOR );
533 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP );
534 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == DevelTextEditor::Property::INPUT_METHOD_SETTINGS );
535 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FILTER ) == DevelTextEditor::Property::INPUT_FILTER );
540 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
543 Property::Map imageMap;
544 imageMap[mapKey] =mapValue;
546 editor.SetProperty( property , imageMap );
547 Property::Value propValue = editor.GetProperty( property );
548 Property::Map* resultMap = propValue.GetMap();
550 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
558 // Positive test case for a method
559 int UtcDaliTextEditorSetPropertyP(void)
561 ToolkitTestApplication application;
562 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
563 TextEditor editor = TextEditor::New();
564 DALI_TEST_CHECK( editor );
565 application.GetScene().Add( editor );
567 // Note - we can't check the defaults since the stylesheets are platform-specific
569 // Check the render backend property.
570 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
571 DALI_TEST_EQUALS( (DevelText::RenderingType)editor.GetProperty<int>( DevelTextEditor::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
573 // Check text property.
574 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
575 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
577 // Check text's color property
578 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
579 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
581 // Check font properties.
582 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
583 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
585 Property::Map fontStyleMapSet;
586 Property::Map fontStyleMapGet;
587 Property::Value* slantValue = NULL;
589 fontStyleMapSet.Insert( "weight", "bold" );
590 fontStyleMapSet.Insert( "width", "condensed" );
591 fontStyleMapSet.Insert( "slant", "italic" );
593 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
594 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
595 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
596 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
598 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
599 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
601 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 2.5f );
602 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
603 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 1.0f );
606 fontStyleMapSet.Clear();
607 fontStyleMapSet.Insert( "weight", "normal" );
608 fontStyleMapSet.Insert( "slant", "oblique" );
609 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
610 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
611 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
612 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
614 fontStyleMapSet.Clear();
615 fontStyleMapSet.Insert( "slant", "roman" );
616 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
617 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
619 // Replace 'roman' for 'normal'.
620 slantValue = fontStyleMapGet.Find( "slant" );
621 if( NULL != slantValue )
623 if( "normal" == slantValue->Get<std::string>() )
625 fontStyleMapGet["slant"] = "roman";
628 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
629 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
631 fontStyleMapSet.Clear();
633 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
634 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
635 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
636 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
638 // Check that the Alignment properties can be correctly set
639 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
640 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
642 // Check scroll properties.
643 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
644 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
645 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
646 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
648 // Check cursor properties
649 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
650 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
651 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
652 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
654 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
655 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
656 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
657 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
658 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
659 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
660 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
661 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
663 // Check handle images
664 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
665 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
666 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
667 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
668 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
670 // Check handle images
671 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
672 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
673 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
674 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
675 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
676 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
678 // Check the highlight color
679 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
680 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
682 // Decoration bounding box
683 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
684 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
686 // Check the enable markup property.
687 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
688 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
689 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
691 // Check input color property.
692 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
693 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
695 // Check input font properties.
696 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
697 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
699 fontStyleMapSet.Clear();
700 fontStyleMapSet.Insert( "weight", "bold" );
701 fontStyleMapSet.Insert( "width", "condensed" );
702 fontStyleMapSet.Insert( "slant", "italic" );
704 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
705 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
706 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
707 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
709 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
710 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
712 // Reset input font style.
713 fontStyleMapSet.Clear();
714 fontStyleMapSet.Insert( "weight", "normal" );
715 fontStyleMapSet.Insert( "slant", "oblique" );
717 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
718 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
719 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
720 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
722 fontStyleMapSet.Clear();
723 fontStyleMapSet.Insert( "slant", "roman" );
725 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
726 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
728 // Replace 'roman' for 'normal'.
729 slantValue = fontStyleMapGet.Find( "slant" );
730 if( NULL != slantValue )
732 if( "normal" == slantValue->Get<std::string>() )
734 fontStyleMapGet["slant"] = "roman";
737 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
738 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
740 fontStyleMapSet.Clear();
742 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
743 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
744 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
745 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
747 // Check the line spacing property
748 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
749 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
750 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
752 // Check the input line spacing property
753 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
754 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
755 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
757 // Check the underline property
759 Property::Map underlineMapSet;
760 Property::Map underlineMapGet;
762 underlineMapSet.Insert( "enable", true );
763 underlineMapSet.Insert( "color", Color::RED );
764 underlineMapSet.Insert( "height", 1 );
766 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
768 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
769 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
770 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
772 // Check the input underline property
773 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
774 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
776 // Check the shadow property
777 Property::Map shadowMapSet;
778 Property::Map shadowMapGet;
780 shadowMapSet.Insert( "color", Color::GREEN );
781 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
782 shadowMapSet.Insert( "blurRadius", 3.0f );
784 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
786 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
787 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
788 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
790 // Check the input shadow property
791 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
792 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
794 // Check the emboss property
795 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
796 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
798 // Check the input emboss property
799 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
800 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
802 // Check the outline property
804 // Test string type first
805 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
806 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
807 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
809 // Then test the property map type
810 Property::Map outlineMapSet;
811 Property::Map outlineMapGet;
813 outlineMapSet["color"] = Color::RED;
814 outlineMapSet["width"] = 2.0f;
816 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
818 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
819 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
820 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
822 // Check the input outline property
823 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
824 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
826 // Check the smooth scroll property
827 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
828 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
829 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
831 // Check the smooth scroll duration property
832 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
833 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
835 // Check the scroll bar property
836 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
837 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
838 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
840 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
841 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
842 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
843 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
845 // Check the pixel size of font
846 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
847 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
849 // Check placeholder text properties.
850 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
851 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
853 // Check placeholder text's color property.
854 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
855 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
857 // Check the enable selection property
858 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
859 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
861 // Check the placeholder property with pixel size
862 Property::Map placeholderPixelSizeMapSet;
863 Property::Map placeholderPixelSizeMapGet;
864 Property::Map placeholderFontstyleMap;
865 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
866 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
867 placeholderPixelSizeMapSet["color"] = Color::BLUE;
868 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
869 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
871 placeholderFontstyleMap.Insert( "weight", "bold" );
872 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
873 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
875 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
876 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
878 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
879 Property::Map placeholderConversionMap;
880 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
881 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
882 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
883 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
884 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
885 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
887 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
889 // Check the placeholder property with point size
890 Property::Map placeholderMapSet;
891 Property::Map placeholderMapGet;
892 placeholderMapSet["text"] = "Setting Placeholder Text";
893 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
894 placeholderMapSet["color"] = Color::RED;
895 placeholderMapSet["fontFamily"] = "Arial";
896 placeholderMapSet["pointSize"] = 12.0f;
897 // Check the placeholder font style property
898 placeholderFontstyleMap.Clear();
900 placeholderFontstyleMap.Insert( "weight", "bold" );
901 placeholderFontstyleMap.Insert( "width", "condensed" );
902 placeholderFontstyleMap.Insert( "slant", "italic" );
903 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
904 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
906 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
907 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
909 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
910 placeholderConversionMap.Clear();
911 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
912 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
913 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
914 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
915 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
916 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
917 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
920 placeholderFontstyleMap.Clear();
921 placeholderFontstyleMap.Insert( "weight", "normal" );
922 placeholderFontstyleMap.Insert( "slant", "oblique" );
923 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
924 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
926 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
927 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
928 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
929 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
931 placeholderFontstyleMap.Clear();
932 placeholderFontstyleMap.Insert( "slant", "roman" );
933 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
934 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
936 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
938 placeholderFontstyleMap.Clear();
939 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
941 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
942 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
943 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
944 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
945 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
947 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
948 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
950 // Check handle color
951 editor.SetProperty( DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN );
952 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
954 // Test the ENABLE_GRAB_HANDLE_POPUP property
955 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP, false );
956 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP ), false, TEST_LOCATION);
958 // Check the input method setting
959 Property::Map propertyMap;
960 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
961 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
962 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
963 int inputVariation = 1;
964 propertyMap["PANEL_LAYOUT"] = panelLayout;
965 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
966 propertyMap["BUTTON_ACTION"] = buttonAction;
967 propertyMap["VARIATION"] = inputVariation;
968 editor.SetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS, propertyMap );
970 Property::Value value = editor.GetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS );
972 DALI_TEST_CHECK( value.Get( map ) );
975 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
976 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
979 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
980 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
983 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
984 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
987 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
988 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
990 // Check the input filter property
991 Property::Map inputFilterMapSet;
992 Property::Map inputFilterMapGet;
993 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
994 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
996 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
998 inputFilterMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::INPUT_FILTER);
999 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1002 inputFilterMapSet.Clear();
1003 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1005 application.SendNotification();
1006 application.Render();
1008 // Check the line size property
1009 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::MIN_LINE_SIZE ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1010 editor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 50.f );
1011 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::MIN_LINE_SIZE ), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1016 // Positive Atlas Text Renderer test
1017 int utcDaliTextEditorAtlasRenderP(void)
1019 ToolkitTestApplication application;
1020 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
1021 StyleManager styleManager = StyleManager::Get();
1022 styleManager.ApplyDefaultTheme();
1023 TextEditor editor = TextEditor::New();
1024 DALI_TEST_CHECK( editor );
1026 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1028 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1030 application.GetScene().Add( editor );
1034 // Render some text with the shared atlas backend
1035 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1036 application.SendNotification();
1037 application.Render();
1041 tet_result(TET_FAIL);
1046 // Positive test for the anchorClicked signal.
1047 int utcDaliTextEditorAnchorClickedP(void)
1049 ToolkitTestApplication application;
1050 tet_infoline(" utcDaliTextEditorAnchorClickedP");
1051 TextEditor editor = TextEditor::New();
1052 DALI_TEST_CHECK(editor);
1054 application.GetScene().Add(editor);
1056 // connect to the anchor clicked signal.
1057 ConnectionTracker* testTracker = new ConnectionTracker();
1058 DevelTextEditor::AnchorClickedSignal(editor).Connect(&TestAnchorClickedCallback);
1059 bool anchorClickedSignal = false;
1060 editor.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1062 gAnchorClickedCallBackCalled = false;
1063 editor.SetProperty(TextEditor::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1064 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1065 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1066 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1067 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1069 application.SendNotification();
1070 application.Render();
1071 editor.SetKeyInputFocus();
1073 // Create a tap event to touch the text editor.
1074 TestGenerateTap(application, 5.0f, 5.0f);
1075 application.SendNotification();
1076 application.Render();
1078 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1079 DALI_TEST_CHECK(anchorClickedSignal);
1081 gAnchorClickedCallBackNotCalled = true;
1082 // Tap the outside of anchor, callback should not be called.
1083 TestGenerateTap(application, 150.f, 100.f);
1084 application.SendNotification();
1085 application.Render();
1087 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1092 // Positive test for the textChanged signal.
1093 int utcDaliTextEditorTextChangedP(void)
1095 ToolkitTestApplication application;
1096 tet_infoline(" utcDaliTextEditorTextChangedP");
1097 TextEditor editor = TextEditor::New();
1098 DALI_TEST_CHECK( editor );
1100 application.GetScene().Add( editor );
1102 // connect to the text changed signal.
1103 ConnectionTracker* testTracker = new ConnectionTracker();
1104 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
1105 bool textChangedSignal = false;
1106 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1108 gTextChangedCallBackCalled = false;
1109 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
1110 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1111 DALI_TEST_CHECK( textChangedSignal );
1113 application.SendNotification();
1114 editor.SetKeyInputFocus();
1116 gTextChangedCallBackCalled = false;
1117 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1118 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1121 editor.SetProperty( TextField::Property::TEXT, "" );
1123 // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
1124 gTextChangedCallBackCalled = false;
1125 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1126 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1128 // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
1129 gTextChangedCallBackCalled = false;
1130 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1131 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1136 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1138 ToolkitTestApplication application;
1139 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1140 TextEditor editor = TextEditor::New();
1141 DALI_TEST_CHECK( editor );
1144 application.GetScene().Add( editor );
1146 // connect to the text changed signal.
1147 ConnectionTracker* testTracker = new ConnectionTracker();
1148 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1149 bool textChangedSignal = false;
1150 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1153 // get InputMethodContext
1155 InputMethodContext::EventData imfEvent;
1156 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext( editor );
1158 editor.SetKeyInputFocus();
1159 editor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
1162 gTextChangedCallBackCalled = false;
1163 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1164 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1165 application.SendNotification();
1166 application.Render();
1167 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1168 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1170 gTextChangedCallBackCalled = false;
1171 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1172 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1173 application.SendNotification();
1174 application.Render();
1175 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1176 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호"), TEST_LOCATION );
1178 gTextChangedCallBackCalled = false;
1179 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1180 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1181 application.SendNotification();
1182 application.Render();
1183 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1184 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1186 gTextChangedCallBackCalled = false;
1187 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1188 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1189 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1191 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1192 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1193 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1195 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1196 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1197 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1199 application.SendNotification();
1200 application.Render();
1201 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1202 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1208 int utcDaliTextEditorInputStyleChanged01(void)
1210 // The text-editor emits signals when the input style changes. These changes of style are
1211 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1212 // can't be emitted during the size negotiation as the callbacks may update the UI.
1213 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1214 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1215 ToolkitTestApplication application;
1216 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1220 char* pathNamePtr = get_current_dir_name();
1221 const std::string pathName( pathNamePtr );
1222 free( pathNamePtr );
1224 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1225 fontClient.SetDpi( 93u, 93u );
1227 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1228 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1230 TextEditor editor = TextEditor::New();
1231 DALI_TEST_CHECK( editor );
1234 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1235 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1236 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1238 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1239 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1241 // connect to the text changed signal.
1242 ConnectionTracker* testTracker = new ConnectionTracker();
1243 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1244 bool inputStyleChangedSignal = false;
1245 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1247 application.GetScene().Add( editor );
1249 // Render and notify
1250 application.SendNotification();
1251 application.Render();
1253 // Executes the idle callbacks added by the text control on the change of input style.
1254 application.RunIdles();
1256 gInputStyleChangedCallbackCalled = false;
1257 gInputStyleMask = TextEditor::InputStyle::NONE;
1258 inputStyleChangedSignal = false;
1260 // Create a tap event to touch the text editor.
1261 TestGenerateTap( application, 18.0f, 25.0f );
1263 // Render and notify
1264 application.SendNotification();
1265 application.Render();
1267 // Executes the idle callbacks added by the text control on the change of input style.
1268 application.RunIdles();
1270 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1271 if( gInputStyleChangedCallbackCalled )
1273 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1275 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1276 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1278 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1279 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1281 DALI_TEST_CHECK( inputStyleChangedSignal );
1283 gInputStyleChangedCallbackCalled = false;
1284 gInputStyleMask = TextEditor::InputStyle::NONE;
1285 inputStyleChangedSignal = false;
1287 // Create a tap event to touch the text editor.
1288 TestGenerateTap( application, 30.0f, 25.0f );
1290 // Render and notify
1291 application.SendNotification();
1292 application.Render();
1294 // Executes the idle callbacks added by the text control on the change of input style.
1295 application.RunIdles();
1297 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1298 DALI_TEST_CHECK( !inputStyleChangedSignal );
1300 gInputStyleChangedCallbackCalled = false;
1301 gInputStyleMask = TextEditor::InputStyle::NONE;
1302 inputStyleChangedSignal = false;
1304 // Create a tap event to touch the text editor.
1305 TestGenerateTap( application, 43.0f, 25.0f );
1307 // Render and notify
1308 application.SendNotification();
1309 application.Render();
1311 // Executes the idle callbacks added by the text control on the change of input style.
1312 application.RunIdles();
1314 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1315 if( gInputStyleChangedCallbackCalled )
1317 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1319 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1320 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1322 DALI_TEST_CHECK( inputStyleChangedSignal );
1324 gInputStyleChangedCallbackCalled = false;
1325 gInputStyleMask = TextEditor::InputStyle::NONE;
1326 inputStyleChangedSignal = false;
1328 // Create a tap event to touch the text editor.
1329 TestGenerateTap( application, 88.0f, 25.0f );
1331 // Render and notify
1332 application.SendNotification();
1333 application.Render();
1335 // Executes the idle callbacks added by the text control on the change of input style.
1336 application.RunIdles();
1338 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1339 if( gInputStyleChangedCallbackCalled )
1341 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1343 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1344 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1346 Property::Map fontStyleMapSet;
1347 Property::Map fontStyleMapGet;
1349 fontStyleMapSet.Insert( "weight", "bold" );
1351 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1352 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1353 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1355 DALI_TEST_CHECK( inputStyleChangedSignal );
1357 gInputStyleChangedCallbackCalled = false;
1358 gInputStyleMask = TextEditor::InputStyle::NONE;
1359 inputStyleChangedSignal = false;
1361 // Create a tap event to touch the text editor.
1362 TestGenerateTap( application, 115.0f, 25.0f );
1364 // Render and notify
1365 application.SendNotification();
1366 application.Render();
1368 // Executes the idle callbacks added by the text control on the change of input style.
1369 application.RunIdles();
1371 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1372 DALI_TEST_CHECK( !inputStyleChangedSignal );
1374 gInputStyleChangedCallbackCalled = false;
1375 gInputStyleMask = TextEditor::InputStyle::NONE;
1376 inputStyleChangedSignal = false;
1378 // Create a tap event to touch the text editor.
1379 TestGenerateTap( application, 164.0f, 25.0f );
1381 // Render and notify
1382 application.SendNotification();
1383 application.Render();
1385 // Executes the idle callbacks added by the text control on the change of input style.
1386 application.RunIdles();
1388 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1389 if( gInputStyleChangedCallbackCalled )
1391 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1393 Property::Map fontStyleMapSet;
1394 Property::Map fontStyleMapGet;
1396 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1397 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1398 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1400 DALI_TEST_CHECK( inputStyleChangedSignal );
1402 gInputStyleChangedCallbackCalled = false;
1403 gInputStyleMask = TextEditor::InputStyle::NONE;
1404 inputStyleChangedSignal = false;
1406 // Create a tap event to touch the text editor.
1407 TestGenerateTap( application, 191.0f, 25.0f );
1409 // Render and notify
1410 application.SendNotification();
1411 application.Render();
1413 // Executes the idle callbacks added by the text control on the change of input style.
1414 application.RunIdles();
1416 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1417 DALI_TEST_CHECK( !inputStyleChangedSignal );
1422 int utcDaliTextEditorInputStyleChanged02(void)
1424 // The text-editor emits signals when the input style changes. These changes of style are
1425 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1426 // can't be emitted during the size negotiation as the callbacks may update the UI.
1427 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1428 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1429 ToolkitTestApplication application;
1430 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1434 char* pathNamePtr = get_current_dir_name();
1435 const std::string pathName( pathNamePtr );
1436 free( pathNamePtr );
1438 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1439 fontClient.SetDpi( 93u, 93u );
1441 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1442 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1444 TextEditor editor = TextEditor::New();
1445 DALI_TEST_CHECK( editor );
1448 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1449 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1450 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1452 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1453 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>" );
1455 // connect to the text changed signal.
1456 ConnectionTracker* testTracker = new ConnectionTracker();
1457 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1458 bool inputStyleChangedSignal = false;
1459 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1461 application.GetScene().Add( editor );
1463 // Render and notify
1464 application.SendNotification();
1465 application.Render();
1467 // Executes the idle callbacks added by the text control on the change of input style.
1468 application.RunIdles();
1470 gInputStyleChangedCallbackCalled = false;
1471 gInputStyleMask = TextEditor::InputStyle::NONE;
1472 inputStyleChangedSignal = false;
1474 // Create a tap event to touch the text editor.
1475 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1476 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1478 // Render and notify
1479 application.SendNotification();
1480 application.Render();
1482 // Executes the idle callbacks added by the text control on the change of input style.
1483 application.RunIdles();
1485 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1486 if( gInputStyleChangedCallbackCalled )
1488 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1489 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1490 TextEditor::InputStyle::POINT_SIZE |
1491 TextEditor::InputStyle::COLOR ),
1494 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1495 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1497 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1498 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1500 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1501 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1503 DALI_TEST_CHECK( inputStyleChangedSignal );
1505 gInputStyleChangedCallbackCalled = false;
1506 gInputStyleMask = TextEditor::InputStyle::NONE;
1507 inputStyleChangedSignal = false;
1509 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1511 // Render and notify
1512 application.SendNotification();
1513 application.Render();
1515 // Executes the idle callbacks added by the text control on the change of input style.
1516 application.RunIdles();
1518 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1519 if( gInputStyleChangedCallbackCalled )
1521 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1522 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1525 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1526 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1528 DALI_TEST_CHECK( inputStyleChangedSignal );
1530 gInputStyleChangedCallbackCalled = false;
1531 gInputStyleMask = TextEditor::InputStyle::NONE;
1532 inputStyleChangedSignal = false;
1534 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1536 // Render and notify
1537 application.SendNotification();
1538 application.Render();
1540 // Executes the idle callbacks added by the text control on the change of input style.
1541 application.RunIdles();
1543 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1544 DALI_TEST_CHECK( !inputStyleChangedSignal );
1546 gInputStyleChangedCallbackCalled = false;
1547 gInputStyleMask = TextEditor::InputStyle::NONE;
1548 inputStyleChangedSignal = false;
1550 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1552 // Render and notify
1553 application.SendNotification();
1554 application.Render();
1556 // Executes the idle callbacks added by the text control on the change of input style.
1557 application.RunIdles();
1559 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1560 if( gInputStyleChangedCallbackCalled )
1562 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1563 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1566 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1567 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1569 DALI_TEST_CHECK( inputStyleChangedSignal );
1571 gInputStyleChangedCallbackCalled = false;
1572 gInputStyleMask = TextEditor::InputStyle::NONE;
1573 inputStyleChangedSignal = false;
1575 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1577 Property::Map fontStyleMapSet;
1578 fontStyleMapSet.Insert( "weight", "thin" );
1579 fontStyleMapSet.Insert( "width", "condensed" );
1580 fontStyleMapSet.Insert( "slant", "italic" );
1582 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1583 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1584 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1586 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1587 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1588 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1589 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1591 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1593 // Render and notify
1594 application.SendNotification();
1595 application.Render();
1597 // Executes the idle callbacks added by the text control on the change of input style.
1598 application.RunIdles();
1600 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1601 DALI_TEST_CHECK( !inputStyleChangedSignal );
1603 // Create a tap event to touch the text editor.
1604 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1606 // Render and notify
1607 application.SendNotification();
1608 application.Render();
1610 // Executes the idle callbacks added by the text control on the change of input style.
1611 application.RunIdles();
1613 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1614 if( gInputStyleChangedCallbackCalled )
1616 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1617 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1618 TextEditor::InputStyle::POINT_SIZE |
1619 TextEditor::InputStyle::FONT_STYLE |
1620 TextEditor::InputStyle::LINE_SPACING |
1621 TextEditor::InputStyle::UNDERLINE |
1622 TextEditor::InputStyle::SHADOW |
1623 TextEditor::InputStyle::EMBOSS |
1624 TextEditor::InputStyle::OUTLINE ),
1627 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1628 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1630 DALI_TEST_CHECK( inputStyleChangedSignal );
1632 gInputStyleChangedCallbackCalled = false;
1633 gInputStyleMask = TextEditor::InputStyle::NONE;
1634 inputStyleChangedSignal = false;
1636 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1638 fontStyleMapSet.Clear();
1639 fontStyleMapSet.Insert( "weight", "black" );
1640 fontStyleMapSet.Insert( "width", "expanded" );
1641 fontStyleMapSet.Insert( "slant", "oblique" );
1643 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1645 // Create a tap event to touch the text editor.
1646 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1648 // Render and notify
1649 application.SendNotification();
1650 application.Render();
1652 // Executes the idle callbacks added by the text control on the change of input style.
1653 application.RunIdles();
1655 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1656 if( gInputStyleChangedCallbackCalled )
1658 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1659 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1660 TextEditor::InputStyle::POINT_SIZE |
1661 TextEditor::InputStyle::FONT_STYLE ),
1664 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1665 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1667 DALI_TEST_CHECK( inputStyleChangedSignal );
1672 int utcDaliTextEditorEvent01(void)
1674 ToolkitTestApplication application;
1675 tet_infoline(" utcDaliTextEditorEvent01");
1677 // Creates a tap event. After creating a tap event the text editor should
1678 // have the focus and add text with key events should be possible.
1680 TextEditor editor = TextEditor::New();
1681 DALI_TEST_CHECK( editor );
1683 application.GetScene().Add( editor );
1685 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1686 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1687 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1689 // Avoid a crash when core load gl resources.
1690 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1692 // Render and notify
1693 application.SendNotification();
1694 application.Render();
1696 // Add a key event but as the text editor has not the focus it should do nothing.
1697 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1699 // Render and notify
1700 application.SendNotification();
1701 application.Render();
1703 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1705 // Create a tap event to touch the text editor.
1706 TestGenerateTap( application, 150.0f, 25.0f );
1708 // Render and notify
1709 application.SendNotification();
1710 application.Render();
1712 // Now the text editor has the focus, so it can handle the key events.
1713 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1714 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1716 // Render and notify
1717 application.SendNotification();
1718 application.Render();
1720 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1722 // Create a second text editor and send key events to it.
1723 TextEditor editor2 = TextEditor::New();
1725 editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1726 editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1727 editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1728 editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1730 application.GetScene().Add( editor2 );
1732 // Render and notify
1733 application.SendNotification();
1734 application.Render();
1736 // Create a tap event on the second text editor.
1737 TestGenerateTap( application, 150.0f, 125.0f );
1739 // Render and notify
1740 application.SendNotification();
1741 application.Render();
1743 // The second text editor has the focus. It should handle the key events.
1744 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1745 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1747 // Render and notify
1748 application.SendNotification();
1749 application.Render();
1751 // Check the text has been added to the second text editor.
1752 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1757 int utcDaliTextEditorEvent02(void)
1759 ToolkitTestApplication application;
1760 tet_infoline(" utcDaliTextEditorEvent02");
1762 // Checks if the right number of actors are created.
1764 TextEditor editor = TextEditor::New();
1765 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1766 DALI_TEST_CHECK( editor );
1768 application.GetScene().Add( editor );
1770 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1771 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1772 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1774 // Avoid a crash when core load gl resources.
1775 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1777 // Render and notify
1778 application.SendNotification();
1779 application.Render();
1781 // Check there are the expected number of children (the stencil).
1782 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1784 Actor stencil = editor.GetChildAt( 0u );
1786 // Create a tap event to touch the text editor.
1787 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1789 // Render and notify
1790 application.SendNotification();
1791 application.Render();
1793 Actor layer = editor.GetChildAt( 1u );
1794 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1795 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1797 // Now the text editor has the focus, so it can handle the key events.
1798 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1799 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1801 // Render and notify
1802 application.SendNotification();
1803 application.Render();
1805 // Checks the cursor and the renderer have been created.
1806 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1807 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1809 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1810 DALI_TEST_CHECK( cursor );
1812 // The stencil actor has a container with all the actors which contain the text renderers.
1813 Actor container = stencil.GetChildAt( 0u );
1814 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1816 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1817 DALI_TEST_CHECK( renderer );
1820 // Move the cursor and check the position changes.
1821 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1823 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1824 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1826 // Render and notify
1827 application.SendNotification();
1828 application.Render();
1830 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1832 DALI_TEST_CHECK( position2.x < position1.x );
1834 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1835 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1837 // Render and notify
1838 application.SendNotification();
1839 application.Render();
1841 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1843 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1845 // Send some taps and check the cursor positions.
1847 // Try to tap at the beginning.
1848 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1850 // Render and notify
1851 application.SendNotification();
1852 application.Render();
1854 // Cursor position should be the same than position1.
1855 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1857 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1859 // Tap away from the start position.
1860 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1862 // Render and notify
1863 application.SendNotification();
1864 application.Render();
1866 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1868 DALI_TEST_CHECK( position5.x > position4.x );
1870 // Remove all the text.
1871 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1872 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1873 editor.SetProperty( TextEditor::Property::TEXT, "" );
1875 // Render and notify
1876 application.SendNotification();
1877 application.Render();
1879 // Cursor position should be the same than position2.
1880 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1882 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1884 // Should not be a renderer.
1885 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1890 int utcDaliTextEditorEvent03(void)
1892 ToolkitTestApplication application;
1893 tet_infoline(" utcDaliTextEditorEvent03");
1895 // Checks if the highlight actor is created.
1897 TextEditor editor = TextEditor::New();
1898 DALI_TEST_CHECK( editor );
1900 application.GetScene().Add( editor );
1902 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1903 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1904 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1905 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1906 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1908 // Avoid a crash when core load gl resources.
1909 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1911 // Render and notify
1912 application.SendNotification();
1913 application.Render();
1915 // Send some taps and check text controller with clipboard window
1916 Dali::Clipboard clipboard = Clipboard::Get();
1917 clipboard.ShowClipboard();
1918 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1919 clipboard.HideClipboard();
1921 // Render and notify
1922 application.SendNotification();
1923 application.Render();
1925 // Tap first to get the focus.
1926 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1928 // Render and notify
1929 application.SendNotification();
1930 application.Render();
1932 // Double tap to select a word.
1933 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1935 // Render and notify
1936 application.SendNotification();
1937 application.Render();
1939 // The stencil actor should have two actors: the renderer and the highlight actor.
1940 Actor stencil = editor.GetChildAt( 0u );
1942 // Highlight needs to be drawn before text, so should come first in child order
1943 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1944 DALI_TEST_CHECK( highlight );
1946 // The stencil actor has a container with all the actors which contain the text renderers.
1947 Actor container = stencil.GetChildAt( 1u );
1948 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1950 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1951 DALI_TEST_CHECK( renderer );
1954 // Double tap out of bounds
1955 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1956 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1958 // Render and notify
1959 application.SendNotification();
1960 application.Render();
1962 // The stencil actor should have one actors: the renderer actor.
1963 stencil = editor.GetChildAt( 0u );
1965 // The stencil actor has a container with all the actors which contain the text renderers.
1966 container = stencil.GetChildAt( 0u );
1967 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1969 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1970 DALI_TEST_CHECK( renderer );
1974 TestGenerateLongPress(application, 1.0f, 25.0f);
1976 // Render and notify
1977 application.SendNotification();
1978 application.Render();
1981 TestGenerateMiniPan(application);
1983 // Render and notify
1984 application.SendNotification();
1985 application.Render();
1990 int utcDaliTextEditorEvent04(void)
1992 ToolkitTestApplication application;
1993 tet_infoline(" utcDaliTextEditorEvent04");
1995 // Checks if the highlight actor is created.
1997 TextEditor editor = TextEditor::New();
1998 DALI_TEST_CHECK( editor );
2000 application.GetScene().Add( editor );
2002 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
2003 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2004 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2005 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2006 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2008 // Avoid a crash when core load gl resources.
2009 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2011 // Render and notify
2012 application.SendNotification();
2013 application.Render();
2015 // Tap on the text editor
2016 TestGenerateTap( application, 3.0f, 25.0f );
2018 // Render and notify
2019 application.SendNotification();
2020 application.Render();
2022 // Move at the end of the text.
2023 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2024 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2026 // Render and notify
2027 application.SendNotification();
2028 application.Render();
2030 for( unsigned int index = 0u; index < 10u; ++index )
2032 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2033 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2035 // Render and notify
2036 application.SendNotification();
2037 application.Render();
2041 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2043 // Render and notify
2044 application.SendNotification();
2045 application.Render();
2047 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2049 // Add some key events
2050 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2051 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2053 // Render and notify
2054 application.SendNotification();
2055 application.Render();
2057 for( unsigned int index = 0u; index < 10u; ++index )
2059 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2060 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2062 // Render and notify
2063 application.SendNotification();
2064 application.Render();
2068 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2070 // Render and notify
2071 application.SendNotification();
2072 application.Render();
2074 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2079 int utcDaliTextEditorEvent05(void)
2081 ToolkitTestApplication application;
2082 tet_infoline(" utcDaliTextEditorEvent05");
2084 // Checks if the highlight actor is created.
2086 TextEditor editor = TextEditor::New();
2087 DALI_TEST_CHECK( editor );
2089 application.GetScene().Add( editor );
2091 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
2092 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2093 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2094 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2095 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2096 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2097 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
2098 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2099 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
2100 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
2102 // Avoid a crash when core load gl resources.
2103 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2105 // Render and notify
2106 application.SendNotification();
2107 application.Render();
2109 // Tap on the text editor
2110 TestGenerateTap( application, 3.0f, 25.0f );
2112 // Render and notify
2113 application.SendNotification();
2114 application.Render();
2116 // Move at the end of the text.
2117 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2118 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2120 // Render and notify
2121 application.SendNotification();
2122 application.Render();
2124 for( unsigned int index = 0u; index < 10u; ++index )
2127 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2129 // Render and notify
2130 application.SendNotification();
2131 application.Render();
2133 // Modify duration after scroll is enabled
2134 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
2136 // Continuous scroll left to increase coverage
2137 for( unsigned int index = 0u; index < 10u; ++index )
2139 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2141 // Render and notify
2142 application.SendNotification();
2143 application.Render();
2145 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2146 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
2147 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
2148 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2149 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2151 // Press Escape to increase coverage
2152 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2153 application.SendNotification();
2154 application.Render();
2156 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
2161 int utcDaliTextEditorEvent06(void)
2163 ToolkitTestApplication application;
2164 tet_infoline(" utcDaliTextEditorEvent06");
2166 // Checks if the highlight actor is created.
2168 TextEditor editor = TextEditor::New();
2169 DALI_TEST_CHECK( editor );
2171 application.GetScene().Add( editor );
2173 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2174 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2175 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2176 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2177 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2179 // Avoid a crash when core load gl resources.
2180 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2182 // Render and notify
2183 application.SendNotification();
2184 application.Render();
2186 // Tap on the text editor
2187 TestGenerateTap( application, 3.0f, 25.0f );
2189 // Render and notify
2190 application.SendNotification();
2191 application.Render();
2193 // Move to seconds line of the text.
2194 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2196 // Render and notify
2197 application.SendNotification();
2198 application.Render();
2200 float layoutHeight = editor.GetHeightForWidth( 100.f );
2203 // Add another script characters ( glyph height is defferent )
2204 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2205 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2207 // Delete characters
2208 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2209 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2211 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2213 // Render and notify
2214 application.SendNotification();
2215 application.Render();
2217 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2220 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2221 application.SendNotification();
2222 application.Render();
2224 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2225 application.SendNotification();
2226 application.Render();
2228 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2229 application.SendNotification();
2230 application.Render();
2232 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2233 application.SendNotification();
2234 application.Render();
2236 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2237 application.SendNotification();
2238 application.Render();
2240 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2241 application.SendNotification();
2242 application.Render();
2244 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2245 application.SendNotification();
2246 application.Render();
2251 int utcDaliTextEditorEvent07(void)
2253 ToolkitTestApplication application;
2254 tet_infoline(" utcDaliTextEditorEvent07");
2256 // Checks if the highlight actor is created.
2258 TextEditor editor = TextEditor::New();
2259 DALI_TEST_CHECK( editor );
2261 application.GetScene().Add( editor );
2263 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2264 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2265 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2266 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2267 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2269 // Avoid a crash when core load gl resources.
2270 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2272 // Render and notify
2273 application.SendNotification();
2274 application.Render();
2276 // Tap on the text editor
2277 TestGenerateTap( application, 3.0f, 25.0f );
2279 // Render and notify
2280 application.SendNotification();
2281 application.Render();
2283 // Move to second line of the text.
2284 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2286 // Render and notify
2287 application.SendNotification();
2288 application.Render();
2290 // Select some text in the right of the current cursor position
2291 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2292 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2293 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2294 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2296 // Render and notify
2297 application.SendNotification();
2298 application.Render();
2300 // Cut the selected text
2301 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2302 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 ) );
2304 // Render and notify
2305 application.SendNotification();
2306 application.Render();
2308 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2310 // Select some text in the left of the current cursor position
2311 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2312 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2313 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2314 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2316 // Render and notify
2317 application.SendNotification();
2318 application.Render();
2320 // Copy the selected text
2321 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2322 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 ) );
2324 // Render and notify
2325 application.SendNotification();
2326 application.Render();
2328 // Move the cursor to the third line
2329 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2330 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2332 // Render and notify
2333 application.SendNotification();
2334 application.Render();
2336 // Paste the selected text at the current cursor position
2337 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2338 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 ) );
2340 // Render and notify
2341 application.SendNotification();
2342 application.Render();
2344 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2347 // Disable Shift Selection
2348 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2350 // Test to select some text in the right of the current cursor position
2351 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2352 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2353 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2354 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2356 // Render and notify
2357 application.SendNotification();
2358 application.Render();
2360 // Cut the selected text
2361 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2362 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 ) );
2364 // Render and notify
2365 application.SendNotification();
2366 application.Render();
2368 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2369 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2371 // Test to select some text in the left of the current cursor position
2372 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2373 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2374 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2375 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2377 // Render and notify
2378 application.SendNotification();
2379 application.Render();
2381 // Copy the selected text
2382 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2383 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 ) );
2385 // Render and notify
2386 application.SendNotification();
2387 application.Render();
2389 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2390 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2393 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 ) );
2395 // Render and notify
2396 application.SendNotification();
2397 application.Render();
2399 // replace text with "c"
2400 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2402 // Render and notify
2403 application.SendNotification();
2404 application.Render();
2407 DALI_TEST_EQUALS( "c", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2410 DevelTextEditor::SelectWholeText(editor);
2412 // Render and notify
2413 application.SendNotification();
2414 application.Render();
2416 // Copy the selected text using logical keys
2417 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2418 application.ProcessEvent( GenerateKey( "ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2420 // Render and notify
2421 application.SendNotification();
2422 application.Render();
2425 DevelTextEditor::SelectNone(editor);
2427 // Render and notify
2428 application.SendNotification();
2429 application.Render();
2431 // Paste the selected using logical keys
2432 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2433 application.ProcessEvent( GenerateKey( "ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2436 DALI_TEST_EQUALS( "cc", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2438 // select all using logical keys
2439 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2440 application.ProcessEvent( GenerateKey( "ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2442 // Render and notify
2443 application.SendNotification();
2444 application.Render();
2446 // cut 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( "ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2450 // Render and notify
2451 application.SendNotification();
2452 application.Render();
2455 DALI_TEST_EQUALS( "", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2460 int utcDaliTextEditorEvent08(void)
2462 ToolkitTestApplication application;
2463 tet_infoline(" utcDaliTextEditorEvent08");
2465 // Checks if the highlight actor is released correctly.
2467 TextEditor editor = TextEditor::New();
2468 DALI_TEST_CHECK( editor );
2470 application.GetScene().Add( editor );
2472 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2473 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2474 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2475 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2476 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2478 // Avoid a crash when core load gl resources.
2479 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2481 // Render and notify
2482 application.SendNotification();
2483 application.Render();
2485 // Tap on the text editor
2486 TestGenerateTap( application, 3.0f, 25.0f );
2488 // Render and notify
2489 application.SendNotification();
2490 application.Render();
2492 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2493 // Test to select some text in the left of the current cursor position
2494 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2495 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2496 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2497 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2499 // Render and notify
2500 application.SendNotification();
2501 application.Render();
2503 // Test to the left selection handle position and the right selection handle position
2504 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2505 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2506 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2507 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2509 // Render and notify
2510 application.SendNotification();
2511 application.Render();
2513 // Test to select full text in the left of the current cursor position
2514 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2515 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2516 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2517 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2518 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2519 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2521 // Render and notify
2522 application.SendNotification();
2523 application.Render();
2525 // Test to release the current full text selection
2526 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2527 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 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 move the current cursor position correctly
2534 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2536 // Render and notify
2537 application.SendNotification();
2538 application.Render();
2541 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2543 // Render and notify
2544 application.SendNotification();
2545 application.Render();
2547 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2549 // Test to select some text in the right of the current cursor position
2550 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2551 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2552 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2554 // Render and notify
2555 application.SendNotification();
2556 application.Render();
2558 // Test the cursor position with right arrow key
2559 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2561 // Render and notify
2562 application.SendNotification();
2563 application.Render();
2566 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2568 // Render and notify
2569 application.SendNotification();
2570 application.Render();
2572 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2574 // Test to select some text in the left of the current cursor position
2575 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2576 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2577 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2578 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2579 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2581 // Render and notify
2582 application.SendNotification();
2583 application.Render();
2585 // Test the cursor position with left arrow key
2586 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2588 // Render and notify
2589 application.SendNotification();
2590 application.Render();
2593 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2595 // Render and notify
2596 application.SendNotification();
2597 application.Render();
2599 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2601 // Test to select some text in the right of the current cursor position
2602 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2603 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2604 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2605 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2607 // Render and notify
2608 application.SendNotification();
2609 application.Render();
2611 // Test the cursor position with left arrow key
2612 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2614 // Render and notify
2615 application.SendNotification();
2616 application.Render();
2619 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2621 // Render and notify
2622 application.SendNotification();
2623 application.Render();
2625 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2627 // Test to select some text in the left of the current cursor position
2628 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2629 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2630 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2631 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2633 // Render and notify
2634 application.SendNotification();
2635 application.Render();
2637 // Test the cursor position with right arrow key
2638 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2640 // Render and notify
2641 application.SendNotification();
2642 application.Render();
2645 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2647 // Render and notify
2648 application.SendNotification();
2649 application.Render();
2651 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2656 int utcDaliTextEditorHandles(void)
2658 ToolkitTestApplication application;
2659 tet_infoline(" utcDaliTextEditorHandles");
2661 TextEditor editor = TextEditor::New();
2662 DALI_TEST_CHECK( editor );
2664 application.GetScene().Add( editor );
2666 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2667 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2668 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2669 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2671 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2672 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2673 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2674 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2676 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2677 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2678 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2680 // Avoid a crash when core load gl resources.
2681 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2683 // Render and notify
2684 application.SendNotification();
2685 application.Render();
2687 // Tap first to get the focus.
2688 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2690 // Render and notify
2691 application.SendNotification();
2692 application.Render();
2694 // Tap to create the grab handle.
2695 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2697 // Render and notify
2698 application.SendNotification();
2699 application.Render();
2701 // Get the active layer where the text's decoration is added.
2702 Actor activeLayer = editor.GetChildAt( 1u );
2704 // Get the handle's actor.
2705 Actor handle = activeLayer.GetChildAt( 1u );
2706 handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2708 // Render and notify
2709 application.SendNotification();
2710 application.Render();
2712 // Touch the grab handle to set it as pressed.
2713 Vector2 touchPos( 10.0f, 50.0f );
2714 Dali::Integration::TouchEvent event;
2715 event = Dali::Integration::TouchEvent();
2716 event.AddPoint( GetPointDownInside( touchPos ) );
2717 application.ProcessEvent( event );
2719 // Render and notify
2720 application.SendNotification();
2721 application.Render();
2723 // Pan the grab handle
2724 uint32_t time = 100;
2725 TestStartPan( application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time );
2726 TestMovePan( application, Vector2(10.0f, 30.0f), time );
2727 TestEndPan( application, Vector2(10.0f, 50.0f), time);
2728 application.SendNotification();
2729 application.Render();
2732 // Release the grab handle.
2733 event = Dali::Integration::TouchEvent();
2734 event.AddPoint( GetPointUpInside( touchPos ) );
2735 application.ProcessEvent( event );
2737 // Render and notify
2738 application.SendNotification();
2739 application.Render();
2741 // Tap first to get the focus.
2742 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2744 // Render and notify
2745 application.SendNotification();
2746 application.Render();
2748 // Double tap to select a word and create the selection handles.
2749 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2751 // Render and notify
2752 application.SendNotification();
2753 application.Render();
2755 touchPos = Vector2( 10.0f, 50.0f );
2757 // Touch the left selection handle to set it as pressed.
2758 event = Dali::Integration::TouchEvent();
2759 event.AddPoint( GetPointDownInside( touchPos ) );
2760 application.ProcessEvent( event );
2762 // Render and notify
2763 application.SendNotification();
2764 application.Render();
2766 // Release the left selection handle.
2767 event = Dali::Integration::TouchEvent();
2768 event.AddPoint( GetPointUpInside( touchPos ) );
2769 application.ProcessEvent( event );
2771 // Render and notify
2772 application.SendNotification();
2773 application.Render();
2778 int utcDaliTextEditorUnderPropertyStringP(void)
2780 ToolkitTestApplication application;
2781 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2782 TextEditor editor = TextEditor::New();
2783 DALI_TEST_CHECK( editor );
2785 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2787 application.GetScene().Add( editor );
2789 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2790 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2792 tet_infoline("Set underline settings with a map");
2793 // Check the input underline property
2794 Property::Map underlineMapSet;
2795 Property::Map underlineMapGet;
2796 underlineMapSet.Insert( "enable", true );
2797 underlineMapSet.Insert( "color", Color::BLUE );
2798 underlineMapSet.Insert( "height", 2 );
2800 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2801 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2802 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2803 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2805 tet_infoline("Set underline settings with a string");
2806 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2807 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2810 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2812 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2813 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2814 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2815 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2817 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2822 int utcDaliTextEditorShadowPropertyStringP(void)
2824 ToolkitTestApplication application;
2825 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2827 TextEditor editor = TextEditor::New();
2829 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2831 application.GetScene().Add( editor );
2833 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2835 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2839 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2844 int utcDaliTextEditorFontStylePropertyStringP(void)
2846 ToolkitTestApplication application;
2847 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2849 TextEditor editor = TextEditor::New();
2851 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2853 application.GetScene().Add( editor );
2855 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2857 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2861 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2866 int utcDaliTextEditorGetPropertyLinecountP(void)
2868 ToolkitTestApplication application;
2870 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2874 TextEditor editor = TextEditor::New();
2875 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2876 editor.SetProperty( TextEditor::Property::TEXT,
2877 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2879 application.GetScene().Add( editor );
2881 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2882 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2883 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2885 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
2886 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2887 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2892 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2895 ToolkitTestApplication application;
2896 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2898 TextEditor editor = TextEditor::New();
2899 DALI_TEST_CHECK( editor );
2901 application.GetScene().Add( editor );
2903 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2904 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2905 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2906 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2907 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2908 editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2910 bool startedCalled = false;
2911 bool finishedCalled = false;
2913 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2914 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2916 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2918 // Render and notify
2919 application.SendNotification();
2920 application.Render();
2922 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2923 application.SendNotification();
2924 application.Render(6000);
2926 application.SendNotification();
2927 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2928 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2933 int UtcDaliToolkitTextEditorTextWrapMode(void)
2935 ToolkitTestApplication application;
2936 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2940 TextEditor editor = TextEditor::New();
2941 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
2942 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2944 application.GetScene().Add( editor );
2946 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2947 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2949 application.SendNotification();
2950 application.Render();
2952 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2953 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2955 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2956 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2958 application.SendNotification();
2959 application.Render();
2961 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2962 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2964 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2965 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2967 application.SendNotification();
2968 application.Render();
2970 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2971 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2973 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2974 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2976 application.SendNotification();
2977 application.Render();
2979 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2980 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2985 int UtcDaliTextEditorSetPaddingProperty(void)
2987 ToolkitTestApplication application;
2988 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2990 TextEditor editor = TextEditor::New();
2991 DALI_TEST_CHECK( editor );
2992 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2993 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2994 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2995 application.GetScene().Add( editor );
2997 application.SendNotification();
2998 application.Render();
3000 Vector3 originalSize = editor.GetNaturalSize();
3002 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
3004 application.SendNotification();
3005 application.Render();
3007 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
3009 Vector3 paddingAddedSize = editor.GetNaturalSize();
3011 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3013 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3018 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
3020 ToolkitTestApplication application;
3021 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
3023 TextEditor editor = TextEditor::New();
3024 DALI_TEST_CHECK( editor );
3025 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3026 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3027 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3028 application.GetScene().Add( editor );
3030 application.SendNotification();
3031 application.Render();
3033 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3034 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
3036 // Check the enable shift selection property
3037 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
3038 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
3040 application.SendNotification();
3041 application.Render();
3046 int UtcDaliTextEditorEnableGrabHandleProperty(void)
3048 ToolkitTestApplication application;
3049 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
3051 TextEditor editor = TextEditor::New();
3052 DALI_TEST_CHECK( editor );
3053 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3054 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3055 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3056 application.GetScene().Add( editor );
3058 application.SendNotification();
3059 application.Render();
3061 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3062 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
3064 // Check the enable grab handle property
3065 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
3066 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
3068 application.SendNotification();
3069 application.Render();
3074 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
3076 ToolkitTestApplication application;
3077 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
3079 TextEditor editor = TextEditor::New();
3080 DALI_TEST_CHECK( editor );
3081 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3082 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3083 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3084 application.GetScene().Add( editor );
3086 application.SendNotification();
3087 application.Render();
3089 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3090 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
3092 // Check the disable match system language direction property
3093 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
3094 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
3096 application.SendNotification();
3097 application.Render();
3102 int UtcDaliTextEditorGetInputMethodContext(void)
3104 ToolkitTestApplication application;
3105 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
3107 TextEditor editor = TextEditor::New();
3108 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );
3113 int utcDaliTextEditorMaxCharactersReached(void)
3115 ToolkitTestApplication application;
3116 tet_infoline("utcDaliTextEditorMaxCharactersReached");
3118 TextEditor editor = TextEditor::New();
3119 DALI_TEST_CHECK( editor );
3121 application.GetScene().Add( editor );
3123 const int maxNumberOfCharacters = 1;
3124 editor.SetProperty( DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters );
3125 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelTextEditor::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
3127 editor.SetKeyInputFocus();
3129 // connect to the text changed signal.
3130 ConnectionTracker* testTracker = new ConnectionTracker();
3131 DevelTextEditor::MaxLengthReachedSignal( editor ).Connect(&TestMaxLengthReachedCallback);
3132 bool maxLengthReachedSignal = false;
3133 editor.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
3135 gMaxCharactersCallBackCalled = false;
3137 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3138 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3140 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
3141 DALI_TEST_CHECK( maxLengthReachedSignal );
3146 int utcDaliTextEditorInputFiltered(void)
3148 ToolkitTestApplication application;
3149 tet_infoline(" utcDaliTextEditorInputFiltered");
3150 TextEditor editor = TextEditor::New();
3151 DALI_TEST_CHECK(editor);
3153 application.GetScene().Add(editor);
3155 Property::Map inputFilter;
3157 // Only digit is accepted.
3158 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
3160 // Set input filter to TextEditor.
3161 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3163 editor.SetKeyInputFocus();
3165 // connect to the input filtered signal.
3166 ConnectionTracker* testTracker = new ConnectionTracker();
3167 DevelTextEditor::InputFilteredSignal(editor).Connect(&TestInputFilteredCallback);
3168 bool inputFilteredSignal = false;
3169 editor.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
3171 gInputFilteredAcceptedCallbackCalled = false;
3173 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ));
3175 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3176 DALI_TEST_CHECK(inputFilteredSignal);
3178 // Word is rejected.
3179 inputFilter[InputFilter::Property::ACCEPTED] = "";
3180 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
3182 // Set input filter to TextEditor.
3183 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3185 editor.SetKeyInputFocus();
3187 inputFilteredSignal = false;
3188 gInputFilteredRejectedCallbackCalled = false;
3190 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3192 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3193 DALI_TEST_CHECK(inputFilteredSignal);
3198 int UtcDaliTextEditorSelectWholeText(void)
3200 ToolkitTestApplication application;
3201 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3203 TextEditor textEditor = TextEditor::New();
3205 application.GetScene().Add( textEditor );
3207 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3208 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3209 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3211 // Avoid a crash when core load gl resources.
3212 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3214 application.SendNotification();
3215 application.Render();
3217 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3219 DevelTextEditor::SelectWholeText( textEditor );
3221 application.SendNotification();
3222 application.Render();
3224 // Nothing should have been selected. The number of children is still 1
3225 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3227 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3229 application.SendNotification();
3230 application.Render();
3232 DevelTextEditor::SelectWholeText( textEditor );
3234 application.SendNotification();
3235 application.Render();
3237 // Should be 2 children, the stencil and the layer
3238 DALI_TEST_EQUALS( 2u, textEditor.GetChildCount(), TEST_LOCATION );
3240 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3241 Actor stencil = textEditor.GetChildAt( 0u );
3243 // The highlight actor is drawn first, so is the first actor in the list
3244 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3245 DALI_TEST_CHECK( highlight );
3250 int UtcDaliTextEditorSelectText(void)
3252 ToolkitTestApplication application;
3253 tet_infoline(" UtcDaliTextEditorSelectText ");
3255 TextEditor textEditor = TextEditor::New();
3257 application.GetScene().Add( textEditor );
3259 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3260 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3261 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3263 // Avoid a crash when core load gl resources.
3264 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3266 application.SendNotification();
3267 application.Render();
3269 DevelTextEditor::SelectText( textEditor ,0, 5 );
3271 application.SendNotification();
3272 application.Render();
3274 // Nothing is selected
3275 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3276 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3278 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3280 application.SendNotification();
3281 application.Render();
3283 DevelTextEditor::SelectText( textEditor, 0, 5 );
3285 application.SendNotification();
3286 application.Render();
3288 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3289 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3291 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3292 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3294 // world is selected
3295 DevelTextEditor::SelectText( textEditor, 6, 11 );
3297 application.SendNotification();
3298 application.Render();
3300 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3301 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3303 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3304 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3309 int UtcDaliTextEditorSelectNone(void)
3311 ToolkitTestApplication application;
3312 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3314 TextEditor textEditor = TextEditor::New();
3316 application.GetScene().Add( textEditor );
3318 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3319 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3320 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3322 // Avoid a crash when core load gl resources.
3323 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3325 application.SendNotification();
3326 application.Render();
3328 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3330 application.SendNotification();
3331 application.Render();
3333 // Nothing is selected
3334 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3335 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3337 DevelTextEditor::SelectWholeText( textEditor );
3339 application.SendNotification();
3340 application.Render();
3342 // whole text is selected
3343 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3344 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3346 DevelTextEditor::SelectNone( textEditor );
3348 application.SendNotification();
3349 application.Render();
3351 // Nothing is selected
3352 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3353 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3358 int UtcDaliTextEditorSelectRange(void)
3360 ToolkitTestApplication application;
3361 tet_infoline("utcDaliTextEditorSelectRange");
3363 TextEditor textEditor = TextEditor::New();
3364 DALI_TEST_CHECK( textEditor );
3366 application.GetScene().Add( textEditor );
3368 // Avoid a crash when core load gl resources.
3369 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3371 application.SendNotification();
3372 application.Render();
3374 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3376 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_START, 0 );
3377 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_END, 5 );
3379 // Hello is selected
3380 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3381 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3383 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3384 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3389 int UtcDaliTextEditorEnableEditing(void)
3391 ToolkitTestApplication application;
3392 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3394 TextEditor textEditor = TextEditor::New();
3396 application.GetScene().Add( textEditor );
3398 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3399 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3400 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3402 // Avoid a crash when core load gl resources.
3403 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3405 application.SendNotification();
3406 application.Render();
3408 textEditor.SetKeyInputFocus();
3409 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, false );
3410 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3412 // Render and notify
3413 application.SendNotification();
3414 application.Render();
3416 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3417 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3419 textEditor.SetKeyInputFocus();
3420 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
3421 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3423 // Render and notify
3424 application.SendNotification();
3425 application.Render();
3427 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3428 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3433 int UtcDaliTextEditorScrolling(void)
3435 ToolkitTestApplication application;
3436 tet_infoline(" UtcDaliTextEditorScrolling ");
3438 TextEditor textEditor = TextEditor::New();
3439 DALI_TEST_CHECK( textEditor );
3441 application.GetScene().Add( textEditor );
3443 // Avoid a crash when core load gl resources.
3444 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3446 application.SendNotification();
3447 application.Render();
3449 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
3450 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
3451 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
3452 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
3454 application.SendNotification();
3455 application.Render();
3457 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3458 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3461 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
3463 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, TEST_LOCATION );
3464 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3466 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
3468 DALI_TEST_NOT_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, 0.1f, TEST_LOCATION );
3469 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3471 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION , 0.0f);
3472 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION , 0.0f);
3474 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3475 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3480 int UtcDaliToolkitTextEditorFontSizeScale(void)
3482 ToolkitTestApplication application;
3483 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
3485 TextEditor textEditor = TextEditor::New();
3486 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 30.f );
3487 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3488 Vector3 nonScaledSize = textEditor.GetNaturalSize();
3490 TextEditor textEditorScaled = TextEditor::New();
3491 textEditorScaled.SetProperty( TextEditor::Property::POINT_SIZE, 15.f );
3492 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3493 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3494 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
3496 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3498 textEditor.SetProperty( TextEditor::Property::PIXEL_SIZE, 30.f );
3499 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3500 nonScaledSize = textEditor.GetNaturalSize();
3502 textEditorScaled.SetProperty( TextEditor::Property::PIXEL_SIZE, 15.f );
3503 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3504 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3505 scaledSize = textEditorScaled.GetNaturalSize();
3507 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3512 int UtcDaliTextEditorPrimaryCursorPosition(void)
3514 ToolkitTestApplication application;
3515 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
3517 TextEditor textEditor = TextEditor::New();
3519 application.GetScene().Add( textEditor );
3521 textEditor.SetProperty( TextEditor::Property::TEXT, "ABCEF");
3522 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3523 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3524 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3526 // Avoid a crash when core load gl resources.
3527 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3529 textEditor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
3530 application.SendNotification();
3531 application.Render();
3532 textEditor.SetKeyInputFocus();
3534 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3536 // Render and notify
3537 application.SendNotification();
3538 application.Render();
3540 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3541 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3546 int UtcDaliTextEditorLineCountAfterGetNaturalSize(void)
3548 ToolkitTestApplication application;
3549 tet_infoline(" UtcDaliTextEditorLineCountAfterGetNaturalSize ");
3551 TextEditor textEditor = TextEditor::New();
3552 textEditor.SetProperty(TextEditor::Property::TEXT, "A\nB\nC\nD\nE\nF\n");
3553 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3554 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3555 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3556 application.GetScene().Add( textEditor );
3558 application.SendNotification();
3559 application.Render();
3562 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3563 DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3565 textEditor.GetNaturalSize();
3567 // Create a tap event to touch the text editor.
3568 TestGenerateTap( application, 18.0f, 25.0f );
3570 application.SendNotification();
3571 application.Render();
3573 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3574 DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3580 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase(void)
3582 ToolkitTestApplication application;
3584 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase ");
3586 int lineCountBefore =0 ;
3587 int lineCountAfter =0 ;
3589 // Create a text editor
3590 TextEditor textEditor = TextEditor::New();
3591 //Set very large font-size using point-size
3592 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3593 //Specify font-family
3594 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3596 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3597 //Set text longer than width of textEditor
3598 textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3600 application.GetScene().Add( textEditor );
3602 application.SendNotification();
3603 application.Render();
3605 //Failed case is the GetHeightForWidth change LineCount then the scrollor will not arrive to latest line
3606 //GetHeightForWidth is a retrieval method which should not modify object
3607 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3608 textEditor.GetHeightForWidth(200.f);
3610 //This is to simulate focus into text editor after calling GetHeightForWidth
3611 //Create a tap event to touch the text editor.
3612 TestGenerateTap( application, 18.0f, 25.0f );
3614 application.SendNotification();
3615 application.Render();
3617 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3619 //The LineCount must not be changed when calling GetHeightForWidth.
3620 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3625 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase(void)
3627 ToolkitTestApplication application;
3629 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase ");
3631 int lineCountBefore =0 ;
3632 int lineCountAfter =0 ;
3634 // Create a text editor
3635 TextEditor textEditor = TextEditor::New();
3636 //Set very large font-size using point-size
3637 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3638 //Specify font-family
3639 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3641 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3642 //Set text longer than width of textEditor
3643 textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3644 //Set line wrap mode Character
3645 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3647 application.GetScene().Add( textEditor );
3649 application.SendNotification();
3650 application.Render();
3652 //Failed case is the GetHeightForWidth change LineCount which make position of cursor invalid in TextEditor
3653 //GetHeightForWidth is a retrieval method which should not modify object
3654 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3655 textEditor.GetHeightForWidth(200.f);
3657 //This is to simulate focus into text editor after calling GetHeightForWidth
3658 //Create a tap event to touch the text editor.
3659 TestGenerateTap( application, 18.0f, 25.0f );
3661 application.SendNotification();
3662 application.Render();
3664 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3666 //The LineCount must not be changed when calling GetHeightForWidth.
3667 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3672 int utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged(void)
3674 ToolkitTestApplication application;
3676 tet_infoline(" utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged ");
3678 int lineCountBefore =0 ;
3679 int lineCountAfter =0 ;
3681 // Create a text editor
3682 TextEditor textEditor = TextEditor::New();
3683 //Set very large font-size using point-size
3684 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3685 //Specify font-family
3686 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3688 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 100.f ) );
3689 //Set text longer than width of textEditor
3690 textEditor.SetProperty( TextEditor::Property::TEXT, "Short text");
3691 //Set line wrap mode Character
3692 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3694 application.GetScene().Add( textEditor );
3696 application.SendNotification();
3697 application.Render();
3700 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3702 textEditor.SetProperty( TextEditor::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
3703 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3705 // When the text changed, the Line-count should be updated according to new text.
3706 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
3707 DALI_TEST_EQUALS( lineCountBefore ,1, TEST_LOCATION );
3708 DALI_TEST_GREATER( lineCountAfter,1, TEST_LOCATION );
3715 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase(void)
3717 ToolkitTestApplication application;
3719 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase ");
3721 int lineCountBefore =0 ;
3722 int lineCountAfter =0 ;
3724 // Create a text editor
3725 TextEditor textEditor = TextEditor::New();
3726 //Set very large font-size using point-size
3727 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3728 //Specify font-family
3729 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3731 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3732 //Set text longer than width of textEditor
3733 textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3735 application.GetScene().Add( textEditor );
3737 application.SendNotification();
3738 application.Render();
3740 //Failed case is the GetNaturalSize change LineCount then the scrollor will not arrive to latest line
3741 //GetNaturalSize is a retrieval method which should not modify object
3742 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3743 textEditor.GetNaturalSize();
3745 //This is to simulate focus into text editor after calling GetNaturalSize
3746 //Create a tap event to touch the text editor.
3747 TestGenerateTap( application, 18.0f, 25.0f );
3749 application.SendNotification();
3750 application.Render();
3752 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3754 //The LineCount must not be changed when calling GetNaturalSize.
3755 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3760 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase(void)
3762 ToolkitTestApplication application;
3764 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase ");
3766 int lineCountBefore =0 ;
3767 int lineCountAfter =0 ;
3769 // Create a text editor
3770 TextEditor textEditor = TextEditor::New();
3771 //Set very large font-size using point-size
3772 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3773 //Specify font-family
3774 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3776 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3777 //Set text longer than width of textEditor
3778 textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3779 //Set line wrap mode Character
3780 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3782 application.GetScene().Add( textEditor );
3784 application.SendNotification();
3785 application.Render();
3787 //Failed case is the GetNaturalSize change LineCount which make position of cursor invalid in TextEditor
3788 //GetNaturalSize is a retrieval method which should not modify object
3789 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3790 textEditor.GetNaturalSize( );
3792 //This is to simulate focus into text editor after calling GetNaturalSize
3793 //Create a tap event to touch the text editor.
3794 TestGenerateTap( application, 18.0f, 25.0f );
3796 application.SendNotification();
3797 application.Render();
3799 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3801 //The LineCount must not be changed when calling GetNaturalSize.
3802 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3807 int UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize(void)
3809 ToolkitTestApplication application;
3810 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize ");
3812 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3813 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3814 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3816 // Create a text editor
3817 TextEditor textEditor = TextEditor::New();
3819 //Set size to avoid automatic eliding
3820 textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3821 //Set very large font-size using point-size
3822 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 1000) ;
3823 //Specify font-family
3824 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3825 //Set text to check if appear or not
3826 textEditor.SetProperty( TextEditor::Property::TEXT, "A");
3828 application.GetScene().Add( textEditor );
3830 application.SendNotification();
3831 application.Render();
3832 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3833 Vector3 naturalSize = textEditor.GetNaturalSize();
3835 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3836 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3841 int UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases(void)
3843 ToolkitTestApplication application;
3844 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases ");
3846 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3847 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3848 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3850 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3851 // Create a text editor
3852 TextEditor textEditor = TextEditor::New();
3853 //Set size to avoid automatic eliding
3854 textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3855 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3856 textEditor.SetProperty( TextEditor::Property::TEXT, "A");
3858 const int numberOfCases = 6;
3859 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
3861 for (int index=0; index < numberOfCases; index++)
3863 tet_printf(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
3864 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, arrayCases[index]) ;
3865 application.GetScene().Add( textEditor );
3866 application.SendNotification();
3867 application.Render();
3868 naturalSize = textEditor.GetNaturalSize();
3869 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3870 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3877 int UtcDaliTextEditorHyphenWrapMode(void)
3879 ToolkitTestApplication application;
3880 tet_infoline(" UtcDaliTextEditorHyphenWrapMode ");
3883 TextEditor textEditor = TextEditor::New();
3885 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
3887 application.GetScene().Add( textEditor );
3888 application.SendNotification();
3889 application.Render();
3891 textEditor.SetProperty( TextEditor::Property::TEXT, "Hi Experimen" );
3892 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
3893 DALI_TEST_EQUALS( textEditor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::HYPHENATION ), TEST_LOCATION );
3895 application.SendNotification();
3896 application.Render();
3898 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3904 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
3906 textEditor.SetProperty( TextEditor::Property::TEXT, "Hi Experimen" );
3907 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
3908 DALI_TEST_EQUALS( textEditor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::MIXED ), TEST_LOCATION );
3910 application.SendNotification();
3911 application.Render();
3913 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3920 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
3925 int UtcDaliToolkitTextEditorEllipsisPositionProperty(void)
3927 ToolkitTestApplication application;
3928 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty ");
3929 TextEditor textEditor = TextEditor::New();
3931 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Default is END");
3932 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3934 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START");
3935 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
3936 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3938 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE");
3939 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
3940 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3942 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END");
3943 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
3944 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3946 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START using integer");
3947 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 1);
3948 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3950 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE using integer");
3951 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 2);
3952 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3954 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END using integer");
3955 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 0);
3956 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3958 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
3959 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "START");
3960 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3962 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
3963 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "MIDDLE");
3964 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3966 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
3967 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "END");
3968 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3970 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
3971 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "start");
3972 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3974 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
3975 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "middle");
3976 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3978 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
3979 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "end");
3980 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3985 int UtcDaliTextEditorLineSpacing(void)
3987 ToolkitTestApplication application;
3988 tet_infoline(" UtcDaliTextEditorLineSpacing ");
3990 TextEditor textEditor = TextEditor::New();
3991 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.f ) );
3992 application.GetScene().Add( textEditor );
3993 application.SendNotification();
3994 application.Render();
3996 textEditor.SetProperty( TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3" );
3997 textEditor.SetProperty( DevelTextEditor::Property::LINE_SPACING, 0 );
3999 Vector3 sizeBefore = textEditor.GetNaturalSize();
4001 textEditor.SetProperty( DevelTextEditor::Property::LINE_SPACING, 20 );
4003 //add 20 for each line 20 * 3
4004 DALI_TEST_EQUALS(sizeBefore.height + 60.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4009 int UtcDaliTextEditorMinLineSize(void)
4011 ToolkitTestApplication application;
4012 tet_infoline(" UtcDaliTextEditorMinLineSize ");
4014 TextEditor textEditor = TextEditor::New();
4015 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.f ) );
4016 application.GetScene().Add( textEditor );
4017 application.SendNotification();
4018 application.Render();
4020 textEditor.SetProperty( TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3" );
4021 textEditor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 0 );
4023 Vector3 sizeBefore = textEditor.GetNaturalSize();
4025 textEditor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 60 );
4027 DALI_TEST_NOT_EQUALS( sizeBefore, textEditor.GetNaturalSize(), 0.0f, TEST_LOCATION);
4030 DALI_TEST_EQUALS(180.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);